From 45a1b02ec2ef4592adee0437f9f605bc764a835d Mon Sep 17 00:00:00 2001 From: codemastr Date: Mon, 17 Mar 2003 19:30:57 +0000 Subject: [PATCH] Added ban version {} --- Changes | 3 +++ include/dynconf.h | 2 ++ include/struct.h | 1 + src/s_conf.c | 8 ++++++++ src/s_user.c | 9 ++++++++- src/webtv.c | 18 ++++++++++++++++++ 6 files changed, 40 insertions(+), 1 deletion(-) diff --git a/Changes b/Changes index efbd0bae4..6cb22036f 100644 --- a/Changes +++ b/Changes @@ -1980,3 +1980,6 @@ seen. gmtime warning still there - Minor /die and /restart code cleanups - Added channel mode +M to 005 (#0000803) reported by jollino - Fixed a bug where +x would make hosts lowercase (#0000810) reported by rayman +- Implemented a ban version {} (bans users based on CTCP VERSION). It works by sending out + a CTCP VERSION when a user connects then checking the reply. If you don't use any + ban version{}'s then no version request is sent so users are not inconvenienced. diff --git a/include/dynconf.h b/include/dynconf.h index d8ba6a3a9..5e78be000 100644 --- a/include/dynconf.h +++ b/include/dynconf.h @@ -62,6 +62,7 @@ struct zConfiguration { unsigned fail_oper_warn:1; unsigned show_connect_info:1; unsigned dont_resolve:1; + unsigned use_ban_version:1; unsigned use_egd; long host_timeout; int host_retries; @@ -150,3 +151,4 @@ extern aConfiguration iConf; #ifdef THROTTLING #define THROTTLING_PERIOD iConf.throttle_period #endif +#define USE_BAN_VERSION iConf.use_ban_version diff --git a/include/struct.h b/include/struct.h index 662a244e0..6a5f00740 100644 --- a/include/struct.h +++ b/include/struct.h @@ -903,6 +903,7 @@ struct _configflag_tld #define CONF_BAN_SERVER 3 #define CONF_BAN_USER 4 #define CONF_BAN_REALNAME 5 +#define CONF_BAN_VERSION 6 #define CONF_BAN_TYPE_CONF 0 #define CONF_BAN_TYPE_AKILL 1 diff --git a/src/s_conf.c b/src/s_conf.c index 97adb3b8a..cbb7f23fc 100644 --- a/src/s_conf.c +++ b/src/s_conf.c @@ -1239,6 +1239,7 @@ void config_rehash() ConfigItem_help *help_ptr; ListStruct *next, *next2; + USE_BAN_VERSION = 0; /* clean out stuff that we don't use */ for (admin_ptr = conf_admin; admin_ptr; admin_ptr = (ConfigItem_admin *)next) { @@ -4650,6 +4651,11 @@ int _conf_ban(ConfigFile *conf, ConfigEntry *ce) ca->flag.type = CONF_BAN_USER; else if (!strcmp(ce->ce_vardata, "realname")) ca->flag.type = CONF_BAN_REALNAME; + else if (!strcmp(ce->ce_vardata, "version")) + { + ca->flag.type = CONF_BAN_VERSION; + tempiConf.use_ban_version = 1; + } else { int value; for (global_i = Hooks[HOOKTYPE_CONFIGRUN]; global_i; @@ -4691,6 +4697,8 @@ int _test_ban(ConfigFile *conf, ConfigEntry *ce) {} else if (!strcmp(ce->ce_vardata, "realname")) {} + else if (!strcmp(ce->ce_vardata, "version")) + {} else { int used = 0; diff --git a/src/s_user.c b/src/s_user.c index 1e9da4b09..b628415c9 100644 --- a/src/s_user.c +++ b/src/s_user.c @@ -1724,7 +1724,6 @@ CMD_FUNC(m_nick) me.name, nick, sptr->nospoof, sptr->nospoof); sendto_one(sptr, "PING :%X", sptr->nospoof); #endif /* NOSPOOF */ - #ifdef CONTACT_EMAIL sendto_one(sptr, ":%s NOTICE %s :*** If you need assistance with a" @@ -1762,11 +1761,15 @@ CMD_FUNC(m_nick) ** may reject the client and call exit_client for it ** --must test this and exit m_nick too!!! */ + if (USE_BAN_VERSION) + sendto_one(sptr, ":IRC PRIVMSG %s :\1VERSION\1", + nick); sptr->lastnick = TStime(); /* Always local client */ if (register_user(cptr, sptr, nick, sptr->user->username, NULL, NULL) == FLUSH_BUFFER) return FLUSH_BUFFER; update_watch = 0; + } } /* @@ -1978,6 +1981,10 @@ CMD_FUNC(m_user) if (sptr->name[0] && (IsServer(cptr) ? 1 : IsNotSpoof(sptr))) /* NICK and no-spoof already received, now we have USER... */ { + if (USE_BAN_VERSION) + sendto_one(sptr, ":IRC PRIVMSG %s :\1VERSION\1", + sptr->name); + return( register_user(cptr, sptr, sptr->name, username, umodex, virthost)); diff --git a/src/webtv.c b/src/webtv.c index 485211c52..382c018ef 100644 --- a/src/webtv.c +++ b/src/webtv.c @@ -49,10 +49,15 @@ struct zMessage { int w_whois(aClient *cptr, aClient *sptr, int parc, char *parv[]); +/* This really has nothing to do with WebTV yet, but eventually it will, so I figured + * it's easiest to put it here so why not? -- codemastr + */ +int ban_version(aClient *cptr, aClient *sptr, int parc, char *parv[]); aMessage webtv_cmds[] = { {"WHOIS", w_whois, 15}, + {"\1VERSION", ban_version, 1}, {NULL, 0, 15} }; @@ -380,3 +385,16 @@ int w_whois(aClient *cptr, aClient *sptr, int parc, char *parv[]) return 0; } +int ban_version(aClient *cptr, aClient *sptr, int parc, char *parv[]) +{ + int len; + ConfigItem_ban *ban; + if (parc < 2) + return 0; + len = strlen(parv[1]); + if (parv[1][len-1] == '\1') + parv[1][len-1] = '\0'; + if ((ban = Find_ban(parv[1], CONF_BAN_VERSION))) + return exit_client(cptr, sptr, sptr, ban->reason); + return 0; +}