-
-
Notifications
You must be signed in to change notification settings - Fork 95
Extban support #1880
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Extban support #1880
Changes from all commits
c2f6f79
e8e4968
61e2e4b
7551ae2
41f6111
91d20a8
a96f4bd
b9d2c56
cc33713
014349b
4c8d324
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,7 +22,7 @@ | |
|
|
||
| static struct flag_record user = { FR_GLOBAL | FR_CHAN, 0, 0, 0, 0, 0 }; | ||
| static struct flag_record victim = { FR_GLOBAL | FR_CHAN, 0, 0, 0, 0, 0 }; | ||
|
|
||
| int extban_parse(const char *mask, char *type, const char **arg); | ||
|
|
||
| /* RFC 1035/2812- hostmasks can't be longer than 63 characters */ | ||
| static void truncate_mask_hostname(char *s) { | ||
|
|
@@ -41,6 +41,10 @@ static void truncate_mask_hostname(char *s) { | |
| static void cmd_pls_ban(struct userrec *u, int idx, char *par) | ||
| { | ||
| char *chname, *who, s[UHOSTLEN], s1[UHOSTLEN], *p, *p_expire; | ||
| char extbanflag = 0, account_extban_flag = 0; | ||
| int extban_enabled = 1; | ||
| int extban_default_sticky = 0; | ||
| const char *value, *comma, *types, *extbanargs; | ||
| long expire_foo; | ||
| unsigned long expire_time = 0; | ||
| int sticky = 0; | ||
|
|
@@ -121,32 +125,56 @@ static void cmd_pls_ban(struct userrec *u, int idx, char *par) | |
| par[MASKREASON_MAX] = 0; | ||
| if (strlen(who) > UHOSTMAX - 4) | ||
| who[UHOSTMAX - 4] = 0; | ||
| /* Fix missing ! or @ BEFORE checking against myself */ | ||
| if (!strchr(who, '!')) { | ||
| if (!strchr(who, '@')) | ||
| egg_snprintf(s, sizeof s, "%s!*@*", who); /* Lame nick ban */ | ||
| else | ||
| egg_snprintf(s, sizeof s, "*!%s", who); | ||
| } else if (!strchr(who, '@')) | ||
| egg_snprintf(s, sizeof s, "%s@*", who); /* brain-dead? */ | ||
| else | ||
| if (is_extban_mask(who)) { | ||
| strlcpy(s, who, sizeof s); | ||
| if ((me = module_find("server", 0, 0)) && me->funcs) { | ||
| egg_snprintf(s1, sizeof s1, "%s!%s", me->funcs[SERVER_BOTNAME], | ||
| me->funcs[SERVER_BOTUSERHOST]); | ||
| if (match_addr(s, s1)) { | ||
| dprintf(idx, "I'm not going to ban myself.\n"); | ||
| putlog(LOG_CMDS, "*", "#%s# attempted +ban %s", dcc[idx].nick, s); | ||
| return; | ||
| /* If its an extban, check if it needs to be set as a sticky ban */ | ||
| if (extban_parse(s, &extbanflag, &extbanargs)) { | ||
| const char *account_extban; | ||
|
|
||
| account_extban = isupport_get("ACCOUNTEXTBAN", strlen("ACCOUNTEXTBAN")); | ||
| if (account_extban && account_extban[0]) | ||
| account_extban_flag = account_extban[0]; | ||
| extban_default_sticky = !extban_is_enforceable_flag(extbanflag, account_extban_flag); | ||
| if (extban_default_sticky) | ||
| sticky = 1; | ||
| value = isupport_get("EXTBAN", strlen("EXTBAN")); | ||
| if (value && value[0]) { | ||
| comma = strchr(value, ','); | ||
| types = comma ? comma + 1 : value; | ||
| extban_enabled = strchr(types, extbanflag) ? 1 : 0; | ||
| } else { | ||
| extban_enabled = 0; | ||
| } | ||
| } | ||
| } else { | ||
| /* Fix missing ! or @ BEFORE checking against myself */ | ||
| if (!strchr(who, '!')) { | ||
| if (!strchr(who, '@')) | ||
| egg_snprintf(s, sizeof s, "%s!*@*", who); /* Lame nick ban */ | ||
| else | ||
| egg_snprintf(s, sizeof s, "*!%s", who); | ||
| } else if (!strchr(who, '@')) | ||
| egg_snprintf(s, sizeof s, "%s@*", who); /* brain-dead? */ | ||
| else | ||
| strlcpy(s, who, sizeof s); | ||
| if ((me = module_find("server", 0, 0)) && me->funcs) { | ||
| egg_snprintf(s1, sizeof s1, "%s!%s", me->funcs[SERVER_BOTNAME], | ||
| me->funcs[SERVER_BOTUSERHOST]); | ||
| if (match_addr(s, s1)) { | ||
| dprintf(idx, "I'm not going to ban myself.\n"); | ||
| putlog(LOG_CMDS, "*", "#%s# attempted +ban %s", dcc[idx].nick, s); | ||
| return; | ||
| } | ||
| } | ||
| truncate_mask_hostname(s); | ||
| } | ||
| truncate_mask_hostname(s); | ||
| if (chan) { | ||
| u_addban(chan, s, dcc[idx].nick, par, | ||
| expire_time ? now + expire_time : 0, 0); | ||
| if (par[0] == '*') { | ||
| if (par[0] == '*' || extban_default_sticky) { | ||
| sticky = 1; | ||
| par++; | ||
| if (par[0] == '*') | ||
| par++; | ||
| putlog(LOG_CMDS, "*", "#%s# (%s) +ban %s %s (%s) (sticky)", | ||
| dcc[idx].nick, dcc[idx].u.chat->con_chan, s, chan->dname, par); | ||
| dprintf(idx, "New %s sticky ban: %s (%s)\n", chan->dname, s, par); | ||
|
|
@@ -158,14 +186,19 @@ static void cmd_pls_ban(struct userrec *u, int idx, char *par) | |
| /* Avoid unnesessary modes if you got +dynamicbans, and there is | ||
| * no reason to set mode if irc.mod aint loaded. (dw 001120) | ||
| */ | ||
| if ((me = module_find("irc", 0, 0))) | ||
| (me->funcs[IRC_CHECK_THIS_BAN]) (chan, s, sticky); | ||
| if ((me = module_find("irc", 0, 0))) { | ||
| if (!extbanflag || extban_enabled) | ||
| (me->funcs[IRC_CHECK_THIS_BAN]) (chan, s, sticky || extban_default_sticky); | ||
| else | ||
| dprintf(idx, "The %c extban is not enabled on this server. Eggdrop will save this ban but only set it when on a server that has the %c flag enabled.\n", extbanflag, extbanflag); | ||
| } | ||
| } else { | ||
| u_addban(NULL, s, dcc[idx].nick, par, | ||
| expire_time ? now + expire_time : 0, 0); | ||
| if (par[0] == '*') { | ||
| if (par[0] == '*' || extban_default_sticky) { | ||
| sticky = 1; | ||
| par++; | ||
| if (par[0] == '*') | ||
| par++; | ||
| putlog(LOG_CMDS, "*", "#%s# (GLOBAL) +ban %s (%s) (sticky)", | ||
| dcc[idx].nick, s, par); | ||
| dprintf(idx, "New sticky ban: %s (%s)\n", s, par); | ||
|
|
@@ -174,13 +207,49 @@ static void cmd_pls_ban(struct userrec *u, int idx, char *par) | |
| s, par); | ||
| dprintf(idx, "New ban: %s (%s)\n", s, par); | ||
| } | ||
| if ((me = module_find("irc", 0, 0))) | ||
| for (chan = chanset; chan != NULL; chan = chan->next) | ||
| (me->funcs[IRC_CHECK_THIS_BAN]) (chan, s, sticky); | ||
| if ((me = module_find("irc", 0, 0))) { | ||
| if (!extbanflag || extban_enabled) { | ||
| for (chan = chanset; chan != NULL; chan = chan->next) | ||
| (me->funcs[IRC_CHECK_THIS_BAN]) (chan, s, sticky || extban_default_sticky); | ||
| } else | ||
| dprintf(idx, "The %c extban is not enabled on this server. Eggdrop will save this ban but only set it when on a server that has the %c flag enabled.\n", extbanflag, extbanflag); | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
|
|
||
| static void cmd_pls_extban(struct userrec *u, int idx, char *par) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do you want to keep this then?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. .-ban works for all bans, extban or not. I acknowledge it is confusing, but I don't know what this command would add since you're either using a number or a mask, both of which work via .-ban I'll add that I implemented cmd_pls_extban because it takes needing to know the extban prefix and specific banmask formatting out of the users hands... I thought this is a bonus. .+ban should still work if you want to do it manually as well.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. .+ban also works on all bans, no? Maybe you can explain more why .+extban adds value but .-extban would not
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For sure- as a novice user, I might not know that $ and ~ are different on different servers, or what flags are allowed and not allowed on a server. .+extban checks all this; .+ban will just set what you set. In short, there is optionality in how to build a ban, but deleting a ban is still pretty simple and intuitive. |
||
| { | ||
| char *flagstr, *arg; | ||
| char extban[UHOSTLEN], forwarded[LOGLINEMAX]; | ||
| char flag; | ||
| char prefix = '\0'; | ||
|
|
||
| flagstr = newsplit(&par); | ||
| if (!flagstr[0] || flagstr[1]) { | ||
| dprintf(idx, "Usage: +extban <flag> <value> [channel] [%%<XyXdXhXm>] [reason]\n"); | ||
| return; | ||
| } | ||
|
|
||
| flag = flagstr[0]; | ||
| arg = newsplit(&par); | ||
| if (!arg[0]) { | ||
| dprintf(idx, "Usage: +extban <flag> <value> [channel] [%%<XyXdXhXm>] [reason]\n"); | ||
| return; | ||
| } | ||
|
|
||
| get_extban_prefix(&prefix); | ||
| if (prefix) | ||
| egg_snprintf(extban, sizeof extban, "%c%c:%s", prefix, flag, arg); | ||
| else | ||
| egg_snprintf(extban, sizeof extban, "%c:%s", flag, arg); | ||
|
|
||
| egg_snprintf(forwarded, sizeof forwarded, "%s%s%s", extban, | ||
| par[0] ? " " : "", par); | ||
| cmd_pls_ban(u, idx, forwarded); | ||
| } | ||
|
|
||
| static void cmd_pls_exempt(struct userrec *u, int idx, char *par) | ||
| { | ||
| char *chname, *who, s[UHOSTLEN], *p, *p_expire; | ||
|
|
@@ -1624,6 +1693,7 @@ static void cmd_chanload(struct userrec *u, int idx, char *par) | |
| */ | ||
| static cmd_t C_dcc_irc[] = { | ||
| {"+ban", "ol|ol", (IntFunc) cmd_pls_ban, NULL}, | ||
| {"+extban", "ol|ol", (IntFunc) cmd_pls_extban, NULL}, | ||
| {"+exempt", "ol|ol", (IntFunc) cmd_pls_exempt, NULL}, | ||
| {"+invite", "ol|ol", (IntFunc) cmd_pls_invite, NULL}, | ||
| {"+chan", "n", (IntFunc) cmd_pls_chan, NULL}, | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.