]> jfr.im git - solanum.git/blobdiff - src/s_conf.c
Remove s_assert definition from ircd_defs.h and add it to its own header.
[solanum.git] / src / s_conf.c
index 11d2d0a10cb0995c8af8b227a0fe80be871794eb..57c32fc44a0855935b25c7b0d6c371fd908f6cea 100644 (file)
@@ -51,6 +51,9 @@
 #include "sslproc.h"
 #include "bandbi.h"
 #include "operhash.h"
+#include "chmode.h"
+#include "hook.h"
+#include "s_assert.h"
 
 struct config_server_hide ConfigServerHide;
 
@@ -483,14 +486,13 @@ attach_iline(struct Client *client_p, struct ConfItem *aconf)
        int local_count = 0;
        int global_count = 0;
        int ident_count = 0;
-       int unidented = 0;
+       int unidented;
 
        if(IsConfExemptLimits(aconf))
                return (attach_conf(client_p, aconf));
 
-       if(*client_p->username == '~')
-               unidented = 1;
-
+       unidented = !IsGotId(client_p) && !IsNoTilde(aconf) &&
+               (!IsConfDoSpoofIp(aconf) || !strchr(aconf->info.name, '@'));
 
        /* find_hostname() returns the head of the list to search */
        RB_DLINK_FOREACH(ptr, find_hostname(client_p->host))
@@ -742,9 +744,12 @@ set_default_conf(void)
        ConfigFileEntry.use_whois_actually = YES;
        ConfigFileEntry.burst_away = NO;
        ConfigFileEntry.collision_fnc = YES;
+       ConfigFileEntry.resv_fnc = YES;
        ConfigFileEntry.global_snotices = YES;
        ConfigFileEntry.operspy_dont_care_user_info = NO;
        ConfigFileEntry.use_propagated_bans = YES;
+       ConfigFileEntry.max_ratelimit_tokens = 30;
+       ConfigFileEntry.away_interval = 30;
 
 #ifdef HAVE_LIBZ
        ConfigFileEntry.compression_level = 4;
@@ -757,8 +762,8 @@ set_default_conf(void)
 
        ConfigChannel.use_except = YES;
        ConfigChannel.use_invex = YES;
-       ConfigChannel.use_knock = YES;
        ConfigChannel.use_forward = YES;
+       ConfigChannel.use_knock = YES;
        ConfigChannel.knock_delay = 300;
        ConfigChannel.knock_delay_channel = 60;
        ConfigChannel.max_chans_per_user = 15;
@@ -773,6 +778,8 @@ set_default_conf(void)
        ConfigChannel.no_join_on_split = NO;
        ConfigChannel.no_create_on_split = YES;
        ConfigChannel.resv_forcepart = YES;
+       ConfigChannel.channel_target_change = YES;
+       ConfigChannel.disable_local_channels = NO;
 
        ConfigServerHide.flatten_links = 0;
        ConfigServerHide.links_delay = 300;
@@ -782,7 +789,7 @@ set_default_conf(void)
        ConfigFileEntry.min_nonwildcard = 4;
        ConfigFileEntry.min_nonwildcard_simple = 3;
        ConfigFileEntry.default_floodcount = 8;
-       ConfigFileEntry.client_flood = CLIENT_FLOOD_DEFAULT;
+       ConfigFileEntry.default_ident_timeout = 5;
        ConfigFileEntry.tkline_expire_notices = 0;
 
         ConfigFileEntry.reject_after_count = 5;
@@ -791,8 +798,16 @@ set_default_conf(void)
        ConfigFileEntry.throttle_count = 4;
        ConfigFileEntry.throttle_duration = 60;
 
+       ConfigFileEntry.client_flood_max_lines = CLIENT_FLOOD_DEFAULT;
+       ConfigFileEntry.client_flood_burst_rate = 5;
+       ConfigFileEntry.client_flood_burst_max = 5;
+       ConfigFileEntry.client_flood_message_time = 1;
+       ConfigFileEntry.client_flood_message_num = 2;
+
        ServerInfo.default_max_clients = MAXCONNECTIONS;
 
+       ConfigFileEntry.nicklen = NICKLEN;
+
        if (!alias_dict)
                alias_dict = irc_dictionary_create(strcasecmp);
 }
@@ -819,6 +834,7 @@ read_conf(FILE * file)
        /* Some global values are also loaded here. */
        check_class();          /* Make sure classes are valid */
        privilegeset_delete_all_illegal();
+       construct_cflags_strings();
 }
 
 static void
@@ -856,9 +872,21 @@ validate_conf(void)
                                
        }
 
-       if((ConfigFileEntry.client_flood < CLIENT_FLOOD_MIN) ||
-          (ConfigFileEntry.client_flood > CLIENT_FLOOD_MAX))
-               ConfigFileEntry.client_flood = CLIENT_FLOOD_MAX;
+       /* RFC 1459 says 1 message per 2 seconds on average and bursts of
+        * 5 messages are acceptable, so allow at least that.
+        */
+       if(ConfigFileEntry.client_flood_burst_rate < 5)
+               ConfigFileEntry.client_flood_burst_rate = 5;
+       if(ConfigFileEntry.client_flood_burst_max < 5)
+               ConfigFileEntry.client_flood_burst_max = 5;
+       if(ConfigFileEntry.client_flood_message_time >
+                       ConfigFileEntry.client_flood_message_num * 2)
+               ConfigFileEntry.client_flood_message_time =
+                       ConfigFileEntry.client_flood_message_num * 2;
+
+       if((ConfigFileEntry.client_flood_max_lines < CLIENT_FLOOD_MIN) ||
+          (ConfigFileEntry.client_flood_max_lines > CLIENT_FLOOD_MAX))
+               ConfigFileEntry.client_flood_max_lines = CLIENT_FLOOD_MAX;
 
        if(!split_users || !split_servers ||
           (!ConfigChannel.no_create_on_split && !ConfigChannel.no_join_on_split))
@@ -1064,6 +1092,36 @@ deactivate_conf(struct ConfItem *aconf, rb_dlink_node *ptr)
        }
 }
 
+/* Given a new ban ConfItem, look for any matching ban, update the lifetime
+ * from it and delete it.
+ */
+void
+replace_old_ban(struct ConfItem *aconf)
+{
+       rb_dlink_node *ptr;
+       struct ConfItem *oldconf;
+
+       ptr = find_prop_ban(aconf->status, aconf->user, aconf->host);
+       if(ptr != NULL)
+       {
+               oldconf = ptr->data;
+               /* Remember at least as long as the old one. */
+               if(oldconf->lifetime > aconf->lifetime)
+                       aconf->lifetime = oldconf->lifetime;
+               /* Force creation time to increase. */
+               if(oldconf->created >= aconf->created)
+                       aconf->created = oldconf->created + 1;
+               /* Leave at least one second of validity. */
+               if(aconf->hold <= aconf->created)
+                       aconf->hold = aconf->created + 1;
+               if(aconf->lifetime < aconf->hold)
+                       aconf->lifetime = aconf->hold;
+               /* Tell deactivate_conf() to destroy it. */
+               oldconf->lifetime = rb_current_time();
+               deactivate_conf(oldconf, ptr);
+       }
+}
+
 static void
 expire_prop_bans(void *list)
 {
@@ -1231,7 +1289,7 @@ get_user_ban_reason(struct ConfItem *aconf)
                rb_snprintf(reasonbuf, sizeof reasonbuf,
                                "Temporary %c-line %d min. - ",
                                aconf->status == CONF_DLINE ? 'D' : 'K',
-                               (aconf->hold - aconf->created) / 60);
+                               (int)((aconf->hold - aconf->created) / 60));
        else
                reasonbuf[0] = '\0';
        if (aconf->passwd)
@@ -1293,6 +1351,8 @@ read_conf_files(int cold)
           dont know anything else
 
           - Gozem 2002-07-21 
+
+
         */
        rb_strlcpy(conffilebuf, filename, sizeof(conffilebuf));
 
@@ -1300,7 +1360,15 @@ read_conf_files(int cold)
        {
                if(cold)
                {
+                       inotice("Failed in reading configuration file %s, aborting", filename);
                        ilog(L_MAIN, "Failed in reading configuration file %s", filename);
+
+                       int e;
+                       e = errno;
+
+                       inotice("FATAL: %s %s", strerror(e), filename);
+                       ilog(L_MAIN, "FATAL: %s %s", strerror(e), filename);
+
                        exit(-1);
                }
                else
@@ -1316,7 +1384,10 @@ read_conf_files(int cold)
                clear_out_old_conf();
        }
 
+       call_hook(h_conf_read_start, NULL);
        read_conf(conf_fbfile_in);
+       call_hook(h_conf_read_end, NULL);
+
        fclose(conf_fbfile_in);
 }
 
@@ -1531,9 +1602,7 @@ yyerror(const char *msg)
 int
 conf_fgets(char *lbuf, int max_size, FILE * fb)
 {
-       char *buff;
-
-       if((buff = fgets(lbuf, max_size, fb)) == NULL)
+       if(fgets(lbuf, max_size, fb) == NULL)
                return (0);
 
        return (strlen(lbuf));