operserv: notify_exclude gains server:<glob> to mute a whole relay server from the feed
All checks were successful
CI / check (push) Successful in 4m1s
All checks were successful
CI / check (push) Successful in 4m1s
This commit is contained in:
parent
4d327c3f47
commit
4247df8844
4 changed files with 24 additions and 11 deletions
|
|
@ -56,12 +56,14 @@ protocol = 1206 # InspIRCd link protocol version (1206 = insp4, 1205
|
||||||
# surfaced. Omit the section to disable the feed.
|
# surfaced. Omit the section to disable the feed.
|
||||||
# [log]
|
# [log]
|
||||||
# channel = "#services"
|
# channel = "#services"
|
||||||
# Masks OperServ NOTIFY never announces, so they can't flood the feed. A `#channel`
|
# Masks OperServ NOTIFY never announces, so they can't flood the feed. Three kinds:
|
||||||
# mask mutes that channel (e.g. keep a broad `#*` watch out of "#staff"); any other
|
# "#channel" mute a channel (keep a broad `#*` watch out of "#staff")
|
||||||
# mask mutes a user — nick globs, user@host, or extbans, same syntax as a NOTIFY
|
# "server:<glob>" mute everyone on a server (a relay whose users have clean
|
||||||
# mask. "*/*" silences PyLink relay clients (their nicks carry a `/network` suffix).
|
# nicks; alias "via:", matching the "via <server>" in the feed)
|
||||||
|
# anything else mute a user — nick glob, user@host, or extban ("*/*" catches
|
||||||
|
# PyLink relays that suffix nicks with /network)
|
||||||
# Reloadable with OperServ REHASH.
|
# Reloadable with OperServ REHASH.
|
||||||
# notify_exclude = ["*/*", "#staff"]
|
# notify_exclude = ["*/*", "server:chatnova.relay", "#staff"]
|
||||||
|
|
||||||
# Inactivity-expiry: accounts not identified to, and channels not joined, for
|
# Inactivity-expiry: accounts not identified to, and channels not joined, for
|
||||||
# longer than the threshold are dropped on a periodic pass (opers, live
|
# longer than the threshold are dropped on a periodic pass (opers, live
|
||||||
|
|
|
||||||
|
|
@ -123,11 +123,12 @@ impl Expire {
|
||||||
#[derive(Debug, Deserialize, Clone)]
|
#[derive(Debug, Deserialize, Clone)]
|
||||||
pub struct Log {
|
pub struct Log {
|
||||||
pub channel: String,
|
pub channel: String,
|
||||||
// Masks NOTIFY never announces: a `#channel` mask mutes that channel, any other
|
// Masks NOTIFY never announces, three kinds: `#channel` mutes that channel,
|
||||||
// mask (nick glob / user@host / extban) mutes a user. Set "*/*" to silence
|
// `server:<glob>` (or `via:`) mutes everyone on a matching server — the handle
|
||||||
// PyLink relay clients — their nicks carry a `/network` suffix — and add a
|
// on a relay whose users have clean nicks — and any other mask (nick glob /
|
||||||
// channel like "#staff" to keep a broad `#*` watch out of it. Reloadable with
|
// user@host / extban) mutes a user. E.g. "*/*" silences PyLink relays that
|
||||||
// REHASH.
|
// suffix nicks, "server:chatnova.relay" a relay that doesn't, "#staff" keeps a
|
||||||
|
// broad `#*` watch out of a channel. Reloadable with REHASH.
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub notify_exclude: Vec<String>,
|
pub notify_exclude: Vec<String>,
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -191,7 +191,11 @@ impl Db {
|
||||||
// mutes events in that channel, any other mask mutes a user (e.g. `*/*` for
|
// mutes events in that channel, any other mask mutes a user (e.g. `*/*` for
|
||||||
// PyLink relay clients). A match means the event never reaches the feed.
|
// PyLink relay clients). A match means the event never reaches the feed.
|
||||||
let excluded = self.notify_exclude.iter().any(|m| {
|
let excluded = self.notify_exclude.iter().any(|m| {
|
||||||
if m.starts_with('#') || m.starts_with('&') {
|
if let Some(srv) = m.strip_prefix("server:").or_else(|| m.strip_prefix("via:")) {
|
||||||
|
// `server:<glob>` mutes everyone on a matching server — the only handle
|
||||||
|
// on a relay whose users carry clean nicks (no /network suffix).
|
||||||
|
target.is_some_and(|t| glob_match(&srv.to_ascii_lowercase(), &t.server.to_ascii_lowercase()))
|
||||||
|
} else if m.starts_with('#') || m.starts_with('&') {
|
||||||
chan.is_some_and(|c| glob_match(m, c))
|
chan.is_some_and(|c| glob_match(m, c))
|
||||||
} else {
|
} else {
|
||||||
target.is_some_and(|t| echo_api::akick_matches(m, t) || (!m.contains(['@', '!']) && glob_match(m, t.nick)))
|
target.is_some_and(|t| echo_api::akick_matches(m, t) || (!m.contains(['@', '!']) && glob_match(m, t.nick)))
|
||||||
|
|
|
||||||
|
|
@ -5389,6 +5389,12 @@ fn notify_flags_match_user_nick_channel_and_expiry() {
|
||||||
db.set_notify_exclude(vec!["#staff".to_string()]);
|
db.set_notify_exclude(vec!["#staff".to_string()]);
|
||||||
assert!(db.notify_flags(Some(&bt("nice", "h.example")), Some("#staff")).is_empty(), "excluded channel is muted");
|
assert!(db.notify_flags(Some(&bt("nice", "h.example")), Some("#staff")).is_empty(), "excluded channel is muted");
|
||||||
assert!(db.notify_flags(Some(&bt("nice", "h.example")), Some("#warez7")).contains('j'), "other channels still watched");
|
assert!(db.notify_flags(Some(&bt("nice", "h.example")), Some("#warez7")).contains('j'), "other channels still watched");
|
||||||
|
// `server:<glob>` mutes everyone on a matching server — a relay whose users have
|
||||||
|
// clean nicks. bt() puts users on server "s.net".
|
||||||
|
db.set_notify_exclude(vec!["server:s.net".to_string()]);
|
||||||
|
assert!(db.notify_flags(Some(&bt("relayed", "h.example")), Some("#warez7")).is_empty(), "user on the excluded server is muted");
|
||||||
|
db.set_notify_exclude(vec!["via:other.net".to_string()]);
|
||||||
|
assert!(db.notify_flags(Some(&bt("relayed", "h.example")), Some("#warez7")).contains('j'), "user on a different server still watched");
|
||||||
db.set_notify_exclude(vec![]);
|
db.set_notify_exclude(vec![]);
|
||||||
// DEL by mask removes just that one.
|
// DEL by mask removes just that one.
|
||||||
assert!(db.notify_del("baddie*!*@*").unwrap());
|
assert!(db.notify_del("baddie*!*@*").unwrap());
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue