Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions dragonfly-client-config/src/dfdaemon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,9 @@ pub struct Host {

/// ip is the advertise ip of the host.
pub ip: Option<IpAddr>,

/// enable_dual_stack indicates whether enable dual stack.
pub enable_dual_stack: bool,
}

/// Host implements Default.
Expand All @@ -398,6 +401,7 @@ impl Default for Host {
location: None,
hostname: default_host_hostname(),
ip: None,
enable_dual_stack: false,
}
}
}
Expand Down Expand Up @@ -1079,6 +1083,9 @@ pub struct ProxyServer {
/// ip is the listen ip of the proxy server.
pub ip: Option<IpAddr>,

/// enable_dual_stack indicates whether enable dual stack.
pub enable_dual_stack: bool,

/// port is the port to the proxy server.
#[serde(default = "default_proxy_server_port")]
pub port: u16,
Expand Down Expand Up @@ -1289,6 +1296,9 @@ pub struct Security {
pub struct Network {
/// enable_ipv6 indicates whether enable ipv6.
pub enable_ipv6: bool,

/// enable_dual_stack indicates whether enable dual stack.
pub enable_dual_stack: bool,
}

/// HealthServer is the health server configuration for dfdaemon.
Expand Down Expand Up @@ -1349,6 +1359,9 @@ impl Default for MetricsServer {
pub struct Metrics {
/// server is the metrics server configuration for dfdaemon.
pub server: MetricsServer,

/// enable_dual_stack indicates whether enable dual stack.
pub enable_dual_stack: bool,
}

/// StatsServer is the stats server configuration for dfdaemon.
Expand Down Expand Up @@ -1379,6 +1392,9 @@ impl Default for StatsServer {
pub struct Stats {
/// server is the stats server configuration for dfdaemon.
pub server: StatsServer,

/// enable_dual_stack indicates whether enable dual stack.
pub enable_dual_stack: bool,
}

/// Tracing is the tracing configuration for dfdaemon.
Expand Down
25 changes: 24 additions & 1 deletion dragonfly-client-util/src/net/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
use bytesize::{ByteSize, MB};
use pnet::datalink::{self, NetworkInterface};
use std::cmp::min;
use std::net::IpAddr;
use std::net::{IpAddr, Ipv4Addr, Ipv6Addr};

#[cfg(not(target_os = "linux"))]
use tracing::warn;
Expand Down Expand Up @@ -83,3 +83,26 @@ pub fn get_interface_info(ip: IpAddr, rate_limit: ByteSize) -> Option<Interface>
}),
}
}

/// DualStack represents a dual stack with ipv4 and ipv6.
pub struct DualStack {
pub ipv4: Option<Ipv4Addr>,
pub ipv6: Option<Ipv6Addr>,
}

impl DualStack {
/// new creates a new DualStack.
pub fn new(ipv4: Option<Ipv4Addr>, ipv6: Option<Ipv6Addr>) -> Self {
Self { ipv4, ipv6 }
}

// get_ip returns the ip address.
pub fn get_ip(&self) -> Option<String> {
match (self.ipv4, self.ipv6) {
(Some(v4), Some(v6)) => Some(format!("{},{}", v4, v6)),
(Some(v4), None) => Some(v4.to_string()),
(None, Some(v6)) => Some(v6.to_string()),
(None, None) => None,
}
}
}
Loading