]> jfr.im git - irc/rqf/shadowircd.git/blobdiff - modules/core/m_server.c
Send a few more snotes about remote connects netwide.
[irc/rqf/shadowircd.git] / modules / core / m_server.c
index f6fb2b4b37a2a302e0f34a4ef31c26f6df24b161..bd38f0f193783ad8b725bba45ce61a3d0224120f 100644 (file)
@@ -21,7 +21,7 @@
  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
  *  USA
  *
- *  $Id: m_server.c 3179 2007-02-01 00:34:33Z jilles $
+ *  $Id: m_server.c 3291 2007-03-28 14:30:10Z jilles $
  */
 
 #include "stdinc.h"
@@ -38,7 +38,7 @@
 #include "s_log.h"             /* log level defines */
 #include "s_serv.h"            /* server_estab, check_server */
 #include "s_stats.h"           /* ServerStats */
-#include "scache.h"            /* find_or_add */
+#include "scache.h"
 #include "send.h"              /* sendto_one */
 #include "msg.h"
 #include "parse.h"
@@ -59,7 +59,7 @@ struct Message sid_msgtab = {
 
 mapi_clist_av1 server_clist[] = { &server_msgtab, &sid_msgtab, NULL };
 
-DECLARE_MODULE_AV1(server, NULL, NULL, server_clist, NULL, NULL, "$Revision: 3179 $");
+DECLARE_MODULE_AV1(server, NULL, NULL, server_clist, NULL, NULL, "$Revision: 3291 $");
 
 int bogus_host(const char *host);
 static int set_server_gecos(struct Client *, const char *);
@@ -83,6 +83,17 @@ mr_server(struct Client *client_p, struct Client *source_p, int parc, const char
        hop = atoi(parv[2]);
        strlcpy(info, parv[3], sizeof(info));
 
+       if (IsHandshake(client_p) && irccmp(client_p->name, name))
+       {
+               sendto_realops_snomask(SNO_GENERAL, is_remote_connect(client_p) ? L_NETWIDE : L_ALL,
+                               "Server %s has unexpected name %s",
+                               get_server_name(client_p, HIDE_IP), name);
+               ilog(L_SERVER, "Server %s has unexpected name %s",
+                               log_client_name(client_p, SHOW_IP), name);
+               exit_client(client_p, client_p, client_p, "Server name mismatch");
+               return 0;
+       }
+
        /* 
         * Reject a direct nonTS server connection if we're TS_ONLY -orabidoo
         */
@@ -123,7 +134,7 @@ mr_server(struct Client *client_p, struct Client *source_p, int parc, const char
                break;
 
        case -2:
-               sendto_realops_snomask(SNO_GENERAL, L_ALL,
+               sendto_realops_snomask(SNO_GENERAL, is_remote_connect(client_p) ? L_NETWIDE : L_ALL,
                                     "Unauthorised server connection attempt from %s: "
                                     "Bad password for server %s",
                                     get_server_name(client_p, HIDE_IP), name);
@@ -192,7 +203,7 @@ mr_server(struct Client *client_p, struct Client *source_p, int parc, const char
 
        if(has_id(client_p) && (target_p = find_id(client_p->id)) != NULL)
        {
-               sendto_realops_snomask(SNO_GENERAL, L_ALL,
+               sendto_realops_snomask(SNO_GENERAL, is_remote_connect(client_p) ? L_NETWIDE : L_ALL,
                                     "Attempt to re-introduce SID %s from %s%s",
                                     client_p->id,
                                     EmptyString(client_p->name) ? name : "",
@@ -407,11 +418,6 @@ ms_server(struct Client *client_p, struct Client *source_p, int parc, const char
 
        set_server_gecos(target_p, info);
 
-       target_p->serv->up = find_or_add(source_p->name);
-
-       if(has_id(source_p))
-               target_p->serv->upid = source_p->id;
-
        target_p->servptr = source_p;
 
        SetServer(target_p);
@@ -421,6 +427,8 @@ ms_server(struct Client *client_p, struct Client *source_p, int parc, const char
        add_to_client_hash(target_p->name, target_p);
        dlinkAdd(target_p, &target_p->lnode, &target_p->servptr->serv->servers);
 
+       target_p->serv->nameinfo = scache_connect(target_p->name, target_p->info, IsHidden(target_p));
+
        sendto_server(client_p, NULL, NOCAPS, NOCAPS,
                      ":%s SERVER %s %d :%s%s",
                      source_p->name, target_p->name, target_p->hopcount + 1,
@@ -476,7 +484,7 @@ ms_sid(struct Client *client_p, struct Client *source_p, int parc, const char *p
                ilog(L_SERVER, "Link %s cancelled, SID %s already exists",
                        client_p->name, parv[3]);
 
-               exit_client(NULL, client_p, &me, "Server Exists");
+               exit_client(NULL, client_p, &me, "SID Exists");
                return 0;
        }
 
@@ -559,11 +567,6 @@ ms_sid(struct Client *client_p, struct Client *source_p, int parc, const char *p
        strcpy(target_p->id, parv[3]);
        set_server_gecos(target_p, parv[4]);
 
-       target_p->serv->up = find_or_add(source_p->name);
-
-       if(has_id(source_p))
-               target_p->serv->upid = source_p->id;
-
        target_p->servptr = source_p;
        SetServer(target_p);
 
@@ -573,6 +576,8 @@ ms_sid(struct Client *client_p, struct Client *source_p, int parc, const char *p
        add_to_id_hash(target_p->id, target_p);
        dlinkAdd(target_p, &target_p->lnode, &target_p->servptr->serv->servers);
 
+       target_p->serv->nameinfo = scache_connect(target_p->name, target_p->info, IsHidden(target_p));
+
        sendto_server(client_p, NULL, CAP_TS6, NOCAPS,
                      ":%s SID %s %d %s :%s%s",
                      source_p->id, target_p->name, target_p->hopcount + 1,