From b7371738c4d8bb540bc490acedb910b63d427567 Mon Sep 17 00:00:00 2001 From: gVisor bot Date: Sun, 26 Feb 2023 21:01:44 +0800 Subject: [PATCH] fix: handle no IP address --- component/dialer/dialer.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/component/dialer/dialer.go b/component/dialer/dialer.go index d4c937e7..3a37620d 100644 --- a/component/dialer/dialer.go +++ b/component/dialer/dialer.go @@ -218,13 +218,17 @@ func dualStackDialContext( return res.Conn, nil } fallback = res + } else { + err = res.error } - err = res.error } } } func parallelDialContext(ctx context.Context, network string, ips []netip.Addr, port string, opt *option) (net.Conn, error) { + if len(ips) == 0 { + return nil, errors.New("no ip address") + } results := make(chan dialResult) returned := make(chan struct{}) defer close(returned) @@ -267,6 +271,9 @@ func parallelDialContext(ctx context.Context, network string, ips []netip.Addr, } func serialDialContext(ctx context.Context, network string, ips []netip.Addr, port string, opt *option) (net.Conn, error) { + if len(ips) == 0 { + return nil, errors.New("no ip address") + } var ( conn net.Conn err error