Browse Source

* Now checking new botuserhost at same time that we SET it (after the server connect WHOIS)

svn: 1982
Bryan Drewery 21 years ago
parent
commit
786b35d07f
4 changed files with 27 additions and 41 deletions
  1. 0 36
      src/mod/irc.mod/irc.c
  2. 0 1
      src/mod/server.mod/server.c
  3. 1 1
      src/mod/server.mod/server.h
  4. 26 3
      src/mod/server.mod/servmsg.c

+ 0 - 36
src/mod/irc.mod/irc.c

@@ -596,37 +596,6 @@ getin_request(char *botnick, char *code, char *par)
   }
   }
 }
 }
 
 
-void
-check_hostmask()
-{
-  if (!server_online || !botuserhost[0])
-    return;
-
-  char s[UHOSTLEN + 2] = "";
-
-  checked_hostmask = 1;
-
-  sprintf(s, "*!%s", botuserhost);		/* just add actual user@ident, regardless of ~ */
-
-  /* dont add the host if it conflicts with another in the userlist */
-  struct userrec *u = NULL;
-  struct list_type *q = NULL;
-
-  for (u = userlist; u; u = u->next) {
-    q = (struct list_type *) get_user(&USERENTRY_HOSTS, u);
-    for (; q; q = q->next) {
-      if (wild_match(s, q->extra) || wild_match(q->extra, s)) {
-        if (u != conf.bot->u)
-          putlog(LOG_WARN, "*", "My automatic hostmask '%s' would conflict with user: '%s'. (Not adding)", s, u->handle);
-        return;
-      }
-    }
-  }
-
-  addhost_by_handle(conf.bot->nick, s);
-  putlog(LOG_GETIN, "*", "Updated my hostmask: %s", s);
-}
-
 static void
 static void
 request_op(struct chanset_t *chan)
 request_op(struct chanset_t *chan)
 {
 {
@@ -665,9 +634,6 @@ request_op(struct chanset_t *chan)
            OPREQ_SECONDS);
            OPREQ_SECONDS);
     return;
     return;
   }
   }
-  if (!checked_hostmask)
-    check_hostmask();           /* check, and update hostmask */
-
   int cnt = OP_BOTS, i2;
   int cnt = OP_BOTS, i2;
   memberlist *ml = NULL;
   memberlist *ml = NULL;
   memberlist *botops[MAX_BOTS];
   memberlist *botops[MAX_BOTS];
@@ -763,8 +729,6 @@ request_in(struct chanset_t *chan)
   char s[255] = "", *l = (char *) my_calloc(1, IN_BOTS * 30);
   char s[255] = "", *l = (char *) my_calloc(1, IN_BOTS * 30);
   int cnt = IN_BOTS, n;
   int cnt = IN_BOTS, n;
 
 
