From e34090c39a5dfaa9f7730ec5154c6ae8cf78d3fa Mon Sep 17 00:00:00 2001 From: comwrg Date: Wed, 28 Aug 2019 22:28:02 +0800 Subject: [PATCH] Improve: url-test retry dial when failed (#283) --- adapters/outbound/urltest.go | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/adapters/outbound/urltest.go b/adapters/outbound/urltest.go index 6f61d8d7..b9efd8d2 100644 --- a/adapters/outbound/urltest.go +++ b/adapters/outbound/urltest.go @@ -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 { +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 + } u.fallback() - } else { - a.AppendToChains(u) } - return a, err + return } func (u *URLTest) DialUDP(metadata *C.Metadata) (C.PacketConn, net.Addr, error) {