@@ -913,37 +913,24 @@ pub fn parse_listening_addresses(
913913 IpAddr :: V4 ( v4_addr) => match & maybe_ipv4 {
914914 Some ( first_ipv4_addr) => {
915915 return Err ( format ! (
916- "When setting the --listen-address option twice, use an IpV4 address and an Ipv6 address. \
917- Got two IpV4 addresses {first_ipv4_addr} and {v4_addr}"
916+ "When setting the --listen-address option twice, use an IPv4 address and an IPv6 address. \
917+ Got two IPv4 addresses {first_ipv4_addr} and {v4_addr}"
918918 ) ) ;
919919 }
920920 None => maybe_ipv4 = Some ( v4_addr) ,
921921 } ,
922922 IpAddr :: V6 ( v6_addr) => match & maybe_ipv6 {
923923 Some ( first_ipv6_addr) => {
924924 return Err ( format ! (
925- "When setting the --listen-address option twice, use an IpV4 address and an Ipv6 address. \
926- Got two IpV6 addresses {first_ipv6_addr} and {v6_addr}"
925+ "When setting the --listen-address option twice, use an IPv4 address and an IPv6 address. \
926+ Got two IPv6 addresses {first_ipv6_addr} and {v6_addr}"
927927 ) ) ;
928928 }
929929 None => maybe_ipv6 = Some ( v6_addr) ,
930930 } ,
931931 }
932932 }
933933
934- // If we have specified an IPv4 listen address and not an IPv6 address and the
935- // host has a globally routeable IPv6 address and the CLI doesn't expressly disable IPv6,
936- // then we also listen on IPv6.
937- // Note that we will only listen on all interfaces if the IPv4 counterpart is also listening on
938- // all interfaces, to prevent accidental exposure of ports.
939- if maybe_ipv4 == Some ( Ipv4Addr :: UNSPECIFIED )
940- && maybe_ipv6. is_none ( )
941- && !cli_args. get_flag ( "disable_ipv6" )
942- && NetworkConfig :: is_ipv6_supported ( )
943- {
944- maybe_ipv6 = Some ( Ipv6Addr :: UNSPECIFIED ) ;
945- }
946-
947934 // parse the possible tcp ports
948935 let port = cli_args
949936 . get_one :: < String > ( "port" )
@@ -991,11 +978,22 @@ pub fn parse_listening_addresses(
991978 format ! ( "Failed to parse --quic6-port as an integer: {parse_error}" )
992979 } ) ?;
993980
981+ // Here we specify the default listening addresses for Lighthouse.
982+ // By default, we listen on 0.0.0.0.
983+ //
984+ // IF the host supports a globally routable IPv6 address, we also listen on ::.
985+ if matches ! ( ( maybe_ipv4, maybe_ipv6) , ( None , None ) ) {
986+ maybe_ipv4 = Some ( Ipv4Addr :: UNSPECIFIED ) ;
987+
988+ if NetworkConfig :: is_ipv6_supported ( ) {
989+ maybe_ipv6 = Some ( Ipv6Addr :: UNSPECIFIED ) ;
990+ }
991+ }
992+
994993 // Now put everything together
995994 let listening_addresses = match ( maybe_ipv4, maybe_ipv6) {
996995 ( None , None ) => {
997- // This should never happen unless clap is broken
998- return Err ( "No listening addresses provided" . into ( ) ) ;
996+ unreachable ! ( "This path is handled above this match statement" ) ;
999997 }
1000998 ( None , Some ( ipv6) ) => {
1001999 // A single ipv6 address was provided. Set the ports
0 commit comments