modules: port maphide and tline
This commit is contained in:
parent
140554719b
commit
3186af07e8
3 changed files with 111 additions and 0 deletions
44
src/modules/maphide.rs
Normal file
44
src/modules/maphide.rs
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
//! maphide — hide the server map (`LINKS` / `MAP`) from ordinary users, so the
|
||||
//! network topology isn't exposed to non-operators. Off unless `maphide = yes`.
|
||||
//!
|
||||
//! Behaviour reference: InspIRCd's `m_maphide`. Original native Rust.
|
||||
|
||||
use crate::module::{ModResult, Module};
|
||||
use crate::server::Server;
|
||||
use crate::Uid;
|
||||
|
||||
pub struct MapHide;
|
||||
|
||||
impl Module for MapHide {
|
||||
fn name(&self) -> &'static str {
|
||||
"maphide"
|
||||
}
|
||||
|
||||
fn on_pre_command(
|
||||
&mut self,
|
||||
srv: &mut Server,
|
||||
uid: Uid,
|
||||
cmd: &str,
|
||||
_params: &[String],
|
||||
) -> ModResult {
|
||||
if !srv.conf_bool("maphide", false) || srv.is_oper(uid) {
|
||||
return ModResult::Passthru;
|
||||
}
|
||||
if cmd.eq_ignore_ascii_case("LINKS") || cmd.eq_ignore_ascii_case("MAP") {
|
||||
let nick = srv
|
||||
.users
|
||||
.get(&uid)
|
||||
.map(|u| u.nick.clone())
|
||||
.unwrap_or_default();
|
||||
srv.send(
|
||||
uid,
|
||||
format!(
|
||||
":{} NOTICE {nick} :The server map is hidden; ask an operator.",
|
||||
srv.name
|
||||
),
|
||||
);
|
||||
return ModResult::Deny;
|
||||
}
|
||||
ModResult::Passthru
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue