mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-03-26 02:11:53 +00:00
bugfix: inverts mapping for lan config
This commit is contained in:
committed by
Aiden McClelland
parent
f57f7022a1
commit
3c8b6e4f83
@@ -186,9 +186,32 @@ pub struct TorConfig {
|
||||
pub port_mapping: BTreeMap<Port, Port>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
||||
#[derive(Clone, Debug, Serialize)]
|
||||
#[serde(rename_all = "kebab-case")]
|
||||
pub struct LanPortConfig {
|
||||
pub ssl: bool,
|
||||
pub mapping: u16,
|
||||
pub internal: u16,
|
||||
}
|
||||
impl<'de> Deserialize<'de> for LanPortConfig {
|
||||
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
|
||||
where
|
||||
D: Deserializer<'de>,
|
||||
{
|
||||
#[derive(Deserialize)]
|
||||
#[serde(rename_all = "kebab-case")]
|
||||
struct PermissiveLanPortConfig {
|
||||
ssl: bool,
|
||||
internal: Option<u16>,
|
||||
mapping: Option<u16>,
|
||||
}
|
||||
|
||||
let config = PermissiveLanPortConfig::deserialize(deserializer)?;
|
||||
Ok(LanPortConfig {
|
||||
ssl: config.ssl,
|
||||
internal: config
|
||||
.internal
|
||||
.or(config.mapping)
|
||||
.ok_or_else(|| serde::de::Error::missing_field("internal"))?,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -112,16 +112,12 @@ impl NginxControllerInner {
|
||||
crate::net::ssl::export_cert(&chain, &ssl_path_cert)
|
||||
)?;
|
||||
(
|
||||
format!("{} ssl", lan_port_config.mapping),
|
||||
format!("{} ssl", port.0),
|
||||
format!("ssl_certificate {};", ssl_path_cert.to_str().unwrap()),
|
||||
format!("ssl_certificate_key {};", ssl_path_key.to_str().unwrap()),
|
||||
)
|
||||
} else {
|
||||
(
|
||||
format!("{}", lan_port_config.mapping),
|
||||
String::from(""),
|
||||
String::from(""),
|
||||
)
|
||||
(format!("{}", port.0), String::from(""), String::from(""))
|
||||
};
|
||||
// write nginx configs
|
||||
let nginx_conf_path = nginx_root.join(format!(
|
||||
@@ -138,7 +134,7 @@ impl NginxControllerInner {
|
||||
ssl_certificate_line = ssl_certificate_line,
|
||||
ssl_certificate_key_line = ssl_certificate_key_line,
|
||||
app_ip = ipv4,
|
||||
internal_port = port.0,
|
||||
internal_port = lan_port_config.internal,
|
||||
),
|
||||
)
|
||||
.await
|
||||
|
||||
Reference in New Issue
Block a user