IPv6 support (hopefully with fewer future transition pains)
[ircu2.10.12-pk.git] / ircd / ircd.c
index 7dd10811415c1ee1d3ffd1e6ab906536990c6e6c..b8c7cb4b985f9e35c178c08801119e93215b4ec8 100644 (file)
@@ -35,6 +35,7 @@
 #include "ircd_reply.h"
 #include "ircd_signal.h"
 #include "ircd_string.h"
+#include "ircd_crypt.h"
 #include "jupe.h"
 #include "list.h"
 #include "match.h"
@@ -255,7 +256,7 @@ static void try_connections(struct Event* ev) {
   Debug((DEBUG_NOTICE, "Connection check at   : %s", myctime(CurrentTime)));
   for (aconf = GlobalConfList; aconf; aconf = aconf->next) {
     /* Also when already connecting! (update holdtimes) --SRB */
-    if (!(aconf->status & CONF_SERVER) || aconf->port == 0 || aconf->hold == 0)
+    if (!(aconf->status & CONF_SERVER) || aconf->address.port == 0 || aconf->hold == 0)
       continue;
 
     /* Also skip juped servers */
@@ -363,18 +364,54 @@ static void check_pings(struct Event* ev) {
           cli_name(cptr),
           IsPingSent(cptr) ? "[Ping Sent]" : "[]", 
           max_ping, (int)(CurrentTime - cli_lasttime(cptr))));
-          
 
     /* Ok, the thing that will happen most frequently, is that someone will
      * have sent something recently.  Cover this first for speed.
+     * -- 
+     * If it's an unregisterd client and hasn't managed to register within
+     * max_ping then it's obviously having problems (broken client) or it's
+     * just up to no good, so we won't skip it, even if its been sending
+     * data to us. 
+     * -- hikari
      */
-    if (CurrentTime-cli_lasttime(cptr) < max_ping) {
+    if ((CurrentTime-cli_lasttime(cptr) < max_ping) && IsRegistered(cptr)) {
       expire = cli_lasttime(cptr) + max_ping;
       if (expire < next_check) 
        next_check = expire;
       continue;
     }
 
+    /* Unregistered clients pingout after max_ping seconds, they don't
+     * get given a second chance - if they were then people could not quite
+     * finish registration and hold resources without being subject to k/g
+     * lines
+     */
+    if (!IsRegistered(cptr)) {
+      assert(!IsServer(cptr));
+      if ((CurrentTime-cli_firsttime(cptr) >= max_ping)) {
+       /* Display message if they have sent a NICK and a USER but no
+        * nospoof PONG.
+        */
+       if (*(cli_name(cptr)) && cli_user(cptr) && *(cli_user(cptr))->username) {
+         send_reply(cptr, SND_EXPLICIT | ERR_BADPING,
+           ":Your client may not be compatible with this server.");
+         send_reply(cptr, SND_EXPLICIT | ERR_BADPING,
+           ":Compatible clients are available at %s",
+         feature_str(FEAT_URL_CLIENTS));
+       }
+       exit_client_msg(cptr,cptr,&me, "Registration Timeout");
+       continue;
+      } else {
+        /* OK, they still have enough time left, so we'll just skip to the
+         * next client.  Set the next check to be when their time is up, if
+         * that's before the currently scheduled next check -- hikari */
+        expire = cli_firsttime(cptr) + max_ping;
+        if (expire < next_check)
+          next_check = expire;
+        continue;
+      }
+    }
+
     /* Quit the client after max_ping*2 - they should have answered by now */
     if (CurrentTime-cli_lasttime(cptr) >= (max_ping*2) )
     {
@@ -386,28 +423,6 @@ static void check_pings(struct Event* ev) {
       exit_client_msg(cptr, cptr, &me, "Ping timeout");
       continue;
     }
-
-    /* Unregistered clients pingout after max_ping seconds, they don't
-     * get given a second chance - if they were then people could not quite
-     * finish registration and hold resources without being subject to k/g
-     * lines
-     */
-    if (!IsRegistered(cptr))
-    {
-      /* Display message if they have sent a NICK and a USER but no
-       * nospoof PONG.
-       */
-      if (*(cli_name(cptr)) && cli_user(cptr) && *(cli_user(cptr))->username)
-      {
-       send_reply(cptr, SND_EXPLICIT | ERR_BADPING,
-                  ":Your client may not be compatible with this server.");
-       send_reply(cptr, SND_EXPLICIT | ERR_BADPING,
-                   ":Compatible clients are available at %s",
-                   feature_str(FEAT_URL_CLIENTS));
-      }    
-      exit_client_msg(cptr,cptr,&me, "Ping Timeout");
-      continue;
-    }
     
     if (!IsPingSent(cptr))
     {
@@ -633,10 +648,6 @@ int main(int argc, char **argv) {
   setup_signals();
   feature_init(); /* initialize features... */
   log_init(*argv);
-  if (check_pid()) {
-    Debug((DEBUG_FATAL, "Failed to acquire PID file lock after fork"));
-    exit(2);
-  }
   set_nomem_handler(outofmemory);
   
   if (!init_string()) {
@@ -654,6 +665,10 @@ int main(int argc, char **argv) {
 
   init_resolver();
 
+  /* we need this for now, when we're modular this 
+     should be removed -- hikari */
+  ircd_crypt_init();
+
   motd_init();
 
   if (!init_conf()) {
@@ -662,6 +677,11 @@ int main(int argc, char **argv) {
     return 7;
   }
 
+  if (check_pid()) {
+    Debug((DEBUG_FATAL, "Failed to acquire PID file lock after fork"));
+    exit(2);
+  }
+
   init_server_identity();
 
   uping_init();