Anonymous ports

This is the other way to allow ports to work when the processes
themselves cannot be enumerated: just report the port with an empty
description. We need to do some work to make sure this is safe for the
client; see comments.
This commit is contained in:
John Doty 2024-08-10 07:44:06 -07:00
parent 69b9bc9824
commit a4745c92e2
5 changed files with 51 additions and 6 deletions

View file

@ -1178,4 +1178,30 @@ mod tests {
drop(sender);
}
#[test]
fn empty_port_desc_disabled_on_refresh() {
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);
// Just do it again, make sure we haven't broken the refresh path.
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);
}
}