Add channel::ip_bans_through_vhost

This commit is contained in:
Ed Kellett 2021-04-24 12:15:20 +01:00
parent d58de35b83
commit dfeba65563
6 changed files with 15 additions and 2 deletions

View file

@ -794,6 +794,9 @@ channel {
* as PRIVMSG @#channel when sent to clients. * as PRIVMSG @#channel when sent to clients.
*/ */
opmod_send_statusmsg = no; opmod_send_statusmsg = no;
/* ip_bans_through_vhost: should channel IP bans see through dynamic spoofed hosts? */
ip_bans_through_vhost = yes;
}; };

View file

@ -285,6 +285,7 @@ struct config_channel_entry
int displayed_usercount; int displayed_usercount;
int strip_topic_colors; int strip_topic_colors;
int opmod_send_statusmsg; int opmod_send_statusmsg;
int ip_bans_through_vhost;
}; };
struct config_server_hide struct config_server_hide

View file

@ -22,6 +22,7 @@
#include "client.h" #include "client.h"
#include "ircd.h" #include "ircd.h"
#include "match.h" #include "match.h"
#include "s_conf.h"
#include "s_assert.h" #include "s_assert.h"
/* /*
@ -622,6 +623,7 @@ int ircncmp(const char *s1, const char *s2, int n)
void matchset_for_client(struct Client *who, struct matchset *m) void matchset_for_client(struct Client *who, struct matchset *m)
{ {
bool hide_ip = IsIPSpoof(who) || (!ConfigChannel.ip_bans_through_vhost && IsDynSpoof(who));
unsigned hostn = 0; unsigned hostn = 0;
unsigned ipn = 0; unsigned ipn = 0;
@ -629,7 +631,7 @@ void matchset_for_client(struct Client *who, struct matchset *m)
sprintf(m->host[hostn++], "%s!%s@%s", who->name, who->username, who->host); sprintf(m->host[hostn++], "%s!%s@%s", who->name, who->username, who->host);
if (!IsIPSpoof(who)) if (!hide_ip)
{ {
sprintf(m->ip[ipn++], "%s!%s@%s", who->name, who->username, who->sockhost); sprintf(m->ip[ipn++], "%s!%s@%s", who->name, who->username, who->sockhost);
} }
@ -648,7 +650,7 @@ void matchset_for_client(struct Client *who, struct matchset *m)
sprintf(m->host[hostn++], "%s!%s@%s", who->name, who->username, who->localClient->mangledhost); sprintf(m->host[hostn++], "%s!%s@%s", who->name, who->username, who->localClient->mangledhost);
} }
} }
if (!IsIPSpoof(who) && GET_SS_FAMILY(&who->localClient->ip) == AF_INET6 && if (!hide_ip && GET_SS_FAMILY(&who->localClient->ip) == AF_INET6 &&
rb_ipv4_from_ipv6((const struct sockaddr_in6 *)&who->localClient->ip, &ip4)) rb_ipv4_from_ipv6((const struct sockaddr_in6 *)&who->localClient->ip, &ip4))
{ {
int n = sprintf(m->ip[ipn++], "%s!%s@", who->name, who->username); int n = sprintf(m->ip[ipn++], "%s!%s@", who->name, who->username);

View file

@ -2744,6 +2744,7 @@ static struct ConfEntry conf_channel_table[] =
{ "displayed_usercount", CF_INT, NULL, 0, &ConfigChannel.displayed_usercount }, { "displayed_usercount", CF_INT, NULL, 0, &ConfigChannel.displayed_usercount },
{ "strip_topic_colors", CF_YESNO, NULL, 0, &ConfigChannel.strip_topic_colors }, { "strip_topic_colors", CF_YESNO, NULL, 0, &ConfigChannel.strip_topic_colors },
{ "opmod_send_statusmsg", CF_YESNO, NULL, 0, &ConfigChannel.opmod_send_statusmsg }, { "opmod_send_statusmsg", CF_YESNO, NULL, 0, &ConfigChannel.opmod_send_statusmsg },
{ "ip_bans_through_vhost", CF_YESNO, NULL, 0, &ConfigChannel.ip_bans_through_vhost },
{ "\0", 0, NULL, 0, NULL } { "\0", 0, NULL, 0, NULL }
}; };

View file

@ -808,6 +808,7 @@ set_default_conf(void)
ConfigChannel.disable_local_channels = false; ConfigChannel.disable_local_channels = false;
ConfigChannel.displayed_usercount = 3; ConfigChannel.displayed_usercount = 3;
ConfigChannel.opmod_send_statusmsg = false; ConfigChannel.opmod_send_statusmsg = false;
ConfigChannel.ip_bans_through_vhost= true;
ConfigChannel.autochanmodes = MODE_TOPICLIMIT | MODE_NOPRIVMSGS; ConfigChannel.autochanmodes = MODE_TOPICLIMIT | MODE_NOPRIVMSGS;

View file

@ -581,6 +581,11 @@ static struct InfoStruct info_table[] = {
"Send messages to @#channel if affected by +z", "Send messages to @#channel if affected by +z",
INFO_INTBOOL_YN(&ConfigChannel.opmod_send_statusmsg), INFO_INTBOOL_YN(&ConfigChannel.opmod_send_statusmsg),
}, },
{
"ip_bans_through_vhost",
"Channel IP bans see through dynamic spoofs",
INFO_INTBOOL_YN(&ConfigChannel.ip_bans_through_vhost),
},
{ {
"hide_opers", "hide_opers",
"Hide all opers from unprivileged users", "Hide all opers from unprivileged users",