From 451a05d951abef9e176db98d802eaf3bd208e215 Mon Sep 17 00:00:00 2001
From: stskeeps UnrealIRCd now has support for CIDR (Classless Interdomain Routing). CIDR allows you to ban
IP ranges. IPs are allocated to ISPs using CIDR, therefore, being able to set a CIDR based ban
allows you to easily ban an ISP. Unreal supports CIDR for both IPv4 and IPv6. CIDR masks may be
-used in the allow::ip, ban user::mask, ban ip::mask, except ban::mask, except throttle::mask,
-and except tkl::mask (for gzline, gline, and shun). Additionally, CIDR can be used in /kline,
-/gline, /zline, /gzline, and /shun. Unreal uses the standard syntax of IP/bits, e.g.,
-127.0.0.0/8 (matches 127.0.0.0 - 127.255.255.255), and fe80:0:0:123::/64 (matches
-fe80:0:0:123:0:0:0:0 - fe80:0:0:123:ffff:ffff:ffff:ffff).
UnrealIRCd now has the ability to specify which charsets/languages should be allowed diff --git a/include/struct.h b/include/struct.h index 45cdaa089..8a0c0acb5 100644 --- a/include/struct.h +++ b/include/struct.h @@ -1159,6 +1159,7 @@ struct _configitem_oper_from { ConfigItem *prev, *next; ConfigFlag flag; char *name; + struct irc_netmask *netmask; }; struct _configitem_drpass { diff --git a/src/modules/m_oper.c b/src/modules/m_oper.c index f4d7320ab..53214ad27 100644 --- a/src/modules/m_oper.c +++ b/src/modules/m_oper.c @@ -198,7 +198,8 @@ DLLFUNC int m_oper(aClient *cptr, aClient *sptr, int parc, char *parv[]) { strlcpy(nuhhost2, make_user_host(sptr->user->username, Inet_ia2p(&sptr->ip)), sizeof(nuhhost2)); for (oper_from = (ConfigItem_oper_from *) aconf->from; oper_from; oper_from = (ConfigItem_oper_from *) oper_from->next) - if (!match(oper_from->name, nuhhost) || !match(oper_from->name, nuhhost2)) + /* if (!match(oper_from->name, nuhhost) || !match(oper_from->name, nuhhost2)) */ + if (match_ip(sptr->ip, nuhhost, oper_from->name, oper_from->netmask)) break; if (!oper_from) { sendto_one(sptr, err_str(ERR_NOOPERHOST), me.name, parv[0]); diff --git a/src/s_conf.c b/src/s_conf.c index 1fb0868e9..947902dea 100644 --- a/src/s_conf.c +++ b/src/s_conf.c @@ -1845,6 +1845,10 @@ void config_rehash() { next2 = (ListStruct *)oper_from->next; ircfree(oper_from->name); + if (oper_from->netmask) + { + MyFree(oper_from->netmask); + } DelListItem(oper_from, oper_ptr->from); MyFree(oper_from); } @@ -3167,6 +3171,7 @@ int _conf_oper(ConfigFile *conf, ConfigEntry *ce) ConfigItem_oper *oper = NULL; ConfigItem_oper_from *from; OperFlag *ofp = NULL; + struct irc_netmask tmp; oper = MyMallocEx(sizeof(ConfigItem_oper)); oper->name = strdup(ce->ce_vardata); @@ -3236,6 +3241,12 @@ int _conf_oper(ConfigFile *conf, ConfigEntry *ce) { from = MyMallocEx(sizeof(ConfigItem_oper_from)); ircstrdup(from->name, cepp->ce_vardata); + tmp.type = parse_netmask(from->name, &tmp); + if (tmp.type != HM_HOST) + { + from->netmask = MyMallocEx(sizeof(struct irc_netmask)); + bcopy(&tmp, from->netmask, sizeof(struct irc_netmask)); + } AddListItem(from, oper->from); } }