IPv6 support (hopefully with fewer future transition pains)
[ircu2.10.12-pk.git] / ircd / s_serv.c
index 4777df1280abb8b148435c8939bedfe3593571e0..72d7be03e2d5b5453b67f2f95a2f628931cc3928 100644 (file)
@@ -35,7 +35,7 @@
 #include "ircd_reply.h"
 #include "ircd_string.h"
 #include "ircd_snprintf.h"
-#include "ircd_xopen.h"
+#include "ircd_crypt.h"
 #include "jupe.h"
 #include "list.h"
 #include "match.h"
@@ -51,7 +51,6 @@
 #include "s_misc.h"
 #include "s_user.h"
 #include "send.h"
-#include "sprintf_irc.h"
 #include "struct.h"
 #include "sys.h"
 #include "userload.h"
@@ -94,18 +93,15 @@ int a_kills_b_too(struct Client *a, struct Client *b)
  * May only be called after a SERVER was received from cptr,
  * and thus make_server was called, and serv->prot set. --Run
  */
-int server_estab(struct Client *cptr, struct ConfItem *aconf,
-                 struct Jupe *ajupe)
+int server_estab(struct Client *cptr, struct ConfItem *aconf)
 {
   struct Client* acptr = 0;
   const char*    inpath;
-  int split,     i;
+  int            i;
 
   assert(0 != cptr);
   assert(0 != cli_local(cptr));
 
-  split = (0 != ircd_strcmp(cli_name(cptr), cli_sockhost(cptr))
-      &&   0 != ircd_strncmp(cli_info(cptr), "JUPE", 4));
   inpath = cli_name(cptr);
 
   if (IsUnknown(cptr)) {
@@ -114,15 +110,17 @@ int server_estab(struct Client *cptr, struct ConfItem *aconf,
     /*
      *  Pass my info to the new server
      */
-    sendrawto_one(cptr, MSG_SERVER " %s 1 %Tu %Tu J%s %s%s :%s", cli_name(&me),
-                  cli_serv(&me)->timestamp, cli_serv(cptr)->timestamp, MAJOR_PROTOCOL,
-                  NumServCap(&me), *(cli_info(&me)) ? cli_info(&me) : "IRCers United");
+    sendrawto_one(cptr, MSG_SERVER " %s 1 %Tu %Tu J%s %s%s +%s :%s",
+                 cli_name(&me), cli_serv(&me)->timestamp,
+                 cli_serv(cptr)->timestamp, MAJOR_PROTOCOL, NumServCap(&me),
+                 feature_bool(FEAT_HUB) ? "h" : "",
+                 *(cli_info(&me)) ? cli_info(&me) : "IRCers United");
     /*
      * Don't charge this IP# for connecting
      * XXX - if this comes from a server port, it will not have been added
      * to the IP check registry, see add_connection in s_bsd.c
      */
-    IPcheck_connect_fail(cli_ip(cptr));
+    IPcheck_connect_fail(&cli_ip(cptr));
   }
 
   det_confs_butmask(cptr, CONF_LEAF | CONF_HUB | CONF_SERVER | CONF_UWORLD);
@@ -137,7 +135,7 @@ int server_estab(struct Client *cptr, struct ConfItem *aconf,
 
   SetBurst(cptr);
 
-  nextping = CurrentTime;
+/*    nextping = CurrentTime; */
 
   /*
    * NOTE: check for acptr->user == cptr->serv->user is necessary to insure
@@ -176,18 +174,20 @@ int server_estab(struct Client *cptr, struct ConfItem *aconf,
       continue;
     if (!match(cli_name(&me), cli_name(cptr)))
       continue;
-    if (ajupe)
-      sendcmdto_one(&me, CMD_SERVER, acptr,
-                    "%s 2 0 %Tu J%02u %s%s 0 %%%Tu :%s", cli_name(cptr),
-                    cli_serv(cptr)->timestamp, Protocol(cptr), NumServCap(cptr),
-                    JupeLastMod(ajupe), cli_info(cptr));
-    else
-      sendcmdto_one(&me, CMD_SERVER, acptr,
-                    "%s 2 0 %Tu J%02u %s%s 0 :%s", cli_name(cptr),
-                    cli_serv(cptr)->timestamp, Protocol(cptr), NumServCap(cptr),
-                    cli_info(cptr));
+    sendcmdto_one(&me, CMD_SERVER, acptr,
+                 "%s 2 0 %Tu J%02u %s%s +%s%s :%s", cli_name(cptr),
+                 cli_serv(cptr)->timestamp, Protocol(cptr), NumServCap(cptr),
+                 IsHub(cptr) ? "h" : "", IsService(cptr) ? "s" : "",
+                 cli_info(cptr));
   }
 
+  /* Send these as early as possible so that glined users/juped servers can
+   * be removed from the network while the remote server is still chewing
+   * our burst.
+   */
+  gline_burst(cptr);
+  jupe_burst(cptr);
+
   /*
    * Pass on my client information to the new server
    *
@@ -217,21 +217,12 @@ int server_estab(struct Client *cptr, struct ConfItem *aconf,
 
       if (0 == match(cli_name(&me), cli_name(acptr)))
         continue;
-      split = (MyConnect(acptr) && 
-               0 != ircd_strcmp(cli_name(acptr), cli_sockhost(acptr)) &&
-               0 != ircd_strncmp(cli_info(acptr), "JUPE", 4));
-      if ((ajupe = jupe_find(cli_name(acptr))) && !JupeIsLocal(ajupe))
-        sendcmdto_one(cli_serv(acptr)->up, CMD_SERVER, cptr,
-                      "%s %d 0 %Tu %s%u %s%s 0 %%%Tu :%s", cli_name(acptr),
-                      cli_hopcount(acptr) + 1, cli_serv(acptr)->timestamp,
-                      protocol_str, Protocol(acptr), NumServCap(acptr),
-                      JupeLastMod(ajupe), cli_info(acptr));
-      else
-        sendcmdto_one(cli_serv(acptr)->up, CMD_SERVER, cptr,
-                      "%s %d 0 %Tu %s%u %s%s 0 :%s", cli_name(acptr),
-                      cli_hopcount(acptr) + 1, cli_serv(acptr)->timestamp,
-                      protocol_str, Protocol(acptr), NumServCap(acptr),
-                      cli_info(acptr));
+      sendcmdto_one(cli_serv(acptr)->up, CMD_SERVER, cptr,
+                   "%s %d 0 %Tu %s%u %s%s +%s%s :%s", cli_name(acptr),
+                   cli_hopcount(acptr) + 1, cli_serv(acptr)->timestamp,
+                   protocol_str, Protocol(acptr), NumServCap(acptr),
+                   IsHub(acptr) ? "h" : "", IsService(acptr) ? "s" : "",
+                   cli_info(acptr));
     }
   }
 
@@ -242,27 +233,15 @@ int server_estab(struct Client *cptr, struct ConfItem *aconf,
       continue;
     if (IsUser(acptr))
     {
-      char xxx_buf[8];
+      char xxx_buf[25];
       char *s = umode_str(acptr);
-      struct Gline *agline = 0;
-      if ((agline = gline_lookup(acptr, GLINE_GLOBAL | GLINE_LASTMOD)))
-        sendcmdto_one(cli_user(acptr)->server, CMD_NICK, cptr,
-                      "%s %d %Tu %s %s %s%s%s%%%Tu:%s@%s %s %s%s :%s",
-                      cli_name(acptr), cli_hopcount(acptr) + 1, cli_lastnick(acptr),
-                      cli_user(acptr)->username, cli_user(acptr)->host,
-                      *s ? "+" : "", s, *s ? " " : "",
-                      GlineLastMod(agline), GlineUser(agline),
-                      GlineHost(agline),
-                      inttobase64(xxx_buf, ntohl(cli_ip(acptr).s_addr), 6),
-                      NumNick(acptr), cli_info(acptr));
-      else
-        sendcmdto_one(cli_user(acptr)->server, CMD_NICK, cptr,
-                      "%s %d %Tu %s %s %s%s%s%s %s%s :%s",
-                      cli_name(acptr), cli_hopcount(acptr) + 1, cli_lastnick(acptr),
-                      cli_user(acptr)->username, cli_user(acptr)->host,
-                      *s ? "+" : "", s, *s ? " " : "",
-                      inttobase64(xxx_buf, ntohl(cli_ip(acptr).s_addr), 6),
-                      NumNick(acptr), cli_info(acptr));
+      sendcmdto_one(cli_user(acptr)->server, CMD_NICK, cptr,
+                   "%s %d %Tu %s %s %s%s%s%s %s%s :%s",
+                   cli_name(acptr), cli_hopcount(acptr) + 1, cli_lastnick(acptr),
+                   cli_user(acptr)->username, cli_user(acptr)->realhost,
+                   *s ? "+" : "", s, *s ? " " : "",
+                   iptobase64(xxx_buf, &cli_ip(acptr), sizeof(xxx_buf)),
+                   NumNick(acptr), cli_info(acptr));
     }
   }
   /*
@@ -274,8 +253,6 @@ int server_estab(struct Client *cptr, struct ConfItem *aconf,
     for (chptr = GlobalChannelList; chptr; chptr = chptr->next)
       send_channel_modes(cptr, chptr);
   }
-  jupe_burst(cptr);
-  gline_burst(cptr);
   sendcmdto_one(&me, CMD_END_OF_BURST, cptr, "");
   return 0;
 }