From: sirvulcan Date: Mon, 31 Jul 2006 02:58:11 +0000 (+0000) Subject: Moved defcon gline check out to check_new_user and added a shun check also for defcon X-Git-Tag: 1.9~480 X-Git-Url: https://jfr.im/git/irc/evilnet/x3.git/commitdiff_plain/0272358ecd076f0c513b1bc45d97d06f9d45ba3a?hp=08895577a28fd6caf98febbb9b2d7827905595d8 Moved defcon gline check out to check_new_user and added a shun check also for defcon --- diff --git a/ChangeLog b/ChangeLog index 38ff49b..fee923e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,19 @@ /*********************************************************************** X3 ChangeLog +2006-07-31 Neil Spierling + + * x3.conf.example: Added SHUN setting for DEFCON. + + * doc/DEFCON: Added SHUN setting for DEFCON. + + * src/opserv.c: Moved the gline check to here. Also added a SHUN + check. + + * src/opserv.h: Added SHUN setting for DEFCON. + + * src/proto-p10.c: Moved the DEFCON gline check to opserv.c + 2006-07-31 Neil Spierling * x3.conf.example: Added new Defcon system settings diff --git a/docs/DEFCON b/docs/DEFCON index dfe55b9..9eb1b67 100644 --- a/docs/DEFCON +++ b/docs/DEFCON @@ -50,6 +50,7 @@ X3 DefCon Services will silently ignore everyone but opers 128 GLINE all new clients trying to connect 256 No new memos sent to block MemoServ attacks 512 + SHUN all new clients trying to connect 1024 These are the values used to determine each defcon setting, are set via: diff --git a/src/opserv.c b/src/opserv.c index 77c945d..e0a3c8e 100644 --- a/src/opserv.c +++ b/src/opserv.c @@ -390,6 +390,7 @@ static const struct message_entry msgtab[] = { { "OSMSG_DEFCON_OPER_ONLY", "Allowing Services Communication With Opers Only" }, { "OSMSG_DEFCON_SILENT_OPER_ONLY", "Allowing Services Communication With Opers Only AND Silently Ignoring Regular Users" }, { "OSMSG_DEFCON_GLINE_NEW_CLIENTS", "Glining New Clients" }, + { "OSMSG_DEFCON_SHUN_NEW_CLIENTS", "Shunning New Clients" }, { "OSMSG_DEFCON_NO_NEW_MEMOS", "Disallowing New Memos" }, { NULL, NULL } @@ -630,6 +631,9 @@ void showDefConSettings(struct userNode *user, struct svccmd *cmd) if (checkDefCon(DEFCON_GLINE_NEW_CLIENTS)) reply("OSMSG_DEFCON_GLINE_NEW_CLIENTS"); + if (checkDefCon(DEFCON_SHUN_NEW_CLIENTS)) + reply("OSMSG_DEFCON_SHUN_NEW_CLIENTS"); + if (checkDefCon(DEFCON_NO_NEW_MEMOS)) reply("OSMSG_DEFCON_NO_NEW_MEMOS"); @@ -2392,6 +2396,18 @@ opserv_new_user_check(struct userNode *user) return 0; } + if ( (checkDefCon(DEFCON_GLINE_NEW_CLIENTS) || checkDefCon(DEFCON_SHUN_NEW_CLIENTS)) && !IsOper(user)) { + char target[IRC_NTOP_MAX_SIZE + 3] = { '*', '@', '\0' }; + + strcpy(target + 2, user->hostname); + if (checkDefCon(DEFCON_GLINE_NEW_CLIENTS)) + gline_add(opserv->nick, target, DefConGlineExpire, DefConGlineReason, now, 1, 0); + else if (checkDefCon(DEFCON_SHUN_NEW_CLIENTS)) + shun_add(opserv->nick, target, DefConGlineExpire, DefConGlineReason, now, 1); + + return 0; + } + /* Only warn or G-line if there's an untrusted max and their IP is sane. */ if (opserv_conf.untrusted_max && irc_in_addr_is_valid(user->ip) diff --git a/src/opserv.h b/src/opserv.h index d78db9c..3847f62 100644 --- a/src/opserv.h +++ b/src/opserv.h @@ -23,7 +23,7 @@ #define DEFCON_NO_NEW_CHANNELS 1 /* No New Channel Registrations */ #define DEFCON_NO_NEW_NICKS 2 /* No New Nick Registrations */ -#define DEFCON_NO_MODE_CHANGE 4 /* No SET MODE changes */ +#define DEFCON_NO_MODE_CHANGE 4 /* No channel MODE changes */ #define DEFCON_FORCE_CHAN_MODES 8 /* Force Chan Mode */ #define DEFCON_REDUCE_SESSION 16 /* Reduce Session Limit */ #define DEFCON_NO_NEW_CLIENTS 32 /* Kill any NEW clients */ @@ -31,11 +31,13 @@ #define DEFCON_SILENT_OPER_ONLY 128 /* Silently ignore non-opers */ #define DEFCON_GLINE_NEW_CLIENTS 256 /* Gline any new clients */ #define DEFCON_NO_NEW_MEMOS 512 /* No New Memos Sent */ +#define DEFCON_SHUN_NEW_CLIENTS 1024 /* Shun any new clients */ extern int DefCon[6]; extern int checkDefCon(int level); extern void DefConProcess(struct userNode *user); extern void defcon_timeout(UNUSED_ARG(void *data)); + void init_opserv(const char *nick); unsigned int gag_create(const char *mask, const char *owner, const char *reason, time_t expires); int opserv_bad_channel(const char *name); diff --git a/src/proto-p10.c b/src/proto-p10.c index 7756798..edf23c7 100644 --- a/src/proto-p10.c +++ b/src/proto-p10.c @@ -320,10 +320,8 @@ static struct userNode *AddUser(struct server* uplink, const char *nick, const c extern int off_channel; extern int DefConLevel; -extern int DefConGlineExpire; extern int DefConTimeOut; extern char *DefConChanModes; -extern char *DefConGlineReason; static int parse_oplevel(char *str); @@ -1319,17 +1317,6 @@ static CMD_FUNC(cmd_nick) else strcpy(modes, "+"); nuser = AddUser(serv, argv[1], argv[4], argv[5], modes, argv[argc-2], argv[argc-1], atoi(argv[3]), argv[argc-3]); - if (checkDefCon(DEFCON_GLINE_NEW_CLIENTS) && !IsOper(nuser)) { - char target[IRC_NTOP_MAX_SIZE + 3] = { '*', '@', '\0' }; - const char *str; - - str = conf_get_data("services/opserv/nick", RECDB_QSTRING); - if (str) { - strcpy(target + 2, nuser->hostname); - gline_add(str, target, DefConGlineExpire, DefConGlineReason, now, 1, 0); - } - return 0; - } } return 1; } diff --git a/x3.conf.example b/x3.conf.example index 77a3c9d..fbba289 100644 --- a/x3.conf.example +++ b/x3.conf.example @@ -283,6 +283,7 @@ // Services will silently ignore everyone but opers 128 // GLINE all new clients trying to connect 256 // No new memos sent to block MemoServ attacks 512 + // SHUN all new clients trying to connect 1024 // // These are the values are added together to determine each defcon setting: "DefCon1" "415"; @@ -296,8 +297,8 @@ // If defcon is limiting sessions then how many sessions should O3 allow? "DefConSessionLimit" "2"; - // Length of the gline set on newly connecting clients, if defcon is glining - // newly connecting clients + // Length of glines and shuns set on newly connecting clients, if defcon is glining + // or shunning newly connecting clients "DefConGlineExpire" "5m"; // Mode to set on all channels if defcon is forcing channel modes on all channels @@ -325,7 +326,7 @@ // This notice will be used if GlobalOnDefcon and GlobalOnDefconMore are off "DefConOffMessage" "Services are now back to normal, sorry for any inconvenience"; - // Reason placed in defcon Glines. + // Reason placed in defcon Glines and Shuns. "DefConGlineReason" "This network is currently not accepting connections, please try again later"; // ------------------------------------------------------------------