0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-09-27 19:28:52 +02: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 "rsdb.h"
#include <ircd/defaults.h>
#include <ircd/defaults.h>
using namespace ircd;
#define MAXPARA 10

View file

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

View file

@ -34,83 +34,76 @@
* Don't change these - edit the conf file instead.
*/
#ifdef __cplusplus
inline namespace ircd {
namespace ircd {
inline namespace defaults {
enum general
constexpr auto CLIENT_FLOOD_DEFAULT = 20; // default for client_flood
constexpr auto CLIENT_FLOOD_MAX = 2000;
constexpr auto CLIENT_FLOOD_MIN = 10;
constexpr auto LINKS_DELAY_DEFAULT = 300;
constexpr auto MAX_TARGETS_DEFAULT = 4; // default for max_targets */
constexpr auto IDENT_TIMEOUT_DEFAULT = 5;
constexpr auto BLACKLIST_TIMEOUT_DEFAULT = 10;
constexpr auto OPM_TIMEOUT_DEFAULT = 10;
constexpr auto RDNS_TIMEOUT_DEFAULT = 5;
constexpr auto MIN_JOIN_LEAVE_TIME = 60;
constexpr auto MAX_JOIN_LEAVE_COUNT = 25;
constexpr auto OPER_SPAM_COUNTDOWN = 5;
constexpr auto JOIN_LEAVE_COUNT_EXPIRE_TIME = 120;
constexpr auto MIN_SPAM_NUM = 5;
constexpr auto MIN_SPAM_TIME = 60;
constexpr auto HOSTLEN = 63; // Length of hostname.
constexpr auto DEFAULT_SENDQ = 20000000; // default max SendQ
constexpr auto PORTNUM = 6667; // default outgoing portnum
constexpr auto DEFAULT_PINGFREQUENCY = 120; // Default ping frequency
constexpr auto DEFAULT_CONNECTFREQUENCY = 600; // Default connect frequency
constexpr auto TS_MAX_DELTA_MIN = 10; // min value for ts_max_delta
constexpr auto TS_MAX_DELTA_DEFAULT = 600; // default for ts_max_delta
constexpr auto TS_WARN_DELTA_MIN = 10; // min value for ts_warn_delta
constexpr auto 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;
// reason length of klines, parts, quits etc
/* 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]
* takes at most 246 bytes (including CRLF and '\0') and together with the
* quit reason should fit in 512 */
constexpr auto REASONLEN = 260; // kick/part/quit
constexpr auto BANREASONLEN = 390; // kline/dline
constexpr auto AWAYLEN = TOPICLEN;
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
constexpr auto HELPLEN = 400;
constexpr auto OPERNICKLEN // Length of OPERNICKs.
{
CLIENT_FLOOD_DEFAULT = 20, // default for client_flood
CLIENT_FLOOD_MAX = 2000,
CLIENT_FLOOD_MIN = 10,
LINKS_DELAY_DEFAULT = 300,
MAX_TARGETS_DEFAULT = 4, // default for max_targets */
IDENT_TIMEOUT_DEFAULT = 5,
BLACKLIST_TIMEOUT_DEFAULT = 10,
OPM_TIMEOUT_DEFAULT = 10,
RDNS_TIMEOUT_DEFAULT = 5,
MIN_JOIN_LEAVE_TIME = 60,
MAX_JOIN_LEAVE_COUNT = 25,
OPER_SPAM_COUNTDOWN = 5,
JOIN_LEAVE_COUNT_EXPIRE_TIME = 120,
MIN_SPAM_NUM = 5,
MIN_SPAM_TIME = 60,
HOSTLEN = 63, // Length of hostname.
NICKLEN * 2
};
enum iline
constexpr auto USERHOST_REPLYLEN
{
DEFAULT_SENDQ = 20000000, // default max SendQ
PORTNUM = 6667, // default outgoing portnum
DEFAULT_PINGFREQUENCY = 120, // Default ping frequency
DEFAULT_CONNECTFREQUENCY = 600, // Default connect frequency
TS_MAX_DELTA_MIN = 10, // min value for ts_max_delta
TS_MAX_DELTA_DEFAULT = 600, // default for ts_max_delta
TS_WARN_DELTA_MIN = 10, // min value for ts_warn_delta
TS_WARN_DELTA_DEFAULT = 30, // default for ts_warn_delta
NICKLEN + HOSTLEN + USERLEN + 5
};
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
/* 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]
* takes at most 246 bytes (including CRLF and '\0') and together with the
* quit reason should fit in 512 */
REASONLEN = 260, // kick/part/quit
BANREASONLEN = 390, // kline/dline
AWAYLEN = TOPICLEN,
KILLLEN = 200, // with Killed (nick ()) added this should fit in quit
KEYLEN = 24, // 23+1 for \0
OPERNICKLEN = (NICKLEN*2), // Length of OPERNICKs.
USERHOST_REPLYLEN = (NICKLEN+HOSTLEN+USERLEN+5),
MAX_DATE_STRING = 32, // maximum string length for a date string
HELPLEN = 400,
};
#define BUFSIZE 512 /* WARNING: *DONT* CHANGE THIS!!!! */
#define MAXCONNECTIONS 65536 /* default max connections if getrlimit doesn't work */
#define NETWORK_NAME_DEFAULT "DefaultNet" /* default for network_name */
constexpr auto BUFSIZE = 512; // WARNING: *DONT* CHANGE THIS!!!!
constexpr auto MAXCONNECTIONS = 65536; // default max connections if getrlimit doesn't work
constexpr auto NETWORK_NAME_DEFAULT = "DefaultNet"; // default for network_name
/*
* message return values
*/
#define CLIENT_EXITED -2
#define CLIENT_PARSE_ERROR -1
#define CLIENT_OK 1
constexpr auto CLIENT_EXITED = -2;
constexpr auto CLIENT_PARSE_ERROR = -1;
constexpr auto CLIENT_OK = 1;
/* Read buffer size */
#define READBUF_SIZE 16384
constexpr auto READBUF_SIZE = 16384; // Read buffer size */
/* 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
* other end of the connection has time to notice it broke too.
*/
#define HANGONRETRYDELAY 60 /* Recommended value: 30-60 seconds */
#define HANGONGOODLINK 3600 /* Recommended value: 30-60 minutes */
constexpr auto HANGONRETRYDELAY = 60; /* Recommended value: 30-60 seconds */
constexpr auto HANGONGOODLINK = 3600; /* Recommended value: 30-60 minutes */
/* KILLCHASETIMELIMIT -
* Max time from the nickname change that still causes KILL
* 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
* The amount of fds to reserve for clients exempt from limits
* and dns lookups.
*/
#define MAX_BUFFER 60
constexpr auto MAX_BUFFER = 60;
/*
* Use SOMAXCONN if OS has it, otherwise use this value for the