From 26e6d83f8b7873759e2c0d27bfe80d747acbe7db Mon Sep 17 00:00:00 2001 From: xishang0128 Date: Wed, 7 May 2025 17:07:39 +0800 Subject: [PATCH] chore: make select display the specified testUrl for https://github.com/MetaCubeX/mihomo/issues/2013 --- adapter/outboundgroup/selector.go | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/adapter/outboundgroup/selector.go b/adapter/outboundgroup/selector.go index a3f42525..03ee192c 100644 --- a/adapter/outboundgroup/selector.go +++ b/adapter/outboundgroup/selector.go @@ -13,6 +13,7 @@ type Selector struct { *GroupBase disableUDP bool selected string + testUrl string Hidden bool Icon string } @@ -55,13 +56,20 @@ func (s *Selector) MarshalJSON() ([]byte, error) { for _, proxy := range s.GetProxies(false) { all = append(all, proxy.Name()) } + // When testurl is the default value + // do not append a value to ensure that the web dashboard follows the settings of the dashboard + var url string + if s.testUrl != C.DefaultTestURL { + url = s.testUrl + } return json.Marshal(map[string]any{ - "type": s.Type().String(), - "now": s.Now(), - "all": all, - "hidden": s.Hidden, - "icon": s.Icon, + "type": s.Type().String(), + "now": s.Now(), + "all": all, + "testUrl": url, + "hidden": s.Hidden, + "icon": s.Icon, }) } @@ -114,6 +122,7 @@ func NewSelector(option *GroupCommonOption, providers []provider.ProxyProvider) }), selected: "COMPATIBLE", disableUDP: option.DisableUDP, + testUrl: option.URL, Hidden: option.Hidden, Icon: option.Icon, }