From abd584417b459ebcc93ea0f8cf6baaee3ead41bf Mon Sep 17 00:00:00 2001 From: Skyxim Date: Tue, 1 Oct 2024 02:58:53 +0000 Subject: [PATCH] chore: add warning for unified delay test when second failed --- adapter/adapter.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/adapter/adapter.go b/adapter/adapter.go index 3efc8166f0..b840c10cbd 100644 --- a/adapter/adapter.go +++ b/adapter/adapter.go @@ -10,6 +10,7 @@ import ( "net/netip" "net/url" "strconv" + "strings" "time" "github.com/metacubex/mihomo/common/atomic" @@ -18,6 +19,7 @@ import ( "github.com/metacubex/mihomo/component/ca" "github.com/metacubex/mihomo/component/dialer" C "github.com/metacubex/mihomo/constant" + "github.com/metacubex/mihomo/log" "github.com/puzpuzpuz/xsync/v3" ) @@ -260,10 +262,16 @@ func (p *Proxy) URLTest(ctx context.Context, url string, expectedStatus utils.In if unifiedDelay { second := time.Now() - resp, err = client.Do(req) - if err == nil { + var ignoredErr error + resp, ignoredErr = client.Do(req) + if ignoredErr == nil { _ = resp.Body.Close() start = second + } else { + log.Errorln("UnifiedDelay failed to get the second response: %v", ignoredErr) + if strings.HasPrefix(url, "http://") { + log.Warnln("It is recommended to use HTTPS for provider.health-check.url and group.url to ensure better reliability. Due to some proxy providers hijacking test addresses and not being compatible with repeated HEAD requests, using HTTP may result in failed tests.") + } } }