-  if (!checked_hostmask)
-    check_hostmask();           /* check, and update hostmask */
   sprintf(s, "gi i %s %s %s!%s %s", chan->dname, botname, botname, botuserhost, botuserip);
   sprintf(s, "gi i %s %s %s!%s %s", chan->dname, botname, botname, botuserhost, botuserip);
   while (cnt) {
   while (cnt) {
     n = randint(i);
     n = randint(i);

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

@@ -28,7 +28,6 @@
 #include <stdarg.h>
 #include <stdarg.h>
 
 
 bool floodless = 0;		/* floodless iline? */
 bool floodless = 0;		/* floodless iline? */
-bool checked_hostmask = 0;	/* Used in request_op()/check_hostmask() cleared on connect */
 int ctcp_mode;
 int ctcp_mode;
 int serv = -1;		/* sock # of server currently */
 int serv = -1;		/* sock # of server currently */
 int servidx = -1;		/* idx of server */
 int servidx = -1;		/* idx of server */

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

@@ -45,7 +45,7 @@ enum {
 
 
 extern bind_table_t	*BT_ctcp, *BT_ctcr, *BT_msgc;
 extern bind_table_t	*BT_ctcp, *BT_ctcr, *BT_msgc;
 extern size_t		nick_len;
 extern size_t		nick_len;
-extern bool		checked_hostmask, quiet_reject, trigger_on_ignore, floodless;
+extern bool		quiet_reject, trigger_on_ignore, floodless;
 extern int 		servidx, ctcp_mode, flud_thr, flud_ctcp_thr, answer_ctcp, serv;
 extern int 		servidx, ctcp_mode, flud_thr, flud_ctcp_thr, answer_ctcp, serv;
 extern port_t		default_port, newserverport;
 extern port_t		default_port, newserverport;
 extern time_t		server_online, cycle_time, flud_time, flud_ctcp_time;
 extern time_t		server_online, cycle_time, flud_time, flud_ctcp_time;

+ 26 - 3
src/mod/server.mod/servmsg.c

@@ -150,7 +150,6 @@ static int got001(char *from, char *msg)
   struct server_list *x = NULL;
   struct server_list *x = NULL;
 
 
   server_online = now;
   server_online = now;
-  checked_hostmask = 0;
   fixcolon(msg);
   fixcolon(msg);
   /* Ok...param #1 of 001 = what server thinks my nick is */
   /* Ok...param #1 of 001 = what server thinks my nick is */
   strlcpy(botname, msg, NICKLEN);
   strlcpy(botname, msg, NICKLEN);
@@ -921,7 +920,6 @@ static void disconnect_server(int idx, int dolost)
   serv = -1;
   serv = -1;
   servidx = -1;
   servidx = -1;
   server_online = 0;
   server_online = 0;
-  checked_hostmask = 0;
   floodless = 0;
   floodless = 0;
   botuserhost[0] = 0;
   botuserhost[0] = 0;
   botuserip[0] = 0; 
   botuserip[0] = 0; 
@@ -1084,6 +1082,31 @@ irc_whois(char *nick, char *format, ...)
       dprintf(idx, "%s\n", va_out);
       dprintf(idx, "%s\n", va_out);
 }
 }
 
 
+static void check_hostmask()
+{
+  char s[UHOSTLEN + 2] = "";
+
+  simple_sprintf(s, "*!%s", botuserhost);              /* just add actual user@ident, regardless of ~ */
+
+  /* dont add the host if it conflicts with another in the userlist */
+  struct userrec *u = NULL;
+  struct list_type *q = NULL;
+
+  for (u = userlist; u; u = u->next) {
+    q = (struct list_type *) get_user(&USERENTRY_HOSTS, u);
+    for (; q; q = q->next) {
+      if (wild_match(s, q->extra) || wild_match(q->extra, s)) {
+        if (u != conf.bot->u)
+          putlog(LOG_WARN, "*", "My automatic hostmask '%s' would conflict with user: '%s'. (Not adding)", s, u->handle);
+        return;
+      }
+    }
+  }
+  addhost_by_handle(conf.bot->nick, s);
+
+  putlog(LOG_GETIN, "*", "Updated my hostmask: %s", s);
+}
+
 /* 311 $me nick username address * :realname */
 /* 311 $me nick username address * :realname */
 static int got311(char *from, char *msg)
 static int got311(char *from, char *msg)
 {
 {
@@ -1099,7 +1122,7 @@ static int got311(char *from, char *msg)
     
     
   if (match_my_nick(nick)) {
   if (match_my_nick(nick)) {
     egg_snprintf(botuserhost, sizeof botuserhost, "%s@%s", username, address);
     egg_snprintf(botuserhost, sizeof botuserhost, "%s@%s", username, address);
-    checked_hostmask = 0;
+    check_hostmask();
   }
   }
 
 
   irc_whois(nick, "$b%s$b [%s@%s]", nick, username, address);
   irc_whois(nick, "$b%s$b [%s@%s]", nick, username, address);