Fix secure tunnel session handling

This commit is contained in:
RWDai
2026-05-22 14:35:43 +08:00
parent b05f2a270a
commit 33633637e5
11 changed files with 40 additions and 67 deletions

View File

@@ -41,6 +41,7 @@ tar = "0.4"
socket2 = { version = "0.5", features = ["all"] }
tower-service = "0.3"
webpki-roots = "0.26"
uuid.workspace = true
[dev-dependencies]
aether-gateway.workspace = true

View File

@@ -61,6 +61,7 @@ pub async fn connect_and_run(
);
let node_id = server.node_id.read().unwrap().clone();
headers.insert("X-Node-Id", http::HeaderValue::from_str(&node_id)?);
let security_session = uuid::Uuid::new_v4().simple().to_string();
if server.tunnel_security == crate::config::TunnelSecurity::NonTlsRequired {
headers.insert(
TUNNEL_SECURITY_HEADER,
@@ -68,7 +69,7 @@ pub async fn connect_and_run(
);
headers.insert(
TUNNEL_SECURITY_SESSION_HEADER,
http::HeaderValue::from_str(&node_id)?,
http::HeaderValue::from_str(&security_session)?,
);
}
// Use dynamic node_name (may be updated by remote config) instead of
@@ -142,7 +143,7 @@ pub async fn connect_and_run(
.ok_or_else(|| anyhow::anyhow!("secure tunnel requires tunnel_encryption_key"))?;
Some(Arc::new(SecureFrameCodec::new(
key,
&node_id,
&security_session,
TunnelSecurityRole::Client,
)?))
} else {