Respect server-wide auto setting

This commit is contained in:
John Doty 2024-08-10 06:54:26 -07:00
parent cc004df6e8
commit de06612eb1
2 changed files with 44 additions and 10 deletions

View file

@ -21,11 +21,20 @@ impl ServerConfig {
ServerConfig { auto: true, ports: HashMap::new() }
}
#[cfg(test)]
pub fn set_auto(&mut self, auto: bool) {
self.auto = auto;
}
#[cfg(test)]
pub fn insert(&mut self, port: u16, config: PortConfig) {
self.ports.insert(port, config);
}
pub fn auto(&self) -> bool {
self.auto
}
pub fn iter(&self) -> hash_map::Iter<u16, PortConfig> {
self.ports.iter()
}
@ -33,13 +42,6 @@ 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 },
Some(c) => c.clone(),
}
}
}
#[derive(Debug)]