Ver Fonte

* Localhub: Don't share out VAR_NOLDEF vars to child bots until linked to a hub

Bryan Drewery há 16 anos atrás
pai
commit
6188eb8f3a
4 ficheiros alterados com 17 adições e 4 exclusões
  1. 4 1
      src/dcc.c
  2. 1 0
      src/main.c
  3. 1 1
      src/main.h
  4. 11 2
      src/set.c

+ 4 - 1
src/dcc.c

@@ -310,13 +310,16 @@ bot_version(int idx, char *par)
 
 
   if (conf.bot->hub || conf.bot->localhub) {
   if (conf.bot->hub || conf.bot->localhub) {
     if (bot_hublevel(dcc[idx].user) < 999) {
     if (bot_hublevel(dcc[idx].user) < 999) {
-      if (!bot_aggressive_to(dcc[idx].user))    //not aggressive, so they are technically my uplink.
+      if (!bot_aggressive_to(dcc[idx].user)) {   //not aggressive, so they are technically my uplink.
         uplink_idx = idx;
         uplink_idx = idx;
+        have_linked_to_hub = 1;
+      }
       dcc[idx].hub = 1;
       dcc[idx].hub = 1;
     }
     }
 
 
     botnet_send_nlinked(idx, dcc[idx].nick, conf.bot->nick, '!', vlocalhub, vbuildts, vcommit, vversion);
     botnet_send_nlinked(idx, dcc[idx].nick, conf.bot->nick, '!', vlocalhub, vbuildts, vcommit, vversion);
   } else {
   } else {
+    have_linked_to_hub = 1;
     uplink_idx = idx;
     uplink_idx = idx;
     dcc[idx].hub = 1;
     dcc[idx].hub = 1;
   }
   }

+ 1 - 0
src/main.c

@@ -98,6 +98,7 @@ bool	used_B = 0;		/* did we get started with -B? */
 int 	role;
 int 	role;
 bool 	loading = 0;
 bool 	loading = 0;
 int	default_flags = 0;	/* Default user flags and */
 int	default_flags = 0;	/* Default user flags and */
+bool     have_linked_to_hub = 0;  /* Have we ever been linked to a hub? */
 int	default_uflags = 0;	/* Default userdefinied flags for people
 int	default_uflags = 0;	/* Default userdefinied flags for people
 				   who say 'hello' or for .adduser */
 				   who say 'hello' or for .adduser */
 int     do_restart = 0;
 int     do_restart = 0;

+ 1 - 1
src/main.h

@@ -15,7 +15,7 @@ enum {
 
 
 extern int		role, default_flags, default_uflags, do_confedit,
 extern int		role, default_flags, default_uflags, do_confedit,
 			updating, do_restart;
 			updating, do_restart;
-extern bool		use_stderr, backgrd, used_B, term_z, loading, restart_was_update, restarting;
+extern bool		use_stderr, backgrd, used_B, term_z, loading, have_linked_to_hub, restart_was_update, restarting;
 extern char		tempdir[], *binname, owner[], version[151], ver[101], quit_msg[], *socksfile;
 extern char		tempdir[], *binname, owner[], version[151], ver[101], quit_msg[], *socksfile;
 extern time_t		online_since, now, restart_time;
 extern time_t		online_since, now, restart_time;
 extern uid_t		myuid;
 extern uid_t		myuid;

+ 11 - 2
src/set.c

@@ -831,8 +831,17 @@ void write_vars_and_cmdpass(bd::Stream& stream, int idx)
   int i = 0;
   int i = 0;
 
 
   for (i = 0; vars[i].name; i++) {
   for (i = 0; vars[i].name; i++) {
-    /* send blanks if our variable isn't set, theirs MIGHT be set and needs to be UNSET */
-    stream << buf.printf("@ %s %s\n", vars[i].name, vars[i].gdata ? vars[i].gdata : "");
+    // If we're a localhub, dont share variables set to not leaf default unless we're linked to a hub.
+    // Otherwise, we share out servers, and the child bots connect to the default list,
+    // before ever receiving the actual list from the hub. (Along with stuff like realname)
+    if (conf.bot->hub ||
+        (conf.bot->localhub &&
+         (!(vars[i].flags & VAR_NOLDEF) ||
+          ((vars[i].flags & VAR_NOLDEF) && have_linked_to_hub))
+         )) {
+      /* send blanks if our variable isn't set, theirs MIGHT be set and needs to be UNSET */
+      stream << buf.printf("@ %s %s\n", vars[i].name, vars[i].gdata ? vars[i].gdata : "");
+    }
   }
   }
 
 
   for (struct cmd_pass *cp = cmdpass; cp; cp = cp->next)
   for (struct cmd_pass *cp = cmdpass; cp; cp = cp->next)