0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-11-15 22:41:12 +01:00

ircd: Convert defaults to constexprs.

Also cleanup unused defaults.
Also move single-use defaults to a tighter scope.
This commit is contained in:
Jason Volk 2016-08-12 17:38:20 -07:00
parent fb8792da3d
commit 3dafbeaf21
3 changed files with 67 additions and 68 deletions

View file

@ -29,8 +29,9 @@
*/ */
#include <rb/rb.h> #include <rb/rb.h>
#include "rsdb.h" #include "rsdb.h"
#include <ircd/defaults.h>
#include <ircd/defaults.h>
using namespace ircd;
#define MAXPARA 10 #define MAXPARA 10

View file

@ -43,6 +43,11 @@
/* mode structure for channels */ /* mode structure for channels */
struct Mode struct Mode
{ {
static constexpr size_t KEYLEN
{
24 // 23+1 for \0
};
unsigned int mode; unsigned int mode;
int limit; int limit;
char key[KEYLEN]; char key[KEYLEN];

View file

@ -34,83 +34,76 @@
* Don't change these - edit the conf file instead. * Don't change these - edit the conf file instead.
*/ */
#ifdef __cplusplus #ifdef __cplusplus
inline namespace ircd { namespace ircd {
inline namespace defaults { inline namespace defaults {
enum general constexpr auto CLIENT_FLOOD_DEFAULT = 20; // default for client_flood
{ constexpr auto CLIENT_FLOOD_MAX = 2000;
CLIENT_FLOOD_DEFAULT = 20, // default for client_flood constexpr auto CLIENT_FLOOD_MIN = 10;
CLIENT_FLOOD_MAX = 2000, constexpr auto LINKS_DELAY_DEFAULT = 300;
CLIENT_FLOOD_MIN = 10, constexpr auto MAX_TARGETS_DEFAULT = 4; // default for max_targets */
LINKS_DELAY_DEFAULT = 300, constexpr auto IDENT_TIMEOUT_DEFAULT = 5;
MAX_TARGETS_DEFAULT = 4, // default for max_targets */ constexpr auto BLACKLIST_TIMEOUT_DEFAULT = 10;
IDENT_TIMEOUT_DEFAULT = 5, constexpr auto OPM_TIMEOUT_DEFAULT = 10;
BLACKLIST_TIMEOUT_DEFAULT = 10, constexpr auto RDNS_TIMEOUT_DEFAULT = 5;
OPM_TIMEOUT_DEFAULT = 10, constexpr auto MIN_JOIN_LEAVE_TIME = 60;
RDNS_TIMEOUT_DEFAULT = 5, constexpr auto MAX_JOIN_LEAVE_COUNT = 25;
MIN_JOIN_LEAVE_TIME = 60, constexpr auto OPER_SPAM_COUNTDOWN = 5;
MAX_JOIN_LEAVE_COUNT = 25, constexpr auto JOIN_LEAVE_COUNT_EXPIRE_TIME = 120;
OPER_SPAM_COUNTDOWN = 5, constexpr auto MIN_SPAM_NUM = 5;
JOIN_LEAVE_COUNT_EXPIRE_TIME = 120, constexpr auto MIN_SPAM_TIME = 60;
MIN_SPAM_NUM = 5, constexpr auto HOSTLEN = 63; // Length of hostname.
MIN_SPAM_TIME = 60,
HOSTLEN = 63, // Length of hostname.
};
enum iline constexpr auto DEFAULT_SENDQ = 20000000; // default max SendQ
{ constexpr auto PORTNUM = 6667; // default outgoing portnum
DEFAULT_SENDQ = 20000000, // default max SendQ constexpr auto DEFAULT_PINGFREQUENCY = 120; // Default ping frequency
PORTNUM = 6667, // default outgoing portnum constexpr auto DEFAULT_CONNECTFREQUENCY = 600; // Default connect frequency
DEFAULT_PINGFREQUENCY = 120, // Default ping frequency constexpr auto TS_MAX_DELTA_MIN = 10; // min value for ts_max_delta
DEFAULT_CONNECTFREQUENCY = 600, // Default connect frequency constexpr auto TS_MAX_DELTA_DEFAULT = 600; // default for ts_max_delta
TS_MAX_DELTA_MIN = 10, // min value for ts_max_delta constexpr auto TS_WARN_DELTA_MIN = 10; // min value for ts_warn_delta
TS_MAX_DELTA_DEFAULT = 600, // default for ts_max_delta constexpr auto TS_WARN_DELTA_DEFAULT = 30; // default for ts_warn_delta
TS_WARN_DELTA_MIN = 10, // min value for ts_warn_delta
TS_WARN_DELTA_DEFAULT = 30, // default for ts_warn_delta constexpr auto IRCD_RES_HOSTLEN = 255; // Longest hostname we're willing to work with due to DNSBLs this is more than HOSTLEN.
}; constexpr auto USERLEN = 10;
constexpr auto REALLEN = 50; // real name max length
constexpr auto CHANNELLEN = 200;
constexpr auto LOC_CHANNELLEN = 50;
enum len
{
IRCD_RES_HOSTLEN = 255, // Longest hostname we're willing to work with due to DNSBLs this is more than HOSTLEN.
USERLEN = 10,
REALLEN = 50,
CHANNELLEN = 200,
LOC_CHANNELLEN = 50,
// reason length of klines, parts, quits etc // reason length of klines, parts, quits etc
/* for quit messages, note that a client exit server notice /* for quit messages, note that a client exit server notice
* :012345678901234567890123456789012345678901234567890123456789123 NOTICE * :*** Notice -- Client exiting: 012345678901234567 (0123456789@012345678901234567890123456789012345678901234567890123456789123) [] [1111:2222:3333:4444:5555:6666:7777:8888] * :012345678901234567890123456789012345678901234567890123456789123 NOTICE * :*** Notice -- Client exiting: 012345678901234567 (0123456789@012345678901234567890123456789012345678901234567890123456789123) [] [1111:2222:3333:4444:5555:6666:7777:8888]
* takes at most 246 bytes (including CRLF and '\0') and together with the * takes at most 246 bytes (including CRLF and '\0') and together with the
* quit reason should fit in 512 */ * quit reason should fit in 512 */
REASONLEN = 260, // kick/part/quit constexpr auto REASONLEN = 260; // kick/part/quit
BANREASONLEN = 390, // kline/dline constexpr auto BANREASONLEN = 390; // kline/dline
AWAYLEN = TOPICLEN, constexpr auto AWAYLEN = TOPICLEN;
KILLLEN = 200, // with Killed (nick ()) added this should fit in quit constexpr auto KILLLEN = 200; // with Killed (nick ()) added this should fit in quit
constexpr auto MAX_DATE_STRING = 32; // maximum string length for a date string
KEYLEN = 24, // 23+1 for \0 constexpr auto HELPLEN = 400;
OPERNICKLEN = (NICKLEN*2), // Length of OPERNICKs. constexpr auto OPERNICKLEN // Length of OPERNICKs.
{
USERHOST_REPLYLEN = (NICKLEN+HOSTLEN+USERLEN+5), NICKLEN * 2
MAX_DATE_STRING = 32, // maximum string length for a date string
HELPLEN = 400,
}; };
constexpr auto USERHOST_REPLYLEN
{
NICKLEN + HOSTLEN + USERLEN + 5
};
#define BUFSIZE 512 /* WARNING: *DONT* CHANGE THIS!!!! */ constexpr auto BUFSIZE = 512; // WARNING: *DONT* CHANGE THIS!!!!
#define MAXCONNECTIONS 65536 /* default max connections if getrlimit doesn't work */ constexpr auto MAXCONNECTIONS = 65536; // default max connections if getrlimit doesn't work
#define NETWORK_NAME_DEFAULT "DefaultNet" /* default for network_name */ constexpr auto NETWORK_NAME_DEFAULT = "DefaultNet"; // default for network_name
/* /*
* message return values * message return values
*/ */
#define CLIENT_EXITED -2 constexpr auto CLIENT_EXITED = -2;
#define CLIENT_PARSE_ERROR -1 constexpr auto CLIENT_PARSE_ERROR = -1;
#define CLIENT_OK 1 constexpr auto CLIENT_OK = 1;
/* Read buffer size */ constexpr auto READBUF_SIZE = 16384; // Read buffer size */
#define READBUF_SIZE 16384
/* Below are somewhat configurable settings (though it's probably a bad idea /* Below are somewhat configurable settings (though it's probably a bad idea
@ -126,20 +119,20 @@ enum len
* (HANGONRETRYDELAY). This latter has to be long enough that the * (HANGONRETRYDELAY). This latter has to be long enough that the
* other end of the connection has time to notice it broke too. * other end of the connection has time to notice it broke too.
*/ */
#define HANGONRETRYDELAY 60 /* Recommended value: 30-60 seconds */ constexpr auto HANGONRETRYDELAY = 60; /* Recommended value: 30-60 seconds */
#define HANGONGOODLINK 3600 /* Recommended value: 30-60 minutes */ constexpr auto HANGONGOODLINK = 3600; /* Recommended value: 30-60 minutes */
/* KILLCHASETIMELIMIT - /* KILLCHASETIMELIMIT -
* Max time from the nickname change that still causes KILL * Max time from the nickname change that still causes KILL
* automatically to switch for the current nick of that user. (seconds) * automatically to switch for the current nick of that user. (seconds)
*/ */
#define KILLCHASETIMELIMIT 90 /* Recommended value: 90 */ constexpr auto KILLCHASETIMELIMIT = 90; /* Recommended value: 90 */
/* MAX_BUFFER /* MAX_BUFFER
* The amount of fds to reserve for clients exempt from limits * The amount of fds to reserve for clients exempt from limits
* and dns lookups. * and dns lookups.
*/ */
#define MAX_BUFFER 60 constexpr auto MAX_BUFFER = 60;
/* /*
* Use SOMAXCONN if OS has it, otherwise use this value for the * Use SOMAXCONN if OS has it, otherwise use this value for the