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

* Ported [2837] [2838] to 1.2.10
* Hubs will now boot removed users/bots upon userfile reload. (addresses #243)


svn: 2839

Bryan Drewery 20 лет назад
Родитель
Сommit
761e16bfb9
5 измененных файлов с 43 добавлено и 3 удалено
  1. 1 0
      doc/UPDATES
  2. 15 1
      src/chanprog.c
  3. 9 2
      src/mod/share.mod/share.c
  4. 17 0
      src/users.c
  5. 1 0
      src/users.h

+ 1 - 0
doc/UPDATES

@@ -23,6 +23,7 @@ Lines prefixed with '-' were disabled before release and are not finished, or ar
 * Added mIRC 6.17 version reply
 * Fixed empty version replies. (fixes #236)
 * Fixed a sharing segfault with an empty userfile. (fixes #243)
+* Hubs will now boot removed users/bots upon userfile reload. (addresses #243)
 
 1.2.9 - http://tracker.shatow.net/milestone/1.2.9
 * Fixed cmd_[un]stick not properly using numbers for channel masks. (#160)

+ 15 - 1
src/chanprog.c

@@ -599,7 +599,21 @@ void reload()
   checkchans(0);
   if (!readuserfile(userfile, &userlist))
     fatal("User file is missing!", 0);
-  Auth::FillUsers();
+
+  /* ensure we did not lose our internal users */
+  load_internal_users();
+  /* make sure I am added and conf.bot->u is set */
+  add_myself_to_userlist();
+
+  /* Make sure no removed users/bots are still connected. */
+  check_stale_dcc_users();
+  
+  /* I don't think these will ever be called anyway. */
+  if (!conf.bot->hub) {
+    Auth::FillUsers();
+    check_hostmask();
+  }
+
   checkchans(1);
   loading = 0;
   var_parse_my_botset();

+ 9 - 2
src/mod/share.mod/share.c

@@ -1312,8 +1312,15 @@ finish_share(int idx)
   /* Our hostmask may have been updated on connect, but the new userfile may not have it. */
   check_hostmask();
 
-  /* copy over any auth users */
-  Auth::FillUsers();
+  /* Make sure no removed users/bots are still connected. */
+  check_stale_dcc_users();
+
+  if (!conf.bot->hub) {  
+    /* Our hostmask may have been updated on connect, but the new userfile may not have it. */
+    check_hostmask();
+    /* copy over any auth users */
+    Auth::FillUsers();
+  }
 
   cmdpass_free(old_cmdpass);
 

+ 17 - 0
src/users.c

@@ -904,6 +904,7 @@ int readuserfile(const char *file, struct userrec **ret)
           sdprintf("FAILED TO UNPACK '%s'", e->name);
       }
   }
+
   /* process the user data *now* */
   if (!conf.bot->hub)
     unlink(userfile);
@@ -1174,3 +1175,19 @@ void autolink_cycle(char *start)
   else
     autolink_cycle_leaf(start);
 }
+
+
+void check_stale_dcc_users() 
+{
+  for (int i = 0; i < dcc_total; ++i) {
+    if (!dcc[i].type || !dcc[i].nick[0]) continue;
+    
+
+    if (dcc[i].user == NULL) { /* Removed user */
+      if (dcc[i].type == &DCC_BOT || dcc[i].type == &DCC_FORK_BOT || dcc[i].type == &DCC_BOT_NEW)
+        botunlink(i, dcc[i].nick, "No longer a valid bot.");
+      else if (dcc[i].type == &DCC_CHAT)
+        do_boot(i, "internal", "No longer a valid user.");
+    }
+  }
+}

+ 1 - 0
src/users.h

@@ -173,6 +173,7 @@ void tell_users_match(int, char *, int, int, char *, int);
 int readuserfile(const char *, struct userrec **);
 void check_pmode();
 void link_pref_val(struct userrec *u, char *lval);
+void check_stale_dcc_users();
 
 extern char			userfile[];
 extern time_t			ignore_time;