Просмотр исходного кода

Merge branch 'restart-no-cycle'

* restart-no-cycle:
  * Fix bot forgetting its own userip due to irc.mod not being active during restart
  * Disable irc.mod while restarting
  * Change +backup warning to be DEBUG
  * Update UPDATES
  * Also retain active channels in shouldjoin() when restarting if somehow received full WHO results while restarting
  * Write out pending channels as well when restarting
  * Only do the special restart checking if using the new method
  * Fix bot thinking it should part chans in some cases during restart
  * Add more debugs on PART
  * Don't save status flags as ints, it's not upgrade-compat
  * Use sizeof() for chan name size
  * Enable debug of socksfile
  * Only avoid cycling if possible
  * Don't cycle on restart

Conflicts:
	src/misc.c
	src/mod/channels.mod/tclchan.c
Bryan Drewery 16 лет назад
Родитель
Сommit
a4f159146d

+ 1 - 0
doc/UPDATES

@@ -116,6 +116,7 @@
   * Add chanset 'protect-backup' which will optionally set +backup in the event of a takeover with +protect.
   * Add chanset 'protect-backup' which will optionally set +backup in the event of a takeover with +protect.
   * Channel settings 'mop' and 'mdop' now react to non-users.
   * Channel settings 'mop' and 'mdop' now react to non-users.
   * set 'fight-threshold' now requires +protect and is a trigger for +protect. See 'help chanset' for +protect info.
   * set 'fight-threshold' now requires +protect and is a trigger for +protect. See 'help chanset' for +protect info.
+  * Bots no longer cycle channels when restarting/upgrading. (This will take effect AFTER upgrading to 1.3)
 
 
 1.2.16.1
 1.2.16.1
 * Fix linux compile errors
 * Fix linux compile errors

+ 3 - 3
src/auth.c

@@ -186,7 +186,7 @@ sdprintf(STR("GETIDX: auth: %s, idx: %d"), nick, idx);
     else {
     else {
       sdprintf(STR("FIRST FOUND: %d"), idx);
       sdprintf(STR("FIRST FOUND: %d"), idx);
       strlcpy(dcc[idx].simulbot, chname ? chname : nick, sizeof(dcc[idx].simulbot));
       strlcpy(dcc[idx].simulbot, chname ? chname : nick, sizeof(dcc[idx].simulbot));
-      strlcpy(dcc[idx].u.chat->con_chan, chname ? chname : "*", 81);
+      strlcpy(dcc[idx].u.chat->con_chan, chname ? chname : "*", sizeof(dcc[idx].u.chat->con_chan));
       return 1;
       return 1;
     }
     }
   }
   }
@@ -201,7 +201,7 @@ sdprintf(STR("GETIDX: auth: %s, idx: %d"), nick, idx);
       dcc[i].simultime = now;
       dcc[i].simultime = now;
       idx = i;
       idx = i;
       strlcpy(dcc[idx].simulbot, chname ? chname : nick, sizeof(dcc[idx].simulbot));
       strlcpy(dcc[idx].simulbot, chname ? chname : nick, sizeof(dcc[idx].simulbot));
-      strlcpy(dcc[idx].u.chat->con_chan, chname ? chname : "*", 81);
+      strlcpy(dcc[idx].u.chat->con_chan, chname ? chname : "*", sizeof(dcc[idx].u.chat->con_chan));
 
 
       return 1;
       return 1;
     }
     }
@@ -218,7 +218,7 @@ sdprintf(STR("GETIDX: auth: %s, idx: %d"), nick, idx);
     dcc[idx].status = STAT_COLOR;
     dcc[idx].status = STAT_COLOR;
     dcc[idx].u.chat->con_flags = 0;
     dcc[idx].u.chat->con_flags = 0;
     strlcpy(dcc[idx].simulbot, chname ? chname : nick, sizeof(dcc[idx].simulbot));
     strlcpy(dcc[idx].simulbot, chname ? chname : nick, sizeof(dcc[idx].simulbot));
