snoop: connect notice includes port, sni and account (present fields only)
This commit is contained in:
parent
a587d25873
commit
6e8d6c31fb
6 changed files with 28 additions and 6 deletions
|
|
@ -2828,6 +2828,7 @@ mod tests {
|
|||
secure: false,
|
||||
certfp: None,
|
||||
tls_info: None,
|
||||
sni: None,
|
||||
brand_server: None,
|
||||
brand_network: None,
|
||||
account: None,
|
||||
|
|
@ -2920,6 +2921,7 @@ mod tests {
|
|||
secure: false,
|
||||
certfp: None,
|
||||
tls_info: None,
|
||||
sni: None,
|
||||
brand_server: None,
|
||||
brand_network: None,
|
||||
account: None,
|
||||
|
|
|
|||
|
|
@ -375,6 +375,7 @@ mod tests {
|
|||
secure: false,
|
||||
certfp: None,
|
||||
tls_info: None,
|
||||
sni: None,
|
||||
brand_server: None,
|
||||
brand_network: None,
|
||||
account: Some("reverse".into()),
|
||||
|
|
|
|||
|
|
@ -12,15 +12,30 @@ impl Module for Snoop {
|
|||
"snoop"
|
||||
}
|
||||
fn on_user_connect(&mut self, srv: &mut Server, uid: Uid) {
|
||||
let info = srv
|
||||
.users
|
||||
.get(&uid)
|
||||
.map(|u| (u.nick.clone(), u.ident.clone(), u.host.clone()));
|
||||
if let Some((nick, ident, host)) = info {
|
||||
let info = srv.users.get(&uid).map(|u| {
|
||||
(
|
||||
u.nick.clone(),
|
||||
u.ident.clone(),
|
||||
u.host.clone(),
|
||||
u.port,
|
||||
u.sni.clone(),
|
||||
u.account.clone(),
|
||||
)
|
||||
});
|
||||
if let Some((nick, ident, host, port, sni, account)) = info {
|
||||
if srv.conf_bool("snoop_stderr", false) {
|
||||
eprintln!("[snoop] connect {nick} ({ident}@{host})");
|
||||
}
|
||||
srv.snotice_c('c', &format!("Client connecting: {nick} ({ident}@{host})"));
|
||||
// port is always shown; sni/account only when present, so plaintext or
|
||||
// anonymous connects don't carry empty fields.
|
||||
let mut extra = format!(", port: {port}");
|
||||
if let Some(sni) = &sni {
|
||||
extra.push_str(&format!(", sni: {sni}"));
|
||||
}
|
||||
if let Some(acct) = &account {
|
||||
extra.push_str(&format!(", account: {acct}"));
|
||||
}
|
||||
srv.snotice_c('c', &format!("Client connecting: {nick} ({ident}@{host}){extra}"));
|
||||
}
|
||||
}
|
||||
fn on_join(&mut self, srv: &mut Server, uid: Uid, chan: &str) {
|
||||
|
|
|
|||
|
|
@ -75,6 +75,7 @@ impl Node {
|
|||
secure: false,
|
||||
certfp: None,
|
||||
tls_info: None,
|
||||
sni: None,
|
||||
brand_server: None,
|
||||
brand_network: None,
|
||||
account: None,
|
||||
|
|
|
|||
|
|
@ -412,6 +412,7 @@ impl Server {
|
|||
secure,
|
||||
certfp,
|
||||
tls_info,
|
||||
sni,
|
||||
brand_server,
|
||||
brand_network,
|
||||
account: None,
|
||||
|
|
@ -1585,6 +1586,7 @@ mod tests {
|
|||
secure: false,
|
||||
certfp: None,
|
||||
tls_info: None,
|
||||
sni: None,
|
||||
brand_server: None,
|
||||
brand_network: None,
|
||||
account: None,
|
||||
|
|
|
|||
|
|
@ -231,6 +231,7 @@ pub struct User {
|
|||
pub secure: bool, // connected over TLS (drives WHOIS 671 / sslinfo)
|
||||
pub certfp: Option<String>, // TLS client-cert fingerprint (SASL EXTERNAL / CertFP)
|
||||
pub tls_info: Option<String>, // negotiated TLS version/group/cipher (WHOIS 671)
|
||||
pub sni: Option<String>, // TLS SNI hostname the client requested (connect notice)
|
||||
pub brand_server: Option<String>, // per-SNI display server name (None = global)
|
||||
pub brand_network: Option<String>, // per-SNI display network name (None = global)
|
||||
pub account: Option<String>, // logged-in account name (set by services)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue