xline: tell a banned user when the ban expires, not just why

This commit is contained in:
Jean Chevronnet 2026-08-21 15:18:23 +00:00
parent 745ddd540e
commit 7cb9256ff5
No known key found for this signature in database
GPG key ID: 439666D63A9477E4
2 changed files with 34 additions and 4 deletions

View file

@ -1655,6 +1655,21 @@ mod tests {
assert!(joined.contains("XLINE: Z-line on 192.0.2.5 expired"), "expire: {joined}");
}
#[test]
fn banned_user_message_shows_expiry() {
let mut s = srv();
s.conf_path = std::env::temp_dir().join("echo-ban-expiry-test").display().to_string();
// permanent K-line: reason only, no expiry tail
s.add_xline(crate::xline::XKind::Kline, "*@perm.example", 0, "op", "spam");
let perm = s.matched_xline("bob", "perm.example", "1.2.3.4").unwrap();
assert_eq!(perm, "K-lined: spam", "permanent ban shows no expiry: {perm}");
// timed Z-line: reason + when it lifts
s.add_xline(crate::xline::XKind::Zline, "5.6.7.8", 604800, "op", "botnet");
let timed = s.matched_xline("bob", "any.host", "5.6.7.8").unwrap();
assert!(timed.starts_with("Z-lined: botnet (expires in "), "timed ban shows expiry: {timed}");
assert!(timed.contains(" on ") && timed.ends_with(')'), "with an absolute date: {timed}");
}
#[test]
fn dnsbl_hit_emits_expected_snotices() {
use std::net::Ipv4Addr;