Fix inconsistent URLTest results

This commit is contained in:
世界
2026-07-25 13:05:31 +08:00
parent 397fb4d20a
commit cb0051d64d
6 changed files with 42 additions and 1 deletions

View File

@@ -11,6 +11,7 @@ import (
"github.com/sagernet/sing-box/adapter"
C "github.com/sagernet/sing-box/constant"
"github.com/sagernet/sing/common"
M "github.com/sagernet/sing/common/metadata"
N "github.com/sagernet/sing/common/network"
"github.com/sagernet/sing/common/ntp"
@@ -72,7 +73,18 @@ func (s *HistoryStorage) Close() error {
return nil
}
func URLTest(ctx context.Context, link string, detour N.Dialer) (t uint16, err error) {
func URLTest(ctx context.Context, link string, detour N.Dialer) (uint16, error) {
multiplexOutbound, isMultiplexOutbound := common.Cast[adapter.OutboundWithMultiplex](detour)
if isMultiplexOutbound && multiplexOutbound.MultiplexEnabled() {
_, err := urlTest(ctx, link, detour)
if err != nil {
return 0, err
}
}
return urlTest(ctx, link, detour)
}
func urlTest(ctx context.Context, link string, detour N.Dialer) (t uint16, err error) {
if link == "" {
link = "https://www.gstatic.com/generate_204"
}