@@ -18,7 +18,7 @@ func NetProbe(proxy *Proxy, address string, timeout int) error {
1818 } else {
1919 dlog .Critical (err )
2020 }
21- remoteUDPAddr , err := net . ResolveUDPAddr ( "udp" , address )
21+ remoteUDPAddrs , err := resolveNetprobeAddresses ( address )
2222 if err != nil {
2323 return err
2424 }
@@ -29,15 +29,21 @@ func NetProbe(proxy *Proxy, address string, timeout int) error {
2929 timeout = Min (MaxTimeout , timeout )
3030 }
3131 for tries := timeout ; tries > 0 ; tries -- {
32- pc , err := net .DialTimeout ("udp" , remoteUDPAddr .String (), proxy .timeout )
33- if err == nil {
32+ var err error
33+ for _ , remoteUDPAddr := range remoteUDPAddrs {
34+ var pc net.Conn
35+ pc , err = net .DialTimeout ("udp" , remoteUDPAddr .String (), proxy .timeout )
36+ if err != nil {
37+ continue
38+ }
3439 // Write at least 1 byte. This ensures that sockets are ready to use for writing.
3540 // Windows specific: during the system startup, sockets can be created but the underlying buffers may not be
3641 // set up yet. If this is the case Write fails with WSAENOBUFS: "An operation on a socket could not be
3742 // performed because the system lacked sufficient buffer space or because a queue was full"
3843 _ , err = pc .Write ([]byte {0 })
39- if err != nil {
40- pc .Close ()
44+ pc .Close ()
45+ if err == nil {
46+ break
4147 }
4248 }
4349 if err != nil {
@@ -49,7 +55,6 @@ func NetProbe(proxy *Proxy, address string, timeout int) error {
4955 time .Sleep (1 * time .Second )
5056 continue
5157 }
52- pc .Close ()
5358 dlog .Notice ("Network connectivity detected" )
5459 return nil
5560 }
0 commit comments