瀏覽代碼

* Fixed bots mass sending out CONFIG entries when they linked.

svn: 746
Bryan Drewery 22 年之前
父節點
當前提交
d25449ae5a
共有 6 個文件被更改,包括 26 次插入8 次删除
  1. 2 1
      doc/UPDATES
  2. 7 1
      src/botcmd.c
  3. 1 1
      src/botmsg.c
  4. 10 2
      src/cfg.c
  5. 3 3
      src/cfg.h
  6. 3 0
      src/mod/server.mod/server.c

+ 2 - 1
doc/UPDATES

@@ -8,7 +8,8 @@ This is a summary of ChangeLog basically.
 5.Fixed a double log cosmetic bug with dcc cmds.
 6.If no config file, one is generated now.
 7.And if no bots are listed, the bot nows gives an error.
-
+8.cmd_quit was not returning from 'su' correctly.
+9.Fixed bots mass sending out CONFIG entries when they linked.
 
 1.1.0
 1.Rewrote the shell config parsing...

+ 7 - 1
src/botcmd.c

@@ -156,7 +156,12 @@ void bot_cmdpass(int idx, char *par)
 
 void bot_config(int idx, char *par)
 {
-  got_config_share(idx, par);
+  got_config_share(idx, par, 0);
+}
+
+void bot_configbroad(int idx, char *par)
+{
+  got_config_share(idx, par, 1);
 }
 
 void bot_remotecmd(int idx, char *par) {
@@ -1313,6 +1318,7 @@ botcmd_t C_bot[] =
   {"bye",		(Function) bot_bye},
   {"c",			(Function) bot_chan2},
   {"cg",                (Function) bot_config},
+  {"cgb",		(Function) bot_configbroad},
 #ifdef S_DCCPASS
   {"cp", 		(Function) bot_cmdpass},
 #endif

+ 1 - 1
src/botmsg.c

@@ -457,7 +457,7 @@ void botnet_send_cfg(int idx, struct cfg_entry * entry) {
 void botnet_send_cfg_broad(int idx, struct cfg_entry * entry) {
   int l;
   if (tands > 0) {
-      l = simple_sprintf(OBUF, STR("cg %s %s\n"), entry->name, entry->gdata ? entry->gdata : "");
+      l = simple_sprintf(OBUF, STR("cgb %s %s\n"), entry->name, entry->gdata ? entry->gdata : "");
     send_tand_but(idx, OBUF, l);
   }
 }

+ 10 - 2
src/cfg.c

@@ -705,7 +705,9 @@ void init_config()
   add_cfg(&CFG_SERVERS);
   add_cfg(&CFG_SERVERS6);
   add_cfg(&CFG_REALNAME);
+  cfg_noshare = 1;
   set_cfg_str(NULL, STR("realname"), "A deranged product of evil coders");
+  cfg_noshare = 0;
   add_cfg(&CFG_OPBOTS);
   add_cfg(&CFG_INBOTS);
   add_cfg(&CFG_LAGTHRESHOLD);
@@ -798,13 +800,18 @@ void userfile_cfg_line(char *ln)
     if (!strcmp(cfg[i]->name, name))
       cfgent = cfg[i];
   if (cfgent) {
+    /* if we are a leaf, dont share the cfg line. */
+    if (bot_hublevel(conf.bot->u) == 999)
+      cfg_noshare = 1;
     set_cfg_str(NULL, cfgent->name, (ln && ln[0]) ? ln : NULL);
+    /* regardless of leaf/hub it is safe to set this to 0 */
+    cfg_noshare = 0;
   } else
     putlog(LOG_ERRORS, "*", STR("Unrecognized config entry %s in userfile"), name);
 
 }
 
-void got_config_share(int idx, char *ln)
+void got_config_share(int idx, char *ln, int broad)
 {
   char *name = NULL;
   int i;
@@ -817,7 +824,8 @@ void got_config_share(int idx, char *ln)
       cfgent = cfg[i];
   if (cfgent) {
     set_cfg_str(NULL, cfgent->name, (ln && ln[0]) ? ln : NULL);
-    botnet_send_cfg_broad(idx, cfgent);
+    if (broad)
+      botnet_send_cfg_broad(idx, cfgent);
   } else
     putlog(LOG_ERRORS, "*", STR("Unrecognized config entry %s in userfile"), name);
   cfg_noshare = 0;

+ 3 - 3
src/cfg.h

@@ -19,10 +19,10 @@ typedef struct cfg_entry {
 } cfg_entry_T;
 
 #ifndef MAKING_MODS
-void set_cfg_str(char *target, char *entryname, char *data);
+void set_cfg_str(char *, char *, char *);
 void add_cfg(struct cfg_entry *);
-void got_config_share(int idx, char * ln);
-void userfile_cfg_line(char *ln);
+void got_config_share(int, char *, int);
+void userfile_cfg_line(char *);
 void trigger_cfg_changed();
 #ifdef S_DCCPASS
 int check_cmd_pass(const char *, char *);

+ 3 - 0
src/mod/server.mod/server.c

@@ -15,6 +15,7 @@
 
 static Function *global = NULL;
 extern struct cfg_entry CFG_OPTIMESLACK;
+extern int		cfg_noshare;
 static int checked_hostmask;	/* Used in request_op()/check_hostmask() cleared on connect */
 static int ctcp_mode;
 static int serv;		/* sock # of server currently */
@@ -1625,7 +1626,9 @@ char *server_start(Function *global_funcs)
   add_cfg(&CFG_SERVERS);
   add_cfg(&CFG_SERVERS6);
   add_cfg(&CFG_REALNAME);
+  cfg_noshare = 1;
   set_cfg_str(NULL, STR("realname"), "A deranged product of evil coders.");
+  cfg_noshare = 0;
   return NULL;
 }
 #endif /* LEAF */