Improve: url-test retry dial when failed (#283)

This commit is contained in:
comwrg 2019-08-28 22:28:02 +08:00 committed by Dreamacro
parent 5cc66e51db
commit e34090c39a

View file

@ -33,14 +33,16 @@ func (u *URLTest) Now() string {
return u.fast.Name()
}
func (u *URLTest) Dial(metadata *C.Metadata) (C.Conn, error) {
a, err := u.fast.Dial(metadata)
if err != nil {
u.fallback()
} else {
a.AppendToChains(u)
func (u *URLTest) Dial(metadata *C.Metadata) (c C.Conn, err error) {
for i := 0; i < 3; i++ {
c, err = u.fast.Dial(metadata)
if err == nil {
c.AppendToChains(u)
return
}
return a, err
u.fallback()
}
return
}
func (u *URLTest) DialUDP(metadata *C.Metadata) (C.PacketConn, net.Addr, error) {