Author: Isomer <isomer@coders.net>
authorPerry Lorier <isomer@undernet.org>
Thu, 30 Mar 2000 22:09:52 +0000 (22:09 +0000)
committerPerry Lorier <isomer@undernet.org>
Thu, 30 Mar 2000 22:09:52 +0000 (22:09 +0000)
Log message:

Well:
 * Fixed wrapped U: in example.conf
 * Added reason to when people are glined.
   *** Quits: BadBoy (G-Lined (You're a bad boy))
 * Rewrote check pings.
 * Fixed several problems with /map
 * Added some reasons to quit msg's.
 * removed redundant nick[socket] from error quitmsg's.
 * Updated the error messages for 'write error'
 * Made server rejection notices explain why the server was rejected
   hopefully we'll get less people asking questions :)
 * Probably some other patches I've been sitting on for a while.

Not very tested for much of this stuff, but it's there. I'm sure the usual
alpha testers will enjoy themselves :)

git-svn-id: file:///home/klmitch/undernet-ircu/undernet-ircu-svn/ircu2/trunk@109 c9e4aea6-c8fd-4c43-8297-357d70d61c8c

13 files changed:
ChangeLog
doc/example.conf
ircd/gline.c
ircd/ircd.c
ircd/list.c
ircd/m_nick.c
ircd/m_server.c
ircd/m_stats.c
ircd/map.c
ircd/s_bsd.c
ircd/s_err.c
ircd/s_serv.c
ircd/send.c

index 538c044628f7a18412fba3478c13c4d049eb210f..cda5b24078fae6d2e07c5dffe4ac6aabc11e52e3 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,23 @@
+2000-03-30  Perry Lorier <isomer@coders.net>
+       * ircd/ircd.c: rewrote check_pings() for maintainability
+       and speed.  Also changed quit msg's so they don't have
+       redundant nick[host] info in them.
+
+       * ircd/send.c: Changed write errors to report what error
+       occured (if possible).
+
+       * ircd/gline.c: added gline comment to the quit.
+
+       * ircd/m_server.c: Added suggestions to server quits mentioning
+       what went wrong so the admin can fix it earlier instead of asking
+       questions...
+
+       * ircd/map.c: Changed m_map() to hide numerics, show a * beside
+       servers that aren't fully burst yet.  And show '(--s)' for servers
+       where its not sure.
+
+       * doc/example.conf: Fixed wrapped U:
+
 2000-03-30  Kevin L. Mitchell  <klmitch@mit.edu>
 
        * ircd/m_mode.c (ms_mode): implemented a new m_mode in terms of
 #
 # ChangeLog for ircu2.10.11
 #
-# $Id: ChangeLog,v 1.45 2000-03-30 22:03:36 kev Exp $
+# $Id: ChangeLog,v 1.46 2000-03-30 22:09:51 isomer Exp $
 #
 # Insert new changes at beginning of the change list.
 #
index 77da1d5036d9f4fe37e1a124077c91542db9d321..bbc0e82726e6e9f57344255596c478d549f76b8a 100644 (file)
@@ -196,9 +196,8 @@ T:*.london.ac.uk:london.motd
 # it is not allowed to jupe others as well.
 
 U:Uworld.EU.undernet.org:EuWorld,E,protocol,StatServ,NoteServ,Undernet:*
-U:Uworld2.undernet.org:UWorld2,W,ChanSvr,ChanSaver,ChanServ,COM1,COM2,COM3,COM4:
-*
-U:Uworld.undernet.org:Uworld,X,NickSvr,NickSaver,NickServ,LPT1,LPT2,AUX:*
+U:Uworld2.undernet.org:UWorld2,ChanSvr,ChanSaver,ChanServ,COM1,COM2,COM3,COM4:*
+U:Uworld.undernet.org:Uworld,X,W,NickSvr,NickSaver,NickServ,LPT1,LPT2,AUX:*
 
 #
 # While running your server, you will most probably encounter individuals
index 4e5245dc6d96f7281a28358dc24ffd27d22f14ed..b7ffdd969fe8c3fccb5d675f7225039a14e178fa 100644 (file)
@@ -259,7 +259,7 @@ void add_gline(struct Client *sptr, int ip_mask, char *host, char *comment,
 
         /* and get rid of him */
         if (sptr != acptr)
-          exit_client(sptr->from, acptr, &me, "G-lined");
+          exit_client_msg(sptr->from, acptr, &me, "G-lined (%s)", agline->reason);
       }
     }
   }
