Remove ports when they're unconfigured
This is closer to what I had intended
This commit is contained in:
parent
46c9643ddf
commit
abbb30d87b
2 changed files with 5 additions and 4 deletions
|
|
@ -15,6 +15,10 @@ pub struct ServerConfig {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ServerConfig {
|
impl ServerConfig {
|
||||||
|
pub fn contains_key(&self, port: u16) -> bool {
|
||||||
|
self.ports.contains_key(&port)
|
||||||
|
}
|
||||||
|
|
||||||
pub fn get(&self, port: u16) -> PortConfig {
|
pub fn get(&self, port: u16) -> PortConfig {
|
||||||
match self.ports.get(&port) {
|
match self.ports.get(&port) {
|
||||||
None => PortConfig { enabled: self.auto, description: None },
|
None => PortConfig { enabled: self.auto, description: None },
|
||||||
|
|
|
||||||
|
|
@ -457,14 +457,11 @@ impl UI {
|
||||||
}
|
}
|
||||||
|
|
||||||
for port in leftover_ports {
|
for port in leftover_ports {
|
||||||
let mut enabled = false;
|
|
||||||
if let Some(listener) = self.ports.get_mut(&port) {
|
if let Some(listener) = self.ports.get_mut(&port) {
|
||||||
enabled = listener.enabled;
|
|
||||||
listener.disconnect();
|
listener.disconnect();
|
||||||
}
|
}
|
||||||
|
|
||||||
if !enabled {
|
if !self.config.contains_key(port) {
|
||||||
// Just... forget it? Or leave it around forever?
|
|
||||||
self.ports.remove(&port);
|
self.ports.remove(&port);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue