From: Remco Rijnders Date: Sat, 7 Mar 2026 17:17:36 +0000 (-0500) Subject: Migrate compile-time settings to runtime configuration via ircd.conf X-Git-Url: http://git.serene-ircd.net/?a=commitdiff_plain;h=c2b4712051134e82d76a1c50d6ed5a27082b6188;p=serene-ircd.git Migrate compile-time settings to runtime configuration via ircd.conf Move network identity, service names, masking hostnames, tuning limits, and feature toggles from #defines in config.h to runtime globals in settings.h/settings.c, parsed from network{}, limits{}, and general{} blocks in ircd.conf. A single binary can now serve different networks without recompilation. Co-Authored-By: Claude Opus 4.6 --- diff --git a/doc/example.conf b/doc/example.conf index 358e0cc..ed8da5f 100644 --- a/doc/example.conf +++ b/doc/example.conf @@ -226,18 +226,107 @@ uworld { }; # -# general {} - OPTIONAL (replaces G-lines) -# General runtime configuration options. +# general {} - OPTIONAL +# General runtime configuration options and feature toggles. +# +# hub - Enable hub mode (accepts multiple server links). +# throttle - Enable clone/throttle detection (yes/no). +# seeuserstats - Show user stat notifications to opers (yes/no). +# crypt_oper_password - Oper passwords are encrypted (yes/no). +# crypt_iline_password - I-line passwords are encrypted (yes/no). +# +general { + # hub yes; + throttle yes; + seeuserstats yes; + crypt_oper_password yes; + crypt_iline_password yes; +}; + # -# hub - Enable hub mode. A hub accepts multiple server connections -# and routes traffic between them. Without this, the server -# runs as a leaf with a single server link. -# Re-evaluated on /rehash. +# network {} - SUGGESTED +# Network identity and service configuration. These settings were formerly +# compile-time defines in config.h. +# +# network - Network name shown in welcome messages. +# adminchan - Default admin/help channel. +# randomserv - Server to suggest when this one is full. +# website - Network website URL. +# aup - Acceptable use policy URL. +# kline_address - Email shown in ban messages. +# contact_url - Optional contact URL shown to new users (empty = disabled). +# services_name - Hostname of the services server. +# chanserv - ChanServ service nickname. +# nickserv - NickServ service nickname. +# memoserv - MemoServ service nickname. +# operserv - OperServ service nickname. +# webserv - WebServ service nickname. +# ircop_host - Masked hostname for IRC operators. +# admin_host - Masked hostname for server admins. +# locop_host - Masked hostname for local operators. +# sadmin_host - Masked hostname for services admins. +# sroot_host - Masked hostname for services root admins. +# netadmin_host - Masked hostname for network admins. +# mask_prefix - Prefix for masked user hostnames. +# x_prefix - Prefix for userspace-X masked hostnames. +# +network { + network Serenity-IRC.Net; + adminchan #help; + randomserv irc.serenity-irc.net; + website "http://www.serenity-irc.net"; + aup "http://www.serenity-irc.net/aup/"; + kline_address kline@serenity-irc.net; + # contact_url "http://www.serenity-irc.net/contact"; + services_name Services.Serenity-IRC.Net; + chanserv ChanServ; + nickserv NickServ; + memoserv MemoServ; + operserv OperServ; + webserv WebServ; + ircop_host IRCop.Serenity-IRC.Net; + admin_host Admin.Serenity-IRC.Net; + locop_host Local.Serenity-IRC.Net; + sadmin_host ServOp.Serenity-IRC.Net; + sroot_host SRA.Serenity-IRC.Net; + netadmin_host NetAdmin.Serenity-IRC.Net; + mask_prefix Serene; + x_prefix Serene; +}; + # -# Uncomment the following to enable hub mode: -#general { -# hub yes; -#}; +# limits {} - OPTIONAL +# Tuning constants. These settings were formerly compile-time defines. +# +# maxchannels - Maximum channels a user can join. +# nickdelay - Minimum seconds between nick changes. +# targetdelay - Seconds before new message targets are granted. +# clientflood - Max bytes in client receive queue before flood kill. +# maxsendq - Default max send queue size (bytes). +# bufferpool - Total memory for all send queues (bytes). +# listenqueue - TCP listen backlog size. +# htctime - Half-target-change window (seconds). +# htctrigger - Half-target-change threshold. +# clonelimit - Max connections from same host in cloneperiod. +# cloneperiod - Clone detection window (seconds). +# clonedelay - Throttle delay for clone offenders (seconds). +# zlinetime - Default Z-line duration (minutes). +# +limits { + maxchannels 10; + nickdelay 30; + targetdelay 120; + clientflood 6000; + maxsendq 3000000; + bufferpool 27000000; + listenqueue 5; + htctime 5; + htctrigger 15; + clonelimit 3; + cloneperiod 15; + clonedelay 300; + zlinetime 1; +}; # # quarantine {} - OPTIONAL (replaces Q-lines for nicks) diff --git a/include/config.h b/include/config.h index 2f838e4..aefd6e4 100644 --- a/include/config.h +++ b/include/config.h @@ -23,35 +23,28 @@ #include "setup.h" /* - * * NOTICE * - * Under normal conditions, you should not have to edit this file. Run - * the Config script in the root directory instead! + * Most settings have been moved to runtime configuration in ircd.conf. + * See the network{}, limits{}, and general{} blocks. * + * This file now only contains compile-time constants that cannot be + * changed at runtime (buffer sizes, array dimensions, etc). */ /* * Compression level. 1 is fastest and 9 is slowest. - * Do not use a setting above 5 or the ircd will use a lot more - * cpu. + * Do not use a setting above 5 or the ircd will use a lot more cpu. */ #ifdef ZIP_LINKS #define ZIP_LEVEL 2 #endif /* - What network are we linked to? Define netwide policy here. -*/ - -#define irc_network "Serenity-IRC" -#define admin_chan "#help" -#define random_serv "irc.serenity-irc.net" -#define network_www "http://www.serenity-irc.net" -#define network_aup "http://www.serenity-irc.net/aup/" -#define netwide_kline "kline@serenity-irc.net" - - + * Client and oper hostname masking. + * These enables are compile-time because they affect code structure. + * The actual mask hostnames are runtime settings in ircd.conf network{}. + */ #define CLIENT_MASKING #define MASK_ON_CONNECT #define OPER_MASKS @@ -59,95 +52,21 @@ /* undef this to fix *\*!*@* ban bug */ #undef ESCAPED_MATCHING -#ifdef CLIENT_MASKING -#define userspace_mask_prefix "Serene" -#endif - #define USERSPACE_X -#define userspace_x_prefix "Serene" -/* This will be the maximum length of a quit-message */ - -#define QUITLEN 180 - -/* High Traffic Command protection code settings (-GZ) - * - * HTCTIME Minimum time between sending commands. - * HTCTRIGGER Triggers and sends locops when reached. - */ - -#define HTCTIME 5 -#define HTCTRIGGER 15 - -/* Oper Masks for the hide code */ -#if defined(CLIENT_MASKING) && defined(OPER_MASKS) -#define ircop_host "IRCop.Serenity-IRC.Net" -#define admin_host "Admin.Serenity-IRC.Net" -#define locop_host "Local.Serenity-IRC.Net" -#define sadmin_host "ServOp.Serenity-IRC.Net" -#define sroot_host "SRA.Serenity-IRC.Net" -#define netadmin_host "NetAdmin.Serenity-IRC.Net" -#endif - -/* Additional flags to give FreeBSD's malloc, only play with this if you - * know what you're doing. - */ - +/* Additional flags to give FreeBSD's malloc */ #define MALLOC_FLAGS_EXTRA "" -#define NOSPOOF - - -/* KLINE_ADDRESS - * - * This is the email address displayed to the user when they are K:lined - * so that they can email someone in the server's administration about it. - * It is usually set up by the Config script. - * - * It should be a valid email address for the users to contact. - * - * For StarChat servers, note that this message is displayed when the user - * is affected by a local K:line or k:line. For Services-based autokills, - * the message is set up automatically by Services to ask to email - * kline@starchat.net. It is recommended that you set this up to give a valid - * email address for the server's admin, not kline@starchat.net. - */ -#ifndef KLINE_ADDRESS -#define KLINE_ADDRESS "clueless-admin@poorly.configured.server" -#endif - -/* - * SEEUSERSTATS - Sends a notice to opers set +t that the client is doing - * /stats, /admin or /links, #undef'ing this disables it. -ns - */ -#define SEEUSERSTATS - -/* - * Max size arguments to stats/admin/links can be before truncation. - * Only applies to notices sent to opers (see above). -Ben - */ -#define USERSTATMAX 120 - -/* - * Define this if you wish to output a *file* to a K lined client rather - * than the K line comment (the comment field is treated as a filename) - */ -#undef COMMENT_IS_FILE - - /* #undef DEBUGMODE */ /* define DEBUGMODE to enable debugging mode */ /* * Defining FORCE_CORE will automatically "unlimit core", forcing the - * server to dump a core file whenever it has a fatal error. -mlv - * Make sure to check that your shell allows core files. + * server to dump a core file whenever it has a fatal error. */ #define FORCE_CORE /* - * Full pathnames and defaults of irc system's support files. Please note that - * these are only the recommened names and paths. Change as needed. - * You must define these to something, even if you don't really want them. + * Full pathnames and defaults of irc system's support files. */ #ifndef DPATH #define DPATH "/usr/local/lib/ircd" *//* dir where all ircd stuff is */ @@ -164,10 +83,7 @@ /* * Define this filename to maintain a list of persons who log - * into this server. Logging will stop when the file does not exist. - * Logging will be disable also if you do not define this. - * FNAME_USERLOG just logs user connections, FNAME_OPERLOG logs every - * successful use of /oper. These are either full paths or files within DPATH. + * into this server. */ /* Define this only if you are actually logging -Studded #define FNAME_USERLOG "users.log" @@ -177,373 +93,103 @@ /* CHROOTDIR * * Define for value added security if you are a rooter. - * - * All files you access must be in the directory you define as DPATH. - * (This may effect the PATH locations above, though you can symlink it) - * - * You may want to define IRC_UID and IRC_GID */ /* #define CHROOTDIR */ -/* SHOW_INVISIBLE_LUSERS - * - * As defined this will show the correct invisible count for anyone who does - * LUSERS on your server. On a large net this doesnt mean much, but on a - * small net it might be an advantage to undefine it. - * (This will get defined for you if you're using userload (stats w). -mlv) - */ #define SHOW_INVISIBLE_LUSERS - -/* NO_DEFAULT_INVISIBLE and NO_DEFAULT_HOSTHIDDEN - * - * When defined, your users will not automatically be attributed with user - * mode "i" (i == invisible). Invisibility means people dont showup in - * WHO or NAMES unless they are on the same channel as you. - * Added the ability to hide a users hostname also as with mode z. - * By default this mode needs to be off. - */ - #define NO_DEFAULT_INVISIBLE -/* NO_DEFAULT_HIDE - * - * When defined, your users will not automatically be attributed with user - * mode "x" (x == hidden host). Hide means people dont show their full - * IP when somone wants to see their IP or DNS. buhbye nukes. - */ #ifdef USERSPACE_X #undef NO_DEFAULT_HIDE #endif /* If you want your server to save and restore the local/max client count */ - #define SAVE_MAXCLIENT_STATS - -/* What listen() backlog value do you wish to use? Some servers - * have problems with more than 5, others work fine with many, many - * more. - */ - -#define LISTEN_SIZE 5 - -/* Define your maximum sendq here */ - -#define MAXSENDQLENGTH 3000000 - -/* Define the size of a bufferpool (total of ALL sendq's in use) */ - -#define BUFFERPOOL (9 * MAXSENDQLENGTH) - -/* Define the size of your nickname history for /whowas */ - -#define NICKNAMEHISTORYLENGTH 500 - -/* OPER_* defines - * - * See ./docs/example.conf for examples of how to restrict access for - * your IRC Operators - */ - -/* MAXIMUM LINKS - * - * This define is useful for leaf nodes and gateways. It keeps you from - * connecting to too many places. It works by keeping you from - * connecting to more than "n" nodes which you have C:blah::blah:6667 - * lines for. - * - * Note that any number of nodes can still connect to you. This only - * limits the number that you actively reach out to connect to. - * - * Leaf nodes are nodes which are on the edge of the tree. If you want - * to have a backup link, then sometimes you end up connected to both - * your primary and backup, routing traffic between them. To prevent - * this, #define MAXIMUM_LINKS 1 and set up both primary and - * secondary with C:blah::blah:6667 lines. THEY SHOULD NOT TRY TO - * CONNECT TO YOU, YOU SHOULD CONNECT TO THEM. - * - * Gateways such as the server which connects Australia to the US can - * do a similar thing. Put the American nodes you want to connect to - * in with C:blah::blah:6667 lines, and the Australian nodes with - * C:blah::blah lines. Have the Americans put you in with C:blah::blah - * lines. Then you will only connect to one of the Americans. - * - * This value is only used if you don't have server classes defined, and - * a server is in class 0 (the default class if none is set). - * - */ -#define MAXIMUM_LINKS 1 - -/* - * Hub mode is now a runtime setting via ircd.conf: - * G:hub - * Default is leaf mode (non-hub) if not set. - */ +/* Define this if you wish to output a *file* to a K lined client rather + * than the K line comment (the comment field is treated as a filename) */ +#undef COMMENT_IS_FILE /* * NOTE: defining CMDLINE_CONFIG and installing ircd SUID or SGID is a MAJOR - * security problem - they can use the "-f" option to read any files - * that the 'new' access lets them. Note also that defining this is - * a major security hole if your ircd goes down and some other user - * starts up the server with a new conf file that has some extra - * O-lines. So don't use this unless you're debugging. + * security problem. */ -#undef CMDLINE_CONFIG /* allow conf-file to be specified on command line */ +#undef CMDLINE_CONFIG -/* - * If you wish to have the server send 'vital' messages about server - * through syslog, define USE_SYSLOG. Only system errors and events critical - * to the server are logged although if this is defined with FNAME_USERLOG, - * syslog() is used instead of the above file. It is not recommended that - * this option is used unless you tell the system administrator beforehand - * and obtain their permission to send messages to the system log files. - */ #undef USE_SYSLOG #ifdef USE_SYSLOG -/* - * If you use syslog above, you may want to turn some (none) of the - * spurious log messages for KILL/SQUIT off. - */ -#undef SYSLOG_KILL /* log all operator kills to syslog */ -#undef SYSLOG_SQUIT /* log all remote squits for all servers to syslog */ -#undef SYSLOG_CONNECT /* log remote connect messages for other all servs */ -#undef SYSLOG_USERS /* send userlog stuff to syslog */ -#undef SYSLOG_OPER /* log all users who successfully become an Op */ - -/* - * If you want to log to a different facility than DAEMON, change - * this define. - */ +#undef SYSLOG_KILL +#undef SYSLOG_SQUIT +#undef SYSLOG_CONNECT +#undef SYSLOG_USERS +#undef SYSLOG_OPER #define LOG_FACILITY LOG_DAEMON #endif /* USE_SYSLOG */ -/* - * IDLE_FROM_MSG - * - * Idle-time nullified only from privmsg, if undefined idle-time - * is nullified from everything except ping/pong. - * Added 3.8.1992, kny@cs.hut.fi (nam) - */ #define IDLE_FROM_MSG -/* - * Size of the LISTEN request. Some machines handle this large - * without problem, but not all. It defaults to 5, but can be - * raised if you know your machine handles it. - */ -#ifndef LISTEN_SIZE -#define LISTEN_SIZE 5 -#endif - -/* - * Max amount of internal send buffering when socket is stuck (bytes) - */ -#ifndef MAXSENDQLENGTH -#define MAXSENDQLENGTH 3000000 -#endif -/* - * BUFFERPOOL is the maximum size of the total of all sendq's. - * Recommended value is 2 * MAXSENDQLENGTH, for hubs, 5 *. - */ -#ifndef BUFFERPOOL -#define BUFFERPOOL (9 * MAXSENDQLENGTH) -#endif - /* * IRC_UID * * If you start the server as root but wish to have it run as another user, - * define IRC_UID to that UID. This should only be defined if you are running - * as root and even then perhaps not. + * define IRC_UID to that UID. */ /* #undef IRC_UID */ /* #undef IRC_GID */ -/* - * CLIENT_FLOOD - * - * this controls the number of bytes the server will allow a client to - * send to the server without processing before disconnecting the client for - * flooding it. Values greater than 8000 make no difference to the server. - */ -#define CLIENT_FLOOD 6000 - -/* - * How many seconds in between simultaneous nick changes? - */ -#define NICK_CHANGE_DELAY 30 - -/* - * How many open targets can one nick have for messaging nicks and - * inviting them? - */ - -#define MAXTARGETS 20 -#define TARGET_DELAY 120 - -/* Define default Z:line time for SOCKS -taz */ -#define ZLINE_TIME 300 +/* Prevent mixed case userids that clonebots use */ +/* #undef DISALLOW_MIXED_CASE */ -/* - * StarChat Mandatory section - * - * It is VERY important that you DO NOT change any of the settings - * in this section for a server that is or will be running on StarChat. - * If you feel the need to make a change to one of these settings - * please write to coding@starchat.net FIRST to discuss your reasons. - */ - -/* Client connection throttling - * - * This is based on the ircu version, modified by nikb. - * StarChat servers MUST use throttling. The values can - * be changed, but shouldn't be without good reason. - * - * CHECK_CLONE_LIMIT is the number of clients from the - * same IP that will be allowed. The CHECK_CLONE_LIMIT + 1'th - * client in CHECK_CLONE_PERIOD seconds will be throttled, - * and a temp z-line put in place for CHECK_CLONE_DELAY seconds. - */ -#define THROTTLE -#define CHECK_CLONE_LIMIT 3 -#define CHECK_CLONE_PERIOD 15 -#define CHECK_CLONE_DELAY 300 - -/* - * Define this to prevent mixed case userids that clonebots use. However - * this affects the servers running telclients WLD* FIN* etc. - */ -/* -#undef DISALLOW_MIXED_CASE -*/ - -/* - * Define this if you wish to ignore the case of the first character of - * the user id when disallowing mixed case. This allows PC users to - * enter the more intuitive first name with the first letter capitalised - */ #define IGNORE_CASE_FIRST_CHAR -/* FAILOPER_WARN - * - * When defined, warns users on a failed oper attempt that it was/is logged - * Only works when FNAME_OPERLOG is defined, and a logfile exists. - * NOTE: Failed oper attempts are logged regardless. - */ +/* FAILOPER_WARN - warns users on a failed oper attempt that it was logged */ #define FAILOPER_WARN -/* - * Define your network service names here. - */ -#define ChanServ "ChanServ" -#define MemoServ "MemoServ" -#define NickServ "NickServ" -#define OperServ "OperServ" -#define WebServ "WebServ" - -/* - * End of StarChat Mandatory section - */ - -/* STOP STOP STOP STOP STOP STOP STOP STOP STOP STOP STOP STOP STOP STOP */ - +/* STOP STOP STOP STOP STOP STOP STOP STOP STOP STOP STOP STOP */ /* You shouldn't change anything below this line, unless absolutely needed. */ -/* - * Port where ircd resides. NOTE: This *MUST* be greater than 1024 if you - * plan to run ircd under any other uid than root. - */ -#define PORTNUM 7000 /* 7000 for StarChat */ +#define PORTNUM 7000 /* - * Maximum number of network connections your server will allow. This should - * never exceed max. number of open file descrpitors and wont increase this. - * Should remain LOW as possible. Most sites will usually have under 30 or so - * connections. A busy hub or server may need this to be as high as 50 or 60. - * Making it over 100 decreases any performance boost gained from it being low. - * if you have a lot of server connections, it may be worth splitting the load - * over 2 or more servers. - * 1 server = 1 connection, 1 user = 1 connection. - * This should be at *least* 3: 1 listen port, 1 dns port + 1 client - * - * Note: this figure will be too high for most systems. If you get an - * fd-related error on compile, change this to 256. + * Maximum number of network connections your server will allow. + * This is a compile-time limit on file descriptor table sizes. */ #ifndef MAXCONNECTIONS #define MAXCONNECTIONS 1024 #endif /* - * this defines the length of the nickname history. each time a user changes - * nickname or signs off, their old nickname is added to the top of the list. - * The following sizes are recommended: - * 8MB or less core memory : 500 (at least 1/4 of max users) - * 8MB-16MB core memory : 500-750 (1/4 -> 1/2 of max users) - * 16MB-32MB core memory : 750-1000 (1/2 -> 3/4 of max users) - * 32MB or more core memory : 1000+ (> 3/4 if max users) - * where max users is the expected maximum number of users. - * (100 nicks/users ~ 25k) - * NOTE: this is directly related to the amount of memory ircd will use whilst - * resident and running - it hardly ever gets swapped to disk! You can - * ignore these recommendations- they only are meant to serve as a guide - * NOTE: But the *Minimum* ammount should be 100, in order to make nick - * chasing possible for mode and kick. - */ -#ifndef NICKNAMEHISTORYLENGTH -#define NICKNAMEHISTORYLENGTH 2000 -#endif - -/* - * Time interval to wait and if no messages have been received, then check for - * PINGFREQUENCY and CONNECTFREQUENCY + * Compile-time buffer/array size limits. + * These cannot be runtime because they define static array dimensions. + * The runtime effective values are in ircd.conf limits{}. */ -#define TIMESEC 60 /* Recommended value: 60 */ -/* - * If daemon doesn't receive anything from any of its links within - * PINGFREQUENCY seconds, then the server will attempt to check for - * an active link with a PING message. If no reply is received within - * (PINGFREQUENCY * 2) seconds, then the connection will be closed. - */ -#define PINGFREQUENCY 120 /* Recommended value: 120 */ +/* Max quit message length (static buffer) */ +#define QUITLEN 180 -/* - * If the connection to to uphost is down, then attempt to reconnect every - * CONNECTFREQUENCY seconds. - */ -#define CONNECTFREQUENCY 600 /* Recommended value: 600 */ +/* Max open targets per client (array size in client struct) */ +#define MAXTARGETS 20 -/* - * Often net breaks for a short time and it's useful to try to - * establishing the same connection again faster than CONNECTFREQUENCY - * would allow. But, to keep trying on bad connection, we require - * that connection has been open for certain minimum time - * (HANGONGOODLINK) and we give the net few seconds to steady - * (HANGONRETRYDELAY). This latter has to be long enough that the - * other end of the connection has time to notice it broke too. - */ -#define HANGONRETRYDELAY 240 /* Recommended value: 4 minutes */ -#define HANGONGOODLINK 3600 /* Recommended value: 1 hour */ +/* Nickname history length (static array in whowas.c) */ +#ifndef NICKNAMEHISTORYLENGTH +#define NICKNAMEHISTORYLENGTH 2000 +#endif -/* - * Number of seconds to wait for a connect(2) call to complete. - * NOTE: this must be at *LEAST* 10. When a client connects, it has - * CONNECTTIMEOUT - 10 seconds for its host to respond to an ident lookup - * query and for a DNS answer to be retrieved. - */ -#define CONNECTTIMEOUT 60 /* Recommended value: 60 */ +#define TIMESEC 60 +#define PINGFREQUENCY 120 +#define CONNECTFREQUENCY 600 +#define HANGONRETRYDELAY 240 +#define HANGONGOODLINK 3600 +#define CONNECTTIMEOUT 60 +#define KILLCHASETIMELIMIT 90 -/* - * Max time from the nickname change that still causes KILL - * automaticly to switch for the current nick of that user. (seconds) - */ -#define KILLCHASETIMELIMIT 90 /* Recommended value: 90 */ +#define MAXIMUM_LINKS 1 /* - * Max number of channels a user is allowed to join. + * Hub mode is now a runtime setting via ircd.conf: + * general { hub yes; }; + * Default is leaf mode (non-hub) if not set. */ -#define MAXCHANNELSPERUSER 10 /* Recommended value: 10 */ #endif /* __config_include__ */ - diff --git a/include/settings.h b/include/settings.h new file mode 100644 index 0000000..9677c77 --- /dev/null +++ b/include/settings.h @@ -0,0 +1,65 @@ +/************************************************************************ + * IRC - Internet Relay Chat, include/settings.h + * + * Runtime configuration settings. These replace former compile-time + * defines from config.h, allowing a single binary to be deployed + * across different hosts without recompilation. + * + * Defaults are set in src/settings.c. Values are overridden by + * network{}, limits{}, and general{} blocks in ircd.conf. + */ + +#ifndef __settings_include__ +#define __settings_include__ + +#define CFG_STRLEN 256 + +/* Network identity */ +extern char cfg_network_name[CFG_STRLEN]; +extern char cfg_admin_chan[CFG_STRLEN]; +extern char cfg_random_serv[CFG_STRLEN]; +extern char cfg_network_www[CFG_STRLEN]; +extern char cfg_network_aup[CFG_STRLEN]; +extern char cfg_kline_address[CFG_STRLEN]; +extern char cfg_contact_url[CFG_STRLEN]; +extern char cfg_services_name[CFG_STRLEN]; + +/* Service nicknames */ +extern char cfg_chanserv[CFG_STRLEN]; +extern char cfg_nickserv[CFG_STRLEN]; +extern char cfg_memoserv[CFG_STRLEN]; +extern char cfg_operserv[CFG_STRLEN]; +extern char cfg_webserv[CFG_STRLEN]; + +/* Masking hostnames */ +extern char cfg_ircop_host[CFG_STRLEN]; +extern char cfg_admin_host[CFG_STRLEN]; +extern char cfg_locop_host[CFG_STRLEN]; +extern char cfg_sadmin_host[CFG_STRLEN]; +extern char cfg_sroot_host[CFG_STRLEN]; +extern char cfg_netadmin_host[CFG_STRLEN]; +extern char cfg_mask_prefix[CFG_STRLEN]; +extern char cfg_x_prefix[CFG_STRLEN]; + +/* Limits and tuning */ +extern int cfg_maxchannelsperuser; +extern int cfg_nick_change_delay; +extern int cfg_target_delay; +extern int cfg_client_flood; +extern int cfg_maxsendqlength; +extern long cfg_bufferpool; +extern int cfg_listen_size; +extern int cfg_htctime; +extern int cfg_htctrigger; +extern int cfg_clone_limit; +extern int cfg_clone_period; +extern int cfg_clone_delay; +extern int cfg_zline_time; + +/* Feature toggles */ +extern int cfg_throttle; +extern int cfg_seeuserstats; +extern int cfg_crypt_oper_password; +extern int cfg_crypt_iline_password; + +#endif /* __settings_include__ */ diff --git a/include/struct.h b/include/struct.h index d559ec5..e2d4948 100644 --- a/include/struct.h +++ b/include/struct.h @@ -18,7 +18,8 @@ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -#include "config.h" /* Get SEEUSERSTATS */ +#include "config.h" +#include "settings.h" #include "common.h" #include "sys.h" @@ -217,11 +218,7 @@ typedef struct Zdata aZdata; /* * flags macros. */ -#ifdef SEEUSERSTATS -#define IsStatsF(x) ((x)->umodes & UMODE_STATS) -#else -#define IsStatsF(x) (0) -#endif +#define IsStatsF(x) (cfg_seeuserstats && ((x)->umodes & UMODE_STATS)) #define IsKillsF(x) ((x)->umodes & UMODE_KILLS) #define IsClientF(x) ((x)->umodes & UMODE_CLIENT) #define IsFloodF(x) ((x)->umodes & UMODE_FLOOD) @@ -252,9 +249,7 @@ typedef struct Zdata aZdata; #define GotCapab(x) ((x)->flags & FLAGS_GOTCAPAB) #define IsNotSpoof(x) ((x)->nospoof == 0) -#ifdef SEEUSERSTATS #define SetStatsF(x) ((x)->umodes |= UMODE_STATS) -#endif #define SetKillsF(x) ((x)->umodes |= UMODE_KILLS) #define SetClientF(x) ((x)->umodes |= UMODE_CLIENT) #define SetFloodF(x) ((x)->umodes |= UMODE_FLOOD) @@ -276,9 +271,7 @@ typedef struct Zdata aZdata; #define NoNewLine(x) ((x)->flags & FLAGS_NONL) -#ifdef SEEUSERSTATS #define ClearStatsF(x) ((x)->umodes &= ~UMODE_STATS) -#endif #define ClearAdmin(x) ((x)->umodes &= ~UMODE_ADMIN) #define ClearSAdmin(x) ((x)->umodes &= ~UMODE_SADMIN) #define ClearSRoot(x) ((x)->umodes &= ~UMODE_SROOT) diff --git a/include/sys.h b/include/sys.h index c5e526a..3014f8e 100644 --- a/include/sys.h +++ b/include/sys.h @@ -77,17 +77,7 @@ extern void debug(int, char *, ...); #define MAXCLIENTS (MAXCONNECTIONS-4) -#if defined(CLIENT_FLOOD) -# if (CLIENT_FLOOD > 8000) -# define CLIENT_FLOOD 8000 -# else -# if (CLIENT_FLOOD < 512) -error CLIENT_FLOOD needs redefining. -# endif -# endif -#else -error CLIENT_FLOOD undefined -#endif +/* CLIENT_FLOOD is now a runtime setting (cfg_client_flood) */ #if (NICKNAMEHISTORYLENGTH < 100) # define NICKNAMEHISTORYLENGTH 100 #endif diff --git a/src/Makefile b/src/Makefile index b16ab11..0557bca 100644 --- a/src/Makefile +++ b/src/Makefile @@ -18,7 +18,7 @@ #*/ OBJS=bsd.o dbuf.o packet.o send.o match.o parse.o support.o channel.o \ - class.o hash.o ircd.o list.o res.o masking.o s_bsd.o s_conf.o \ + class.o hash.o ircd.o list.o res.o masking.o settings.o s_bsd.o s_conf.o \ s_debug.o s_err.o s_misc.o s_numeric.o s_ping.o s_serv.o s_user.o s_zip.o \ whowas.o userload.o md5.o $(RES) $(STRTOUL) diff --git a/src/channel.c b/src/channel.c index 1d7a706..7f67a51 100644 --- a/src/channel.c +++ b/src/channel.c @@ -2126,7 +2126,7 @@ static void add_invite (aClient *cptr, aChannel *chptr) /* * delete last link in chain if the list is max length */ - if (list_length (cptr->user->invited) >= MAXCHANNELSPERUSER) { + if (list_length (cptr->user->invited) >= cfg_maxchannelsperuser) { for (tmp = cptr->user->invited; tmp->next; tmp = tmp->next); del_invite (cptr, tmp->value.chptr); @@ -2135,7 +2135,7 @@ static void add_invite (aClient *cptr, aChannel *chptr) * since otherwise mass-inviters could take up some major * resources -Donwulff */ - if (list_length (chptr->invites) >= MAXCHANNELSPERUSER) { + if (list_length (chptr->invites) >= cfg_maxchannelsperuser) { for (tmp = chptr->invites; tmp->next; tmp = tmp->next); del_invite (tmp->value.cptr, chptr); } @@ -3096,7 +3096,7 @@ int m_join (aClient *cptr, aClient *sptr, int parc, char *parv[]) else flags = CHFL_DEOPPED; - if (sptr->user->joined >= MAXCHANNELSPERUSER) { + if (sptr->user->joined >= cfg_maxchannelsperuser) { sendto_one (sptr, err_str (ERR_TOOMANYCHANNELS), me.name, parv[0], name); return 0; @@ -4055,7 +4055,7 @@ int m_names (aClient *cptr, aClient *sptr, int parc, char *parv[]) if (cptr->htcignore) { sendto_ops ("HTC ignore"); - if ((time (NULL) - cptr->lasthtc) > (HTCTIME * 3)) { + if ((time (NULL) - cptr->lasthtc) > (cfg_htctime * 3)) { cptr->htcignore = 0; cptr->htccount = 0; cptr->lasthtc = time (NULL); @@ -4063,24 +4063,24 @@ int m_names (aClient *cptr, aClient *sptr, int parc, char *parv[]) else { cptr->lasthtc = time (NULL); sendto_one (sptr, rpl_str (ERR_HTCTOOFAST), me.name, - sptr->name, (HTCTIME * 3)); + sptr->name, (cfg_htctime * 3)); return 0; } } - if (((time (NULL) - cptr->lasthtc) < HTCTIME) && !IsAnOper (cptr)) + if (((time (NULL) - cptr->lasthtc) < cfg_htctime) && !IsAnOper (cptr)) cptr->htccount++; else cptr->htccount = 0; - if (cptr->htccount > HTCTRIGGER) { + if (cptr->htccount > cfg_htctrigger) { cptr->htcignore = 1; cptr->lasthtc = time (NULL); sendto_locfailops ("Warning! %s!%s@%s is exceeding HTC trigger value.", cptr->name, cptr->user->username, cptr->user->host); sendto_one (sptr, rpl_str (ERR_HTCTOOFAST), me.name, sptr->name, - (HTCTIME * 3)); + (cfg_htctime * 3)); return 0; } diff --git a/src/class.c b/src/class.c index 46e906c..a4463fc 100644 --- a/src/class.c +++ b/src/class.c @@ -137,7 +137,7 @@ void add_class (int class, int ping, int confreq, int maxli, long sendq) ConFreq (p) = confreq; PingFreq (p) = ping; MaxLinks (p) = maxli; - MaxSendq (p) = (sendq > 0) ? sendq : MAXSENDQLENGTH; + MaxSendq (p) = (sendq > 0) ? sendq : cfg_maxsendqlength; if (p != t) Links (p) = 0; } @@ -181,7 +181,7 @@ void initclass () ConFreq (FirstClass ()) = CONNECTFREQUENCY; PingFreq (FirstClass ()) = PINGFREQUENCY; MaxLinks (FirstClass ()) = MAXIMUM_LINKS; - MaxSendq (FirstClass ()) = MAXSENDQLENGTH; + MaxSendq (FirstClass ()) = cfg_maxsendqlength; Links (FirstClass ()) = 0; NextClass (FirstClass ()) = NULL; } @@ -198,7 +198,7 @@ void report_classes (aClient *sptr) long get_sendq (aClient *cptr) { - int sendq = MAXSENDQLENGTH, retc = BAD_CLIENT_CLASS; + int sendq = cfg_maxsendqlength, retc = BAD_CLIENT_CLASS; Link *tmp; aClass *cl; diff --git a/src/dbuf.c b/src/dbuf.c index b1509d4..158016f 100644 --- a/src/dbuf.c +++ b/src/dbuf.c @@ -53,7 +53,7 @@ static dbufbuf *dbuf_alloc () freelist = freelist->next; return dbptr; } - if (dbufalloc * DBUFSIZ > BUFFERPOOL) { + if (dbufalloc * DBUFSIZ > cfg_bufferpool) { dbufalloc--; return NULL; } diff --git a/src/masking.c b/src/masking.c index 8761218..dde9b70 100644 --- a/src/masking.c +++ b/src/masking.c @@ -77,17 +77,17 @@ char *return_oper_mask(struct Client *acptr) { if (IsHidden(acptr)) { if (IsNetAdmin(acptr)) - return netadmin_host; + return cfg_netadmin_host; else if (IsSRoot(acptr)) - return sroot_host; + return cfg_sroot_host; else if (IsSAdmin(acptr)) - return sadmin_host; + return cfg_sadmin_host; else if (IsAdmin(acptr)) - return admin_host; + return cfg_admin_host; else if (IsOper(acptr)) - return ircop_host; + return cfg_ircop_host; else if (IsLocOp(acptr)) - return locop_host; + return cfg_locop_host; } else { return acptr->user->host; } @@ -151,10 +151,10 @@ char *return_user_mask(char *s) dot = (char *) strchr(s, '.'); if (dot == NULL) { - sprintf(mask, userspace_mask_prefix "%i%i%i%i%i%i.%s",csum[14]%10,csum[15]%10,csum[16]%10,csum[17]%10,csum[18]%10,csum[19]%10, s); + sprintf(mask, "%s%i%i%i%i%i%i.%s", cfg_mask_prefix, csum[14]%10,csum[15]%10,csum[16]%10,csum[17]%10,csum[18]%10,csum[19]%10, s); return mask; } else { - sprintf(mask, userspace_mask_prefix "%i%i%i%i%i%i.%s",csum[14]%10,csum[15]%10,csum[16]%10,csum[17]%10,csum[18]%10,csum[19]%10, dot + 1); + sprintf(mask, "%s%i%i%i%i%i%i.%s", cfg_mask_prefix, csum[14]%10,csum[15]%10,csum[16]%10,csum[17]%10,csum[18]%10,csum[19]%10, dot + 1); return mask; } } diff --git a/src/s_bsd.c b/src/s_bsd.c index fa84a0b..1bfa782 100644 --- a/src/s_bsd.c +++ b/src/s_bsd.c @@ -227,7 +227,7 @@ int inetport (aClient *cptr, char *name, int port) highest_fd = cptr->fd; cptr->ip.s_addr = name ? inet_addr (ipname) : me.ip.s_addr; cptr->port = (int) ntohs (server.sin_port); - (void) listen (cptr->fd, LISTEN_SIZE); + (void) listen (cptr->fd, cfg_listen_size); local[cptr->fd] = cptr; return 0; @@ -1076,13 +1076,13 @@ static int read_packet (aClient *cptr, fd_set *rfd) if (dbuf_put (&cptr->recvQ, readbuf, length) < 0) return exit_client (cptr, cptr, cptr, "dbuf_put fail"); - if (IsPerson (cptr) && DBufLength (&cptr->recvQ) > CLIENT_FLOOD) { + if (IsPerson (cptr) && DBufLength (&cptr->recvQ) > cfg_client_flood) { sendto_umode (UMODE_FLOOD | UMODE_OPER, "*** Flood -- %s!%s@%s (%d) exceeds %d recvQ", cptr->name[0] ? cptr->name : "*", cptr->user ? cptr->user->username : "*", cptr->user ? cptr->user->host : "*", - DBufLength (&cptr->recvQ), CLIENT_FLOOD); + DBufLength (&cptr->recvQ), cfg_client_flood); return exit_client (cptr, cptr, cptr, "Excess Flood"); } while (DBufLength (&cptr->recvQ) && !NoNewLine (cptr) && diff --git a/src/s_conf.c b/src/s_conf.c index 77dafc1..97313ba 100644 --- a/src/s_conf.c +++ b/src/s_conf.c @@ -39,6 +39,7 @@ #include #include "h.h" +#include "settings.h" static int lookup_confhost (aConfItem *); static int advanced_check (char *, int); int ZLineExists (char *); @@ -49,7 +50,7 @@ aJinxItem *jinx = NULL; aConfItem *conf = NULL; extern char zlinebuf[]; -int socks_zline_time = ZLINE_TIME; +int socks_zline_time = 1; /* default, overridden by cfg_zline_time */ static int del_temp_conf (unsigned int, char *, char *, char *, int, int, unsigned int); @@ -1056,7 +1057,6 @@ int initconf (int opt) int b_admin_count = 0, b_host_count = 0; int b_hub_mode = 0; int b_pingfreq = 0, b_connfreq = 0, b_maxlinks = 0, b_sendq = 0; - int b_zline_time = 0; memset (b_admin, 0, sizeof (b_admin)); @@ -1125,8 +1125,85 @@ int initconf (int opt) b_maxlinks = atoi (value); else if (!mycmp (key, "sendq")) b_sendq = atoi (value); - else if (!mycmp (key, "time")) - b_zline_time = atoi (value); + /* network{} keys */ + else if (!mycmp (key, "network")) + strncpyzt (cfg_network_name, value, CFG_STRLEN); + else if (!mycmp (key, "adminchan")) + strncpyzt (cfg_admin_chan, value, CFG_STRLEN); + else if (!mycmp (key, "randomserv")) + strncpyzt (cfg_random_serv, value, CFG_STRLEN); + else if (!mycmp (key, "website")) + strncpyzt (cfg_network_www, value, CFG_STRLEN); + else if (!mycmp (key, "aup")) + strncpyzt (cfg_network_aup, value, CFG_STRLEN); + else if (!mycmp (key, "kline_address")) + strncpyzt (cfg_kline_address, value, CFG_STRLEN); + else if (!mycmp (key, "contact_url")) + strncpyzt (cfg_contact_url, value, CFG_STRLEN); + else if (!mycmp (key, "services_name")) + strncpyzt (cfg_services_name, value, CFG_STRLEN); + else if (!mycmp (key, "chanserv")) + strncpyzt (cfg_chanserv, value, CFG_STRLEN); + else if (!mycmp (key, "nickserv")) + strncpyzt (cfg_nickserv, value, CFG_STRLEN); + else if (!mycmp (key, "memoserv")) + strncpyzt (cfg_memoserv, value, CFG_STRLEN); + else if (!mycmp (key, "operserv")) + strncpyzt (cfg_operserv, value, CFG_STRLEN); + else if (!mycmp (key, "webserv")) + strncpyzt (cfg_webserv, value, CFG_STRLEN); + else if (!mycmp (key, "ircop_host")) + strncpyzt (cfg_ircop_host, value, CFG_STRLEN); + else if (!mycmp (key, "admin_host")) + strncpyzt (cfg_admin_host, value, CFG_STRLEN); + else if (!mycmp (key, "locop_host")) + strncpyzt (cfg_locop_host, value, CFG_STRLEN); + else if (!mycmp (key, "sadmin_host")) + strncpyzt (cfg_sadmin_host, value, CFG_STRLEN); + else if (!mycmp (key, "sroot_host")) + strncpyzt (cfg_sroot_host, value, CFG_STRLEN); + else if (!mycmp (key, "netadmin_host")) + strncpyzt (cfg_netadmin_host, value, CFG_STRLEN); + else if (!mycmp (key, "mask_prefix")) + strncpyzt (cfg_mask_prefix, value, CFG_STRLEN); + else if (!mycmp (key, "x_prefix")) + strncpyzt (cfg_x_prefix, value, CFG_STRLEN); + /* limits{} keys */ + else if (!mycmp (key, "maxchannels")) + cfg_maxchannelsperuser = atoi (value); + else if (!mycmp (key, "nickdelay")) + cfg_nick_change_delay = atoi (value); + else if (!mycmp (key, "targetdelay")) + cfg_target_delay = atoi (value); + else if (!mycmp (key, "clientflood")) + cfg_client_flood = atoi (value); + else if (!mycmp (key, "maxsendq")) + cfg_maxsendqlength = atoi (value); + else if (!mycmp (key, "bufferpool")) + cfg_bufferpool = atol (value); + else if (!mycmp (key, "listenqueue")) + cfg_listen_size = atoi (value); + else if (!mycmp (key, "htctime")) + cfg_htctime = atoi (value); + else if (!mycmp (key, "htctrigger")) + cfg_htctrigger = atoi (value); + else if (!mycmp (key, "clonelimit")) + cfg_clone_limit = atoi (value); + else if (!mycmp (key, "cloneperiod")) + cfg_clone_period = atoi (value); + else if (!mycmp (key, "clonedelay")) + cfg_clone_delay = atoi (value); + else if (!mycmp (key, "zlinetime")) + cfg_zline_time = atoi (value); + /* general{} toggle keys */ + else if (!mycmp (key, "throttle")) + cfg_throttle = (!mycmp (value, "yes") || !mycmp (value, "1")); + else if (!mycmp (key, "seeuserstats")) + cfg_seeuserstats = (!mycmp (value, "yes") || !mycmp (value, "1")); + else if (!mycmp (key, "crypt_oper_password")) + cfg_crypt_oper_password = (!mycmp (value, "yes") || !mycmp (value, "1")); + else if (!mycmp (key, "crypt_iline_password")) + cfg_crypt_iline_password = (!mycmp (value, "yes") || !mycmp (value, "1")); else Debug ((DEBUG_ERROR, "Unknown key '%s' in block '%s'", key, blocktype)); @@ -1251,8 +1328,14 @@ int initconf (int opt) else if (!mycmp (blocktype, "general")) { if (b_hub_mode) is_hub = 1; - if (b_zline_time) - socks_zline_time = b_zline_time * 60; + } + else if (!mycmp (blocktype, "network")) { + /* All handled by key-value parser above */ + } + else if (!mycmp (blocktype, "limits")) { + /* Key-value parser handles most settings; apply zline_time */ + if (cfg_zline_time) + socks_zline_time = cfg_zline_time * 60; } else if (!mycmp (blocktype, "quarantine")) { /* Q::reason:nick */ @@ -1426,8 +1509,9 @@ int find_kill (aClient *cptr) if (BadPtr (tmp->passwd)) sendto_one (cptr, ":%s %d %s :*** You are not welcome on this server." - " Email " KLINE_ADDRESS " for more information.", - me.name, ERR_YOUREBANNEDCREEP, cptr->name); + " Email %s for more information.", + me.name, ERR_YOUREBANNEDCREEP, cptr->name, + cfg_kline_address); else #ifdef COMMENT_IS_FILE m_killcomment (cptr, cptr->name, tmp->passwd); @@ -1442,9 +1526,9 @@ int find_kill (aClient *cptr) else sendto_one (cptr, ":%s %d %s :*** You are not welcome on this server: " - "%s. Email " KLINE_ADDRESS - " for more information.", me.name, - ERR_YOUREBANNEDCREEP, cptr->name, tmp->passwd); + "%s. Email %s for more information.", me.name, + ERR_YOUREBANNEDCREEP, cptr->name, tmp->passwd, + cfg_kline_address); } } #endif /* COMMENT_IS_FILE */ @@ -2114,11 +2198,11 @@ int m_zline (aClient *cptr, aClient *sptr, int parc, char *parv[]) else { if (person) sendto_ops ("%s z:lined %s (*@%s) on %s [%s]", parv[0], person, - userhost, server ? server : irc_network, + userhost, server ? server : cfg_network_name, reason ? reason : ""); else sendto_ops ("%s z:lined *@%s on %s [%s]", parv[0], userhost, - server ? server : irc_network, reason ? reason : ""); + server ? server : cfg_network_name, reason ? reason : ""); (void) add_temp_conf (CONF_ZAP, userhost, reason, NULL, 0, 0, KLINE_AKILL); } diff --git a/src/s_debug.c b/src/s_debug.c index e6d33ce..3b8a60c 100644 --- a/src/s_debug.c +++ b/src/s_debug.c @@ -41,9 +41,7 @@ char serveropts[] = { #ifdef IDLE_FROM_MSG 'M', #endif -#ifdef CRYPT_OPER_PASSWORD 'p', -#endif 'n', #ifdef USE_SYSLOG 'Y', diff --git a/src/s_err.c b/src/s_err.c index b564228..b61e164 100644 --- a/src/s_err.c +++ b/src/s_err.c @@ -37,7 +37,7 @@ static Numeric local_replies[] = { /* 000 */ {0, (char *) NULL}, /* 001 */ - {RPL_WELCOME, ":Hello %s, Welcome to the " irc_network " IRC Network!"}, + {RPL_WELCOME, ":Hello %s, Welcome to the %s IRC Network!"}, /* 002 */ {RPL_YOURHOST, ":Your host is %s, running version %s"}, /* 003 */ @@ -192,8 +192,7 @@ static Numeric numeric_errors[] = { {ERR_PASSWDMISMATCH, ":Password Incorrect"}, /* 465 */ {ERR_YOUREBANNEDCREEP, - ":You are banned from this server. Mail " KLINE_ADDRESS - " for more information"}, + ":You are banned from this server"}, /* 466 */ {ERR_YOUWILLBEBANNED, (char *) NULL}, /* 467 */ diff --git a/src/s_serv.c b/src/s_serv.c index cb44fd1..3b3e6b3 100644 --- a/src/s_serv.c +++ b/src/s_serv.c @@ -37,6 +37,8 @@ static void report_jinx (aClient * sptr); +#define USERSTATMAX 120 + static char buf[BUFSIZE]; void s_die (); /* I guess we can move this to somewhere else ... */ @@ -901,8 +903,7 @@ int m_info (aClient *cptr, aClient *sptr, int parc, char *parv[]) return 0; */ -#ifdef SEEUSERSTATS - if (!IsAnOper (sptr)) { + if (cfg_seeuserstats && !IsAnOper (sptr)) { if (parc > 1 && strlen (parv[1]) > USERSTATMAX) { sendto_umode (UMODE_OPER | UMODE_STATS, "*** Notice -- INFO [truncated] requested by %s (%s@%s)", @@ -919,7 +920,6 @@ int m_info (aClient *cptr, aClient *sptr, int parc, char *parv[]) (sptr->user) ? sptr->user->host : ""); } } -#endif /* Send users an error if they try to do /info . -Studded */ if (parc > 1) { @@ -1369,8 +1369,7 @@ int m_stats (aClient *cptr, aClient *sptr, int parc, char *parv[]) HUNTED_ISME) return 0; -#ifdef SEEUSERSTATS - if (!IsAnOper (sptr)) { + if (cfg_seeuserstats && !IsAnOper (sptr)) { if (parc > 1 && strlen (parv[1]) > USERSTATMAX) { sendto_umode (UMODE_OPER | UMODE_STATS, "*** Notice -- STATS [truncated] requested by %s (%s@%s)", @@ -1387,7 +1386,6 @@ int m_stats (aClient *cptr, aClient *sptr, int parc, char *parv[]) (sptr->user) ? sptr->user->host : ""); } } -#endif if (parc > 2) { name = parv[2]; @@ -1687,8 +1685,7 @@ int m_help (aClient *cptr, aClient *sptr, int parc, char *parv[]) { int i; if (MyClient (sptr)) { -#ifdef SEEUSERSTATS - if (!IsAnOper (sptr)) { + if (cfg_seeuserstats && !IsAnOper (sptr)) { if (parc > 1 && strlen (parv[1]) > USERSTATMAX) { sendto_umode (UMODE_OPER | UMODE_STATS, "*** Notice -- HELP [truncated] requested by %s (%s@%s)", @@ -1705,7 +1702,6 @@ int m_help (aClient *cptr, aClient *sptr, int parc, char *parv[]) (sptr->user) ? sptr->user->host : ""); } } -#endif sendto_one (sptr, ":%s NOTICE %s :Full command list:", me.name, parv[0]); sendto_one (sptr, ":%s NOTICE %s :command token", me.name, parv[0]); @@ -2125,8 +2121,7 @@ int m_admin (aClient *cptr, aClient *sptr, int parc, char *parv[]) HUNTED_ISME) return 0; -#ifdef SEEUSERSTATS - if (!IsAnOper (sptr)) { + if (cfg_seeuserstats && !IsAnOper (sptr)) { if (parc > 1 && strlen (parv[1]) > USERSTATMAX) { sendto_umode (UMODE_OPER | UMODE_STATS, "*** Notice -- ADMIN [truncated] requested by %s (%s@%s)", @@ -2143,7 +2138,6 @@ int m_admin (aClient *cptr, aClient *sptr, int parc, char *parv[]) (sptr->user) ? sptr->user->host : ""); } } -#endif if ((aconf = find_admin ())) { sendto_one (sptr, rpl_str (RPL_ADMINME), me.name, parv[0], me.name); @@ -2827,7 +2821,7 @@ int find_services (void) aClient *cptr; - if ((cptr = find_server (SERVICES_NAME, (aClient *) NULL))) + if ((cptr = find_server (cfg_services_name, (aClient *) NULL))) return 1; return 0; diff --git a/src/s_user.c b/src/s_user.c index ed4a2ed..b22cc68 100644 --- a/src/s_user.c +++ b/src/s_user.c @@ -33,6 +33,7 @@ #include #include #include "h.h" +#include "settings.h" void send_umode_out (aClient *, aClient *, int); void send_svsmode_out (aClient *, aClient *, aClient *, int); @@ -41,9 +42,7 @@ static int is_silenced (aClient *, aClient *); static char buf[BUFSIZE], buf2[BUFSIZE]; -#if defined(THROTTLE) int ZLineExists (char *); -#endif /* @@ -231,7 +230,7 @@ int check_for_target_limit (aClient * sptr, void *target, const char *name) return 0; } if (now < sptr->nexttarget) { - if (sptr->nexttarget - now < TARGET_DELAY + 8) { + if (sptr->nexttarget - now < cfg_target_delay + 8) { sptr->nexttarget += 2; sendto_one (sptr, err_str (ERR_TARGETTOOFAST), me.name, sptr->name, name, sptr->nexttarget - now); @@ -239,22 +238,20 @@ int check_for_target_limit (aClient * sptr, void *target, const char *name) return 1; } else { - sptr->nexttarget += TARGET_DELAY; - if (sptr->nexttarget < now - (TARGET_DELAY * (MAXTARGETS - 1))) - sptr->nexttarget = now - (TARGET_DELAY * (MAXTARGETS - 1)); + sptr->nexttarget += cfg_target_delay; + if (sptr->nexttarget < now - (cfg_target_delay * (MAXTARGETS - 1))) + sptr->nexttarget = now - (cfg_target_delay * (MAXTARGETS - 1)); } memmove (&sptr->targets[1], &sptr->targets[0], MAXTARGETS - 1); sptr->targets[0] = hash; return 0; } -#ifdef THROTTLE - /* * check_clones * * This function counts the number of clients with the same IP number - * as cptr that connected less than CHECK_CLONE_PERIOD seconds ago. + * as cptr that connected less than cfg_clone_period seconds ago. * return value * -1: reject connections * 0: permit connections @@ -305,7 +302,7 @@ int check_clones (aClient * cptr, const char *remote) return 0; while (*tscn && (cptr->ip.s_addr != (*tscn)->ip.s_addr)) { - if ((*tscn)->last + CHECK_CLONE_PERIOD < now) { + if ((*tscn)->last + cfg_clone_period < now) { tptr = *tscn; *tscn = tptr->next; free (tptr->connected); @@ -316,7 +313,7 @@ int check_clones (aClient * cptr, const char *remote) } if ((tptr = *tscn)) { /* There is a record for this host */ - if (!(tptr->last + CHECK_CLONE_PERIOD < now)) { /* not expired */ + if (!(tptr->last + cfg_clone_period < now)) { /* not expired */ if (remote && !tptr->connected && (tptr->connected = (char *) MyMalloc (strlen (remote) + 1))) @@ -325,7 +322,7 @@ int check_clones (aClient * cptr, const char *remote) tptr->last = now; if (tptr->count >= 0) { - if (++tptr->count == CHECK_CLONE_LIMIT) + if (++tptr->count == cfg_clone_limit) tptr->count = THROTTLE_HITLIMIT; return 0; @@ -366,7 +363,6 @@ int check_clones (aClient * cptr, const char *remote) /* we should never get here, but just in case */ return 0; } -#endif /* THROTTLE */ /* ** 'do_nick_name' ensures that the given parameter (nick) is @@ -478,10 +474,8 @@ static int register_user (aClient *cptr, aClient *sptr, char *nick, char *userna anUser *user = sptr->user; aClient *nsptr; int i; -#ifdef CRYPT_ILINE_PASSWORD char salt[3]; extern char *crypt (); -#endif /* CRYPT_ILINE_PASSWORD */ user->last = time (NULL); parv[0] = sptr->name; @@ -492,8 +486,7 @@ static int register_user (aClient *cptr, aClient *sptr, char *nick, char *userna sptr->lasthtc = time (NULL); sptr->htccount = 0; sptr->htcignore = 0; -#ifdef THROTTLE - if (check_clones (sptr, get_client_host (sptr)) == -1) { + if (cfg_throttle && check_clones (sptr, get_client_host (sptr)) == -1) { int ret = exit_client (cptr, sptr, sptr, "Your host/ip has been throttled"); static char hostip[128]; @@ -502,11 +495,10 @@ static int register_user (aClient *cptr, aClient *sptr, char *nick, char *userna add_temp_conf (CONF_ZAP, hostip, "Too_many_connection_attempts_from_your_IP_address", NULL, 0, 0, KLINE_TEMP); - AddEvent (RemoveZLine, hostip, CHECK_CLONE_DELAY); + AddEvent (RemoveZLine, hostip, cfg_clone_delay); } return ret; } -#endif /* THROTTLE */ if ((i = check_client (sptr))) { sendto_umode (UMODE_OPER | UMODE_CLIENT, @@ -514,13 +506,16 @@ static int register_user (aClient *cptr, aClient *sptr, char *nick, char *userna i == -3 ? "Too many connections" : "Unauthorized connection", get_client_host (sptr)); ircstp->is_ref++; -#ifdef THROTTLE - if (i == -3) + if (cfg_throttle && i == -3) remove_clone_check (sptr); -#endif - return exit_client (cptr, sptr, &me, i == -3 ? - "This server is full. Please try " - random_serv : + if (i == -3) { + static char fullmsg[256]; + snprintf (fullmsg, sizeof (fullmsg), + "This server is full. Please try %s", + cfg_random_serv); + return exit_client (cptr, sptr, &me, fullmsg); + } + return exit_client (cptr, sptr, &me, "You are not authorized to connect to this server"); } if (IsUnixSocket (sptr)) @@ -588,30 +583,28 @@ static int register_user (aClient *cptr, aClient *sptr, char *nick, char *userna u1 = NULL; if (!BadPtr (aconf->passwd)) { -#ifdef CRYPT_ILINE_PASSWORD - /* use first two chars of the password they send in as salt */ - /* passwd may be NULL. Head it off at the pass... */ - salt[0] = '\0'; - if (sptr->passwd && aconf->passwd && aconf->passwd[0] && - aconf->passwd[1]) { - salt[0] = aconf->passwd[0]; - salt[1] = aconf->passwd[1]; - salt[2] = '\0'; - encr = crypt (sptr->passwd, salt); - } - else - encr = ""; -#else - encr = sptr->passwd; -#endif /* CRYPT_ILINE_PASSWORD */ + if (cfg_crypt_iline_password) { + /* use first two chars of the password they send in as salt */ + /* passwd may be NULL. Head it off at the pass... */ + salt[0] = '\0'; + if (sptr->passwd && aconf->passwd && aconf->passwd[0] && + aconf->passwd[1]) { + salt[0] = aconf->passwd[0]; + salt[1] = aconf->passwd[1]; + salt[2] = '\0'; + encr = crypt (sptr->passwd, salt); + } + else + encr = ""; + } else + encr = sptr->passwd; if (!StrEq (encr, aconf->passwd)) { ircstp->is_ref++; sendto_one (sptr, err_str (ERR_PASSWDMISMATCH), me.name, parv[0]); -#ifdef THROTTLE - remove_clone_check (sptr); -#endif + if (cfg_throttle) + remove_clone_check (sptr); return exit_client (cptr, sptr, &me, "Bad Password"); } /* .. Else password check was successful, clear the pass @@ -672,7 +665,7 @@ static int register_user (aClient *cptr, aClient *sptr, char *nick, char *userna if (MyConnect (sptr)) { sendto_one (sptr, rpl_str (RPL_WELCOME), me.name, nick, nick, - user->username, user->host); + cfg_network_name); /* This is a duplicate of the NOTICE but see below... */ sendto_one (sptr, rpl_str (RPL_YOURHOST), me.name, nick, me.name, version); @@ -752,9 +745,9 @@ static int register_user (aClient *cptr, aClient *sptr, char *nick, char *userna */ if (MyConnect (sptr)) { send_umode_out (cptr, sptr, 0); - if (sptr->passwd[0] && (nsptr = find_person (NickServ, NULL))) + if (sptr->passwd[0] && (nsptr = find_person (cfg_nickserv, NULL))) sendto_one (nsptr, ":%s PRIVMSG %s@%s :IDENTIFY %s", - sptr->name, NickServ, SERVICES_NAME, sptr->passwd); + sptr->name, cfg_nickserv, cfg_services_name, sptr->passwd); } #ifdef USE_SERVICES check_services_butone (SERVICE_WANT_NICK, sptr, @@ -929,11 +922,11 @@ int m_nick (aClient *cptr, aClient *sptr, int parc, char *parv[]) ** So you cannot change now to thses nicknames even ** if you want too :-) */ - if (!IsServer (cptr) && (!strcmp (nick, NickServ) || - !strcmp (nick, ChanServ) || - !strcmp (nick, OperServ) || - !strcmp (nick, WebServ) || - !strcmp (nick, MemoServ))) { + if (!IsServer (cptr) && (!strcmp (nick, cfg_nickserv) || + !strcmp (nick, cfg_chanserv) || + !strcmp (nick, cfg_operserv) || + !strcmp (nick, cfg_webserv) || + !strcmp (nick, cfg_memoserv))) { sendto_one (sptr, err_str (ERR_ERRONEUSNICKNAME), me.name, BadPtr (parv[0]) ? "*" : parv[0], nick, "Reserved Due To Services Abuse."); @@ -1212,18 +1205,10 @@ int m_nick (aClient *cptr, aClient *sptr, int parc, char *parv[]) me.name, nick, sptr->nospoof, sptr->nospoof); sendto_one (sptr, "PING :%X", sptr->nospoof); -#ifdef CONTACT_EMAIL - sendto_one (sptr, ":%s NOTICE %s :*** If you need assistance with a" - " connection problem, please email " CONTACT_EMAIL - " with the name and version of the client you are" - " using, and the server you tried to connect to: %s", - me.name, nick, me.name); -#endif /* CONTACT_EMAIL */ -#ifdef CONTACT_URL - sendto_one (sptr, ":%s NOTICE %s :*** If you need assistance with" - " connecting to this server, %s, please refer to: " - CONTACT_URL, me.name, nick, me.name); -#endif /* CONTACT_URL */ + if (cfg_contact_url[0]) + sendto_one (sptr, ":%s NOTICE %s :*** If you need assistance with" + " connecting to this server, %s, please refer to: %s", + me.name, nick, me.name, cfg_contact_url); /* Copy password to the passwd field if it's given after NICK * - originally by taz, modified by Wizzu @@ -1503,8 +1488,8 @@ static int m_message (aClient *cptr, aClient *sptr, int parc, char *parv[], int continue; } } - if (server && strncasecmp (server + 1, SERVICES_NAME, - strlen (SERVICES_NAME)) == 0) + if (server && strncasecmp (server + 1, cfg_services_name, + strlen (cfg_services_name)) == 0) sendto_one (sptr, err_str (ERR_SERVICESDOWN), me.name, parv[0], nick); else @@ -1528,9 +1513,7 @@ static int user_modes[] = { UMODE_OPER, 'o', UMODE_FLOOD, 'f', UMODE_HIDE, 'x', UMODE_WHOIS, 'y', -#ifdef SEEUSERSTATS UMODE_STATS, 't', -#endif UMODE_IDENTIFY, 'I', UMODE_REGMSGONLY, 'R', 0, 0 @@ -1564,12 +1547,12 @@ int m_chanserv (aClient *cptr, aClient *sptr, int parc, char *parv[]) sendto_one (sptr, err_str (ERR_NOTEXTTOSEND), me.name, parv[0]); return -1; } - if ((acptr = find_person (ChanServ, NULL))) + if ((acptr = find_person (cfg_chanserv, NULL))) sendto_one (acptr, ":%s PRIVMSG %s@%s :%s", parv[0], - ChanServ, SERVICES_NAME, parv[1]); + cfg_chanserv, cfg_services_name, parv[1]); else sendto_one (sptr, err_str (ERR_SERVICESDOWN), me.name, parv[0], - ChanServ); + cfg_chanserv); return 0; } @@ -1585,12 +1568,12 @@ int m_memoserv (aClient *cptr, aClient *sptr, int parc, char *parv[]) sendto_one (sptr, err_str (ERR_NOTEXTTOSEND), me.name, parv[0]); return -1; } - if ((acptr = find_person (MemoServ, NULL))) + if ((acptr = find_person (cfg_memoserv, NULL))) sendto_one (acptr, ":%s PRIVMSG %s@%s :%s", parv[0], - MemoServ, SERVICES_NAME, parv[1]); + cfg_memoserv, cfg_services_name, parv[1]); else sendto_one (sptr, err_str (ERR_SERVICESDOWN), me.name, parv[0], - MemoServ); + cfg_memoserv); return 0; } @@ -1606,12 +1589,12 @@ int m_nickserv (aClient *cptr, aClient *sptr, int parc, char *parv[]) sendto_one (sptr, err_str (ERR_NOTEXTTOSEND), me.name, parv[0]); return -1; } - if ((acptr = find_person (NickServ, NULL))) + if ((acptr = find_person (cfg_nickserv, NULL))) sendto_one (acptr, ":%s PRIVMSG %s@%s :%s", parv[0], - NickServ, SERVICES_NAME, parv[1]); + cfg_nickserv, cfg_services_name, parv[1]); else sendto_one (sptr, err_str (ERR_SERVICESDOWN), me.name, parv[0], - NickServ); + cfg_nickserv); return 0; @@ -1629,12 +1612,12 @@ int m_operserv (aClient *cptr, aClient *sptr, int parc, char *parv[]) sendto_one (sptr, err_str (ERR_NOTEXTTOSEND), me.name, parv[0]); return -1; } - if ((acptr = find_person (OperServ, NULL))) + if ((acptr = find_person (cfg_operserv, NULL))) sendto_one (acptr, ":%s PRIVMSG %s@%s :%s", parv[0], - OperServ, SERVICES_NAME, parv[1]); + cfg_operserv, cfg_services_name, parv[1]); else sendto_one (sptr, err_str (ERR_SERVICESDOWN), me.name, parv[0], - OperServ); + cfg_operserv); return 0; } @@ -1654,12 +1637,12 @@ int m_identify (aClient *cptr, aClient *sptr, int parc, char *parv[]) return -1; } if (*parv[1]) { - if ((acptr = find_person (NickServ, NULL))) + if ((acptr = find_person (cfg_nickserv, NULL))) sendto_one (acptr, ":%s PRIVMSG %s@%s :IDENTIFY %s", parv[0], - NickServ, SERVICES_NAME, parv[1]); + cfg_nickserv, cfg_services_name, parv[1]); else sendto_one (sptr, err_str (ERR_SERVICESDOWN), me.name, - parv[0], NickServ); + parv[0], cfg_nickserv); } return 0; } @@ -1745,7 +1728,7 @@ int m_who (aClient *cptr, aClient *sptr, int parc, char *parv[]) if (MyClient (sptr) && !IsServer (sptr)) { if (cptr->htcignore) { - if ((time (NULL) - cptr->lasthtc) > (HTCTIME * 3)) { + if ((time (NULL) - cptr->lasthtc) > (cfg_htctime * 3)) { cptr->htcignore = 0; cptr->htccount = 0; cptr->lasthtc = time (NULL); @@ -1753,24 +1736,24 @@ int m_who (aClient *cptr, aClient *sptr, int parc, char *parv[]) else { cptr->lasthtc = time (NULL); sendto_one (sptr, rpl_str (ERR_HTCTOOFAST), me.name, - sptr->name, (HTCTIME * 3)); + sptr->name, (cfg_htctime * 3)); return 0; } } - if (((time (NULL) - cptr->lasthtc) < HTCTIME) && !IsAnOper (cptr)) + if (((time (NULL) - cptr->lasthtc) < cfg_htctime) && !IsAnOper (cptr)) cptr->htccount++; else cptr->htccount = 0; - if (cptr->htccount > HTCTRIGGER) { + if (cptr->htccount > cfg_htctrigger) { cptr->htcignore = 1; cptr->lasthtc = time (NULL); sendto_locfailops ("Warning! %s!%s@%s is exceeding HTC trigger value.", cptr->name, cptr->user->username, cptr->user->host); sendto_one (sptr, rpl_str (ERR_HTCTOOFAST), me.name, sptr->name, - (HTCTIME * 3)); + (cfg_htctime * 3)); return 0; } @@ -2706,10 +2689,8 @@ int m_oper (aClient *cptr, aClient *sptr, int parc, char *parv[]) { aConfItem *aconf; char *name, *password, *encr; -#ifdef CRYPT_OPER_PASSWORD char salt[3]; extern char *crypt (); -#endif /* CRYPT_OPER_PASSWORD */ if (check_registered_user (sptr)) return 0; @@ -2761,22 +2742,20 @@ int m_oper (aClient *cptr, aClient *sptr, int parc, char *parv[]) sptr->since += 7; return 0; } -#ifdef CRYPT_OPER_PASSWORD - /* use first two chars of the password they send in as salt */ - - /* passwd may be NULL. Head it off at the pass... */ - salt[0] = '\0'; - if (password && aconf->passwd && aconf->passwd[0] && aconf->passwd[1]) { - salt[0] = aconf->passwd[0]; - salt[1] = aconf->passwd[1]; - salt[2] = '\0'; - encr = crypt (password, salt); - } - else - encr = ""; -#else - encr = password; -#endif /* CRYPT_OPER_PASSWORD */ + if (cfg_crypt_oper_password) { + /* use first two chars of the password they send in as salt */ + /* passwd may be NULL. Head it off at the pass... */ + salt[0] = '\0'; + if (password && aconf->passwd && aconf->passwd[0] && aconf->passwd[1]) { + salt[0] = aconf->passwd[0]; + salt[1] = aconf->passwd[1]; + salt[2] = '\0'; + encr = crypt (password, salt); + } + else + encr = ""; + } else + encr = password; if ((aconf->status & CONF_OPS) && StrEq (encr, aconf->passwd) && !attach_conf (sptr, aconf)) { @@ -2800,10 +2779,8 @@ int m_oper (aClient *cptr, aClient *sptr, int parc, char *parv[]) calc_mask(sptr) ; (void) m_opermotd (sptr, sptr, 1, parv); -#if !defined(CRYPT_OPER_PASSWORD) && (defined(FNAME_OPERLOG) ||\ - (defined(USE_SYSLOG) && defined(SYSLOG_OPER))) - encr = ""; -#endif + if (!cfg_crypt_oper_password) + encr = ""; #if defined(USE_SYSLOG) && defined(SYSLOG_OPER) syslog (LOG_INFO, "OPER (%s) (%s) by (%s!%s@%s)", name, encr, parv[0], sptr->user->username, sptr->sockhost); @@ -3210,10 +3187,8 @@ int m_umode (aClient *cptr, aClient *sptr, int parc, char *parv[]) if (IsNetAdmin (sptr)) ClearNetAdmin (sptr); -#ifdef SEEUSERSTATS if (IsStatsF (sptr)) ClearStatsF (sptr); -#endif } /* * New oper access flags - Only let them set certain usermodes on diff --git a/src/settings.c b/src/settings.c new file mode 100644 index 0000000..651e8d6 --- /dev/null +++ b/src/settings.c @@ -0,0 +1,56 @@ +/************************************************************************ + * IRC - Internet Relay Chat, src/settings.c + * + * Runtime configuration defaults. These values are overridden by + * network{}, limits{}, and general{} blocks in ircd.conf. + */ + +#include "settings.h" + +/* Network identity */ +char cfg_network_name[CFG_STRLEN] = "Serenity-IRC.Net"; +char cfg_admin_chan[CFG_STRLEN] = "#help"; +char cfg_random_serv[CFG_STRLEN] = "irc.serenity-irc.net"; +char cfg_network_www[CFG_STRLEN] = "http://www.serenity-irc.net"; +char cfg_network_aup[CFG_STRLEN] = "http://www.serenity-irc.net/aup/"; +char cfg_kline_address[CFG_STRLEN] = "kline@serenity-irc.net"; +char cfg_contact_url[CFG_STRLEN] = ""; +char cfg_services_name[CFG_STRLEN] = "Services.Serenity-IRC.Net"; + +/* Service nicknames */ +char cfg_chanserv[CFG_STRLEN] = "ChanServ"; +char cfg_nickserv[CFG_STRLEN] = "NickServ"; +char cfg_memoserv[CFG_STRLEN] = "MemoServ"; +char cfg_operserv[CFG_STRLEN] = "OperServ"; +char cfg_webserv[CFG_STRLEN] = "WebServ"; + +/* Masking hostnames */ +char cfg_ircop_host[CFG_STRLEN] = "IRCop.Serenity-IRC.Net"; +char cfg_admin_host[CFG_STRLEN] = "Admin.Serenity-IRC.Net"; +char cfg_locop_host[CFG_STRLEN] = "Local.Serenity-IRC.Net"; +char cfg_sadmin_host[CFG_STRLEN] = "ServOp.Serenity-IRC.Net"; +char cfg_sroot_host[CFG_STRLEN] = "SRA.Serenity-IRC.Net"; +char cfg_netadmin_host[CFG_STRLEN] = "NetAdmin.Serenity-IRC.Net"; +char cfg_mask_prefix[CFG_STRLEN] = "Serene"; +char cfg_x_prefix[CFG_STRLEN] = "Serene"; + +/* Limits and tuning */ +int cfg_maxchannelsperuser = 10; +int cfg_nick_change_delay = 30; +int cfg_target_delay = 120; +int cfg_client_flood = 6000; +int cfg_maxsendqlength = 3000000; +long cfg_bufferpool = 27000000; /* 9 * 3000000 */ +int cfg_listen_size = 5; +int cfg_htctime = 5; +int cfg_htctrigger = 15; +int cfg_clone_limit = 3; +int cfg_clone_period = 15; +int cfg_clone_delay = 300; +int cfg_zline_time = 1; + +/* Feature toggles - defaults match previous compile-time settings */ +int cfg_throttle = 1; +int cfg_seeuserstats = 1; +int cfg_crypt_oper_password = 1; +int cfg_crypt_iline_password = 1;