Update urltest for test a proxy

鉴于auto规则 失败后很久才能重新访问。提供一个思路和实践:节点失败时单个测速,而不是非要等到健康检查。
This commit is contained in:
liuxy 2025-06-11 14:50:59 +08:00 committed by GitHub
parent ae7967f662
commit 165047acae
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -4,6 +4,7 @@ import (
"context"
"encoding/json"
"errors"
"fmt"
"time"
"github.com/metacubex/mihomo/common/callback"
@ -67,6 +68,11 @@ func (u *URLTest) DialContext(ctx context.Context, metadata *C.Metadata) (c C.Co
c.AppendToChains(u)
} else {
u.onDialFailed(proxy.Type(), err, u.healthCheck)
expectedStatus, err := utils.NewUnsignedRanges[uint16](u.expectedStatus)
if err != nil {
return nil, fmt.Errorf("DialContext onDialFailed %s: %w", proxy.Name(), err)
}
proxy.URLTest(ctx, u.testUrl, expectedStatus)
}
if N.NeedHandshake(c) {