index 64418cf676bc4481e4945217a06cdb2bc24c50f5..6fa51e5faa1e734ae2eae1889b939dffec3d9eb6 100644 (file)
@@ -254,16 +254,136 @@ static time_t try_connections(void)
   return (next);
 }
 
+static time_t check_pings(void)
+{
+ int expire=0; 
+             /* Temp to figure out what time this connection will next need
+              * to be checked.
+              */
+ int next_check = CurrentTime + PINGFREQUENCY;
+           /*
+            * The current lowest expire time - ie: the time that check_pings
+            * needs to be called next.
+            */
+ int max_ping = 0;
+            /* 
+             * The time you've got before a ping is sent/your connection is
+             * terminated.
+             */
+             
+ int i=0; /* loop counter */
+  
+ /* Scan through the client table */
+ for (i=0; i <= HighestFd; i++) {
+   struct Client *cptr;
+   
+   cptr = LocalClientArray[i];
+   
+   /* Skip empty entries */
+   if (!cptr)
+     continue;
+     
+   assert(&me != cptr); /* I should never be in the local client array,
+                        * so if I am, dying is a good thing(tm).
+                        */
+   
+   /* Remove dead clients.
+    * We will have sent opers a message when we set the dead flag,
+    * so don't bother to send one now.
+    */
+   if (IsDead(cptr)) {
+     exit_client(cptr, cptr, &me, cptr->info);
+     continue;
+   }
+
+   /* Should we concider adding a class 0 for 'unregistered clients',
+    * where we can specify their 'ping timeout' etc?
+    */
+   max_ping = IsRegistered(cptr) ? get_client_ping(cptr) : CONNECTTIMEOUT;
+   
+   /* Ok, the thing that will happen most frequently, is that someone will
+    * have sent something recently.  Cover this first for speed.
+    */
+   if (CurrentTime-cptr->lasttime <= max_ping) {
+       expire=cptr->lasttime + max_ping;
+       if (next_check<expire) 
+         next_check=expire;
+       continue;
+   }
+
+   /* Quit the client after max_ping*2 - they should have answered by now */
+   if (CurrentTime-cptr->lasttime <= (max_ping*2) ) {
+      
+      /* If it was a server, then tell ops about it. */
+      if (IsServer(cptr) || IsConnecting(cptr) || IsHandshake(cptr))
+        sendto_ops("No response from %s, closing link", cptr->name);
+
+      exit_client_msg(cptr, cptr, &me, "Ping timeout");
+      continue;
+    } /* of testing to see if ping has been sent */
+    
+    /* Unregistered clients pingout after max_ping seconds, they don't
+     * get given a second chance. 
+     */
+    if (!IsRegistered(cptr)) {
+      /* Display message if they have sent a NICK and a USER but no
+       * nospoof PONG.
+       */
+      if (*cptr->name && *cptr->user->username) {
+        sendto_one(cptr,
+            ":%s %d %s :Your client may not be compatible with this server.",
+            me.name, ERR_BADPING, cptr->name);
+        sendto_one(cptr,
+            ":%s %d %s :Compatible clients are available at "
+            "ftp://ftp.undernet.org/pub/irc/clients",
+            me.name, ERR_BADPING, cptr->name);
+      }    
+      exit_client_msg(cptr,cptr,&me, "Ping Timeout");
+      continue;
+    } /* of not registered */
+    
+    if (0 == (cptr->flags & FLAGS_PINGSENT)) {
+      /*
+       * If we havent PINGed the connection and we havent heard from it in a
+       * while, PING it to make sure it is still alive.
+       */
+      cptr->flags |= FLAGS_PINGSENT;
+
+      /*
+       * If we're late in noticing don't hold it against them :)
+       */
+      cptr->lasttime = CurrentTime - max_ping;
+      
+      if (IsUser(cptr))
+        sendto_one(cptr, "PING :%s", me.name);
+      else
+        sendto_one(cptr, "%s " TOK_PING " :%s", NumServ(&me), me.name);
+    } /* of if not ping sent... */
+    
+    expire=cptr->lasttime+max_ping*2;
+    
+    if (expire<next_check)
+       next_check=expire;
+
+  }  /* end of loop over clients */
+  
+  assert(next_check>=CurrentTime);
+  
+  return next_check;
+}
+
+#if 0
 static time_t check_pings(void)
 {
   struct Client *cptr;
-  int ping = 0;
+  int max_ping = 0;
   int i;
   time_t oldest = CurrentTime + PINGFREQUENCY;
   time_t timeout;
 
+  /* For each client... */
   for (i = 0; i <= HighestFd; i++) {
-    if (!(cptr = LocalClientArray[i]))
+    if (!(cptr = LocalClientArray[i])) /* oops! not a client... */
       continue;
     /*
      * me is never in the local client array
@@ -278,15 +398,21 @@ static time_t check_pings(void)
       continue;
     }
 
-    ping = IsRegistered(cptr) ? get_client_ping(cptr) : CONNECTTIMEOUT;
-    Debug((DEBUG_DEBUG, "c(%s)=%d p %d a %d",
-          cptr->name, cptr->status, ping, 
+    max_ping = IsRegistered(cptr) ? get_client_ping(cptr) : CONNECTTIMEOUT;
+    
+    Debug((DEBUG_DEBUG, "check_pings(%s)=status:%d ping: %d current: %d",
+          cptr->name, cptr->status, max_ping, 
           (int)(CurrentTime - cptr->lasttime)));
+          
     /*
      * Ok, so goto's are ugly and can be avoided here but this code
      * is already indented enough so I think its justified. -avalon
      */
-    if (IsRegistered(cptr) && (ping >= CurrentTime - cptr->lasttime))
+    /*
+     * If this is a registered client that we've heard of in a reasonable
+     * time, then skip them.
+     */
+    if (IsRegistered(cptr) && (max_ping >= CurrentTime - cptr->lasttime))
       goto ping_timeout;
     /*
      * If the server hasnt talked to us in 2 * ping seconds
@@ -313,8 +439,7 @@ static time_t check_pings(void)
               "ftp://ftp.undernet.org/pub/irc/clients",
               me.name, ERR_BADPING, cptr->name);
         }
-        exit_client_msg(cptr, cptr, &me, "Ping timeout for %s",
-                        get_client_name(cptr, HIDE_IP));
+        exit_client_msg(cptr, cptr, &me, "Ping timeout");
       }
       continue;
     }
@@ -335,9 +460,9 @@ static time_t check_pings(void)
         sendto_one(cptr, "%s " TOK_PING " :%s", NumServ(&me), me.name);
     }
 ping_timeout:
-    timeout = cptr->lasttime + ping;
+    timeout = cptr->lasttime + max_ping;
     while (timeout <= CurrentTime)
-      timeout += ping;
+      timeout += max_ping;
     if (timeout < oldest)
       oldest = timeout;
   }
@@ -349,6 +474,7 @@ ping_timeout:
 
   return (oldest);
 }
+#endif
 
 /*
  * bad_command
index f798394052193c9aab0debce4faec78fecbb9895..bc44e6325304fabfe02e57281251b3a2e95557c3 100644 (file)
@@ -153,6 +153,7 @@ struct Server *make_server(struct Client *cptr)
     servs.inuse++;
 #endif
     cptr->serv = serv;
+    cptr->serv->lag = 10000;
     *serv->by = '\0';
     DupString(serv->last_error_msg, "<>");      /* String must be non-empty */
   }
index 875a8a13f8d581dac96f0fdc157a6bcf513e6100..02c61f3943d3f2b051729288406291f5be9dff2c 100644 (file)
@@ -268,15 +268,17 @@ int ms_nick(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
   ircd_strncpy(nick, parv[1], NICKLEN);
   nick[NICKLEN] = '\0';
 
-  if (IsServer(sptr)) {
-    lastnick = atoi(parv[3]);
-    if (lastnick > OLDEST_TS) 
-      sptr->serv->lag = TStime() - lastnick;
-  }
-  else {
-    lastnick = atoi(parv[2]); 
-    if (lastnick > OLDEST_TS)
-      sptr->user->server->serv->lag = TStime() - lastnick;
+  if (!IsBurstOrBurstAck(sptr)) {
+     if (IsServer(sptr)) {
+       lastnick = atoi(parv[3]);
+       if (lastnick > OLDEST_TS) 
+         sptr->serv->lag = TStime() - lastnick;
+     }
+     else {
+       lastnick = atoi(parv[2]); 
+       if (lastnick > OLDEST_TS)
+         sptr->user->server->serv->lag = TStime() - lastnick;
+     }
   }
   /*
    * If do_nick_name() returns a null name OR if the server sent a nick
index 3b20d0f33e42cdc448cfbeca7cf9091f1b29b6bb..5578d0f5d350ce6beb55839cd217080e158b6dff 100644 (file)
@@ -400,7 +400,7 @@ int mr_server(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
      *  If my ircd.conf sucks, I can try to connect to myself:
      */
     if (acptr == &me)
-      return exit_client_msg(cptr, cptr, &me, "nick collision with me (%s)", host);
+      return exit_client_msg(cptr, cptr, &me, "nick collision with me (%s), check server number?", host);
     /*
      * Detect wrong numeric.
      */
@@ -627,7 +627,8 @@ int mr_server(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
   {
     if (LHcptr == 0) {
       return exit_new_server(cptr, sptr, host, timestamp,
-          (active_lh_line == 2) ?  "Non-Hub link %s <- %s(%s)" : "Leaf-only link %s <- %s(%s)",
+          (active_lh_line == 2) ?  "Non-Hub link %s <- %s(%s), check H:" : 
+                                   "Leaf-only link %s <- %s(%s), check L:",
           cptr->name, host, 
           lhconf ? (lhconf->name ? lhconf->name : "*") : "!");
     }
@@ -637,7 +638,8 @@ int mr_server(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
       if (active_lh_line < 3)
       {
         if (exit_client_msg(cptr, LHcptr, &me,
-            (active_lh_line == 2) ?  "Non-Hub link %s <- %s(%s)" : "Leaf-only link %s <- %s(%s)",
+            (active_lh_line == 2) ?  "Non-Hub link %s <- %s(%s), check H:" : 
+                                     "Leaf-only link %s <- %s(%s), check L:",
             cptr->name, host,
             lhconf ? (lhconf->name ? lhconf->name : "*") : "!") == CPTR_KILLED)
           return CPTR_KILLED;
@@ -645,7 +647,7 @@ int mr_server(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
       else
       {
         ServerStats->is_ref++;
-        if (exit_client(cptr, LHcptr, &me, "I'm a leaf") == CPTR_KILLED)
+        if (exit_client(cptr, LHcptr, &me, "I'm a leaf, define HUB") == CPTR_KILLED)
           return CPTR_KILLED;
       }
       /*
index 9cc561654627950fec9cd501aa5ca1cf3a0c66ba..291f1c79a47e6060fdd71721e82bbe8cf6ad4674 100644 (file)
@@ -265,7 +265,9 @@ int m_stats(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
         if (doall && IsUser(acptr))
           continue;
         /* Don't show invisible people to unauthorized people when using
-         * wildcards  -- Is this still needed now /stats is oper only ? */
+         * wildcards  -- Is this still needed now /stats is oper only ? 
+         * Yeah it is -- non opers can /stats l, just not remotely.
+         */
         if (IsInvisible(acptr) && (doall || wilds) &&
             !(MyConnect(sptr) && IsOper(sptr)) &&
             !IsAnOper(acptr) && (acptr != sptr))
index 09396fb315e6c91258dfd42c63dd7cb9fd8dc4fa..c4914ad83d2cee362b97e63d83e6663fcc5fb079 100644 (file)
@@ -41,11 +41,21 @@ void dump_map(struct Client *cptr, struct Client *server, char *mask, int prompt
   if (prompt_length > 60)
     sendto_one(cptr, rpl_str(RPL_MAPMORE), me.name, cptr->name,
         prompt, server->name);
-  else
+  else {
+    char lag[512];
+    if (server->serv->lag>10000)
+       strcpy(lag,"(--s)");
+    else if (server->serv->lag<0)
+       strcpy(lag,"(0s)");
+    else
+       sprintf(lag,"(%is)",server->serv->lag);
     sendto_one(cptr, rpl_str(RPL_MAP), me.name, cptr->name,
-        prompt, NumServ(server), server->name, 
-        server->serv->lag>0 ? server->serv->lag : 0,
+        prompt, 
+       ((IsBurstOrBurstAck(server)) ? "*" : ""),
+        server->name, 
+        lag,
         (server == &me) ? UserStats.local_clients : server->serv->clients);
+  }
   if (prompt_length > 0)
   {
     p[-1] = ' ';
index 31fdbaa746b40f960495a1fc272cd2e5a195fcaf..03d95be4031c52fc00c3b13931d86be66c7c1a67 100644 (file)
@@ -1051,8 +1051,8 @@ int read_message(time_t delay)
       const char* msg = (cptr->error) ? strerror(cptr->error) : "EOF from client";
       if (!msg)
         msg = "Unknown error";
-      exit_client_msg(cptr, cptr, &me, "Read error to %s: %s",
-                      get_client_name(cptr, HIDE_IP), msg);
+      exit_client_msg(cptr, cptr, &me, "Read error: %s",
+                      msg);
     }
   }
   return 0;
@@ -1271,8 +1271,8 @@ int read_message(time_t delay)
       const char* msg = (cptr->error) ? strerror(cptr->error) : "EOF from client";
       if (!msg)
         msg = "Unknown error";
-      exit_client_msg(cptr, cptr, &me, "Read error to %s: %s",
-                      get_client_name(cptr, HIDE_IP), msg);
+      exit_client_msg(cptr, cptr, &me, "Read error: %s",
+                      msg);
     }
   }
   return 0;
index 47c390fa8957677fb10770bb9b5e913fe4d52aeb..182c169ca074085ad433f209314c1c5ffbc8bc55 100644 (file)
@@ -60,7 +60,7 @@ static Numeric local_replies[] = {
 /* 014 */
   { 0 },
 /* 015 */
-  { RPL_MAP, ":%s%s:%s (%is) [%i clients]", "015" },
+  { RPL_MAP, ":%s%s%s %s [%i clients]", "015" },
 /* 016 */
   { RPL_MAPMORE, ":%s%s --> *more*", "016" },
 /* 017 */
index 08b391d848409a8faee81851e46fd3dd53bf9f2a..c74be252b4fd2adb710278d6794d360c7092d830 100644 (file)
@@ -69,7 +69,7 @@ int exit_new_server(struct Client *cptr, struct Client *sptr,
   va_start(vl, fmt);
   if (!IsServer(sptr))
     return vexit_client_msg(cptr, cptr, &me, fmt, vl);
-  sprintf_irc(buf, ":%s SQUIT %s " TIME_T_FMT " :", me.name, host, timestamp);
+  sprintf_irc(buf, ":%s " TOK_SQUIT " %s " TIME_T_FMT " :", me.name, host, timestamp);
   strcat(buf, fmt);
   vsendto_one(cptr, buf, vl);
   va_end(vl);
index c160a9eccae98883268da2fb26a1ca3d5e901c0f..f5adb86d5cf8b35b6ab9390a4098979e5c3b80cc 100644 (file)
@@ -61,7 +61,7 @@ int sdbflag;
  * generate ExitClient from the main loop.
  *
  * If 'notice' is not NULL, it is assumed to be a format
- * for a message to local opers. I can contain only one
+ * for a message to local opers. It can contain only one
  * '%s', which will be replaced by the sockhost field of
  * the failing link.
  *
@@ -162,8 +162,11 @@ void send_queued(struct Client *to)
         break;
     }
     else {
-      if (IsDead(to))
-        dead_link(to, "Write error, closing link");
+      if (IsDead(to)) {
+        char tmp[512];
+        sprintf(tmp,"Write error: %s",(strerror(to->error)) ? (strerror(to->error)) : "Unknown error" );
+        dead_link(to, tmp);
+      }
       break;
     }
   }