From 0eb66f150cf9e08d3b5b00893c99e514f54f8bea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joakim=20Frosteg=C3=A5rd?= Date: Mon, 13 Jan 2025 22:14:15 +0100 Subject: [PATCH] Improve network address config documentation, update TODO --- TODO.md | 3 +++ crates/http/src/config.rs | 20 ++++++++------------ crates/udp/src/config.rs | 20 ++++++++------------ crates/ws/src/config.rs | 20 ++++++++------------ 4 files changed, 27 insertions(+), 36 deletions(-) diff --git a/TODO.md b/TODO.md index 1198ea7b..19174912 100644 --- a/TODO.md +++ b/TODO.md @@ -2,6 +2,9 @@ ## High priority +* Change network address handling to accept separate IPv4 and IPv6 + addresses. Open a socket for each one, setting ipv6_only flag on + the IPv6 one (unless user opts out). * update zerocopy version (will likely require minor rewrite) * udp (uring) diff --git a/crates/http/src/config.rs b/crates/http/src/config.rs index 4cee7424..958985be 100644 --- a/crates/http/src/config.rs +++ b/crates/http/src/config.rs @@ -78,18 +78,14 @@ pub struct NetworkConfig { /// - "127.0.0.1:3000" binds to port 3000 on the loopback interface /// (localhost) /// - /// When it comes to IPv6-style addresses, behaviour differs between - /// operating systems. On Linux or macOS, by default, both IPv4 and IPv6 - /// traffic is received. For instance: - /// - "[::]:3000" binds on all interfaces on port 3000, with both IPv4 and - /// IPv6 traffic being accepted - /// - "[::1]:3000" binds on the loopback interface (localhost) on port - /// 3000, with both IPv4 and IPv6 traffic being accepted - /// - /// In this case, to only accept traffic over IPv6, use an IPv6-style - /// address, and additionally set "only_ipv6" below. - /// - /// For other operating systems, please refer to their documentation. + /// When it comes to IPv6-style addresses, behaviour is more complex and + /// differs between operating systems. On Linux, to accept both IPv4 and + /// IPv6 traffic on any interface, use "[::]:3000". Set the "only_ipv6" + /// flag below to limit traffic to IPv6. To bind to the loopback interface + /// and only accept IPv6 packets, use "[::1]:3000" and set the only_ipv6 + /// flag. Receiving both IPv4 and IPv6 traffic on loopback is currently + /// not supported. For other operating systems, please refer to their + /// respective documentation. pub address: SocketAddr, /// Only allow access over IPv6 pub only_ipv6: bool, diff --git a/crates/udp/src/config.rs b/crates/udp/src/config.rs index 40914ba6..9fe1c71c 100644 --- a/crates/udp/src/config.rs +++ b/crates/udp/src/config.rs @@ -62,18 +62,14 @@ pub struct NetworkConfig { /// - "127.0.0.1:3000" binds to port 3000 on the loopback interface /// (localhost) /// - /// When it comes to IPv6-style addresses, behaviour differs between - /// operating systems. On Linux or macOS, by default, both IPv4 and IPv6 - /// traffic is received. For instance: - /// - "[::]:3000" binds on all interfaces on port 3000, with both IPv4 and - /// IPv6 traffic being accepted - /// - "[::1]:3000" binds on the loopback interface (localhost) on port - /// 3000, with both IPv4 and IPv6 traffic being accepted - /// - /// In this case, to only accept traffic over IPv6, use an IPv6-style - /// address, and additionally set "only_ipv6" below. - /// - /// For other operating systems, please refer to their documentation. + /// When it comes to IPv6-style addresses, behaviour is more complex and + /// differs between operating systems. On Linux, to accept both IPv4 and + /// IPv6 traffic on any interface, use "[::]:3000". Set the "only_ipv6" + /// flag below to limit traffic to IPv6. To bind to the loopback interface + /// and only accept IPv6 packets, use "[::1]:3000" and set the only_ipv6 + /// flag. Receiving both IPv4 and IPv6 traffic on loopback is currently + /// not supported. For other operating systems, please refer to their + /// respective documentation. pub address: SocketAddr, /// Only allow access over IPv6 pub only_ipv6: bool, diff --git a/crates/ws/src/config.rs b/crates/ws/src/config.rs index 5abb611e..8bb28294 100644 --- a/crates/ws/src/config.rs +++ b/crates/ws/src/config.rs @@ -82,18 +82,14 @@ pub struct NetworkConfig { /// - "127.0.0.1:3000" binds to port 3000 on the loopback interface /// (localhost) /// - /// When it comes to IPv6-style addresses, behaviour differs between - /// operating systems. On Linux or macOS, by default, both IPv4 and IPv6 - /// traffic is received. For instance: - /// - "[::]:3000" binds on all interfaces on port 3000, with both IPv4 and - /// IPv6 traffic being accepted - /// - "[::1]:3000" binds on the loopback interface (localhost) on port - /// 3000, with both IPv4 and IPv6 traffic being accepted - /// - /// In this case, to only accept traffic over IPv6, use an IPv6-style - /// address, and additionally set "only_ipv6" below. - /// - /// For other operating systems, please refer to their documentation. + /// When it comes to IPv6-style addresses, behaviour is more complex and + /// differs between operating systems. On Linux, to accept both IPv4 and + /// IPv6 traffic on any interface, use "[::]:3000". Set the "only_ipv6" + /// flag below to limit traffic to IPv6. To bind to the loopback interface + /// and only accept IPv6 packets, use "[::1]:3000" and set the only_ipv6 + /// flag. Receiving both IPv4 and IPv6 traffic on loopback is currently + /// not supported. For other operating systems, please refer to their + /// respective documentation. pub address: SocketAddr, /// Only allow access over IPv6 pub only_ipv6: bool,