diff --git a/TODO.md b/TODO.md index 50b9bca..986d9a6 100644 --- a/TODO.md +++ b/TODO.md @@ -20,12 +20,10 @@ * uring * ValidUntil periodic update * statistics - * ipv6_only * shared config keys such as poll interval * mio * stagger connection cleaning intervals? * ipv4-mapped addresses - * ipv6_only * glommio * consider sending local responses immediately * consider adding ConnectedScrapeRequest::Scrape(PendingScrapeRequest) diff --git a/aquatic_udp/src/lib/common/network.rs b/aquatic_udp/src/lib/common/network.rs index ca3edaf..053a7da 100644 --- a/aquatic_udp/src/lib/common/network.rs +++ b/aquatic_udp/src/lib/common/network.rs @@ -123,6 +123,10 @@ pub fn create_socket(config: &Config) -> ::std::net::UdpSocket { } .expect("create socket"); + if config.network.only_ipv6 { + socket.set_only_v6(true).expect("socket: set only ipv6"); + } + socket.set_reuse_port(true).expect("socket: set reuse port"); socket diff --git a/aquatic_udp/src/lib/config.rs b/aquatic_udp/src/lib/config.rs index f6c0247..8f2b8a2 100644 --- a/aquatic_udp/src/lib/config.rs +++ b/aquatic_udp/src/lib/config.rs @@ -38,6 +38,7 @@ impl aquatic_cli_helpers::Config for Config { pub struct NetworkConfig { /// Bind to this address pub address: SocketAddr, + pub only_ipv6: bool, /// Size of socket recv buffer. Use 0 for OS default. /// /// This setting can have a big impact on dropped packages. It might @@ -120,6 +121,7 @@ impl Default for NetworkConfig { fn default() -> Self { Self { address: SocketAddr::from(([0, 0, 0, 0], 3000)), + only_ipv6: false, socket_recv_buffer_size: 4096 * 128, #[cfg(feature = "with-mio")] poll_event_capacity: 4096,