webirc: restrict a gateway password to a source ip-mask; document webirc in the example config
This commit is contained in:
parent
ad8d542e4e
commit
b92101616b
4 changed files with 26 additions and 13 deletions
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
use std::net::{IpAddr, SocketAddr};
|
||||
|
||||
use crate::channels::glob_match;
|
||||
use crate::command::{CmdResult, Command};
|
||||
use crate::numeric::*;
|
||||
use crate::server::Server;
|
||||
|
|
@ -45,11 +46,17 @@ impl Command for WebIrc {
|
|||
return CmdResult::Fail; // can't re-spoof a registered session
|
||||
}
|
||||
let (pass, host, ip) = (¶ms[0], ¶ms[2], ¶ms[3]);
|
||||
// the gateway's own connecting IP (before we spoof it below)
|
||||
let from = s
|
||||
.users
|
||||
.get(&uid)
|
||||
.map(|u| u.addr.ip().to_string())
|
||||
.unwrap_or_default();
|
||||
let Some(gw) = s
|
||||
.webirc
|
||||
.iter()
|
||||
.find(|(p, _)| p == pass)
|
||||
.map(|(_, g)| g.clone())
|
||||
.find(|(p, _, mask)| p == pass && (mask.is_empty() || glob_match(mask, &from)))
|
||||
.map(|(_, g, _)| g.clone())
|
||||
else {
|
||||
s.notice_star(uid, "WEBIRC: invalid credentials");
|
||||
return CmdResult::Fail;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue