Skip to content

Commit

Permalink
Don't enable anonymous ports by default
Browse files Browse the repository at this point in the history
  • Loading branch information
DeCarabas committed Aug 10, 2024
1 parent de06612 commit b86a091
Showing 1 changed file with 27 additions and 1 deletion.
28 changes: 27 additions & 1 deletion src/client/ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -605,12 +605,21 @@ impl UI {
listener.connect(self.socks_port, port_desc);
} else {
assert!(!self.config.contains_key(port_desc.port));

// The server can send us these ports it knows nothing about.
// These might be dangerous to enable by default, so don't.
let enabled = if port_desc.desc.is_empty() {
false
} else {
self.config.auto()
};

self.ports.insert(
port_desc.port,
Listener::from_desc(
self.socks_port,
port_desc,
self.config.auto(),
enabled,
),
);
}
Expand Down Expand Up @@ -1135,4 +1144,21 @@ mod tests {

drop(sender);
}

#[test]
fn empty_port_desc_disabled_by_default() {
let (sender, receiver) = mpsc::channel(64);
let config = ServerConfig::default();
let mut ui = UI::new(receiver, config);

ui.handle_internal_event(Some(UIEvent::Ports(vec![PortDesc {
port: 8080,
desc: "".to_string(),
}])));

let listener = ui.ports.get(&8080).unwrap();
assert_eq!(listener.state(), State::Disabled);

drop(sender);
}
}

0 comments on commit b86a091

Please sign in to comment.