]> jfr.im git - solanum.git/blobdiff - ssld/ssld.c
Merge pull request #178 from staticfox/bsdisms
[solanum.git] / ssld / ssld.c
index f187cd57dd51b4458ac0b6a0f82bf973814db851..403a71a15c71ac822c9ab0b393ce1fe6d184321c 100644 (file)
@@ -17,8 +17,6 @@
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301
  *  USA
- *
- *  $Id$
  */
 
 
@@ -153,12 +151,12 @@ static void conn_plain_read_cb(rb_fde_t *fd, void *data);
 static void conn_plain_read_shutdown_cb(rb_fde_t *fd, void *data);
 static void mod_cmd_write_queue(mod_ctl_t * ctl, const void *data, size_t len);
 static const char *remote_closed = "Remote host closed the connection";
-static int ssl_ok;
+static bool ssld_ssl_ok;
 static int certfp_method = RB_SSL_CERTFP_METH_SHA1;
 #ifdef HAVE_LIBZ
-static int zlib_ok = 1;
+static bool zlib_ok = true;
 #else
-static int zlib_ok = 0;
+static bool zlib_ok = false;
 #endif
 
 
@@ -815,7 +813,10 @@ process_stats(mod_ctl_t * ctl, mod_ctl_buf_t * ctlb)
                return;
 
        snprintf(outstat, sizeof(outstat), "S %s %llu %llu %llu %llu", odata,
-                   conn->plain_out, conn->mod_in, conn->plain_in, conn->mod_out);
+                       (unsigned long long)conn->plain_out,
+                       (unsigned long long)conn->mod_in,
+                       (unsigned long long)conn->plain_in,
+                       (unsigned long long)conn->mod_out);
        conn->plain_out = 0;
        conn->plain_in = 0;
        conn->mod_in = 0;
@@ -832,13 +833,13 @@ change_connid(mod_ctl_t *ctl, mod_ctl_buf_t *ctlb)
        lrb_assert(conn != NULL);
        if(conn == NULL)
        {
-               char buf[256];
+               uint8_t buf[256];
                int len;
 
                buf[0] = 'D';
                uint32_to_buf(&buf[1], newid);
-               sprintf(&buf[5], "connid %d does not exist", id);
-               len = (strlen(&buf[5]) + 1) + 5;
+               sprintf((char *) &buf[5], "connid %d does not exist", id);
+               len = (strlen((char *) &buf[5]) + 1) + 5;
                mod_cmd_write_queue(ctl, buf, len);
 
                return;
@@ -970,6 +971,14 @@ send_i_am_useless(mod_ctl_t * ctl)
        mod_cmd_write_queue(ctl, useless, strlen(useless));
 }
 
+static void
+send_version(mod_ctl_t * ctl)
+{
+       char version[256] = { 'V', 0 };
+       strncpy(&version[1], rb_lib_version(), sizeof(version) - 2);
+       mod_cmd_write_queue(ctl, version, strlen(version));
+}
+
 static void
 send_nozlib_support(mod_ctl_t * ctl, mod_ctl_buf_t * ctlb)
 {
@@ -1006,7 +1015,7 @@ mod_process_cmd_recv(mod_ctl_t * ctl)
                                        break;
                                }
 
-                               if(!ssl_ok)
+                               if(!ssld_ssl_ok)
                                {
                                        send_nossl_support(ctl, ctl_buf);
                                        break;
@@ -1022,7 +1031,7 @@ mod_process_cmd_recv(mod_ctl_t * ctl)
                                        break;
                                }
 
-                               if(!ssl_ok)
+                               if(!ssld_ssl_ok)
                                {
                                        send_nossl_support(ctl, ctl_buf);
                                        break;
@@ -1042,7 +1051,7 @@ mod_process_cmd_recv(mod_ctl_t * ctl)
                        }
                case 'K':
                        {
-                               if(!ssl_ok)
+                               if(!ssld_ssl_ok)
                                {
                                        send_nossl_support(ctl, ctl_buf);
                                        break;
@@ -1195,10 +1204,9 @@ main(int argc, char **argv)
        if(s_ctlfd == NULL || s_pipe == NULL || s_pid == NULL)
        {
                fprintf(stderr,
-                       "This is ircd-ratbox ssld.  You know you aren't supposed to run me directly?\n");
+                       "This is the charybdis ssld for internal ircd use.\n");
                fprintf(stderr,
-                       "You get an Id tag for this: $Id$\n");
-               fprintf(stderr, "Have a nice life\n");
+                       "You aren't supposed to run me directly. Exiting.\n");
                exit(1);
        }
 
@@ -1229,7 +1237,7 @@ main(int argc, char **argv)
        setup_signals();
        rb_lib_init(NULL, NULL, NULL, 0, maxfd, 1024, 4096);
        rb_init_rawbuffers(1024);
-       ssl_ok = rb_supports_ssl();
+       ssld_ssl_ok = rb_supports_ssl();
        mod_ctl = rb_malloc(sizeof(mod_ctl_t));
        mod_ctl->F = rb_open(ctlfd, RB_FD_SOCKET, "ircd control socket");
        mod_ctl->F_pipe = rb_open(pipefd, RB_FD_PIPE, "ircd pipe");
@@ -1239,7 +1247,8 @@ main(int argc, char **argv)
        rb_event_add("check_handshake_flood", check_handshake_flood, NULL, 10);
        read_pipe_ctl(mod_ctl->F_pipe, NULL);
        mod_read_ctl(mod_ctl->F, mod_ctl);
-       if(!zlib_ok && !ssl_ok)
+       send_version(mod_ctl);
+       if(!zlib_ok && !ssld_ssl_ok)
        {
                /* this is really useless... */
                send_i_am_useless(mod_ctl);
@@ -1250,7 +1259,7 @@ main(int argc, char **argv)
 
        if(!zlib_ok)
                send_nozlib_support(mod_ctl, NULL);
-       if(!ssl_ok)
+       if(!ssld_ssl_ok)
                send_nossl_support(mod_ctl, NULL);
        rb_lib_loop(0);
        return 0;