From 7c7065b07eb66fd78a25305bf8872823558af90e Mon Sep 17 00:00:00 2001 From: Ed Kellett Date: Sun, 11 Oct 2020 14:54:24 +0100 Subject: [PATCH] Add class::max_autoconn configuration --- doc/reference.conf | 4 ++-- include/class.h | 2 ++ ircd/newconf.c | 7 +++++++ ircd/s_serv.c | 2 +- 4 files changed, 12 insertions(+), 3 deletions(-) diff --git a/doc/reference.conf b/doc/reference.conf index 91bbe113..ee66aec6 100644 --- a/doc/reference.conf +++ b/doc/reference.conf @@ -290,14 +290,14 @@ class "server" { */ connectfreq = 5 minutes; - /* max number: the amount of servers to autoconnect to. if the number + /* max_autoconn: the amount of servers to autoconnect to. if the number * of servers in the class is or exceeds this, no more servers in the * class are autoconnected. oper initiated connects are unaffected. * this should usually be set to either 0 or 1. (autoconnecting from * hubs to leaves may cause leaves to function as hubs by having * multiple servers connected to them.) */ - max_number = 1; + max_autoconn = 1; /* sendq: servers need a higher sendq as they are sent more data */ sendq = 2 megabytes; diff --git a/include/class.h b/include/class.h index 9a1ab251..0c6ca44f 100644 --- a/include/class.h +++ b/include/class.h @@ -34,6 +34,7 @@ struct Class struct Class *next; char *class_name; int max_total; + int max_autoconn; int max_local; int max_global; int max_ident; @@ -57,6 +58,7 @@ extern struct Class *default_class; #define MaxGlobal(x) ((x)->max_global) #define MaxIdent(x) ((x)->max_ident) #define MaxUsers(x) ((x)->max_total) +#define MaxAutoconn(x) ((x)->max_autoconn) #define PingFreq(x) ((x)->ping_freq) #define MaxSendq(x) ((x)->max_sendq) #define CurrUsers(x) ((x)->total) diff --git a/ircd/newconf.c b/ircd/newconf.c index cff557fc..5b03cd38 100644 --- a/ircd/newconf.c +++ b/ircd/newconf.c @@ -825,6 +825,12 @@ conf_set_class_max_number(void *data) yy_class->max_total = *(unsigned int *) data; } +static void +conf_set_class_max_autoconn(void *data) +{ + yy_class->max_autoconn = *(unsigned int *) data; +} + static void conf_set_class_sendq(void *data) { @@ -2689,6 +2695,7 @@ static struct ConfEntry conf_class_table[] = { "number_per_ident", CF_INT, conf_set_class_number_per_ident, 0, NULL }, { "connectfreq", CF_TIME, conf_set_class_connectfreq, 0, NULL }, { "max_number", CF_INT, conf_set_class_max_number, 0, NULL }, + { "max_autoconn", CF_INT, conf_set_class_max_autoconn, 0, NULL }, { "sendq", CF_TIME, conf_set_class_sendq, 0, NULL }, { "\0", 0, NULL, 0, NULL } }; diff --git a/ircd/s_serv.c b/ircd/s_serv.c index a001cd16..f4003260 100644 --- a/ircd/s_serv.c +++ b/ircd/s_serv.c @@ -297,7 +297,7 @@ try_connections(void *unused) */ client_p = find_server(NULL, tmp_p->name); - if(!client_p && (CurrUsers(cltmp) < MaxUsers(cltmp)) && !connecting) + if(!client_p && (CurrUsers(cltmp) < MaxAutoconn(cltmp)) && !connecting) { server_p = tmp_p;