Skip to content

Commit 8e0a094

Browse files
venkatamutyalakorewaChino
authored andcommitted
fix: Host parsing for IPv6 addresses
1 parent 84f541f commit 8e0a094

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/deployment.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,13 +62,22 @@ fn convert_service_port(svcport: ServicePort) -> String {
6262
/// The function `generate_remote_arg` is returning a `String`. The `String`
6363
/// contains the formatted remote argument which is a combination of the `lb_ip` and `chisel_port`
6464
/// values obtained from the `node` parameter.
65+
use std::net::IpAddr;
66+
6567
pub fn generate_remote_arg(node: &ExitNode) -> String {
6668
// todo: what about ECDSA keys?
6769

6870
let host = node.get_host();
6971

7072
debug!(host = ?host, "Host");
71-
let output = format!("{}:{}", host, node.spec.port);
73+
74+
// Determine if the host is an IPv6 address and format accordingly
75+
let formatted_host = match host.parse::<IpAddr>() {
76+
Ok(IpAddr::V6(_)) => format!("[{}]", host),
77+
_ => host.to_string(),
78+
};
79+
80+
let output = format!("{}:{}", formatted_host, node.spec.port);
7281
debug!(output = ?output, "Output");
7382
output
7483
}

0 commit comments

Comments
 (0)