-    strlcpy(dcc[idx].u.chat->con_chan, chname ? chname : "*", 81);
+    strlcpy(dcc[idx].u.chat->con_chan, chname ? chname : "*", sizeof(dcc[idx].u.chat->con_chan));
     dcc[idx].u.chat->strip_flags = STRIP_ALL;
     dcc[idx].u.chat->strip_flags = STRIP_ALL;
     strlcpy(dcc[idx].nick, handle, sizeof(dcc[idx].nick));
     strlcpy(dcc[idx].nick, handle, sizeof(dcc[idx].nick));
     strlcpy(dcc[idx].host, host, sizeof(dcc[idx].host));
     strlcpy(dcc[idx].host, host, sizeof(dcc[idx].host));

+ 9 - 7
src/chanprog.c

@@ -63,7 +63,7 @@ char 			origbotname[NICKLEN] = "";	/* Nick to regain */
 char                    jupenick[NICKLEN] = "";
 char                    jupenick[NICKLEN] = "";
 char 			botname[NICKLEN] = "";	/* IRC nickname */
 char 			botname[NICKLEN] = "";	/* IRC nickname */
 port_t     		my_port = 0;
 port_t     		my_port = 0;
-bool			reset_chans = 0;
+int			reset_chans = 0;
 bool                    cookies_disabled = 0;
 bool                    cookies_disabled = 0;
 char s2_4[3] = "",s1_6[3] = "",s1_11[3] = "";
 char s2_4[3] = "",s1_6[3] = "",s1_11[3] = "";
 
 
