feat(core): implement multi-transport listeners with ListenerConfig and Vec<ListenerConfig>
- Add ListenerConfig struct with transport_kind, listen_addr, per-transport config - Add Dns and WebTransport variants to TransportKind (tags only, no behavior) - Add .listeners() builder method to ServeOptions for multi-listener config - Keep .transport_mode() backwards compatible (creates single-element listeners vec) - Update Server::run() to use listeners from Server struct (first listener) - Add Server::listeners() accessor for multi-transport listener configs - Update StaticConfig to support listeners field, converted from ServeOptions - All listeners share Arc<ArcSwap<DynamicConfig>>, ConnectionRateLimiter, and IdentityProvider - Graceful shutdown terminates accept loop via existing shutdown signal - TOML [[listeners]] array-of-tables syntax supported via ListenerConfig in StaticConfig - Add comprehensive tests for ListenerConfig, multi-listener ServeOptions, Server creation
This commit is contained in:
@@ -91,6 +91,8 @@ pub enum TransportKind {
|
||||
Tcp,
|
||||
Tls { server_name: Option<String> },
|
||||
Iroh { endpoint_id: String },
|
||||
Dns { domain: String },
|
||||
WebTransport { host: String },
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
@@ -169,6 +171,12 @@ mod tests {
|
||||
let iroh = TransportKind::Iroh {
|
||||
endpoint_id: "abc123".to_string(),
|
||||
};
|
||||
let dns = TransportKind::Dns {
|
||||
domain: "example.com".to_string(),
|
||||
};
|
||||
let wt = TransportKind::WebTransport {
|
||||
host: "example.com".to_string(),
|
||||
};
|
||||
|
||||
if let TransportKind::Tcp = tcp {}
|
||||
if let TransportKind::Tls {
|
||||
@@ -180,5 +188,11 @@ mod tests {
|
||||
if let TransportKind::Iroh { endpoint_id } = iroh {
|
||||
assert_eq!(endpoint_id, "abc123");
|
||||
}
|
||||
if let TransportKind::Dns { domain } = dns {
|
||||
assert_eq!(domain, "example.com");
|
||||
}
|
||||
if let TransportKind::WebTransport { host } = wt {
|
||||
assert_eq!(host, "example.com");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user