Skip to content

Commit

Permalink
fix: dialer dual stack panic
Browse files Browse the repository at this point in the history
  • Loading branch information
Skyxim committed Mar 10, 2023
1 parent 2ccef31 commit 5bcfe1a
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions component/dialer/dialer.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,16 +182,8 @@ func dualStackDialContext(ctx context.Context, dialFn dialFunc, network string,
go racer(ipv6s, preferIPVersion != 4)
var fallback dialResult
var errs []error
for {
for i := 0; i < 2; i++ {
select {
case <-ctx.Done():
if fallback.error == nil && fallback.Conn != nil {
return fallback.Conn, nil
}
if res, ok := <-results; ok && res.error == nil {
return res.Conn, nil
}
return nil, errorsJoin(errs...)
case <-fallbackTicker.C:
if fallback.error == nil && fallback.Conn != nil {
return fallback.Conn, nil
Expand All @@ -211,6 +203,10 @@ func dualStackDialContext(ctx context.Context, dialFn dialFunc, network string,
}
}
}
if fallback.error == nil && fallback.Conn != nil {
return fallback.Conn, nil
}
return nil, errorsJoin(errs...)
}

func parallelDialContext(ctx context.Context, network string, ips []netip.Addr, port string, opt *option) (net.Conn, error) {
Expand Down

0 comments on commit 5bcfe1a

Please sign in to comment.