@@ -913,37 +913,24 @@ pub fn parse_listening_addresses(
913
913
IpAddr :: V4 ( v4_addr) => match & maybe_ipv4 {
914
914
Some ( first_ipv4_addr) => {
915
915
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}"
918
918
) ) ;
919
919
}
920
920
None => maybe_ipv4 = Some ( v4_addr) ,
921
921
} ,
922
922
IpAddr :: V6 ( v6_addr) => match & maybe_ipv6 {
923
923
Some ( first_ipv6_addr) => {
924
924
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}"
927
927
) ) ;
928
928
}
929
929
None => maybe_ipv6 = Some ( v6_addr) ,
930
930
} ,
931
931
}
932
932
}
933
933
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
-
947
934
// parse the possible tcp ports
948
935
let port = cli_args
949
936
. get_one :: < String > ( "port" )
@@ -991,11 +978,22 @@ pub fn parse_listening_addresses(
991
978
format ! ( "Failed to parse --quic6-port as an integer: {parse_error}" )
992
979
} ) ?;
993
980
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
+
994
993
// Now put everything together
995
994
let listening_addresses = match ( maybe_ipv4, maybe_ipv6) {
996
995
( 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" ) ;
999
997
}
1000
998
( None , Some ( ipv6) ) => {
1001
999
// A single ipv6 address was provided. Set the ports
0 commit comments