From bf1446a51b550de59b75cd3a7bcd30f363cdf89d Mon Sep 17 00:00:00 2001 From: reverse Date: Fri, 28 Aug 2026 18:53:04 +0000 Subject: [PATCH] asn: A: matching extban (ban/exempt by origin AS); advertise A in EXTBAN --- src/channels.rs | 3 ++- src/modules/asn.rs | 6 ++++++ src/server.rs | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/channels.rs b/src/channels.rs index 6e205aa..9fd61b6 100644 --- a/src/channels.rs +++ b/src/channels.rs @@ -1337,7 +1337,7 @@ impl Server { /// Whether any entry in `list` catches `uid`: a plain `nick!user@host` glob, or /// a matching extban (`g:` group, `y:` reputation, `r:` realname, `j:` channel, - /// `s:` server, `G:` geoip, `b:` banlist). Acting extbans (`m:`/`c:`/`n:`) never + /// `s:` server, `G:` geoip, `A:` asn, `b:` banlist). Acting extbans (`m:`/`c:`/`n:`) never /// match here — they restrict actions, not join/ban membership. pub fn ban_list_hit(&self, uid: Uid, list: &[Ban]) -> bool { let who = self.users.get(&uid).map(|u| u.prefix()).unwrap_or_default(); @@ -1353,6 +1353,7 @@ impl Server { Some(b'j') => crate::modules::channelban::matches(self, uid, &b.mask[2..]), Some(b's') => crate::modules::serverban::matches(self, uid, &b.mask[2..]), Some(b'G') => crate::modules::geoip::geoban_match(self, uid, &b.mask[2..]), + Some(b'A') => crate::modules::asn::extban_match(self, uid, &b.mask[2..]), Some(b'b') => crate::modules::extbanbanlist::matches(self, uid, &b.mask[2..]), _ => false, } diff --git a/src/modules/asn.rs b/src/modules/asn.rs index 5a153e2..967f918 100644 --- a/src/modules/asn.rs +++ b/src/modules/asn.rs @@ -48,6 +48,12 @@ pub fn user_in(s: &Server, uid: Uid, list: &[u32]) -> bool { !list.is_empty() && of(s, uid).is_some_and(|a| list.contains(&a)) } +/// The `A:` matching extban: is `uid`'s origin AS one of the listed AS +/// numbers? The `AS` prefix is optional — e.g. `+b A:15169` or `+b A:AS3215,16276`. +pub fn extban_match(s: &Server, uid: Uid, spec: &str) -> bool { + user_in(s, uid, &parse_list(spec)) +} + #[cfg(test)] mod tests { use super::*; diff --git a/src/server.rs b/src/server.rs index cd30d33..80f2486 100644 --- a/src/server.rs +++ b/src/server.rs @@ -941,7 +941,7 @@ impl Server { let include_oper = self.conf_bool("operprefix", false) || self.conf_bool("ojoin", false); let prefix = crate::modules::customprefix::isupport(include_oper); let mut tokens: Vec = format!( - "CHANTYPES=# PREFIX={prefix} CHANMODES=beIgXw,k,lfjFLHBJdK,ACDGMNOPQRSTUcimnprstuz EXTBAN=,aGbcgjmnrsy ACCOUNTEXTBAN=a BOT=B WATCH={maxwatch} MONITOR={maxmon} SILENCE={maxsil} CALLERID=g WHOX CHATHISTORY={chathist} MSGREFTYPES=timestamp,msgid UTF8ONLY CASEMAPPING=ascii NICKLEN={maxnick} CHANNELLEN={maxchan} MODES={maxmodes} NETWORK={}", + "CHANTYPES=# PREFIX={prefix} CHANMODES=beIgXw,k,lfjFLHBJdK,ACDGMNOPQRSTUcimnprstuz EXTBAN=,aGAbcgjmnrsy ACCOUNTEXTBAN=a BOT=B WATCH={maxwatch} MONITOR={maxmon} SILENCE={maxsil} CALLERID=g WHOX CHATHISTORY={chathist} MSGREFTYPES=timestamp,msgid UTF8ONLY CASEMAPPING=ascii NICKLEN={maxnick} CHANNELLEN={maxchan} MODES={maxmodes} NETWORK={}", network ) .split(' ')