@@ -589,6 +589,15 @@ func (h *baseHandler) undoAlg(algip netip.Addr, uid string) (undidAlg bool, real
589589 return
590590}
591591
592+ func filterFamilyForDialingWithFailSafe (ipcsv string ) (included []netip.Addr , excluded []netip.Addr , excludedIsIncluded bool ) {
593+ included , excluded , excludedIsIncluded = filterFamilyForDialing (ipcsv )
594+ if (! excludedIsIncluded || len (excluded ) > 0 ) && len (included ) > 0 {
595+ // if not falling back, then include one excluded ip as a fail-safe
596+ included = append (included , core .ChooseOne (excluded ))
597+ }
598+ return included , excluded , excludedIsIncluded
599+ }
600+
592601// filterFamilyForDialing filters out invalid IPs and IPs that are not
593602// of the family that the dialer is configured to use.
594603func filterFamilyForDialing (ipcsv string ) (included []netip.Addr , excluded []netip.Addr , excludedIsIncluded bool ) {
@@ -607,11 +616,11 @@ func filterFamilyForDialing(ipcsv string) (included []netip.Addr, excluded []net
607616 invalids ++
608617 continue
609618 }
610- // always include unspecified IPs as it is used by the client
611- // to make block/no-block decisions
612- if ip . IsUnspecified () || use4 && ip .Is4 () || use6 && ip .Is6 () {
619+ // TODO: always include unspecified IPs as it is used by the client to make block/no-block decisions?
620+ // The above is not true anymore?
621+ if use4 && ip .Is4 () || use6 && ip .Is6 () {
613622 filtered = append (filtered , ip )
614- } else {
623+ } else if ip . IsValid () && ! ip . IsUnspecified () {
615624 unfiltered = append (unfiltered , ip )
616625 }
617626 }
0 commit comments