From eec33b305a89f36ed01d8789cedea549cf55e1f2 Mon Sep 17 00:00:00 2001 From: ant-black <1016930479@qq.com> Date: Wed, 10 Jun 2026 23:18:30 +0800 Subject: [PATCH] fix: enable mihomo ipv6 speed tests --- backend/internal/proxy/speedtest.go | 6 ++++++ backend/internal/proxy/speedtest_test.go | 13 +++++++++++++ 2 files changed, 19 insertions(+) diff --git a/backend/internal/proxy/speedtest.go b/backend/internal/proxy/speedtest.go index 21eb0b65..8bb02629 100644 --- a/backend/internal/proxy/speedtest.go +++ b/backend/internal/proxy/speedtest.go @@ -5,6 +5,7 @@ import ( "time" "github.com/metacubex/mihomo/adapter" + "github.com/metacubex/mihomo/component/resolver" "ant-chrome/backend/internal/config" "ant-chrome/backend/internal/logger" @@ -62,6 +63,7 @@ func SpeedTest( if testURL == "" { return TestResult{ProxyId: proxyId, Ok: false, Error: "测速目标 URL 为空"} } + enableMihomoIPv6() resolvedSrc := src if IsChainSocks5Proxy(src) { @@ -104,3 +106,7 @@ func SpeedTest( adapter.UnifiedDelay.Store(true) return unifiedDelayTest(proxyId, proxyInstance, testURL, cfg.Timeout) } + +func enableMihomoIPv6() { + resolver.DisableIPv6 = false +} diff --git a/backend/internal/proxy/speedtest_test.go b/backend/internal/proxy/speedtest_test.go index 3cd801a1..5120d327 100644 --- a/backend/internal/proxy/speedtest_test.go +++ b/backend/internal/proxy/speedtest_test.go @@ -4,6 +4,8 @@ import ( "encoding/base64" "strings" "testing" + + "github.com/metacubex/mihomo/component/resolver" ) func TestProxyConfigToMappingStandardProxy(t *testing.T) { @@ -31,6 +33,17 @@ func TestProxyConfigToMappingStandardProxy(t *testing.T) { } } +func TestEnableMihomoIPv6(t *testing.T) { + resolver.DisableIPv6 = true + t.Cleanup(func() { resolver.DisableIPv6 = true }) + + enableMihomoIPv6() + + if resolver.DisableIPv6 { + t.Fatal("expected mihomo IPv6 resolver to be enabled") + } +} + func TestProxyConfigToMappingEscapedCredentials(t *testing.T) { t.Parallel()