Add class::max_autoconn configuration

This commit is contained in:
Ed Kellett 2020-10-11 14:54:24 +01:00
parent a7bd528f61
commit 7c7065b07e
4 changed files with 12 additions and 3 deletions

View file

@ -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;

View file

@ -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)

View file

@ -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 }
};

View file

@ -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;