From 7d222b1b713156e2e4c408d9f5d882ecde07116d Mon Sep 17 00:00:00 2001 From: Larvan2 <78135608+Larvan2@users.noreply.github.com> Date: Mon, 13 Nov 2023 17:42:25 +0800 Subject: [PATCH] fix: health check available for 'selector' if configured --- adapter/outboundgroup/parser.go | 9 ++------- hub/executor/executor.go | 5 ++--- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/adapter/outboundgroup/parser.go b/adapter/outboundgroup/parser.go index 806732cf..8607bea1 100644 --- a/adapter/outboundgroup/parser.go +++ b/adapter/outboundgroup/parser.go @@ -92,9 +92,6 @@ func ParseProxyGroup(config map[string]any, proxyMap map[string]C.Proxy, provide return nil, fmt.Errorf("%s: %w", groupName, errDuplicateProvider) } - var url string - var interval uint - // select don't need health check if groupOption.Type != "select" && groupOption.Type != "relay" { if groupOption.URL == "" { @@ -104,12 +101,10 @@ func ParseProxyGroup(config map[string]any, proxyMap map[string]C.Proxy, provide if groupOption.Interval == 0 { groupOption.Interval = 300 } - - url = groupOption.URL - interval = uint(groupOption.Interval) } - hc := provider.NewHealthCheck(ps, url, interval, true, expectedStatus) + hc := provider.NewHealthCheck(ps, groupOption.URL, uint(groupOption.Interval), true, expectedStatus) + pd, err := provider.NewCompatibleProvider(groupName, ps, hc) if err != nil { return nil, fmt.Errorf("%s: %w", groupName, err) diff --git a/hub/executor/executor.go b/hub/executor/executor.go index e0b12039..efd9a076 100644 --- a/hub/executor/executor.go +++ b/hub/executor/executor.go @@ -10,8 +10,6 @@ import ( "sync" "time" - "github.com/metacubex/mihomo/ntp" - "github.com/metacubex/mihomo/adapter" "github.com/metacubex/mihomo/adapter/inbound" "github.com/metacubex/mihomo/adapter/outboundgroup" @@ -35,6 +33,7 @@ import ( "github.com/metacubex/mihomo/listener/inner" "github.com/metacubex/mihomo/listener/tproxy" "github.com/metacubex/mihomo/log" + "github.com/metacubex/mihomo/ntp" "github.com/metacubex/mihomo/tunnel" ) @@ -310,7 +309,7 @@ func loadProxyProvider(proxyProviders map[string]provider.ProxyProvider) { go func() { defer func() { <-ch; wg.Done() }() loadProvider(proxyProvider) - if proxyProvider.VehicleType()==provider.Compatible{ + if proxyProvider.VehicleType() == provider.Compatible { go proxyProvider.HealthCheck() } }()