@@ -832,9 +832,14 @@ chans_delbot(const char *bot, struct chanset_t *chan)
 
 
 bool bot_shouldjoin(struct userrec* u, struct flag_record* fr, struct chanset_t* chan, bool ignore_inactive)
 bool bot_shouldjoin(struct userrec* u, struct flag_record* fr, struct chanset_t* chan, bool ignore_inactive)
 {
 {
+  // If restarting, keep this channel.
+  if (restarting && (reset_chans == 2) && (channel_active(chan) || channel_pending(chan))) return 1;
   /* If the bot is restarting (and hasn't finished getting the userfile for the first time) DO NOT JOIN channels - breaks +B/+backup */
   /* If the bot is restarting (and hasn't finished getting the userfile for the first time) DO NOT JOIN channels - breaks +B/+backup */
   if (restarting || loading) return 0;
   if (restarting || loading) return 0;
 
 
+  // No user record, can't make any safe assumptions really
+  if (!u) return 0;
+
 #ifdef DEBUG
 #ifdef DEBUG
   /* Force debugging bots to only join 3 channels */
   /* Force debugging bots to only join 3 channels */
   if (!strncmp(u->handle, "wtest", 5)) {
   if (!strncmp(u->handle, "wtest", 5)) {
@@ -854,12 +859,9 @@ bool bot_shouldjoin(struct userrec* u, struct flag_record* fr, struct chanset_t*
 
 
 bool shouldjoin(struct chanset_t *chan)
 bool shouldjoin(struct chanset_t *chan)
 {
 {
-  if (conf.bot->u) {
-    struct flag_record fr = { FR_CHAN|FR_GLOBAL|FR_BOT, 0, 0, 0 };
-    get_user_flagrec(conf.bot->u, &fr, chan->dname, chan);
-    return bot_shouldjoin(conf.bot->u, &fr, chan);
-  }
-  return 0;
+  struct flag_record fr = { FR_CHAN|FR_GLOBAL|FR_BOT, 0, 0, 0 };
+  get_user_flagrec(conf.bot->u, &fr, chan->dname, chan);
+  return bot_shouldjoin(conf.bot->u, &fr, chan);
 }
 }
 
 
 /* do_chanset() set (options) on (chan)
 /* do_chanset() set (options) on (chan)

+ 2 - 1
src/chanprog.h

@@ -36,6 +36,7 @@ void setup_HQ(int);
 extern struct chanset_t		*chanset, *chanset_default;
 extern struct chanset_t		*chanset, *chanset_default;
 extern char			admin[], origbotnick[HANDLEN + 1], origbotname[NICKLEN], jupenick[NICKLEN], botname[NICKLEN], *def_chanset;
 extern char			admin[], origbotnick[HANDLEN + 1], origbotname[NICKLEN], jupenick[NICKLEN], botname[NICKLEN], *def_chanset;
 extern port_t			my_port;
 extern port_t			my_port;
-extern bool			reset_chans, cookies_disabled;
+extern int			reset_chans;
+extern bool			cookies_disabled;
 
 
 #endif /* !_CHANPROG_H */
 #endif /* !_CHANPROG_H */

+ 1 - 1
src/cmds.c

@@ -1053,7 +1053,7 @@ static void cmd_console(int idx, char *par)
       return;
       return;
     }
     }
 
 
-    strlcpy(dcc[dest].u.chat->con_chan, nick, 81);
+    strlcpy(dcc[dest].u.chat->con_chan, nick, sizeof(dcc[dest].u.chat->con_chan));
     nick[0] = 0;
     nick[0] = 0;
     if ((dest == idx) && !glob_master(fr) && !chan_master(fr))
     if ((dest == idx) && !glob_master(fr) && !chan_master(fr))
       /* Consoling to another channel for self */
       /* Consoling to another channel for self */

+ 6 - 1
src/main.c

@@ -810,7 +810,6 @@ int main(int argc, char **argv)
   channels_init();
   channels_init();
   if (!conf.bot->hub) {
   if (!conf.bot->hub) {
     server_init();
     server_init();
-    irc_init();
     ctcp_init();
     ctcp_init();
   }
   }
   transfer_init();
   transfer_init();
@@ -883,6 +882,12 @@ int main(int argc, char **argv)
   if (socksfile)
   if (socksfile)
     readsocks(socksfile);
     readsocks(socksfile);
 
 
+  if (!conf.bot->hub) {
+    // Restarting in new method - don't enable irc.mod until after receiving userfile.
+    if (reset_chans != 2)
+      irc_init();
+  }
+
   debug0(STR("main: entering loop"));
   debug0(STR("main: entering loop"));
 
 
   while (1) {
   while (1) {

+ 20 - 4
src/misc.c

@@ -50,6 +50,7 @@
 #include "tandem.h"
 #include "tandem.h"
 #include "src/mod/server.mod/server.h"
 #include "src/mod/server.mod/server.h"
 #include "src/mod/irc.mod/irc.h"
 #include "src/mod/irc.mod/irc.h"
+#include "src/mod/channels.mod/channels.h"
 #include "userrec.h"
 #include "userrec.h"
 #include "stat.h"
 #include "stat.h"
 #include "net.h"
 #include "net.h"
@@ -636,11 +637,13 @@ readsocks(const char *fname)
   stream.loadFile(fname);
   stream.loadFile(fname);
   bd::String str, type;
   bd::String str, type;
 
 
+  reset_chans = 0;
+
   while (stream.tell() < stream.length()) {
   while (stream.tell() < stream.length()) {
     str = stream.getline().chomp();
     str = stream.getline().chomp();
+    dprintf(DP_DEBUG, "read line: %s\n", str.c_str());
     type = newsplit(str);
     type = newsplit(str);
 
 
-//    dprintf(DP_DEBUG, "read line: %s\n", buf.c_str());
     if (type == STR("-dcc"))
     if (type == STR("-dcc"))
       dprintf(DP_DEBUG, STR("Added dcc: %d\n"), dcc_read(stream));
       dprintf(DP_DEBUG, STR("Added dcc: %d\n"), dcc_read(stream));
     else if (type == STR("-sock"))
     else if (type == STR("-sock"))
@@ -655,6 +658,15 @@ readsocks(const char *fname)
       in_deaf = 1;
       in_deaf = 1;
     else if (type == STR("+in_callerid"))
     else if (type == STR("+in_callerid"))
       in_callerid = 1;
       in_callerid = 1;
+    else if (type == STR("+chan")) {
+      bd::String chname = str;
+      channel_add(NULL, chname.c_str(), NULL);
+      struct chanset_t* chan = findchan_by_dname(chname.c_str());
+      strlcpy(chan->name, chan->dname, sizeof(chan->name));
+      chan->status = chan->ircnet_status = 0;
+      chan->ircnet_status |= CHAN_PEND;
+      reset_chans = 2;
+    }
     else if (type == STR("+buildts"))
     else if (type == STR("+buildts"))
       old_buildts = strtol(str.c_str(), NULL, 10);
       old_buildts = strtol(str.c_str(), NULL, 10);
     else if (type == STR("+botname"))
     else if (type == STR("+botname"))
@@ -699,7 +711,8 @@ readsocks(const char *fname)
         replay_cache(servidx, NULL);
         replay_cache(servidx, NULL);
       else
       else
         dprintf(DP_DUMP, "VERSION\n");
         dprintf(DP_DUMP, "VERSION\n");
-      reset_chans = 1;
+      if (!reset_chans)
+        reset_chans = 1;
     }
     }
   }
   }
   delete[] nick;
   delete[] nick;
@@ -765,6 +778,9 @@ restart(int idx)
     stream << buf.printf(STR("+in_deaf\n"));
     stream << buf.printf(STR("+in_deaf\n"));
   if (in_callerid)
   if (in_callerid)
     stream << buf.printf(STR("+in_callerid\n"));
     stream << buf.printf(STR("+in_callerid\n"));
+  for (struct chanset_t *chan = chanset; chan; chan = chan->next)
+    if (shouldjoin(chan) && (channel_active(chan) || channel_pending(chan)))
+      stream << buf.printf(STR("+chan %s\n"), chan->dname);
   stream << buf.printf(STR("+buildts %li\n"), buildts);
   stream << buf.printf(STR("+buildts %li\n"), buildts);
   stream << buf.printf(STR("+ip4 %s\n"), myipstr(AF_INET));
   stream << buf.printf(STR("+ip4 %s\n"), myipstr(AF_INET));
   stream << buf.printf(STR("+ip6 %s\n"), myipstr(AF_INET6));
   stream << buf.printf(STR("+ip6 %s\n"), myipstr(AF_INET6));
@@ -776,12 +792,12 @@ restart(int idx)
 
 
   if (conf.bot->hub)
   if (conf.bot->hub)
     write_userfile(idx);
     write_userfile(idx);
-
+/*
   if (server_online) {
   if (server_online) {
     do_chanset(NULL, NULL, STR("+inactive"), DO_LOCAL);
     do_chanset(NULL, NULL, STR("+inactive"), DO_LOCAL);
     dprintf(DP_DUMP, STR("JOIN 0\n"));
     dprintf(DP_DUMP, STR("JOIN 0\n"));
   }
   }
-
+*/
   fixmod(binname);
   fixmod(binname);
 
 
   /* replace image now */
   /* replace image now */

+ 1 - 1
src/mod/channels.mod/channels.h

@@ -50,7 +50,7 @@ int u_sticky_mask(maskrec *, char *);
 int u_setsticky_mask(struct chanset_t *, maskrec *, char *, int, const char);
 int u_setsticky_mask(struct chanset_t *, maskrec *, char *, int, const char);
 int SplitList(char *, const char *, int *, const char ***);
 int SplitList(char *, const char *, int *, const char ***);
 int channel_modify(char *, struct chanset_t *, int, char **, bool);
 int channel_modify(char *, struct chanset_t *, int, char **, bool);
-int channel_add(char *, char *, char *, bool = 0);
+int channel_add(char *, const char *, char *, bool = 0);
 void clear_channel(struct chanset_t *, bool);
 void clear_channel(struct chanset_t *, bool);
 int u_equals_mask(maskrec *, char *);
 int u_equals_mask(maskrec *, char *);
 bool u_match_mask(struct maskrec *, char *);
 bool u_match_mask(struct maskrec *, char *);

+ 5 - 4
src/mod/channels.mod/tclchan.c

@@ -815,9 +815,10 @@ int channel_modify(char *result, struct chanset_t *chan, int items, char **item,
 
 
   if (!conf.bot->hub && (chan != chanset_default)) {
   if (!conf.bot->hub && (chan != chanset_default)) {
     if ((old_status ^ chan->status) & (CHAN_INACTIVE | CHAN_BACKUP)) {
     if ((old_status ^ chan->status) & (CHAN_INACTIVE | CHAN_BACKUP)) {
-      if (!shouldjoin(chan) && (chan->ircnet_status & (CHAN_ACTIVE | CHAN_PEND)))
+      if (!shouldjoin(chan) && (chan->ircnet_status & (CHAN_ACTIVE | CHAN_PEND))) {
+        putlog(LOG_DEBUG, "*", "In %s, but I shouldn't be, parting...", chan->dname);
         dprintf(DP_SERVER, "PART %s\n", chan->name[0] ? chan->name : chan->dname);
         dprintf(DP_SERVER, "PART %s\n", chan->name[0] ? chan->name : chan->dname);
-      else if (shouldjoin(chan))
+      } else if (shouldjoin(chan))
         join_chan(chan);
         join_chan(chan);
     }
     }
     if (me_op(chan)) {
     if (me_op(chan)) {
@@ -920,7 +921,7 @@ void clear_channel(struct chanset_t *chan, bool reset)
 
 
 /* Create new channel and parse commands.
 /* Create new channel and parse commands.
  */
  */
-int channel_add(char *result, char *newname, char *options, bool isdefault)
+int channel_add(char *result, const char *newname, char *options, bool isdefault)
 {
 {
   /* When loading userfile */
   /* When loading userfile */
   if (newname && newname[0] && loading && !strcmp(newname, "default"))
   if (newname && newname[0] && loading && !strcmp(newname, "default"))
@@ -1018,7 +1019,7 @@ int channel_add(char *result, char *newname, char *options, bool isdefault)
      * any code later on. chan->name gets updated with the channel name as
      * any code later on. chan->name gets updated with the channel name as
      * the server knows it, when we join the channel. <cybah>
      * the server knows it, when we join the channel. <cybah>
      */
      */
-    strlcpy(chan->dname, newname, 81);
+    strlcpy(chan->dname, newname, sizeof(chan->dname));
 
 
     /* Initialize chan->channel info */
     /* Initialize chan->channel info */
     if (isdefault) {
     if (isdefault) {

+ 5 - 12
src/mod/irc.mod/chan.c

@@ -1544,6 +1544,7 @@ void recheck_channel(struct chanset_t *chan, int dobans)
   --stacking;
   --stacking;
 }
 }
 
 
+#ifdef CACHE
 /* got 302: userhost
 /* got 302: userhost
  * <server> 302 <to> :<nick??user@host>
  * <server> 302 <to> :<nick??user@host>
  */
  */
@@ -1551,10 +1552,8 @@ static int got302(char *from, char *msg)
 {
 {
   char *p = NULL, *nick = NULL, *uhost = NULL;
   char *p = NULL, *nick = NULL, *uhost = NULL;
 
 
-#ifdef CACHE
   cache_t *cache = NULL;
   cache_t *cache = NULL;
   cache_chan_t *cchan = NULL;
   cache_chan_t *cchan = NULL;
-#endif
 
 
   newsplit(&msg);
   newsplit(&msg);
   fixcolon(msg);
   fixcolon(msg);
@@ -1572,13 +1571,6 @@ static int got302(char *from, char *msg)
   if ((p = strchr(uhost, ' ')))
   if ((p = strchr(uhost, ' ')))
     *p = 0;
     *p = 0;
 
 
-  if (match_my_nick(nick)) {
-    strlcpy(botuserip, uhost, UHOSTLEN);
-    sdprintf("botuserip: %s", botuserip);
-    return 0;
-  }
-
-#ifdef CACHE
   if ((cache = cache_find(nick))) {
   if ((cache = cache_find(nick))) {
     if (!cache->uhost[0])
     if (!cache->uhost[0])
     strlcpy(cache->uhost, uhost, sizeof(cache->uhost));
     strlcpy(cache->uhost, uhost, sizeof(cache->uhost));
@@ -1606,9 +1598,9 @@ static int got302(char *from, char *msg)
       }
       }
     }
     }
   }
   }
-#endif
   return 0;
   return 0;
 }
 }
+#endif
 
 
 #ifdef CACHE
 #ifdef CACHE
 /* got341 invited
 /* got341 invited
@@ -2634,7 +2626,7 @@ static int gotjoin(char *from, char *chname)
 	  /* It was me joining! Need to update the channel record with the
 	  /* It was me joining! Need to update the channel record with the
 	   * unique name for the channel (as the server see's it). <cybah>
 	   * unique name for the channel (as the server see's it). <cybah>
 	   */
 	   */
-	  strlcpy(chan->name, chname, 81);
+	  strlcpy(chan->name, chname, sizeof(chan->name));
 	  chan->ircnet_status &= ~CHAN_JUPED;
 	  chan->ircnet_status &= ~CHAN_JUPED;
 
 
           /* ... and log us joining. Using chan->dname for the channel is
           /* ... and log us joining. Using chan->dname for the channel is
@@ -2985,6 +2977,7 @@ void check_should_cycle(struct chanset_t *chan)
     }
     }
   }
   }
   if (splitbotops > 5) {
   if (splitbotops > 5) {
+    sdprintf("Cycling %s", chan->dname);
     /* I'm only one opped here... and other side has some ops... so i'm cycling */
     /* I'm only one opped here... and other side has some ops... so i'm cycling */
     if (localnonops) {
     if (localnonops) {
       /* need to unset any +kil first */
       /* need to unset any +kil first */
@@ -3338,8 +3331,8 @@ static int gotnotice(char *from, char *msg)
 
 
 static cmd_t irc_raw[] =
 static cmd_t irc_raw[] =
 {
 {
-  {"302",       "",     (Function) got302,      "irc:302", LEAF},
 #ifdef CACHE
 #ifdef CACHE
+  {"302",       "",     (Function) got302,      "irc:302", LEAF},
   {"341",       "",     (Function) got341,      "irc:341", LEAF},
   {"341",       "",     (Function) got341,      "irc:341", LEAF},
 #endif /* CACHE */
 #endif /* CACHE */
   {"324",	"",	(Function) got324,	"irc:324", LEAF},
   {"324",	"",	(Function) got324,	"irc:324", LEAF},

+ 3 - 1
src/mod/irc.mod/irc.c

@@ -1308,10 +1308,11 @@ reset_chan_info(struct chanset_t *chan)
   if (!chan) return;
   if (!chan) return;
 
 
   if (!chan->name[0])
   if (!chan->name[0])
-    strlcpy(chan->name, chan->dname, 81);
+    strlcpy(chan->name, chan->dname, sizeof(chan->name));
 
 
   /* Don't reset the channel if we're already resetting it */
   /* Don't reset the channel if we're already resetting it */
   if (!shouldjoin(chan)) {
   if (!shouldjoin(chan)) {
+    sdprintf("Resetting %s but I shouldn't be there, parting...", chan->dname);
     dprintf(DP_MODE, "PART %s\n", chan->name);
     dprintf(DP_MODE, "PART %s\n", chan->name);
     return;
     return;
   }
   }
@@ -1510,6 +1511,7 @@ static void
 check_expired_chanstuff(struct chanset_t *chan)
 check_expired_chanstuff(struct chanset_t *chan)
 {
 {
   if ((channel_active(chan) || channel_pending(chan)) && !shouldjoin(chan)) {
   if ((channel_active(chan) || channel_pending(chan)) && !shouldjoin(chan)) {
+    sdprintf("Active/Pending in %s but I shouldn't be there, parting...", chan->dname);
     dprintf(DP_MODE, "PART %s\n", chan->name[0] ? chan->name : chan->dname);
     dprintf(DP_MODE, "PART %s\n", chan->name[0] ? chan->name : chan->dname);
   } else if (channel_active(chan)) {
   } else if (channel_active(chan)) {
     masklist *b = NULL, *e = NULL;
     masklist *b = NULL, *e = NULL;

+ 33 - 0
src/mod/server.mod/servmsg.c

@@ -1602,6 +1602,38 @@ static int got301(char *from, char *msg)
   return 0;
   return 0;
 }
 }
 
 
+/* got 302: userhost
+ * <server> 302 <to> :<nick??user@host>
+ */
+static int got302(char *from, char *msg)
+{
+  char *p = NULL, *nick = NULL, *uhost = NULL;
+
+  newsplit(&msg);
+  fixcolon(msg);
+
+  p = strchr(msg, '=');
+  if (!p)
+    p = strchr(msg, '*');
+  if (!p)
+    return 0;
+  *p = 0;
+  nick = msg;
+  p += 2;		/* skip =|* plus the next char */
+  uhost = p;
+
+  if ((p = strchr(uhost, ' ')))
+    *p = 0;
+
+  if (match_my_nick(nick)) {
+    strlcpy(botuserip, uhost, UHOSTLEN);
+    sdprintf("botuserip: %s", botuserip);
+    return 0;
+  }
+
+  return 0;
+}
+
 /* 313 $me nick :server text */
 /* 313 $me nick :server text */
 static int got313(char *from, char *msg)
 static int got313(char *from, char *msg)
 {
 {
@@ -1778,6 +1810,7 @@ static cmd_t my_raw_binds[] =
   {"001",	"",	(Function) got001,		NULL, LEAF},
   {"001",	"",	(Function) got001,		NULL, LEAF},
   {"004",	"",	(Function) got004,		NULL, LEAF},
   {"004",	"",	(Function) got004,		NULL, LEAF},
   {"005",	"",	(Function) got005,		NULL, LEAF},
   {"005",	"",	(Function) got005,		NULL, LEAF},
+  {"302",       "",     (Function) got302,		NULL, LEAF},
   {"303",	"",	(Function) got303,		NULL, LEAF},
   {"303",	"",	(Function) got303,		NULL, LEAF},
   {"432",	"",	(Function) got432,		NULL, LEAF},
   {"432",	"",	(Function) got432,		NULL, LEAF},
   {"433",	"",	(Function) got433,		NULL, LEAF},
   {"433",	"",	(Function) got433,		NULL, LEAF},

+ 13 - 4
src/mod/share.mod/share.c

@@ -54,6 +54,8 @@
 #include "src/mod/irc.mod/irc.h"
 #include "src/mod/irc.mod/irc.h"
 #include "src/mod/server.mod/server.h"
 #include "src/mod/server.mod/server.h"
 
 
+void irc_init();
+
 static struct flag_record fr = { 0, 0, 0, 0 };
 static struct flag_record fr = { 0, 0, 0, 0 };
 
 
 static bd::Stream* stream_in;
 static bd::Stream* stream_in;
@@ -1451,11 +1453,18 @@ static void share_read_stream(int idx, bd::Stream& stream) {
 
 
   /* If this is ever changed, do mind the restarting bool as it will prevent 001 from dumping JOINs.. */
   /* If this is ever changed, do mind the restarting bool as it will prevent 001 from dumping JOINs.. */
   if (reset_chans) {
   if (reset_chans) {
+    if (reset_chans == 2) {
+      irc_init();
+      putlog(LOG_DEBUG, "*", "Resetting channel info for all channels...");
+      for (chan = chanset; chan; chan = chan->next) {
+        if (shouldjoin(chan) && channel_pending(chan)) { // Set when reading socksfile
+          chan->ircnet_status &= ~(CHAN_PEND); // Reset flags to force a reset
+          reset_chan_info(chan);
+        }
+      }
+    } else
+      join_chans();
     reset_chans = 0;
     reset_chans = 0;
-//    putlog(LOG_DEBUG, "*", "Resetting channel info for all channels...");
-//    for (chan = chanset; chan; chan = chan->next)
-//      reset_chan_info(chan);
-    join_chans();
   }
   }
 }
 }