modules: move all per-module state/config out of server.rs/config.rs into own files

This commit is contained in:
Jean Chevronnet 2026-08-09 11:18:04 +00:00
parent 0d4c9297b5
commit 131471e245
18 changed files with 525 additions and 425 deletions

21
src/modules/whoisport.rs Normal file
View file

@ -0,0 +1,21 @@
//! whoisport — InspIRCd `m_whoisport`. Shows an IRC operator, in WHOIS, the
//! listener port the target connected to. Config-free (derives the port from the
//! `bind` / `bind_tls` listeners); nothing lives on `Server`.
use crate::server::Server;
use crate::Uid;
fn port_of(addr: &str) -> u16 {
addr.rsplit(':')
.next()
.and_then(|p| p.parse().ok())
.unwrap_or(0)
}
/// The `is using port N` WHOIS line for opers, or `None` if the port is unknown.
pub fn line(s: &Server, target: Uid) -> Option<String> {
let secure = s.users.get(&target).map(|u| u.secure).unwrap_or(false);
let bind = if secure { "bind_tls" } else { "bind" };
let port = s.conf(bind).map(port_of).unwrap_or(0);
(port != 0).then(|| format!("is using port {port}"))
}