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

* Allow localhub to operate as a hub in some ways

Bryan Drewery 16 лет назад
Родитель
Сommit
e8e120cde9
8 измененных файлов с 27 добавлено и 12 удалено
  1. 2 2
      src/botcmd.c
  2. 5 1
      src/botnet.c
  3. 8 4
      src/dcc.c
  4. 1 1
      src/dccutil.c
  5. 1 1
      src/main.c
  6. 7 0
      src/misc.c
  7. 2 2
      src/userent.c
  8. 1 1
      src/userrec.c

+ 2 - 2
src/botcmd.c

@@ -539,7 +539,7 @@ static void bot_log(int idx, char *par)
   if (egg_isdigit(par[0])) {
     int type = atoi(newsplit(&par));
 
-    if (conf.bot->hub)
+    if (conf.bot->hub || conf.bot->localhub)
       botnet_send_log(idx, from, type, par);
 
     putlog(type, "@", "(%s) %s", from, par);
@@ -812,7 +812,7 @@ static void bot_timesync(int idx, char *par)
 //  putlog(LOG_DEBUG, "@", "Got timesync from %s: %s (%li - %li)", dcc[idx].nick, par, atol(par), now);
   timesync = atol(par) - now;
 
-  if (conf.bot->hub)
+  if (conf.bot->hub || conf.bot->localhub)
     send_timesync(-1);
 }
 

+ 5 - 1
src/botnet.c

@@ -765,7 +765,7 @@ void dump_links(int z)
   register size_t l;
   char x[1024] = "";
 
-  if (conf.bot->hub) {
+  if (conf.bot->hub || conf.bot->localhub) {
     tand_t *bot = NULL;
     char *p = NULL;
 
@@ -1646,9 +1646,12 @@ void check_botnet_pings()
    if (dcc[i].type) {
      top_index = i;
     if (dcc[i].type == &DCC_BOT) {
+      // Hubs only allow localhubs to link, which CAN link bots now, so this isn't so cut and dry now
+#ifdef no
       if (dcc[i].status & STAT_LEAF) {
         tand_t *via = findbot(dcc[i].nick);
 
+        // Check if this leaf has any linked bots
         for (bot = tandbot; bot; bot = bot->next) {
           if ((via == bot->via) && (bot != via)) {
 	    /* Not leaflike behavior */
@@ -1676,6 +1679,7 @@ void check_botnet_pings()
 	    dcc[i].status &= ~STAT_WARNED;
         }
       }
+#endif
 
       if (dcc[i].status & STAT_PINGED) {
         char s[1024] = "";

+ 8 - 4
src/dcc.c

@@ -222,7 +222,7 @@ greet_new_bot(int idx)
   dcc[idx].u.bot->version[0] = 0;
   dcc[idx].u.bot->sysname[0] = 0;
   dcc[idx].u.bot->numver = 0;
-  if (conf.bot->hub && dcc[idx].user && (!(dcc[idx].user->flags & USER_OP))) {
+  if ((conf.bot->hub || conf.bot->localhub) && dcc[idx].user && (!(dcc[idx].user->flags & USER_OP))) {
     putlog(LOG_BOTS, "*", "Rejecting link from %s", dcc[idx].nick);
     dprintf(idx, "error You are being rejected.\n");
     dprintf(idx, "bye\n");
@@ -300,7 +300,7 @@ bot_version(int idx, char *par)
   if (par[0])
     vversion = newsplit(&par);
 
-  if (conf.bot->hub) {
+  if (conf.bot->hub || (conf.bot->localhub && (dcc[idx].status & STAT_UNIXDOMAIN))) {
     putlog(LOG_BOTS, "*", "Linked to %s.\n", dcc[idx].nick);
     chatout("*** Linked to %s.\n", dcc[idx].nick);
 
@@ -539,6 +539,7 @@ display_dcc_bot(int idx, char *buf, size_t bufsiz)
   buf[i++] = b_status(idx) & STAT_OFFEREDU ? 'B' : 'b';
   buf[i++] = b_status(idx) & STAT_SENDINGU ? 'D' : 'd';
   buf[i++] = b_status(idx) & STAT_GETTINGU ? 'E' : 'e';
+  buf[i++] = b_status(idx) & STAT_UNIXDOMAIN ? 'Z' : 'z';
 #ifdef USE_IPV6
   if (sockprotocol(dcc[idx].sock) == AF_INET6 && dcc[idx].host6[0])
     buf[i++] = '6';
@@ -985,10 +986,13 @@ dcc_chat_pass(int idx, char *buf, int atr)
     } else if (!strcasecmp(pass, STR("neg."))) {		/* we're done, link up! */
       dcc[idx].type = &DCC_BOT_NEW;
       dcc[idx].u.bot = (struct bot_info *) my_calloc(1, sizeof(struct bot_info));
-      dcc[idx].status = STAT_CALLED;
+      if (dcc[idx].status & STAT_UNIXDOMAIN)
+        dcc[idx].status = STAT_UNIXDOMAIN|STAT_CALLED;
+      else
+        dcc[idx].status = STAT_CALLED;
       dprintf(idx, "goodbye!\n");
       greet_new_bot(idx);
-      if (conf.bot->hub)
+      if (conf.bot->hub || conf.bot->localhub)
         send_timesync(idx);
     } else if (!strcasecmp(pass, STR("neg"))) {
       int snum = findanysnum(dcc[idx].sock);

+ 1 - 1
src/dccutil.c

@@ -64,7 +64,7 @@ static int dcc_flood_thr = 3;
 void
 init_dcc()
 {
-  if (!conf.bot->hub)
+  if (!conf.bot->hub || conf.bot->localhub)
     protect_telnet = 0;
   if (max_dcc < 1)
     max_dcc = 1;

+ 1 - 1
src/main.c

@@ -594,7 +594,7 @@ static void core_minutely()
       fatal(STR("MEMORY HACKED"), 0);
     check_maxfiles();
     check_mypid();
-  } else
+  } else if (conf.bot->hub || conf.bot->localhub)
     send_timesync(-1);
 
   check_bind_time(&nowtm);

+ 7 - 0
src/misc.c

@@ -992,6 +992,13 @@ int updatebin(int idx, char *par, int secs)
 
 int bot_aggressive_to(struct userrec *u)
 {
+  if (conf.bot->localhub) {
+    for (conf_bot* bot = conf.bots; bot && bot->nick; bot = bot->next) {
+      if (!strcmp(u->handle, bot->nick))
+        return 1;
+    }
+  }
+
   char mypval[HANDLEN + 4] = "", botpval[HANDLEN + 4] = "";
 
   link_pref_val(u, botpval);

+ 2 - 2
src/userent.c

@@ -299,7 +299,7 @@ static bool set_unpack(struct userrec *u, struct user_entry *e)
   head = curr = e->u.list;
   e->u.extra = NULL;
 
-  if (conf.bot->hub || !strcasecmp(conf.bot->nick, u->handle)) {
+  if (conf.bot->hub || conf.bot->localhub || !strcasecmp(conf.bot->nick, u->handle)) {
     struct xtra_key *t = NULL;
     char *key = NULL, *data = NULL;
 
@@ -351,7 +351,7 @@ static bool set_gotshare(struct userrec *u, struct user_entry *e, char *buf, int
   /* var_set_by_name() called set_user(), no need to do it again... */
   } 
   /* not else if as the hub might have gotten a botset for itself */
-  if (conf.bot->hub) {
+  if (conf.bot->hub || conf.bot->localhub) {
   /* only hubs need to bother saving this stuff, leaf bots just store it in vars[] */
     struct xtra_key *xk = (struct xtra_key *) my_calloc(1, sizeof(struct xtra_key));
 

+ 1 - 1
src/userrec.c

@@ -388,7 +388,7 @@ static void write_user(const struct userrec *u, bd::Stream& stream, int idx)
     } else
 #endif
     if (ue->type)
-      if (conf.bot->hub)
+      if (conf.bot->hub || conf.bot->localhub)
         ue->type->write_userfile(stream, u, ue, idx);
   }
 }