From 2d6562846fb5f0b4179604d1334c6f288e0623ef Mon Sep 17 00:00:00 2001 From: Stephen Bennett Date: Tue, 12 Jan 2010 21:32:18 +0000 Subject: [PATCH 1/3] Initial attempt at the conndelay hack --- include/s_conf.h | 1 + ircd/newconf.c | 1 + ircd/packet.c | 6 ++++++ modules/m_info.c | 6 ++++++ 4 files changed, 14 insertions(+) diff --git a/include/s_conf.h b/include/s_conf.h index 703f4eac..1e9e6b55 100644 --- a/include/s_conf.h +++ b/include/s_conf.h @@ -215,6 +215,7 @@ struct config_file_entry int tkline_expire_notices; int use_whois_actually; int disable_auth; + int connect_delay; int connect_timeout; int burst_away; int reject_ban_time; diff --git a/ircd/newconf.c b/ircd/newconf.c index 6a81208d..00a2642e 100644 --- a/ircd/newconf.c +++ b/ircd/newconf.c @@ -2748,6 +2748,7 @@ static struct ConfEntry conf_general_table[] = { "client_exit", CF_YESNO, NULL, 0, &ConfigFileEntry.client_exit }, { "collision_fnc", CF_YESNO, NULL, 0, &ConfigFileEntry.collision_fnc }, { "resv_fnc", CF_YESNO, NULL, 0, &ConfigFileEntry.resv_fnc }, + { "connect_delay", CF_TIME, NULL, 0, &ConfigFileEntry.connect_delay }, { "connect_timeout", CF_TIME, NULL, 0, &ConfigFileEntry.connect_timeout }, { "default_floodcount", CF_INT, NULL, 0, &ConfigFileEntry.default_floodcount }, { "default_ident_timeout", CF_INT, NULL, 0, &ConfigFileEntry.default_ident_timeout }, diff --git a/ircd/packet.c b/ircd/packet.c index 3eb038ad..9d5bc3a0 100644 --- a/ircd/packet.c +++ b/ircd/packet.c @@ -133,6 +133,12 @@ parse_client_queued(struct Client *client_p) if(client_p->localClient->sent_parsed >= allow_read) break; + /* connect_delay hack. Don't process any messages from a new client for $n seconds, + * to allow network bots to do their thing before channels can be joined. + */ + if (rb_current_time() < client_p->localClient->firsttime + ConfigFileEntry.connect_delay) + break; + dolen = rb_linebuf_get(&client_p->localClient-> buf_recvq, readBuf, READBUF_SIZE, LINEBUF_COMPLETE, LINEBUF_PARSED); diff --git a/modules/m_info.c b/modules/m_info.c index 0f08d04d..8f036012 100644 --- a/modules/m_info.c +++ b/modules/m_info.c @@ -151,6 +151,12 @@ static struct InfoStruct info_table[] = { &ConfigFileEntry.client_flood_message_time, "Time to allow per client_flood_message_num outside of burst", }, + { + "connect_delay", + OUTPUT_DECIMAL, + &ConfigFileEntry.connect_delay, + "Time to wait before processing commands from a new client", + }, { "connect_timeout", OUTPUT_DECIMAL, From 1bb79643784af4d61756e76ed60c6972b0148a93 Mon Sep 17 00:00:00 2001 From: Stephen Bennett Date: Wed, 13 Jan 2010 13:52:28 +0000 Subject: [PATCH 2/3] Add connect_delay to example and reference configs --- doc/ircd.conf.example | 1 + doc/reference.conf | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/doc/ircd.conf.example b/doc/ircd.conf.example index 928cbc44..d3fb1c83 100644 --- a/doc/ircd.conf.example +++ b/doc/ircd.conf.example @@ -603,6 +603,7 @@ general { pace_wait = 10 seconds; short_motd = no; ping_cookie = no; + connect_delay = 0 seconds; connect_timeout = 30 seconds; default_ident_timeout = 5; disable_auth = no; diff --git a/doc/reference.conf b/doc/reference.conf index 98f20931..4cba21fa 100644 --- a/doc/reference.conf +++ b/doc/reference.conf @@ -1288,6 +1288,12 @@ general { */ ping_cookie = no; + /* connect delay: wait this long before processing commands from a newly + * registered user. Used to allow network utility bots to perform any actions + * (such as host changes or proxy scanning) before the user can join channels. + */ + connect_delay = 2 seconds; + /* connect timeout: sets how long we should wait for a connection * request to succeed */ From b3a0099139b1a069ef1cbd84b285eb8145c13bfb Mon Sep 17 00:00:00 2001 From: Stephen Bennett Date: Wed, 13 Jan 2010 23:54:49 +0000 Subject: [PATCH 3/3] Rename connect_delay to post_registration_delay. This matches the ircd-ratbox feature, and better describes what it actually is. Also make sure to set localClient->firsttime on registration, so that the delay counts from the right time. --- doc/ircd.conf.example | 2 +- doc/reference.conf | 12 ++++++------ include/s_conf.h | 2 +- ircd/newconf.c | 2 +- ircd/packet.c | 4 ++-- ircd/s_user.c | 4 +++- modules/m_info.c | 4 ++-- 7 files changed, 16 insertions(+), 14 deletions(-) diff --git a/doc/ircd.conf.example b/doc/ircd.conf.example index d3fb1c83..dbe97c2b 100644 --- a/doc/ircd.conf.example +++ b/doc/ircd.conf.example @@ -603,13 +603,13 @@ general { pace_wait = 10 seconds; short_motd = no; ping_cookie = no; - connect_delay = 0 seconds; connect_timeout = 30 seconds; default_ident_timeout = 5; disable_auth = no; no_oper_flood = yes; max_targets = 4; client_flood_max_lines = 20; + post_registration_delay = 0 seconds; use_whois_actually = no; oper_only_umodes = operwall, locops, servnotice; oper_umodes = locops, servnotice, operwall, wallop; diff --git a/doc/reference.conf b/doc/reference.conf index 4cba21fa..72af5182 100644 --- a/doc/reference.conf +++ b/doc/reference.conf @@ -1288,12 +1288,6 @@ general { */ ping_cookie = no; - /* connect delay: wait this long before processing commands from a newly - * registered user. Used to allow network utility bots to perform any actions - * (such as host changes or proxy scanning) before the user can join channels. - */ - connect_delay = 2 seconds; - /* connect timeout: sets how long we should wait for a connection * request to succeed */ @@ -1318,6 +1312,12 @@ general { */ max_targets = 4; + /* post-registration delay: wait this long before processing commands from a newly + * registered user. Used to allow network utility bots to perform any actions + * (such as host changes or proxy scanning) before the user can join channels. + */ + post_registration_delay = 2 seconds; + /* use_whois_actually: send clients requesting a whois a numeric * giving the real IP of non-spoofed clients to prevent DNS abuse. */ diff --git a/include/s_conf.h b/include/s_conf.h index 1e9e6b55..fec5c8a8 100644 --- a/include/s_conf.h +++ b/include/s_conf.h @@ -215,7 +215,7 @@ struct config_file_entry int tkline_expire_notices; int use_whois_actually; int disable_auth; - int connect_delay; + int post_registration_delay; int connect_timeout; int burst_away; int reject_ban_time; diff --git a/ircd/newconf.c b/ircd/newconf.c index 00a2642e..7a540606 100644 --- a/ircd/newconf.c +++ b/ircd/newconf.c @@ -2748,7 +2748,7 @@ static struct ConfEntry conf_general_table[] = { "client_exit", CF_YESNO, NULL, 0, &ConfigFileEntry.client_exit }, { "collision_fnc", CF_YESNO, NULL, 0, &ConfigFileEntry.collision_fnc }, { "resv_fnc", CF_YESNO, NULL, 0, &ConfigFileEntry.resv_fnc }, - { "connect_delay", CF_TIME, NULL, 0, &ConfigFileEntry.connect_delay }, + { "post_registration_delay", CF_TIME, NULL, 0, &ConfigFileEntry.post_registration_delay }, { "connect_timeout", CF_TIME, NULL, 0, &ConfigFileEntry.connect_timeout }, { "default_floodcount", CF_INT, NULL, 0, &ConfigFileEntry.default_floodcount }, { "default_ident_timeout", CF_INT, NULL, 0, &ConfigFileEntry.default_ident_timeout }, diff --git a/ircd/packet.c b/ircd/packet.c index 9d5bc3a0..502d5344 100644 --- a/ircd/packet.c +++ b/ircd/packet.c @@ -133,10 +133,10 @@ parse_client_queued(struct Client *client_p) if(client_p->localClient->sent_parsed >= allow_read) break; - /* connect_delay hack. Don't process any messages from a new client for $n seconds, + /* post_registration_delay hack. Don't process any messages from a new client for $n seconds, * to allow network bots to do their thing before channels can be joined. */ - if (rb_current_time() < client_p->localClient->firsttime + ConfigFileEntry.connect_delay) + if (rb_current_time() < client_p->localClient->firsttime + ConfigFileEntry.post_registration_delay) break; dolen = rb_linebuf_get(&client_p->localClient-> diff --git a/ircd/s_user.c b/ircd/s_user.c index daba26ec..06d3b6cb 100644 --- a/ircd/s_user.c +++ b/ircd/s_user.c @@ -386,7 +386,9 @@ register_local_user(struct Client *client_p, struct Client *source_p) if(source_p->preClient->auth.cid) return -1; - client_p->localClient->last = rb_current_time(); + /* Set firsttime here so that post_registration_delay works from registration, + * rather than initial connection. */ + source_p->localClient->firsttime = client_p->localClient->last = rb_current_time(); /* XXX - fixme. we shouldnt have to build a users buffer twice.. */ if(!IsGotId(source_p) && (strchr(source_p->username, '[') != NULL)) diff --git a/modules/m_info.c b/modules/m_info.c index 8f036012..d3c8e8c0 100644 --- a/modules/m_info.c +++ b/modules/m_info.c @@ -152,9 +152,9 @@ static struct InfoStruct info_table[] = { "Time to allow per client_flood_message_num outside of burst", }, { - "connect_delay", + "post_registration_delay", OUTPUT_DECIMAL, - &ConfigFileEntry.connect_delay, + &ConfigFileEntry.post_registration_delay, "Time to wait before processing commands from a new client", }, {