Author: Kev <klmitch@mit.edu>
[ircu2.10.12-pk.git] / ircd / m_server.c
index 3759a8e0a477a2f09d3c39c933b0eb84a861e6ce..394fccdb97574960aca5f6f80b8d819c9f25462c 100644 (file)
@@ -79,6 +79,8 @@
  *            note:   it is guaranteed that parv[0]..parv[parc-1] are all
  *                    non-NULL pointers.
  */
+#include "config.h"
+
 #if 0
 /*
  * No need to include handlers.h here the signatures must match
 #include "handlers.h"
 #endif /* 0 */
 #include "client.h"
-#include "crule.h"
 #include "hash.h"
 #include "ircd.h"
 #include "ircd_log.h"
+#include "ircd_features.h"
 #include "ircd_reply.h"
 #include "ircd_string.h"
 #include "jupe.h"
@@ -138,7 +140,6 @@ int mr_server(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
   struct Client*   bcptr;
   struct Client*   LHcptr = 0;
   struct ConfItem* aconf = 0;
-  struct ConfItem* cconf;
   struct ConfItem* lhconf = 0;
   struct Jupe*     ajupe = 0;
   int              hop;
@@ -150,12 +151,6 @@ int mr_server(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
   time_t           recv_time;
   time_t           ghost = 0;
 
-  if (IsUser(cptr))
-  {
-    sendto_one(cptr, err_str(ERR_ALREADYREGISTRED), me.name, parv[0]);
-    return 0;
-  }
-
   if (IsUserPort(cptr))
     return exit_client_msg(cptr, cptr, &me, 
                            "Cannot connect a server to a user port");
@@ -165,7 +160,7 @@ int mr_server(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
 
   if (parc < 7)
   {
-    return need_more_params(sptr, "SERVER");
+    need_more_params(sptr, "SERVER");
     return exit_client(cptr, cptr, &me, "Need more parameters");
   }
   host = parv[1];
@@ -173,7 +168,8 @@ int mr_server(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
   if ((ajupe = jupe_find(host)) && JupeIsActive(ajupe))
     return exit_client_msg(cptr, sptr, &me, "Juped: %s", JupeReason(ajupe));
 
-  ircd_log(L_NOTICE, "SERVER: %s %s[%s]", parv[1], cptr->sockhost, cptr->sock_ip);
+  log_write(LS_NETWORK, L_NOTICE, LOG_NOSNOTICE, "SERVER: %s %s[%s]", parv[1],
+           cli_sockhost(cptr), cli_sock_ip(cptr));
 
   /*
    * Detect protocol
@@ -196,8 +192,8 @@ int mr_server(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
   hop = atoi(parv[2]);
   start_timestamp = atoi(parv[3]);
   timestamp = atoi(parv[4]);
-  Debug((DEBUG_INFO, "Got SERVER %s with timestamp [%s] age " TIME_T_FMT " ("
-        TIME_T_FMT ")", host, parv[4], start_timestamp, me.serv->timestamp));
+  Debug((DEBUG_INFO, "Got SERVER %s with timestamp [%s] age %Tu (%Tu)",
+        host, parv[4], start_timestamp, cli_serv(&me)->timestamp));
 
   if ((timestamp < OLDEST_TS || (hop == 1 && start_timestamp < OLDEST_TS)))
   {
@@ -207,8 +203,8 @@ int mr_server(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
   ircd_strncpy(info, parv[parc - 1], REALLEN);
   info[REALLEN] = '\0';
   if (prot < atoi(MINOR_PROTOCOL)) {
-    sendto_ops("Got incompatible protocol version (%s) from %s",
-               parv[5], cptr->name);
+    sendto_opmask_butone(0, SNO_OLDSNO, "Got incompatible protocol version "
+                        "(%s) from %s", parv[5], cli_name(cptr));
     return exit_new_server(cptr, sptr, host, timestamp,
                            "Incompatible protocol: %s", parv[5]);
   }
@@ -228,7 +224,8 @@ int mr_server(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
       break;
   }
   if (*ch || !strchr(host, '.')) {
-    sendto_ops("Bogus server name (%s) from %s", host, cptr->name);
+    sendto_opmask_butone(0, SNO_OLDSNO, "Bogus server name (%s) from %s",
+                        host, cli_name(cptr));
     return exit_client_msg(cptr, cptr, &me, "Bogus server name (%s)", host);
   }
 
@@ -245,7 +242,7 @@ int mr_server(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
      * See if the newly found server is behind a guaranteed
      * leaf (L-line). If so, close the link.
      */
-    if ((lhconf = find_conf_byhost(cptr->confs, cptr->name, CONF_LEAF)) &&
+    if ((lhconf = find_conf_byhost(cli_confs(cptr), cli_name(cptr), CONF_LEAF)) &&
         (!lhconf->port || (hop > lhconf->port)))
     {
       /*
@@ -254,12 +251,12 @@ int mr_server(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
        * both.
        */
       active_lh_line = 1;
-      if (timestamp <= cptr->serv->timestamp)
+      if (timestamp <= cli_serv(cptr)->timestamp)
         LHcptr = 0;          /* Kill incoming server */
       else
         LHcptr = cptr;          /* Squit ourselfs */
     }
-    else if (!(lhconf = find_conf_byname(cptr->confs, cptr->name, CONF_HUB)) ||
+    else if (!(lhconf = find_conf_byname(cli_confs(cptr), cli_name(cptr), CONF_HUB)) ||
              (lhconf->port && (hop > lhconf->port)))
     {
       struct Client *ac3ptr;
@@ -267,7 +264,7 @@ int mr_server(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
       /* Look for net junction causing this: */
       LHcptr = 0;            /* incoming server */
       if (*parv[5] != 'J') {
-        for (ac3ptr = sptr; ac3ptr != &me; ac3ptr = ac3ptr->serv->up) {
+        for (ac3ptr = sptr; ac3ptr != &me; ac3ptr = cli_serv(ac3ptr)->up) {
           if (IsJunction(ac3ptr)) {
             LHcptr = ac3ptr;
             break;
@@ -297,83 +294,59 @@ int mr_server(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
      * and not mess with hash internals. 
      *                          --Nemesi
      */
-    if (!EmptyString(cptr->name) && 
+    if (!EmptyString(cli_name(cptr)) && 
         (IsUnknown(cptr) || IsHandshake(cptr)) &&
-        0 != ircd_strcmp(cptr->name, host))
+        0 != ircd_strcmp(cli_name(cptr), host))
       hChangeClient(cptr, host);
-    ircd_strncpy(cptr->name, host, HOSTLEN);
-    ircd_strncpy(cptr->info, info[0] ? info : me.name, REALLEN);
-    cptr->hopcount = hop;
+    ircd_strncpy(cli_name(cptr), host, HOSTLEN);
+    ircd_strncpy(cli_info(cptr), info[0] ? info : cli_name(&me), REALLEN);
+    cli_hopcount(cptr) = hop;
 
     /* check connection rules */
-    for (cconf = GlobalConfList; cconf; cconf = cconf->next) {
-      if ((cconf->status == CONF_CRULEALL) && (match(cconf->host, host) == 0)) {
-        if (crule_eval(cconf->passwd)) {
-          ServerStats->is_ref++;
-          sendto_ops("Refused connection from %s.", cptr->name);
-          return exit_client(cptr, cptr, &me, "Disallowed by connection rule");
-        }
-      }
+    if (0 != conf_eval_crule(host, CRULE_ALL)) {
+      ServerStats->is_ref++;
+      sendto_opmask_butone(0, SNO_OLDSNO, "Refused connection from %s.", cli_name(cptr));
+      return exit_client(cptr, cptr, &me, "Disallowed by connection rule");
     }
+
     if (conf_check_server(cptr)) {
       ++ServerStats->is_ref;
-      sendto_ops("Received unauthorized connection from %s.", cptr->name);
+      sendto_opmask_butone(0, SNO_OLDSNO, "Received unauthorized connection "
+                          "from %s.", cli_name(cptr));
       return exit_client(cptr, cptr, &me, "No C:line");
     }
 
-    host = cptr->name;
+    host = cli_name(cptr);
 
     update_load();
 
-    if (!(aconf = find_conf_byname(cptr->confs, host, CONF_SERVER))) {
+    if (!(aconf = find_conf_byname(cli_confs(cptr), host, CONF_SERVER))) {
       ++ServerStats->is_ref;
-#ifndef GODMODE
-      sendto_ops("Access denied. No conf line for server %s", cptr->name);
+      sendto_opmask_butone(0, SNO_OLDSNO, "Access denied. No conf line for "
+                          "server %s", cli_name(cptr));
       return exit_client_msg(cptr, cptr, &me,
-          "Access denied. No conf line for server %s", cptr->name);
-#else /* GODMODE */
-      sendto_ops("General C: line active: No line for server %s", cptr->name);
-      aconf = find_conf_byname(cptr->confs, "general.undernet.org", CONF_SERVER);
-      if (!aconf) {
-        sendto_ops("Neither C lines for server %s nor "
-            "\"general.undernet.org\"", cptr->name);
-        return exit_client_msg(cptr, cptr, &me, "No C lines for server %s", cptr->name);
-      }
-#endif /* GODMODE */
+          "Access denied. No conf line for server %s", cli_name(cptr));
     }
-#ifdef CRYPT_LINK_PASSWORD
-    /* passwd may be NULL. Head it off at the pass... */
-    if (*cptr->passwd) {
-      char salt[3];
+    encr = cli_passwd(cptr);
 
-      salt[0] = aconf->passwd[0];
-      salt[1] = aconf->passwd[1];
-      salt[2] = '\0';
-      encr = ircd_crypt(cptr->passwd, salt);
-    }
-    else
-      encr = "";
-#else
-    encr = cptr->passwd;
-#endif /* CRYPT_LINK_PASSWORD */
-#ifndef GODMODE
     if (*aconf->passwd && !!strcmp(aconf->passwd, encr)) {
       ++ServerStats->is_ref;
-      sendto_ops("Access denied (passwd mismatch) %s", cptr->name);
+      sendto_opmask_butone(0, SNO_OLDSNO, "Access denied (passwd mismatch) %s",
+                          cli_name(cptr));
       return exit_client_msg(cptr, cptr, &me,
-          "No Access (passwd mismatch) %s", cptr->name);
+          "No Access (passwd mismatch) %s", cli_name(cptr));
     }
-#endif /* not GODMODE */
-    memset(cptr->passwd, 0, sizeof(cptr->passwd));
 
-#ifndef HUB
-    for (i = 0; i <= HighestFd; i++)
-      if (LocalClientArray[i] && IsServer(LocalClientArray[i])) {
-        active_lh_line = 3;
-        LHcptr = 0;
-        break;
-      }
-#endif
+    memset(cli_passwd(cptr), 0, sizeof(cli_passwd(cptr)));
+
+    if (!feature_bool(FEAT_HUB)) {
+      for (i = 0; i <= HighestFd; i++)
+       if (LocalClientArray[i] && IsServer(LocalClientArray[i])) {
+         active_lh_line = 3;
+         LHcptr = 0;
+         break;
+       }
+    }
   }
 
   /*
@@ -404,13 +377,13 @@ int mr_server(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
     /*
      * Detect wrong numeric.
      */
-    if (0 != ircd_strcmp(acptr->name, host)) {
-      sendto_serv_butone(cptr,
-          ":%s WALLOPS :SERVER Numeric Collision: %s != %s",
-          me.name, acptr->name, host);
+    if (0 != ircd_strcmp(cli_name(acptr), host)) {
+      sendcmdto_serv_butone(&me, CMD_WALLOPS, cptr,
+                           ":SERVER Numeric Collision: %s != %s",
+                           cli_name(acptr), host);
       return exit_client_msg(cptr, cptr, &me,
           "NUMERIC collision between %s and %s."
-          " Is your server numeric correct ?", host, acptr->name);
+          " Is your server numeric correct ?", host, cli_name(acptr));
     }
     /*
      *  Kill our try, if we had one.
@@ -439,14 +412,15 @@ int mr_server(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
      * Our new server might be a juped server,
      * or someone trying abuse a second Uworld:
      */
-    else if (IsServer(acptr) && (0 == ircd_strncmp(acptr->info, "JUPE", 4) ||
-        find_conf_byhost(cptr->confs, acptr->name, CONF_UWORLD)))
+    else if (IsServer(acptr) && (0 == ircd_strncmp(cli_info(acptr), "JUPE", 4) ||
+        find_conf_byhost(cli_confs(cptr), cli_name(acptr), CONF_UWORLD)))
     {
       if (!IsServer(sptr))
-        return exit_client(cptr, sptr, &me, acptr->info);
-      sendto_one(cptr, ":%s WALLOPS :Received :%s SERVER %s from %s !?!",
-          me.name, parv[0], parv[1], cptr->name);
-      return exit_new_server(cptr, sptr, host, timestamp, "%s", acptr->info);
+        return exit_client(cptr, sptr, &me, cli_info(acptr));
+      sendcmdto_serv_butone(&me, CMD_WALLOPS, cptr,
+                           ":Received :%s SERVER %s from %s !?!", parv[0],
+                           parv[1], cli_name(cptr));
+      return exit_new_server(cptr, sptr, host, timestamp, "%s", cli_info(acptr));
     }
     /*
      * Of course we find the handshake this link was before :)
@@ -467,41 +441,41 @@ int mr_server(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
       struct Client* ac3ptr;
 
       /* Search youngest link: */
-      for (ac3ptr = acptr; ac3ptr != &me; ac3ptr = ac3ptr->serv->up)
-        if (ac3ptr->serv->timestamp > c3ptr->serv->timestamp)
+      for (ac3ptr = acptr; ac3ptr != &me; ac3ptr = cli_serv(ac3ptr)->up)
+        if (cli_serv(ac3ptr)->timestamp > cli_serv(c3ptr)->timestamp)
           c3ptr = ac3ptr;
       if (IsServer(sptr))
       {
-        for (ac3ptr = sptr; ac3ptr != &me; ac3ptr = ac3ptr->serv->up)
-          if (ac3ptr->serv->timestamp > c3ptr->serv->timestamp)
+        for (ac3ptr = sptr; ac3ptr != &me; ac3ptr = cli_serv(ac3ptr)->up)
+          if (cli_serv(ac3ptr)->timestamp > cli_serv(c3ptr)->timestamp)
             c3ptr = ac3ptr;
       }
-      if (timestamp > c3ptr->serv->timestamp)
+      if (timestamp > cli_serv(c3ptr)->timestamp)
       {
         c3ptr = 0;
         c2ptr = acptr;          /* Make sure they differ */
       }
       /* Search second youngest link: */
-      for (ac2ptr = acptr; ac2ptr != &me; ac2ptr = ac2ptr->serv->up)
+      for (ac2ptr = acptr; ac2ptr != &me; ac2ptr = cli_serv(ac2ptr)->up)
         if (ac2ptr != c3ptr &&
-            ac2ptr->serv->timestamp >
-            (c2ptr ? c2ptr->serv->timestamp : timestamp))
+            cli_serv(ac2ptr)->timestamp >
+            (c2ptr ? cli_serv(c2ptr)->timestamp : timestamp))
           c2ptr = ac2ptr;
       if (IsServer(sptr))
       {
-        for (ac2ptr = sptr; ac2ptr != &me; ac2ptr = ac2ptr->serv->up)
+        for (ac2ptr = sptr; ac2ptr != &me; ac2ptr = cli_serv(ac2ptr)->up)
           if (ac2ptr != c3ptr &&
-              ac2ptr->serv->timestamp >
-              (c2ptr ? c2ptr->serv->timestamp : timestamp))
+              cli_serv(ac2ptr)->timestamp >
+              (c2ptr ? cli_serv(c2ptr)->timestamp : timestamp))
             c2ptr = ac2ptr;
       }
-      if (c3ptr && timestamp > (c2ptr ? c2ptr->serv->timestamp : timestamp))
+      if (c3ptr && timestamp > (c2ptr ? cli_serv(c2ptr)->timestamp : timestamp))
         c2ptr = 0;
       /* If timestamps are equal, decide which link to break
        *  by name.
        */
-      if ((c2ptr ? c2ptr->serv->timestamp : timestamp) ==
-          (c3ptr ? c3ptr->serv->timestamp : timestamp))
+      if ((c2ptr ? cli_serv(c2ptr)->timestamp : timestamp) ==
+          (c3ptr ? cli_serv(c3ptr)->timestamp : timestamp))
       {
         char* n2;
         char* n2up;
@@ -509,23 +483,23 @@ int mr_server(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
         char* n3up;
         if (c2ptr)
         {
-          n2 = c2ptr->name;
-          n2up = MyConnect(c2ptr) ? me.name : c2ptr->serv->up->name;
+          n2 = cli_name(c2ptr);
+          n2up = MyConnect(c2ptr) ? cli_name(&me) : cli_name(cli_serv(c2ptr)->up);
         }
         else
         {
           n2 = host;
-          n2up = IsServer(sptr) ? sptr->name : me.name;
+          n2up = IsServer(sptr) ? cli_name(sptr) : cli_name(&me);
         }
         if (c3ptr)
         {
-          n3 = c3ptr->name;
-          n3up = MyConnect(c3ptr) ? me.name : c3ptr->serv->up->name;
+          n3 = cli_name(c3ptr);
+          n3up = MyConnect(c3ptr) ? cli_name(&me) : cli_name(cli_serv(c3ptr)->up);
         }
         else
         {
           n3 = host;
-          n3up = IsServer(sptr) ? sptr->name : me.name;
+          n3up = IsServer(sptr) ? cli_name(sptr) : cli_name(&me);
         }
         if (strcmp(n2, n2up) > 0)
           n2 = n2up;
@@ -542,10 +516,10 @@ int mr_server(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
       if (!c2ptr)
         return exit_new_server(cptr, sptr, host, timestamp,
                                "server %s already exists and is %ld seconds younger.",
-                               host, (long)acptr->serv->timestamp - (long)timestamp);
-      else if (c2ptr->from == cptr || IsServer(sptr))
+                               host, (long)cli_serv(acptr)->timestamp - (long)timestamp);
+      else if (cli_from(c2ptr) == cptr || IsServer(sptr))
       {
-        struct Client *killedptrfrom = c2ptr->from;
+        struct Client *killedptrfrom = cli_from(c2ptr);
         if (active_lh_line)
         {
           /*
@@ -558,7 +532,7 @@ int mr_server(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
            * If breaking the loop here solves the L: or H:
            * line problem, we don't squit that.
            */
-          if (c2ptr->from == cptr || (LHcptr && a_kills_b_too(c2ptr, LHcptr)))
+          if (cli_from(c2ptr) == cptr || (LHcptr && a_kills_b_too(c2ptr, LHcptr)))
             active_lh_line = 0;
           else
           {
@@ -577,16 +551,16 @@ int mr_server(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
          * a Ghost... (20 seconds is more then enough because all
          * SERVER messages are at the beginning of a net.burst). --Run
          */
-        if (CurrentTime - cptr->serv->ghost < 20)
+        if (CurrentTime - cli_serv(cptr)->ghost < 20)
         {
-          killedptrfrom = acptr->from;
+          killedptrfrom = cli_from(acptr);
           if (exit_client(cptr, acptr, &me, "Ghost loop") == CPTR_KILLED)
             return CPTR_KILLED;
         }
         else if (exit_client_msg(cptr, c2ptr, &me,
             "Loop <-- %s (new link is %ld seconds younger)", host,
-            (c3ptr ? (long)c3ptr->serv->timestamp : timestamp) -
-            (long)c2ptr->serv->timestamp) == CPTR_KILLED)
+            (c3ptr ? (long)cli_serv(c3ptr)->timestamp : timestamp) -
+            (long)cli_serv(c2ptr)->timestamp) == CPTR_KILLED)
           return CPTR_KILLED;
         /*
          * Did we kill the incoming server off already ?
@@ -600,7 +574,7 @@ int mr_server(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
         {
           if (LHcptr && a_kills_b_too(LHcptr, acptr))
             break;
-          if (acptr->from == cptr || (LHcptr && a_kills_b_too(acptr, LHcptr)))
+          if (cli_from(acptr) == cptr || (LHcptr && a_kills_b_too(acptr, LHcptr)))
             active_lh_line = 0;
           else
           {
@@ -629,7 +603,7 @@ int mr_server(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
       return exit_new_server(cptr, sptr, host, timestamp,
           (active_lh_line == 2) ?  "Non-Hub link %s <- %s(%s), check H:" : 
                                    "Leaf-only link %s <- %s(%s), check L:",
-          cptr->name, host, 
+          cli_name(cptr), host, 
           lhconf ? (lhconf->name ? lhconf->name : "*") : "!");
     }
     else
@@ -640,7 +614,7 @@ int mr_server(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
         if (exit_client_msg(cptr, LHcptr, &me,
             (active_lh_line == 2) ?  "Non-Hub link %s <- %s(%s), check H:" : 
                                      "Leaf-only link %s <- %s(%s), check L:",
-            cptr->name, host,
+            cli_name(cptr), host,
             lhconf ? (lhconf->name ? lhconf->name : "*") : "!") == CPTR_KILLED)
           return CPTR_KILLED;
       }
@@ -669,43 +643,46 @@ int mr_server(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
 
     acptr = make_client(cptr, STAT_SERVER);
     make_server(acptr);
-    acptr->serv->prot = prot;
-    acptr->serv->timestamp = timestamp;
-    acptr->hopcount = hop;
-    ircd_strncpy(acptr->name, host, HOSTLEN);
-    ircd_strncpy(acptr->info, info, REALLEN);
-    acptr->serv->up = sptr;
-    acptr->serv->updown = add_dlink(&sptr->serv->down, acptr);
+    cli_serv(acptr)->prot = prot;
+    cli_serv(acptr)->timestamp = timestamp;
+    cli_hopcount(acptr) = hop;
+    ircd_strncpy(cli_name(acptr), host, HOSTLEN);
+    ircd_strncpy(cli_info(acptr), info, REALLEN);
+    cli_serv(acptr)->up = sptr;
+    cli_serv(acptr)->updown = add_dlink(&(cli_serv(sptr))->down, acptr);
     /* Use cptr, because we do protocol 9 -> 10 translation
        for numeric nicks ! */
     SetServerYXX(cptr, acptr, parv[6]);
 
     Count_newremoteserver(UserStats);
     if (Protocol(acptr) < 10)
-      acptr->flags |= FLAGS_TS8;
+      cli_flags(acptr) |= FLAGS_TS8;
     add_client_to_list(acptr);
     hAddClient(acptr);
     if (*parv[5] == 'J')
     {
       SetBurst(acptr);
-      sendto_op_mask(SNO_NETWORK, "Net junction: %s %s",
-          sptr->name, acptr->name);
+      sendto_opmask_butone(0, SNO_NETWORK, "Net junction: %s %s",
+          cli_name(sptr), cli_name(acptr));
       SetJunction(acptr);
     }
     /*
      * Old sendto_serv_but_one() call removed because we now need to send
      * different names to different servers (domain name matching).
+     *
+     * Personally, I think this is bogus; it's a feature we don't use here.
+     * -Kev
      */
     for (i = 0; i <= HighestFd; i++)
     {
       if (!(bcptr = LocalClientArray[i]) || !IsServer(bcptr) ||
           bcptr == cptr || IsMe(bcptr))
         continue;
-      if (0 == match(me.name, acptr->name))
+      if (0 == match(cli_name(&me), cli_name(acptr)))
         continue;
-        sendto_one(bcptr, "%s " TOK_SERVER " %s %d 0 %s %s %s%s 0 :%s",
-            NumServ(sptr), acptr->name, hop + 1, parv[4], parv[5],
-            NumServCap(acptr), acptr->info);
+      sendcmdto_one(sptr, CMD_SERVER, bcptr, "%s %d 0 %s %s %s%s 0 :%s",
+                   cli_name(acptr), hop + 1, parv[4], parv[5], NumServCap(acptr),
+                   cli_info(acptr));
     }
     return 0;
   }
@@ -713,69 +690,64 @@ int mr_server(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
   if (IsUnknown(cptr) || IsHandshake(cptr))
   {
     make_server(cptr);
-    cptr->serv->timestamp = timestamp;
-    cptr->serv->prot = prot;
-    cptr->serv->ghost = ghost;
+    cli_serv(cptr)->timestamp = timestamp;
+    cli_serv(cptr)->prot = prot;
+    cli_serv(cptr)->ghost = ghost;
     SetServerYXX(cptr, cptr, parv[6]);
     if (start_timestamp > OLDEST_TS)
     {
-#ifndef RELIABLE_CLOCK
-#ifdef TESTNET
-      sendto_ops("Debug: my start time: " TIME_T_FMT " ; others start time: "
-          TIME_T_FMT, me.serv->timestamp, start_timestamp);
-      sendto_ops("Debug: receive time: " TIME_T_FMT " ; received timestamp: "
-          TIME_T_FMT " ; difference %ld",
-          recv_time, timestamp, timestamp - recv_time);
-#endif
-      if (start_timestamp < me.serv->timestamp)
-      {
-        sendto_ops("got earlier start time: " TIME_T_FMT " < " TIME_T_FMT,
-            start_timestamp, me.serv->timestamp);
-        me.serv->timestamp = start_timestamp;
-        TSoffset += timestamp - recv_time;
-        sendto_ops("clock adjusted by adding %d", (int)(timestamp - recv_time));
+      Debug((DEBUG_DEBUG, "My start time: %Tu; other's start time: %Tu",
+            cli_serv(&me)->timestamp, start_timestamp));
+      Debug((DEBUG_DEBUG, "Receive time: %Tu; received timestamp: %Tu; "
+            "difference %ld", recv_time, timestamp, timestamp - recv_time));
+      if (feature_bool(FEAT_RELIABLE_CLOCK)) {
+       if (start_timestamp < cli_serv(&me)->timestamp)
+         cli_serv(&me)->timestamp = start_timestamp;
+       if (IsUnknown(cptr))
+         cli_serv(cptr)->timestamp = TStime();
+      } else {
+       if (start_timestamp < cli_serv(&me)->timestamp) {
+         sendto_opmask_butone(0, SNO_OLDSNO, "got earlier start time: "
+                              "%Tu < %Tu", start_timestamp,
+                              cli_serv(&me)->timestamp);
+         cli_serv(&me)->timestamp = start_timestamp;
+         TSoffset += timestamp - recv_time;
+         sendto_opmask_butone(0, SNO_OLDSNO, "clock adjusted by adding %d",
+                              (int)(timestamp - recv_time));
+       } else if ((start_timestamp > cli_serv(&me)->timestamp) &&
+                IsUnknown(cptr))
+         cli_serv(cptr)->timestamp = TStime();
+
+       else if (timestamp != recv_time) {
+         /*
+          * Equal start times, we have a collision.  Let the connected-to
+          * server decide. This assumes leafs issue more than half of the
+          * connection attempts.
+          */
+         if (IsUnknown(cptr))
+           cli_serv(cptr)->timestamp = TStime();
+         else if (IsHandshake(cptr)) {
+           sendto_opmask_butone(0, SNO_OLDSNO, "clock adjusted by adding %d",
+                                (int)(timestamp - recv_time));
+           TSoffset += timestamp - recv_time;
+         }
+       }
       }
-      else if ((start_timestamp > me.serv->timestamp) && IsUnknown(cptr))
-        cptr->serv->timestamp = TStime();
-
-      else if (timestamp != recv_time)
-      {
-        /*
-         * Equal start times, we have a collision.  Let the connected-to server
-         * decide. This assumes leafs issue more than half of the connection
-         * attempts.
-         */
-        if (IsUnknown(cptr))
-          cptr->serv->timestamp = TStime();
-        else if (IsHandshake(cptr))
-        {
-          sendto_ops("clock adjusted by adding %d",
-              (int)(timestamp - recv_time));
-          TSoffset += timestamp - recv_time;
-        }
-      }
-#else /* RELIABLE CLOCK IS TRUE, we _always_ use our own clock */
-      if (start_timestamp < me.serv->timestamp)
-        me.serv->timestamp = start_timestamp;
-      if (IsUnknown(cptr))
-        cptr->serv->timestamp = TStime();
-#endif
     }
 
-    ret = server_estab(cptr, aconf);
+    ret = server_estab(cptr, aconf, ajupe);
   }
   else
     ret = 0;
-#ifdef RELIABLE_CLOCK
-  if (abs(cptr->serv->timestamp - recv_time) > 30)
-  {
-    sendto_ops("Connected to a net with a timestamp-clock"
-        " difference of " STIME_T_FMT " seconds! Used SETTIME to correct"
-        " this.", timestamp - recv_time);
-    sendto_one(cptr, ":%s SETTIME " TIME_T_FMT " :%s",
-        me.name, TStime(), me.name);
+
+  if (feature_bool(FEAT_RELIABLE_CLOCK) &&
+      abs(cli_serv(cptr)->timestamp - recv_time) > 30) {
+    sendto_opmask_butone(0, SNO_OLDSNO, "Connected to a net with a "
+                        "timestamp-clock difference of %Td seconds! "
+                        "Used SETTIME to correct this.",
+                        timestamp - recv_time);
+    sendcmdto_one(&me, CMD_SETTIME, cptr, "%Tu :%s", TStime(), cli_name(&me));
   }
-#endif
 
   return ret;
 }
@@ -794,6 +766,8 @@ int mr_server(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
  *    parv[6] = "YMM", where 'Y' is the server numeric and "MM" is the
  *              numeric nick mask of this server.
  *    parv[7] = 0 (not used yet, mandatory unsigned int after u2.10.06)
+ *    parv[8] = %<lastmod> - optional parameter only present if there's an
+ *             outstanding JUPE; specifies the JUPE's lastmod field
  */
 int ms_server(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
 {
@@ -805,7 +779,6 @@ int ms_server(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
   struct Client*   bcptr;
   struct Client*   LHcptr = 0;
   struct ConfItem* aconf = 0;
-  struct ConfItem* cconf;
   struct ConfItem* lhconf = 0;
   struct Jupe*     ajupe = 0;
   int              hop;
@@ -816,12 +789,7 @@ int ms_server(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
   time_t           timestamp = 0;
   time_t           recv_time;
   time_t           ghost = 0;
-
-  if (IsUser(cptr))
-  {
-    sendto_one(cptr, err_str(ERR_ALREADYREGISTRED), me.name, parv[0]);
-    return 0;
-  }
+  time_t           lastmod = 0;
 
   if (IsUserPort(cptr))
     return exit_client_msg(cptr, cptr, &me,
@@ -836,9 +804,6 @@ int ms_server(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
   }
   host = parv[1];
 
-  if ((ajupe = jupe_find(host)) && JupeIsActive(ajupe))
-    jupe_resend(cptr, ajupe);
-
   /*
    * Detect protocol
    */
@@ -860,8 +825,8 @@ int ms_server(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
   hop = atoi(parv[2]);
   start_timestamp = atoi(parv[3]);
   timestamp = atoi(parv[4]);
-  Debug((DEBUG_INFO, "Got SERVER %s with timestamp [%s] age " TIME_T_FMT " ("
-      TIME_T_FMT ")", host, parv[4], start_timestamp, me.serv->timestamp));
+  Debug((DEBUG_INFO, "Got SERVER %s with timestamp [%s] age %Tu (%Tu)",
+        host, parv[4], start_timestamp, cli_serv(&me)->timestamp));
   if ((timestamp < OLDEST_TS || (hop == 1 && start_timestamp < OLDEST_TS)))
   {
     return exit_client_msg(cptr, sptr, &me,
@@ -870,11 +835,21 @@ int ms_server(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
   ircd_strncpy(info, parv[parc - 1], REALLEN);
   info[REALLEN] = '\0';
   if (prot < atoi(MINOR_PROTOCOL)) {
-    sendto_ops("Got incompatible protocol version (%s) from %s",
-               parv[5], cptr->name);
+    sendto_opmask_butone(0, SNO_OLDSNO, "Got incompatible protocol version "
+                        "(%s) from %s", parv[5], cli_name(cptr));
     return exit_new_server(cptr, sptr, host, timestamp,
                            "Incompatible protocol: %s", parv[5]);
   }
+  if (parc > 9 && *parv[8] == '%')
+    lastmod = atoi(parv[8] + 1);
+  /* If there's a jupe that matches, and it's a global jupe, and the
+   * introducer didn't indicate it knew of the jupe or has an older
+   * version of the jupe, and the connection isn't in a BURST, resynch
+   * the jupe.
+   */
+  if ((ajupe = jupe_find(host)) && !JupeIsLocal(ajupe) &&
+      JupeLastMod(ajupe) > lastmod && !IsBurstOrBurstAck(cptr))
+    jupe_resend(cptr, ajupe);
   /*
    * Check for "FRENCH " infection ;-) (actually this should
    * be replaced with routine to check the hostname syntax in
@@ -889,7 +864,8 @@ int ms_server(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
     if (*ch <= ' ' || *ch > '~')
       break;
   if (*ch || !strchr(host, '.')) {
-    sendto_ops("Bogus server name (%s) from %s", host, cptr->name);
+    sendto_opmask_butone(0, SNO_OLDSNO, "Bogus server name (%s) from %s",
+                        host, cli_name(cptr));
     return exit_client_msg(cptr, cptr, &me, "Bogus server name (%s)", host);
   }
 
@@ -906,7 +882,7 @@ int ms_server(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
      * See if the newly found server is behind a guaranteed
      * leaf (L-line). If so, close the link.
      */
-    if ((lhconf = find_conf_byhost(cptr->confs, cptr->name, CONF_LEAF)) &&
+    if ((lhconf = find_conf_byhost(cli_confs(cptr), cli_name(cptr), CONF_LEAF)) &&
         (!lhconf->port || (hop > lhconf->port)))
     {
       /*
@@ -915,12 +891,12 @@ int ms_server(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
        * both.
        */
       active_lh_line = 1;
-      if (timestamp <= cptr->serv->timestamp)
+      if (timestamp <= cli_serv(cptr)->timestamp)
         LHcptr = 0;          /* Kill incoming server */
       else
         LHcptr = cptr;          /* Squit ourselfs */
     }
-    else if (!(lhconf = find_conf_byname(cptr->confs, cptr->name, CONF_HUB)) ||
+    else if (!(lhconf = find_conf_byname(cli_confs(cptr), cli_name(cptr), CONF_HUB)) ||
              (lhconf->port && (hop > lhconf->port)))
     {
       struct Client *ac3ptr;
@@ -928,7 +904,7 @@ int ms_server(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
       /* Look for net junction causing this: */
       LHcptr = 0;            /* incoming server */
       if (*parv[5] != 'J') {
-        for (ac3ptr = sptr; ac3ptr != &me; ac3ptr = ac3ptr->serv->up) {
+        for (ac3ptr = sptr; ac3ptr != &me; ac3ptr = cli_serv(ac3ptr)->up) {
           if (IsJunction(ac3ptr)) {
             LHcptr = ac3ptr;
             break;
@@ -958,87 +934,57 @@ int ms_server(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
      * and not mess with hash internals. 
      *                          --Nemesi
      */
-    if ((!(EmptyString(cptr->name)))
+    if ((!(EmptyString(cli_name(cptr))))
         && (IsUnknown(cptr) || IsHandshake(cptr))
-        && 0 != ircd_strcmp(cptr->name, host))
+        && 0 != ircd_strcmp(cli_name(cptr), host))
       hChangeClient(cptr, host);
-    ircd_strncpy(cptr->name, host, HOSTLEN);
-    ircd_strncpy(cptr->info, info[0] ? info : me.name, REALLEN);
-    cptr->hopcount = hop;
+    ircd_strncpy(cli_name(cptr), host, HOSTLEN);
+    ircd_strncpy(cli_info(cptr), info[0] ? info : cli_name(&me), REALLEN);
+    cli_hopcount(cptr) = hop;
 
     /* check connection rules */
-    for (cconf = GlobalConfList; cconf; cconf = cconf->next) {
-      if ((cconf->status == CONF_CRULEALL) && (match(cconf->host, host) == 0)) {
-        if (crule_eval(cconf->passwd))
-        {
-          ServerStats->is_ref++;
-          sendto_ops("Refused connection from %s.", cptr->name);
-          return exit_client(cptr, cptr, &me, "Disallowed by connection rule");
-        }
-      }
+    if (0 != conf_eval_crule(host, CRULE_ALL)) {
+      ServerStats->is_ref++;
+      sendto_opmask_butone(0, SNO_OLDSNO, "Refused connection from %s.", cli_name(cptr));
+      return exit_client(cptr, cptr, &me, "Disallowed by connection rule");
     }
     if (conf_check_server(cptr)) {
       ++ServerStats->is_ref;
-      sendto_ops("Received unauthorized connection from %s.", cptr->name);
+      sendto_opmask_butone(0, SNO_OLDSNO, "Received unauthorized connection "
+                          "from %s.", cli_name(cptr));
       return exit_client(cptr, cptr, &me, "No C conf lines");
     }
 
-    host = cptr->name;
+    host = cli_name(cptr);
 
     update_load();
 
-    if (!(aconf = find_conf_byname(cptr->confs, host, CONF_SERVER))) {
+    if (!(aconf = find_conf_byname(cli_confs(cptr), host, CONF_SERVER))) {
       ++ServerStats->is_ref;
-#ifndef GODMODE
-      sendto_ops("Access denied. No conf line for server %s", cptr->name);
+      sendto_opmask_butone(0, SNO_OLDSNO, "Access denied. No conf line for "
+                          "server %s", cli_name(cptr));
       return exit_client_msg(cptr, cptr, &me,
-                             "Access denied. No conf line for server %s", cptr->name);
-#else /* GODMODE */
-      sendto_ops("General C line active: No line for server %s", cptr->name);
-      aconf =
-          find_conf_byname(cptr->confs, "general.undernet.org", CONF_SERVER);
-      if (!aconf) {
-        sendto_ops("Neither C lines for server %s nor "
-            "\"general.undernet.org\"", cptr->name);
-        return exit_client_msg(cptr, cptr, &me,
-            "No C lines for server %s", cptr->name);
-      }
-#endif /* GODMODE */
+                             "Access denied. No conf line for server %s", cli_name(cptr));
     }
-#ifdef CRYPT_LINK_PASSWORD
-    /* passwd may be NULL. Head it off at the pass... */
-    if (*cptr->passwd)
-    {
-      char salt[3];
+    encr = cli_passwd(cptr);
 
-      salt[0] = aconf->passwd[0];
-      salt[1] = aconf->passwd[1];
-      salt[2] = '\0';
-      encr = ircd_crypt(cptr->passwd, salt);
-    }
-    else
-      encr = "";
-#else
-    encr = cptr->passwd;
-#endif /* CRYPT_LINK_PASSWORD */
-#ifndef GODMODE
-    if (*aconf->passwd && !!strcmp(aconf->passwd, encr)) {
+    if (*(aconf->passwd) && !!strcmp(aconf->passwd, encr)) {
       ++ServerStats->is_ref;
-      sendto_ops("Access denied (passwd mismatch) %s", cptr->name);
+      sendto_opmask_butone(0, SNO_OLDSNO, "Access denied (passwd mismatch) %s",
+                          cli_name(cptr));
       return exit_client_msg(cptr, cptr, &me,
-                             "No Access (passwd mismatch) %s", cptr->name);
+                             "No Access (passwd mismatch) %s", cli_name(cptr));
+    }
+    memset(cli_passwd(cptr), 0, sizeof(cli_passwd(cptr)));
+
+    if (!feature_bool(FEAT_HUB)) {
+      for (i = 0; i <= HighestFd; i++)
+       if (LocalClientArray[i] && IsServer(LocalClientArray[i])) {
+         active_lh_line = 3;
+         LHcptr = 0;
+         break;
+       }
     }
-#endif /* not GODMODE */
-    memset(cptr->passwd, 0, sizeof(cptr->passwd));
-
-#ifndef HUB
-    for (i = 0; i <= HighestFd; i++)
-      if (LocalClientArray[i] && IsServer(LocalClientArray[i])) {
-        active_lh_line = 3;
-        LHcptr = 0;
-        break;
-      }
-#endif
   }
 
   /*
@@ -1070,14 +1016,14 @@ int ms_server(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
     /*
      * Detect wrong numeric.
      */
-    if (0 != ircd_strcmp(acptr->name, host))
+    if (0 != ircd_strcmp(cli_name(acptr), host))
     {
-      sendto_serv_butone(cptr,
-          ":%s WALLOPS :SERVER Numeric Collision: %s != %s",
-          me.name, acptr->name, host);
+      sendcmdto_serv_butone(&me, CMD_WALLOPS, cptr,
+                           ":SERVER Numeric Collision: %s != %s", cli_name(acptr),
+                           host);
       return exit_client_msg(cptr, cptr, &me,
           "NUMERIC collision between %s and %s."
-          " Is your server numeric correct ?", host, acptr->name);
+          " Is your server numeric correct ?", host, cli_name(acptr));
     }
     /*
      *  Kill our try, if we had one.
@@ -1106,14 +1052,14 @@ int ms_server(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
      * Our new server might be a juped server,
      * or someone trying abuse a second Uworld:
      */
-    else if (IsServer(acptr) && (0 == ircd_strncmp(acptr->info, "JUPE", 4) ||
-        find_conf_byhost(cptr->confs, acptr->name, CONF_UWORLD)))
+    else if (IsServer(acptr) && (0 == ircd_strncmp(cli_info(acptr), "JUPE", 4) ||
+        find_conf_byhost(cli_confs(cptr), cli_name(acptr), CONF_UWORLD)))
     {
       if (!IsServer(sptr))
-        return exit_client(cptr, sptr, &me, acptr->info);
-      sendto_one(cptr, ":%s WALLOPS :Received :%s SERVER %s from %s !?!",
-          me.name, parv[0], parv[1], cptr->name);
-      return exit_new_server(cptr, sptr, host, timestamp, "%s", acptr->info);
+        return exit_client(cptr, sptr, &me, cli_info(acptr));
+      sendcmdto_one(&me, CMD_WALLOPS, cptr, ":Received :%s SERVER %s "
+                   "from %s !?!", parv[0], parv[1], cli_name(cptr));
+      return exit_new_server(cptr, sptr, host, timestamp, "%s", cli_info(acptr));
     }
     /*
      * Of course we find the handshake this link was before :)
@@ -1134,41 +1080,41 @@ int ms_server(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
       struct Client* ac3ptr;
 
       /* Search youngest link: */
-      for (ac3ptr = acptr; ac3ptr != &me; ac3ptr = ac3ptr->serv->up)
-        if (ac3ptr->serv->timestamp > c3ptr->serv->timestamp)
+      for (ac3ptr = acptr; ac3ptr != &me; ac3ptr = cli_serv(ac3ptr)->up)
+        if (cli_serv(ac3ptr)->timestamp > cli_serv(c3ptr)->timestamp)
           c3ptr = ac3ptr;
       if (IsServer(sptr))
       {
-        for (ac3ptr = sptr; ac3ptr != &me; ac3ptr = ac3ptr->serv->up)
-          if (ac3ptr->serv->timestamp > c3ptr->serv->timestamp)
+        for (ac3ptr = sptr; ac3ptr != &me; ac3ptr = cli_serv(ac3ptr)->up)
+          if (cli_serv(ac3ptr)->timestamp > cli_serv(c3ptr)->timestamp)
             c3ptr = ac3ptr;
       }
-      if (timestamp > c3ptr->serv->timestamp)
+      if (timestamp > cli_serv(c3ptr)->timestamp)
       {
         c3ptr = 0;
         c2ptr = acptr;          /* Make sure they differ */
       }
       /* Search second youngest link: */
-      for (ac2ptr = acptr; ac2ptr != &me; ac2ptr = ac2ptr->serv->up)
+      for (ac2ptr = acptr; ac2ptr != &me; ac2ptr = cli_serv(ac2ptr)->up)
         if (ac2ptr != c3ptr &&
-            ac2ptr->serv->timestamp >
-            (c2ptr ? c2ptr->serv->timestamp : timestamp))
+            cli_serv(ac2ptr)->timestamp >
+            (c2ptr ? cli_serv(c2ptr)->timestamp : timestamp))
           c2ptr = ac2ptr;
       if (IsServer(sptr))
       {
-        for (ac2ptr = sptr; ac2ptr != &me; ac2ptr = ac2ptr->serv->up)
+        for (ac2ptr = sptr; ac2ptr != &me; ac2ptr = cli_serv(ac2ptr)->up)
           if (ac2ptr != c3ptr &&
-              ac2ptr->serv->timestamp >
-              (c2ptr ? c2ptr->serv->timestamp : timestamp))
+              cli_serv(ac2ptr)->timestamp >
+              (c2ptr ? cli_serv(c2ptr)->timestamp : timestamp))
             c2ptr = ac2ptr;
       }
-      if (c3ptr && timestamp > (c2ptr ? c2ptr->serv->timestamp : timestamp))
+      if (c3ptr && timestamp > (c2ptr ? cli_serv(c2ptr)->timestamp : timestamp))
         c2ptr = 0;
       /* If timestamps are equal, decide which link to break
        *  by name.
        */
-      if ((c2ptr ? c2ptr->serv->timestamp : timestamp) ==
-          (c3ptr ? c3ptr->serv->timestamp : timestamp))
+      if ((c2ptr ? cli_serv(c2ptr)->timestamp : timestamp) ==
+          (c3ptr ? cli_serv(c3ptr)->timestamp : timestamp))
       {
         char* n2;
         char* n2up;
@@ -1176,23 +1122,23 @@ int ms_server(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
         char* n3up;
         if (c2ptr)
         {
-          n2 = c2ptr->name;
-          n2up = MyConnect(c2ptr) ? me.name : c2ptr->serv->up->name;
+          n2 = cli_name(c2ptr);
+          n2up = MyConnect(c2ptr) ? cli_name(&me) : cli_name(cli_serv(c2ptr)->up);
         }
         else
         {
           n2 = host;
-          n2up = IsServer(sptr) ? sptr->name : me.name;
+          n2up = IsServer(sptr) ? cli_name(sptr) : cli_name(&me);
         }
         if (c3ptr)
         {
-          n3 = c3ptr->name;
-          n3up = MyConnect(c3ptr) ? me.name : c3ptr->serv->up->name;
+          n3 = cli_name(c3ptr);
+          n3up = MyConnect(c3ptr) ? cli_name(&me) : cli_name(cli_serv(c3ptr)->up);
         }
         else
         {
           n3 = host;
-          n3up = IsServer(sptr) ? sptr->name : me.name;
+          n3up = IsServer(sptr) ? cli_name(sptr) : cli_name(&me);
         }
         if (strcmp(n2, n2up) > 0)
           n2 = n2up;
@@ -1209,10 +1155,10 @@ int ms_server(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
       if (!c2ptr)
         return exit_new_server(cptr, sptr, host, timestamp,
             "server %s already exists and is %ld seconds younger.",
-            host, (long)acptr->serv->timestamp - (long)timestamp);
-      else if (c2ptr->from == cptr || IsServer(sptr))
+            host, (long)cli_serv(acptr)->timestamp - (long)timestamp);
+      else if (cli_from(c2ptr) == cptr || IsServer(sptr))
       {
-        struct Client *killedptrfrom = c2ptr->from;
+        struct Client *killedptrfrom = cli_from(c2ptr);
         if (active_lh_line)
         {
           /*
@@ -1225,7 +1171,7 @@ int ms_server(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
            * If breaking the loop here solves the L: or H:
            * line problem, we don't squit that.
            */
-          if (c2ptr->from == cptr || (LHcptr && a_kills_b_too(c2ptr, LHcptr)))
+          if (cli_from(c2ptr) == cptr || (LHcptr && a_kills_b_too(c2ptr, LHcptr)))
             active_lh_line = 0;
           else
           {
@@ -1244,16 +1190,16 @@ int ms_server(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
          * a Ghost... (20 seconds is more then enough because all
          * SERVER messages are at the beginning of a net.burst). --Run
          */
-        if (CurrentTime - cptr->serv->ghost < 20)
+        if (CurrentTime - cli_serv(cptr)->ghost < 20)
         {
-          killedptrfrom = acptr->from;
+          killedptrfrom = cli_from(acptr);
           if (exit_client(cptr, acptr, &me, "Ghost loop") == CPTR_KILLED)
             return CPTR_KILLED;
         }
         else if (exit_client_msg(cptr, c2ptr, &me,
             "Loop <-- %s (new link is %ld seconds younger)", host,
-            (c3ptr ? (long)c3ptr->serv->timestamp : timestamp) -
-            (long)c2ptr->serv->timestamp) == CPTR_KILLED)
+            (c3ptr ? (long)cli_serv(c3ptr)->timestamp : timestamp) -
+            (long)cli_serv(c2ptr)->timestamp) == CPTR_KILLED)
           return CPTR_KILLED;
         /*
          * Did we kill the incoming server off already ?
@@ -1267,7 +1213,7 @@ int ms_server(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
         {
           if (LHcptr && a_kills_b_too(LHcptr, acptr))
             break;
-          if (acptr->from == cptr || (LHcptr && a_kills_b_too(acptr, LHcptr)))
+          if (cli_from(acptr) == cptr || (LHcptr && a_kills_b_too(acptr, LHcptr)))
             active_lh_line = 0;
           else
           {
@@ -1295,7 +1241,7 @@ int ms_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)",
-          cptr->name, host,
+          cli_name(cptr), host,
           lhconf ? (lhconf->name ? lhconf->name : "*") : "!");
     }
     else
@@ -1305,7 +1251,7 @@ int ms_server(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
       {
         if (exit_client_msg(cptr, LHcptr, &me,
             (active_lh_line == 2) ?  "Non-Hub link %s <- %s(%s)" : "Leaf-only link %s <- %s(%s)",
-            cptr->name, host,
+            cli_name(cptr), host,
             lhconf ? (lhconf->name ? lhconf->name : "*") : "!") == CPTR_KILLED)
           return CPTR_KILLED;
       }
@@ -1334,27 +1280,27 @@ int ms_server(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
 
     acptr = make_client(cptr, STAT_SERVER);
     make_server(acptr);
-    acptr->serv->prot = prot;
-    acptr->serv->timestamp = timestamp;
-    acptr->hopcount = hop;
-    ircd_strncpy(acptr->name, host, HOSTLEN);
-    ircd_strncpy(acptr->info, info, REALLEN);
-    acptr->serv->up = sptr;
-    acptr->serv->updown = add_dlink(&sptr->serv->down, acptr);
+    cli_serv(acptr)->prot = prot;
+    cli_serv(acptr)->timestamp = timestamp;
+    cli_hopcount(acptr) = hop;
+    ircd_strncpy(cli_name(acptr), host, HOSTLEN);
+    ircd_strncpy(cli_info(acptr), info, REALLEN);
+    cli_serv(acptr)->up = sptr;
+    cli_serv(acptr)->updown = add_dlink(&(cli_serv(sptr))->down, acptr);
     /* Use cptr, because we do protocol 9 -> 10 translation
        for numeric nicks ! */
     SetServerYXX(cptr, acptr, parv[6]);
 
     Count_newremoteserver(UserStats);
     if (Protocol(acptr) < 10)
-      acptr->flags |= FLAGS_TS8;
+      cli_flags(acptr) |= FLAGS_TS8;
     add_client_to_list(acptr);
     hAddClient(acptr);
     if (*parv[5] == 'J')
     {
       SetBurst(acptr);
-      sendto_op_mask(SNO_NETWORK, "Net junction: %s %s",
-          sptr->name, acptr->name);
+      sendto_opmask_butone(0, SNO_NETWORK, "Net junction: %s %s",
+                          cli_name(sptr), cli_name(acptr));
       SetJunction(acptr);
     }
     /*
@@ -1366,11 +1312,11 @@ int ms_server(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
       if (!(bcptr = LocalClientArray[i]) || !IsServer(bcptr) ||
           bcptr == cptr || IsMe(bcptr))
         continue;
-      if (0 == match(me.name, acptr->name))
+      if (0 == match(cli_name(&me), cli_name(acptr)))
         continue;
-        sendto_one(bcptr, "%s " TOK_SERVER " %s %d 0 %s %s %s%s 0 :%s",
-            NumServ(sptr), acptr->name, hop + 1, parv[4], parv[5],
-            NumServCap(acptr), acptr->info);
+      sendcmdto_one(sptr, CMD_SERVER, bcptr, "%s %d 0 %s %s %s%s 0 :%s",
+                   cli_name(acptr), hop + 1, parv[4], parv[5], NumServCap(acptr),
+                   cli_info(acptr));
     }
     return 0;
   }
@@ -1378,69 +1324,63 @@ int ms_server(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
   if (IsUnknown(cptr) || IsHandshake(cptr))
   {
     make_server(cptr);
-    cptr->serv->timestamp = timestamp;
-    cptr->serv->prot = prot;
-    cptr->serv->ghost = ghost;
+    cli_serv(cptr)->timestamp = timestamp;
+    cli_serv(cptr)->prot = prot;
+    cli_serv(cptr)->ghost = ghost;
     SetServerYXX(cptr, cptr, parv[6]);
     if (start_timestamp > OLDEST_TS)
     {
-#ifndef RELIABLE_CLOCK
-#ifdef TESTNET
-      sendto_ops("Debug: my start time: " TIME_T_FMT " ; others start time: "
-          TIME_T_FMT, me.serv->timestamp, start_timestamp);
-      sendto_ops("Debug: receive time: " TIME_T_FMT " ; received timestamp: "
-          TIME_T_FMT " ; difference %ld",
-          recv_time, timestamp, timestamp - recv_time);
-#endif
-      if (start_timestamp < me.serv->timestamp)
-      {
-        sendto_ops("got earlier start time: " TIME_T_FMT " < " TIME_T_FMT,
-            start_timestamp, me.serv->timestamp);
-        me.serv->timestamp = start_timestamp;
-        TSoffset += timestamp - recv_time;
-        sendto_ops("clock adjusted by adding %d", (int)(timestamp - recv_time));
-      }
-      else if ((start_timestamp > me.serv->timestamp) && IsUnknown(cptr))
-        cptr->serv->timestamp = TStime();
-
-      else if (timestamp != recv_time)
-      {
-        /*
-         * Equal start times, we have a collision.  Let the connected-to server
-         * decide. This assumes leafs issue more than half of the connection
-         * attempts.
-         */
-        if (IsUnknown(cptr))
-          cptr->serv->timestamp = TStime();
-        else if (IsHandshake(cptr))
-        {
-          sendto_ops("clock adjusted by adding %d",
-              (int)(timestamp - recv_time));
-          TSoffset += timestamp - recv_time;
-        }
+      Debug((DEBUG_DEBUG, "My start time: %Tu; other's start time: %Tu",
+            cli_serv(&me)->timestamp, start_timestamp));
+      Debug((DEBUG_DEBUG, "Receive time: %Tu; received timestamp: %Tu; "
+            "difference %ld", recv_time, timestamp, timestamp - recv_time));
+      if (feature_bool(FEAT_RELIABLE_CLOCK)) {
+       if (start_timestamp < cli_serv(&me)->timestamp)
+         cli_serv(&me)->timestamp = start_timestamp;
+       if (IsUnknown(cptr))
+         cli_serv(cptr)->timestamp = TStime();
+      } else {
+       if (start_timestamp < cli_serv(&me)->timestamp) {
+         sendto_opmask_butone(0, SNO_OLDSNO, "got earlier start time: "
+                              "%Tu < %Tu", start_timestamp,
+                              cli_serv(&me)->timestamp);
+         cli_serv(&me)->timestamp = start_timestamp;
+         TSoffset += timestamp - recv_time;
+         sendto_opmask_butone(0, SNO_OLDSNO, "clock adjusted by adding %d",
+                              (int)(timestamp - recv_time));
+       } else if ((start_timestamp > cli_serv(&me)->timestamp) &&
+                  IsUnknown(cptr))
+         cli_serv(cptr)->timestamp = TStime();
+
+       else if (timestamp != recv_time) {
+         /*
+          * Equal start times, we have a collision.  Let the connected-to
+          * server decide. This assumes leafs issue more than half of the
+          * connection attempts.
+          */
+         if (IsUnknown(cptr))
+           cli_serv(cptr)->timestamp = TStime();
+         else if (IsHandshake(cptr)) {
+           sendto_opmask_butone(0, SNO_OLDSNO, "clock adjusted by adding %d",
+                                (int)(timestamp - recv_time));
+           TSoffset += timestamp - recv_time;
+         }
+       }
       }
-#else /* RELIABLE CLOCK IS TRUE, we _always_ use our own clock */
-      if (start_timestamp < me.serv->timestamp)
-        me.serv->timestamp = start_timestamp;
-      if (IsUnknown(cptr))
-        cptr->serv->timestamp = TStime();
-#endif
     }
 
-    ret = server_estab(cptr, aconf);
+    ret = server_estab(cptr, aconf, ajupe);
   }
   else
     ret = 0;
-#ifdef RELIABLE_CLOCK
-  if (abs(cptr->serv->timestamp - recv_time) > 30)
-  {
-    sendto_ops("Connected to a net with a timestamp-clock"
-        " difference of " STIME_T_FMT " seconds! Used SETTIME to correct"
-        " this.", timestamp - recv_time);
-    sendto_one(cptr, ":%s SETTIME " TIME_T_FMT " :%s",
-        me.name, TStime(), me.name);
+
+  if (feature_bool(FEAT_RELIABLE_CLOCK) &&
+      abs(cli_serv(cptr)->timestamp - recv_time) > 30) {
+    sendto_opmask_butone(0, SNO_OLDSNO, "Connected to a net with a "
+                        "timestamp-clock difference of %Td seconds! Used "
+                        "SETTIME to correct this.", timestamp - recv_time);
+    sendcmdto_one(&me, CMD_SETTIME, cptr, "%Tu :%s", TStime(), cli_name(&me));
   }
-#endif
 
   return ret;
 }
@@ -1472,7 +1412,6 @@ int m_server(struct Client *cptr, struct Client *sptr, int parc, char *parv[])
   struct Client*   bcptr;
   struct Client*   LHcptr = 0;
   struct ConfItem* aconf = 0;
-  struct ConfItem* cconf;
   struct ConfItem* lhconf = 0;
   struct Jupe*     ajupe = 0;
   int              hop;
@@ -1486,7 +1425,7 @@ int m_server(struct Client *cptr, struct Client *sptr, int parc, char *parv[])
 
   if (IsUser(cptr))
   {
-    sendto_one(cptr, err_str(ERR_ALREADYREGISTRED), me.name, parv[0]);
+    sendto_one(cptr, err_str(ERR_ALREADYREGISTRED), me.name, parv[0]); /* XXX DEAD */
     return 0;
   }
 
@@ -1534,7 +1473,7 @@ int m_server(struct Client *cptr, struct Client *sptr, int parc, char *parv[])
   ircd_strncpy(info, parv[parc - 1], REALLEN);
   info[REALLEN] = '\0';
   if (prot < atoi(MINOR_PROTOCOL)) {
-    sendto_ops("Got incompatible protocol version (%s) from %s",
+    sendto_ops("Got incompatible protocol version (%s) from %s", /* XXX DEAD */
                parv[5], cptr->name);
     return exit_new_server(cptr, sptr, host, timestamp,
         "Incompatible protocol: %s", parv[5]);
@@ -1554,7 +1493,7 @@ int m_server(struct Client *cptr, struct Client *sptr, int parc, char *parv[])
       break;
   if (*ch || !strchr(host, '.'))
   {
-    sendto_ops("Bogus server name (%s) from %s", host, cptr->name);
+    sendto_ops("Bogus server name (%s) from %s", host, cptr->name); /* XXX DEAD */
     return exit_client_msg(cptr, cptr, &me, "Bogus server name (%s)", host);
   }
 
@@ -1632,19 +1571,14 @@ int m_server(struct Client *cptr, struct Client *sptr, int parc, char *parv[])
     cptr->hopcount = hop;
 
     /* check connection rules */
-    for (cconf = GlobalConfList; cconf; cconf = cconf->next) {
-      if ((cconf->status == CONF_CRULEALL) && (match(cconf->host, host) == 0)) {
-        if (crule_eval(cconf->passwd))
-        {
-          ServerStats->is_ref++;
-          sendto_ops("Refused connection from %s.", cptr->name);
-          return exit_client(cptr, cptr, &me, "Disallowed by connection rule");
-        }
-      }
+    if (0 != conf_eval_crule(host, CRULE_ALL)) {
+      ServerStats->is_ref++;
+      sendto_ops("Refused connection from %s.", cptr->name); /* XXX DEAD */
+      return exit_client(cptr, cptr, &me, "Disallowed by connection rule");
     }
     if (conf_check_server(cptr)) {
       ++ServerStats->is_ref;
-      sendto_ops("Received unauthorized connection from %s.", cptr->name);
+      sendto_ops("Received unauthorized connection from %s.", cptr->name); /* XXX DEAD */
       return exit_client(cptr, cptr, &me, "No C/N conf lines");
     }
 
@@ -1655,15 +1589,15 @@ int m_server(struct Client *cptr, struct Client *sptr, int parc, char *parv[])
     if (!(aconf = find_conf_byname(cptr->confs, host, CONF_SERVER))) {
       ++ServerStats->is_ref;
 #ifndef GODMODE
-      sendto_ops("Access denied. No conf line for server %s", cptr->name);
+      sendto_ops("Access denied. No conf line for server %s", cptr->name); /* XXX DEAD */
       return exit_client_msg(cptr, cptr, &me,
           "Access denied. No conf line for server %s", cptr->name);
 #else /* GODMODE */
-      sendto_ops("General C/N: line active: No line for server %s", cptr->name);
+      sendto_ops("General C/N: line active: No line for server %s", cptr->name); /* XXX DEAD */
       aconf =
           find_conf_byname(cptr->confs, "general.undernet.org", CONF_SERVER);
       if (!aconf) {
-        sendto_ops("Neither C/N lines for server %s nor "
+        sendto_ops("Neither C/N lines for server %s nor " /* XXX DEAD */
             "\"general.undernet.org\"", cptr->name);
         return exit_client_msg(cptr, cptr, &me,
             "No C/N lines for server %s", cptr->name);
@@ -1674,12 +1608,7 @@ int m_server(struct Client *cptr, struct Client *sptr, int parc, char *parv[])
     /* passwd may be NULL. Head it off at the pass... */
     if (*cptr->passwd)
     {
-      char salt[3];
-
-      salt[0] = aconf->passwd[0];
-      salt[1] = aconf->passwd[1];
-      salt[2] = '\0';
-      encr = ircd_crypt(cptr->passwd, salt);
+      encr = ircd_crypt(cptr->passwd, aconf->passwd);
     }
     else
       encr = "";
@@ -1689,7 +1618,7 @@ int m_server(struct Client *cptr, struct Client *sptr, int parc, char *parv[])
 #ifndef GODMODE
     if (*aconf->passwd && !!strcmp(aconf->passwd, encr)) {
       ++ServerStats->is_ref;
-      sendto_ops("Access denied (passwd mismatch) %s", cptr->name);
+      sendto_ops("Access denied (passwd mismatch) %s", cptr->name); /* XXX DEAD */
       return exit_client_msg(cptr, cptr, &me,
           "No Access (passwd mismatch) %s", cptr->name);
     }
@@ -1737,7 +1666,7 @@ int m_server(struct Client *cptr, struct Client *sptr, int parc, char *parv[])
      */
     if (0 != ircd_strcmp(acptr->name, host))
     {
-      sendto_serv_butone(cptr,
+      sendto_serv_butone(cptr, /* XXX DEAD */
           ":%s WALLOPS :SERVER Numeric Collision: %s != %s",
           me.name, acptr->name, host);
       return exit_client_msg(cptr, cptr, &me,
@@ -1776,7 +1705,7 @@ int m_server(struct Client *cptr, struct Client *sptr, int parc, char *parv[])
     {
       if (!IsServer(sptr))
         return exit_client(cptr, sptr, &me, acptr->info);
-      sendto_one(cptr, ":%s WALLOPS :Received :%s SERVER %s from %s !?!",
+      sendto_one(cptr, ":%s WALLOPS :Received :%s SERVER %s from %s !?!", /* XXX DEAD */
           me.name, parv[0], parv[1], cptr->name);
       return exit_new_server(cptr, sptr, host, timestamp, "%s", acptr->info);
     }
@@ -2018,7 +1947,7 @@ int m_server(struct Client *cptr, struct Client *sptr, int parc, char *parv[])
     if (*parv[5] == 'J')
     {
       SetBurst(acptr);
-      sendto_op_mask(SNO_NETWORK, "Net junction: %s %s",
+      sendto_op_mask(SNO_NETWORK, "Net junction: %s %s", /* XXX DEAD */
           sptr->name, acptr->name);
       SetJunction(acptr);
     }
@@ -2033,7 +1962,7 @@ int m_server(struct Client *cptr, struct Client *sptr, int parc, char *parv[])
         continue;
       if (0 == match(me.name, acptr->name))
         continue;
-        sendto_one(bcptr, "%s " TOK_SERVER " %s %d 0 %s %s %s%s 0 :%s",
+        sendto_one(bcptr, "%s " TOK_SERVER " %s %d 0 %s %s %s%s 0 :%s", /* XXX DEAD */
             NumServ(sptr), acptr->name, hop + 1, parv[4], parv[5],
             NumServCap(acptr), acptr->info);
     }
@@ -2051,19 +1980,19 @@ int m_server(struct Client *cptr, struct Client *sptr, int parc, char *parv[])
     {
 #ifndef RELIABLE_CLOCK
 #ifdef TESTNET
-      sendto_ops("Debug: my start time: " TIME_T_FMT " ; others start time: "
+      sendto_ops("Debug: my start time: " TIME_T_FMT " ; others start time: " /* XXX DEAD */
           TIME_T_FMT, me.serv->timestamp, start_timestamp);
-      sendto_ops("Debug: receive time: " TIME_T_FMT " ; received timestamp: "
+      sendto_ops("Debug: receive time: " TIME_T_FMT " ; received timestamp: " /* XXX DEAD */
           TIME_T_FMT " ; difference %ld",
           recv_time, timestamp, timestamp - recv_time);
 #endif
       if (start_timestamp < me.serv->timestamp)
       {
-        sendto_ops("got earlier start time: " TIME_T_FMT " < " TIME_T_FMT,
+        sendto_ops("got earlier start time: " TIME_T_FMT " < " TIME_T_FMT, /* XXX DEAD */
             start_timestamp, me.serv->timestamp);
         me.serv->timestamp = start_timestamp;
         TSoffset += timestamp - recv_time;
-        sendto_ops("clock adjusted by adding %d", (int)(timestamp - recv_time));
+        sendto_ops("clock adjusted by adding %d", (int)(timestamp - recv_time)); /* XXX DEAD */
       }
       else if ((start_timestamp > me.serv->timestamp) && IsUnknown(cptr))
         cptr->serv->timestamp = TStime();
@@ -2079,7 +2008,7 @@ int m_server(struct Client *cptr, struct Client *sptr, int parc, char *parv[])
           cptr->serv->timestamp = TStime();
         else if (IsHandshake(cptr))
         {
-          sendto_ops("clock adjusted by adding %d",
+          sendto_ops("clock adjusted by adding %d", /* XXX DEAD */
               (int)(timestamp - recv_time));
           TSoffset += timestamp - recv_time;
         }
@@ -2092,17 +2021,17 @@ int m_server(struct Client *cptr, struct Client *sptr, int parc, char *parv[])
 #endif
     }
 
-    ret = server_estab(cptr, aconf);
+    ret = server_estab(cptr, aconf); /* XXX DEAD */
   }
   else
     ret = 0;
 #ifdef RELIABLE_CLOCK
   if (abs(cptr->serv->timestamp - recv_time) > 30)
   {
-    sendto_ops("Connected to a net with a timestamp-clock"
+    sendto_ops("Connected to a net with a timestamp-clock" /* XXX DEAD */
         " difference of " STIME_T_FMT " seconds! Used SETTIME to correct"
         " this.", timestamp - recv_time);
-    sendto_one(cptr, ":%s SETTIME " TIME_T_FMT " :%s",
+    sendto_one(cptr, ":%s SETTIME " TIME_T_FMT " :%s", /* XXX DEAD */
         me.name, TStime(), me.name);
   }
 #endif