]> jfr.im git - irc/rqf/shadowircd.git/commitdiff
show_capabilities cleanup and now show whether we are TS or TS6 and SSL link
authorValery Yatsko <redacted>
Mon, 7 Apr 2008 16:21:09 +0000 (20:21 +0400)
committerValery Yatsko <redacted>
Mon, 7 Apr 2008 16:21:09 +0000 (20:21 +0400)
src/s_serv.c

index 60768e4f408a95b028c10c079e5dcd2812b09379..397ae0575869a8f2badd05f5473b6e11b6364a10 100644 (file)
@@ -238,8 +238,8 @@ try_connections(void *unused)
                if(ServerConfIllegal(tmp_p) || !ServerConfAutoconn(tmp_p))
                        continue;
 
-               /* don't allow ssl connections if ssl isn't setup */\r
-               if(ServerConfSSL(tmp_p) && (!ssl_ok || !get_ssld_count()))\r
+               /* don't allow ssl connections if ssl isn't setup */
+               if(ServerConfSSL(tmp_p) && (!ssl_ok || !get_ssld_count()))
                        continue;
 
                cltmp = tmp_p->class;
@@ -369,9 +369,9 @@ check_server(const char *name, struct Client *client_p)
        if(server_p == NULL)
                return error;
 
-       if(ServerConfSSL(server_p) && client_p->localClient->ssl_ctl == NULL)\r
-       {\r
-               return -5;\r
+       if(ServerConfSSL(server_p) && client_p->localClient->ssl_ctl == NULL)
+       {
+               return -5;
        }
 
        attach_server_conf(client_p, server_p);
@@ -838,32 +838,25 @@ show_capabilities(struct Client *target_p)
 {
        static char msgbuf[BUFSIZE];
        struct Capability *cap;
-       char *t;
-       int tl;
 
-       t = msgbuf;
-       tl = rb_sprintf(msgbuf, "TS ");
-       t += tl;
+       if(has_id(target_p))
+               rb_strlcpy(msgbuf, " TS6", sizeof(msgbuf));
+       else
+               rb_strlcpy(msgbuf, " TS", sizeof(msgbuf));
+
+       if(IsSSL(target_p))
+               rb_strlcat(msgbuf, " SSL", sizeof(msgbuf));
 
        if(!IsServer(target_p) || !target_p->serv->caps)        /* short circuit if no caps */
-       {
-               msgbuf[2] = '\0';
-               return msgbuf;
-       }
+               return msgbuf + 1;
 
        for (cap = captab; cap->cap; ++cap)
        {
                if(cap->cap & target_p->serv->caps)
-               {
-                       tl = rb_sprintf(t, "%s ", cap->name);
-                       t += tl;
-               }
+                       rb_snprintf_append(msgbuf, sizeof(msgbuf), " %s", cap->name);
        }
 
-       t--;
-       *t = '\0';
-
-       return msgbuf;
+       return msgbuf + 1;
 }
 
 /*
@@ -950,10 +943,10 @@ server_estab(struct Client *client_p)
                ilog_error("rb_set_buffers failed for server");
 
        /* Enable compression now */
-       if(IsCapable(client_p, CAP_ZIP))\r
-       {\r
-               start_zlib_session(client_p);\r
-       }\r
+       if(IsCapable(client_p, CAP_ZIP))
+       {
+               start_zlib_session(client_p);
+       }
        sendto_one(client_p, "SVINFO %d %d 0 :%ld", TS_CURRENT, TS_MIN, rb_current_time());
 
        client_p->servptr = &me;
@@ -1009,7 +1002,7 @@ server_estab(struct Client *client_p)
        hdata.target = client_p;
        call_hook(h_server_introduced, &hdata);
 
-       rb_snprintf(note, sizeof(note), "Server: %s", client_p->name);\r
+       rb_snprintf(note, sizeof(note), "Server: %s", client_p->name);
        rb_note(client_p->localClient->F, note);
 
        /*
@@ -1103,7 +1096,7 @@ server_estab(struct Client *client_p)
 
        free_pre_client(client_p);
 
-       if (!IsCapable(client_p, CAP_ZIP))\r
+       if (!IsCapable(client_p, CAP_ZIP))
                send_pop_queue(client_p);
 
        return 0;
@@ -1171,15 +1164,15 @@ serv_connect_resolved(struct Client *client_p)
 #endif
                                (server_p->aftype == AF_INET ? "IPv4" : "?"));
 
-               if(ServerConfSSL(server_p))\r
-               {\r
-                       rb_connect_tcp(client_p->localClient->F, (struct sockaddr *)&client_p->localClient->ip,\r
-                                        NULL, 0, serv_connect_ssl_callback, \r
-                                        client_p, ConfigFileEntry.connect_timeout);\r
-               }\r
-               else\r
-                       rb_connect_tcp(client_p->localClient->F, (struct sockaddr *)&client_p->localClient->ip,\r
-                                        NULL, 0, serv_connect_callback, \r
+               if(ServerConfSSL(server_p))
+               {
+                       rb_connect_tcp(client_p->localClient->F, (struct sockaddr *)&client_p->localClient->ip,
+                                        NULL, 0, serv_connect_ssl_callback, 
+                                        client_p, ConfigFileEntry.connect_timeout);
+               }
+               else
+                       rb_connect_tcp(client_p->localClient->F, (struct sockaddr *)&client_p->localClient->ip,
+                                        NULL, 0, serv_connect_callback, 
                                         client_p, ConfigFileEntry.connect_timeout);
                 return 1;
        }
@@ -1193,15 +1186,15 @@ serv_connect_resolved(struct Client *client_p)
                        (server_p->aftype == AF_INET ? "IPv4" : "?"), vhoststr);
 
 
-       if(ServerConfSSL(server_p))\r
-               rb_connect_tcp(client_p->localClient->F, (struct sockaddr *)&client_p->localClient->ip,\r
-                                (struct sockaddr *) &myipnum,\r
-                                GET_SS_LEN(&myipnum), serv_connect_ssl_callback, client_p,\r
-                                ConfigFileEntry.connect_timeout);\r
-       else\r
-               rb_connect_tcp(client_p->localClient->F, (struct sockaddr *)&client_p->localClient->ip,\r
-                                (struct sockaddr *) &myipnum,\r
-                                GET_SS_LEN(&myipnum), serv_connect_callback, client_p,\r
+       if(ServerConfSSL(server_p))
+               rb_connect_tcp(client_p->localClient->F, (struct sockaddr *)&client_p->localClient->ip,
+                                (struct sockaddr *) &myipnum,
+                                GET_SS_LEN(&myipnum), serv_connect_ssl_callback, client_p,
+                                ConfigFileEntry.connect_timeout);
+       else
+               rb_connect_tcp(client_p->localClient->F, (struct sockaddr *)&client_p->localClient->ip,
+                                (struct sockaddr *) &myipnum,
+                                GET_SS_LEN(&myipnum), serv_connect_callback, client_p,
                                 ConfigFileEntry.connect_timeout);
 
        return 1;
@@ -1386,32 +1379,32 @@ serv_connect(struct server_conf *server_p, struct Client *by)
        }
 }
 
-static void\r
-serv_connect_ev(void *data)\r
-{\r
-       struct Client *client_p = data;\r
-       serv_connect_callback(client_p->localClient->F, RB_OK, client_p);\r
+static void
+serv_connect_ev(void *data)
+{
+       struct Client *client_p = data;
+       serv_connect_callback(client_p->localClient->F, RB_OK, client_p);
 }
 
-static void\r
-serv_connect_ssl_callback(rb_fde_t *F, int status, void *data)\r
-{\r
-       struct Client *client_p = data;\r
-       rb_fde_t *xF[2];\r
-       if(status != RB_OK)\r
-       {\r
-               /* XXX deal with failure */\r
-               return;\r
-       }\r
-       rb_connect_sockaddr(F, (struct sockaddr *)&client_p->localClient->ip, sizeof(client_p->localClient->ip));\r
-       rb_socketpair(AF_UNIX, SOCK_STREAM, 0, &xF[0], &xF[1], "Outgoing ssld connection");\r
-       del_from_cli_fd_hash(client_p);\r
-       client_p->localClient->F = xF[0];\r
-       add_to_cli_fd_hash(client_p);\r
-\r
-       client_p->localClient->ssl_ctl = start_ssld_connect(F, xF[1], rb_get_fd(xF[0]));\r
-       SetSSL(client_p);\r
-       rb_event_addonce("serv_connect_ev", serv_connect_ev, client_p, 1);              \r
+static void
+serv_connect_ssl_callback(rb_fde_t *F, int status, void *data)
+{
+       struct Client *client_p = data;
+       rb_fde_t *xF[2];
+       if(status != RB_OK)
+       {
+               /* XXX deal with failure */
+               return;
+       }
+       rb_connect_sockaddr(F, (struct sockaddr *)&client_p->localClient->ip, sizeof(client_p->localClient->ip));
+       rb_socketpair(AF_UNIX, SOCK_STREAM, 0, &xF[0], &xF[1], "Outgoing ssld connection");
+       del_from_cli_fd_hash(client_p);
+       client_p->localClient->F = xF[0];
+       add_to_cli_fd_hash(client_p);
+
+       client_p->localClient->ssl_ctl = start_ssld_connect(F, xF[1], rb_get_fd(xF[0]));
+       SetSSL(client_p);
+       rb_event_addonce("serv_connect_ev", serv_connect_ev, client_p, 1);              
 }
 
 /*
@@ -1446,7 +1439,7 @@ serv_connect_callback(rb_fde_t *F, int status, void *data)
                return;
        }
 
-       if(client_p->localClient->ssl_ctl == NULL)\r
+       if(client_p->localClient->ssl_ctl == NULL)
                rb_connect_sockaddr(F, (struct sockaddr *)&client_p->localClient->ip, sizeof(client_p->localClient->ip));
 
        /* Check the status */