]> jfr.im git - solanum.git/blobdiff - ircd/newconf.c
remove RB_IPV6
[solanum.git] / ircd / newconf.c
index 47a5924c0a124d2f9f0e829c61d4d6b70d3a6b4e..c2d6614062ccbfbe774e57b8f673ea4c99d50376 100644 (file)
@@ -28,6 +28,7 @@
 #include "wsproc.h"
 #include "privilege.h"
 #include "chmode.h"
+#include "certfp.h"
 
 #define CF_TYPE(x) ((x) & CF_MTYPE)
 
@@ -224,7 +225,7 @@ conf_set_serverinfo_sid(void *data)
                        return;
                }
 
-               strcpy(ServerInfo.sid, sid);
+               rb_strlcpy(ServerInfo.sid, sid, sizeof(ServerInfo.sid));
        }
 }
 
@@ -258,7 +259,6 @@ static void
 conf_set_serverinfo_vhost6(void *data)
 {
 
-#ifdef RB_IPV6
        struct rb_sockaddr_storage addr;
 
        if(rb_inet_pton_sock(data, (struct sockaddr *)&addr) <= 0 || GET_SS_FAMILY(&addr) != AF_INET6)
@@ -268,9 +268,6 @@ conf_set_serverinfo_vhost6(void *data)
        }
 
        ServerInfo.bind6 = addr;
-#else
-       conf_report_error("Warning -- ignoring serverinfo::vhost6 -- IPv6 support not available.");
-#endif
 }
 
 static void
@@ -299,7 +296,7 @@ conf_set_modules_module(void *data)
 
        m_bn = rb_basename((char *) data);
 
-       if(findmodule_byname(m_bn) == -1)
+       if(findmodule_byname(m_bn) == NULL)
                load_one_module((char *) data, MAPI_ORIGIN_EXTENSION, false);
 
        rb_free(m_bn);
@@ -364,6 +361,7 @@ static struct mode_table connect_table[] = {
        { "encrypted",  SERVER_ENCRYPTED        },
        { "topicburst", SERVER_TB               },
        { "ssl",        SERVER_SSL              },
+       { "no-export",  SERVER_NO_EXPORT        },
        { NULL,         0                       },
 };
 
@@ -776,7 +774,6 @@ conf_set_class_cidr_ipv4_bitlen(void *data)
 
 }
 
-#ifdef RB_IPV6
 static void
 conf_set_class_cidr_ipv6_bitlen(void *data)
 {
@@ -789,7 +786,6 @@ conf_set_class_cidr_ipv6_bitlen(void *data)
                yy_class->cidr_ipv6_bitlen = *(unsigned int *) data;
 
 }
-#endif
 
 static void
 conf_set_class_number_per_cidr(void *data)
@@ -841,6 +837,8 @@ conf_begin_listen(struct TopConf *tc)
 {
        rb_free(listener_address);
        listener_address = NULL;
+       yy_wsock = 0;
+       yy_defer_accept = 0;
        return 0;
 }
 
@@ -849,6 +847,8 @@ conf_end_listen(struct TopConf *tc)
 {
        rb_free(listener_address);
        listener_address = NULL;
+       yy_wsock = 0;
+       yy_defer_accept = 0;
        return 0;
 }
 
@@ -880,27 +880,23 @@ conf_set_listen_port_both(void *data, int ssl)
                 {
                        if (!ssl)
                        {
-                               conf_report_warning("listener 'ANY/%d': support for plaintext listeners may be removed in a future release per RFC 7194.  "
+                               conf_report_warning("listener 'ANY/%d': support for plaintext listeners may be removed in a future release per RFCs 7194 & 7258.  "
                                                     "It is suggested that users be migrated to SSL/TLS connections.", args->v.number);
                        }
                        add_listener(args->v.number, listener_address, AF_INET, ssl, ssl || yy_defer_accept, yy_wsock);
-#ifdef RB_IPV6
                        add_listener(args->v.number, listener_address, AF_INET6, ssl, ssl || yy_defer_accept, yy_wsock);
-#endif
                 }
                else
                 {
                        int family;
-#ifdef RB_IPV6
                        if(strchr(listener_address, ':') != NULL)
                                family = AF_INET6;
                        else
-#endif
                                family = AF_INET;
 
                        if (!ssl)
                        {
-                               conf_report_warning("listener '%s/%d': support for plaintext listeners may be removed in a future release per RFC 7194.  "
+                               conf_report_warning("listener '%s/%d': support for plaintext listeners may be removed in a future release per RFCs 7194 & 7258.  "
                                                     "It is suggested that users be migrated to SSL/TLS connections.", listener_address, args->v.number);
                        }
 
@@ -1305,11 +1301,16 @@ conf_end_connect(struct TopConf *tc)
                return 0;
        }
 
+       if((yy_server->flags & SERVER_SSL) && EmptyString(yy_server->certfp))
+       {
+               conf_report_error("Ignoring connect block for %s -- no fingerprint provided for SSL connection.",
+                                       yy_server->name);
+               return 0;
+       }
+
        if(EmptyString(yy_server->connect_host)
                        && GET_SS_FAMILY(&yy_server->connect4) != AF_INET
-#ifdef RB_IPV6
                        && GET_SS_FAMILY(&yy_server->connect6) != AF_INET6
-#endif
                )
        {
                conf_report_error("Ignoring connect block for %s -- missing host.",
@@ -1346,12 +1347,10 @@ conf_set_connect_host(void *data)
        {
                yy_server->connect4 = addr;
        }
-#ifdef RB_IPV6
        else if(GET_SS_FAMILY(&addr) == AF_INET6)
        {
                yy_server->connect6 = addr;
        }
-#endif
        else
        {
                conf_report_error("Unsupported IP address for server connect host (%s)",
@@ -1374,12 +1373,10 @@ conf_set_connect_vhost(void *data)
        {
                yy_server->bind4 = addr;
        }
-#ifdef RB_IPV6
        else if(GET_SS_FAMILY(&addr) == AF_INET6)
        {
                yy_server->bind6 = addr;
        }
-#endif
        else
        {
                conf_report_error("Unsupported IP address for server connect vhost (%s)",
@@ -1440,10 +1437,8 @@ conf_set_connect_aftype(void *data)
 
        if(rb_strcasecmp(aft, "ipv4") == 0)
                yy_server->aftype = AF_INET;
-#ifdef RB_IPV6
        else if(rb_strcasecmp(aft, "ipv6") == 0)
                yy_server->aftype = AF_INET6;
-#endif
        else
                conf_report_error("connect::aftype '%s' is unknown.", aft);
 }
@@ -1710,15 +1705,15 @@ conf_set_general_certfp_method(void *data)
 {
        char *method = data;
 
-       if (!rb_strcasecmp(method, "sha1"))
+       if (!rb_strcasecmp(method, CERTFP_NAME_CERT_SHA1))
                ConfigFileEntry.certfp_method = RB_SSL_CERTFP_METH_CERT_SHA1;
-       else if (!rb_strcasecmp(method, "sha256"))
+       else if (!rb_strcasecmp(method, CERTFP_NAME_CERT_SHA256))
                ConfigFileEntry.certfp_method = RB_SSL_CERTFP_METH_CERT_SHA256;
-       else if (!rb_strcasecmp(method, "sha512"))
+       else if (!rb_strcasecmp(method, CERTFP_NAME_CERT_SHA512))
                ConfigFileEntry.certfp_method = RB_SSL_CERTFP_METH_CERT_SHA512;
-       else if (!rb_strcasecmp(method, "spki_sha256"))
+       else if (!rb_strcasecmp(method, CERTFP_NAME_SPKI_SHA256))
                ConfigFileEntry.certfp_method = RB_SSL_CERTFP_METH_SPKI_SHA256;
-       else if (!rb_strcasecmp(method, "spki_sha512"))
+       else if (!rb_strcasecmp(method, CERTFP_NAME_SPKI_SHA512))
                ConfigFileEntry.certfp_method = RB_SSL_CERTFP_METH_SPKI_SHA512;
        else
        {
@@ -2194,7 +2189,6 @@ conf_set_opm_listen_address_both(void *data, bool ipv6)
 
        if(ipv6)
        {
-#ifdef RB_IPV6
                if(GET_SS_FAMILY(&addr) != AF_INET6)
                {
                        conf_report_error("%s is of the wrong address type: %s", confstr, ip);
@@ -2208,10 +2202,6 @@ conf_set_opm_listen_address_both(void *data, bool ipv6)
                }
 
                yy_opm_address_ipv6 = rb_strdup(ip);
-#else
-               conf_report_error("%s requires IPv6 support in your ircd", confstr, ip);
-               return;
-#endif
        }
        else
        {
@@ -2249,14 +2239,6 @@ conf_set_opm_listen_port_both(void *data, bool ipv6)
        int port = *((int *)data);
        const char *confstr = (ipv6 ? "opm::port_ipv6" : "opm::port_ipv4");
 
-#ifndef RB_IPV6
-       if(ipv6)
-       {
-               conf_report_error("%s requires IPv6 support in your ircd", confstr);
-               return;
-       }
-#endif
-
        if(port > 65535 || port <= 0)
        {
                conf_report_error("%s is out of range: %d", confstr, port);
@@ -2683,9 +2665,7 @@ static struct ConfEntry conf_class_table[] =
 {
        { "ping_time",          CF_TIME, conf_set_class_ping_time,              0, NULL },
        { "cidr_ipv4_bitlen",   CF_INT,  conf_set_class_cidr_ipv4_bitlen,               0, NULL },
-#ifdef RB_IPV6
        { "cidr_ipv6_bitlen",   CF_INT,  conf_set_class_cidr_ipv6_bitlen,               0, NULL },
-#endif
        { "number_per_cidr",    CF_INT,  conf_set_class_number_per_cidr,        0, NULL },
        { "number_per_ip",      CF_INT,  conf_set_class_number_per_ip,          0, NULL },
        { "number_per_ip_global", CF_INT,conf_set_class_number_per_ip_global,   0, NULL },