mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-03-30 04:01:58 +00:00
add localhost support to the http server (#1939)
This commit is contained in:
committed by
Aiden McClelland
parent
45a6a930c9
commit
6cea0139d1
@@ -118,12 +118,11 @@ impl NetController {
|
||||
let ip = get_current_ip(rpc_ctx.ethernet_interface.to_owned()).await?;
|
||||
|
||||
let embassy_tor_addr = get_embassyd_tor_addr(rpc_ctx.clone()).await?;
|
||||
|
||||
let embassy_tor_fqdn: ResourceFqdn = embassy_tor_addr.parse()?;
|
||||
|
||||
let host_name_fqdn: ResourceFqdn = host_name.parse()?;
|
||||
let ip_fqdn: ResourceFqdn = ip.parse()?;
|
||||
|
||||
let localhost_fqdn = ResourceFqdn::LocalHost;
|
||||
|
||||
let handler: HttpHandler =
|
||||
crate::net::static_server::main_ui_server_router(rpc_ctx.clone()).await?;
|
||||
@@ -146,6 +145,12 @@ impl NetController {
|
||||
.add_handle(80, ip_fqdn.clone(), handler.clone(), false)
|
||||
.await?;
|
||||
|
||||
rpc_ctx
|
||||
.net_controller
|
||||
.proxy
|
||||
.add_handle(80, localhost_fqdn.clone(), handler.clone(), false)
|
||||
.await?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
||||
@@ -35,6 +35,7 @@ pub enum ResourceFqdn {
|
||||
root: String,
|
||||
tld: Tld,
|
||||
},
|
||||
LocalHost
|
||||
}
|
||||
|
||||
impl fmt::Display for ResourceFqdn {
|
||||
@@ -50,6 +51,7 @@ impl fmt::Display for ResourceFqdn {
|
||||
} => {
|
||||
write!(f, "{}", full_uri)
|
||||
}
|
||||
ResourceFqdn::LocalHost => write!(f, "localhost")
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -76,6 +78,10 @@ impl FromStr for ResourceFqdn {
|
||||
|
||||
fn from_str(input: &str) -> Result<ResourceFqdn, Self::Err> {
|
||||
|
||||
if input == "localhost" {
|
||||
return Ok(ResourceFqdn::LocalHost);
|
||||
}
|
||||
|
||||
if let Ok(ip) = input.parse::<IpAddr>() {
|
||||
return Ok(ResourceFqdn::IpAddr(ip));
|
||||
}
|
||||
|
||||
@@ -124,6 +124,13 @@ impl ProxyController {
|
||||
error!("server io error: {}", e);
|
||||
};
|
||||
}
|
||||
ResourceFqdn::LocalHost => {
|
||||
if let Err(e) =
|
||||
Self::tunnel(upgraded, "localhost".to_string()).await
|
||||
{
|
||||
error!("server io error: {}", e);
|
||||
};
|
||||
}
|
||||
},
|
||||
Err(e) => error!("upgrade error: {}", e),
|
||||
}
|
||||
@@ -224,6 +231,12 @@ impl ProxyControllerInner {
|
||||
root,
|
||||
tld: _,
|
||||
} => self.ssl_manager.certificate_for(&root, &pkg_id).await?,
|
||||
ResourceFqdn::LocalHost => {
|
||||
return Err(Error::new(
|
||||
eyre!("ssl not supported for localhost"),
|
||||
crate::ErrorKind::Network,
|
||||
))
|
||||
}
|
||||
};
|
||||
|
||||
self.vhosts
|
||||
|
||||
Reference in New Issue
Block a user