mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-04-04 14:29:45 +00:00
@@ -217,10 +217,15 @@ where
|
|||||||
.write_all(&buffered)
|
.write_all(&buffered)
|
||||||
.await
|
.await
|
||||||
.with_kind(ErrorKind::Network)?;
|
.with_kind(ErrorKind::Network)?;
|
||||||
return Ok(Some((
|
let stream = match mid.into_stream(Arc::new(cfg)).await {
|
||||||
metadata,
|
Ok(stream) => Box::pin(stream) as AcceptStream,
|
||||||
Box::pin(mid.into_stream(Arc::new(cfg)).await?) as AcceptStream,
|
Err(e) => {
|
||||||
)));
|
tracing::trace!("Error completing TLS handshake: {e}");
|
||||||
|
tracing::trace!("{e:?}");
|
||||||
|
return Ok(None);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
return Ok(Some((metadata, stream)));
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(None)
|
Ok(None)
|
||||||
|
|||||||
@@ -39,6 +39,23 @@ pub struct AddTunnelParams {
|
|||||||
public: bool,
|
public: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn sanitize_config(config: &str) -> String {
|
||||||
|
let mut res = String::with_capacity(config.len());
|
||||||
|
for line in config.lines() {
|
||||||
|
if line
|
||||||
|
.trim()
|
||||||
|
.strip_prefix("AllowedIPs")
|
||||||
|
.map_or(false, |l| l.trim().starts_with("="))
|
||||||
|
{
|
||||||
|
res.push_str("AllowedIPs = 0.0.0.0/0, ::/0");
|
||||||
|
} else {
|
||||||
|
res.push_str(line);
|
||||||
|
}
|
||||||
|
res.push('\n');
|
||||||
|
}
|
||||||
|
res
|
||||||
|
}
|
||||||
|
|
||||||
pub async fn add_tunnel(
|
pub async fn add_tunnel(
|
||||||
ctx: RpcContext,
|
ctx: RpcContext,
|
||||||
AddTunnelParams {
|
AddTunnelParams {
|
||||||
@@ -86,7 +103,7 @@ pub async fn add_tunnel(
|
|||||||
|
|
||||||
let tmpdir = TmpDir::new().await?;
|
let tmpdir = TmpDir::new().await?;
|
||||||
let conf = tmpdir.join(&iface).with_extension("conf");
|
let conf = tmpdir.join(&iface).with_extension("conf");
|
||||||
write_file_atomic(&conf, &config).await?;
|
write_file_atomic(&conf, &sanitize_config(&config)).await?;
|
||||||
Command::new("nmcli")
|
Command::new("nmcli")
|
||||||
.arg("connection")
|
.arg("connection")
|
||||||
.arg("import")
|
.arg("import")
|
||||||
|
|||||||
Reference in New Issue
Block a user