Skip to content

Commit

Permalink
chore: add warning for unified delay test when second failed
Browse files Browse the repository at this point in the history
  • Loading branch information
Skyxim committed Oct 1, 2024
1 parent a330fa1 commit ecd8fac
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions adapter/adapter.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"net/netip"
"net/url"
"strconv"
"strings"
"time"

"github.com/metacubex/mihomo/common/atomic"
Expand All @@ -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"
)

Expand Down Expand Up @@ -260,10 +262,18 @@ 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
var secondResp *http.Response
secondResp, ignoredErr = client.Do(req)
if ignoredErr == nil {
resp = secondResp
_ = resp.Body.Close()
start = second
} else {
if strings.HasPrefix(url, "http://") {
log.Errorln("%s failed to get the second response from %s: %v", p.Name(), url, ignoredErr)
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.")
}
}
}

Expand Down

0 comments on commit ecd8fac

Please sign in to comment.