Remove ports when they're unconfigured

This is closer to what I had intended
This commit is contained in:
John Doty 2022-11-28 07:03:04 -08:00
parent 46c9643ddf
commit abbb30d87b
2 changed files with 5 additions and 4 deletions

View file

@ -15,6 +15,10 @@ pub struct ServerConfig {
}
impl ServerConfig {
pub fn contains_key(&self, port: u16) -> bool {
self.ports.contains_key(&port)
}
pub fn get(&self, port: u16) -> PortConfig {
match self.ports.get(&port) {
None => PortConfig { enabled: self.auto, description: None },

View file

@ -457,14 +457,11 @@ impl UI {
}
for port in leftover_ports {
let mut enabled = false;
if let Some(listener) = self.ports.get_mut(&port) {
enabled = listener.enabled;
listener.disconnect();
}
if !enabled {
// Just... forget it? Or leave it around forever?
if !self.config.contains_key(port) {
self.ports.remove(&port);
}
}