Skip to content

Commit 26e6d83

Browse files
committed
chore: make select display the specified testUrl
for MetaCubeX#2013
1 parent 50d7834 commit 26e6d83

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

adapter/outboundgroup/selector.go

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ type Selector struct {
1313
*GroupBase
1414
disableUDP bool
1515
selected string
16+
testUrl string
1617
Hidden bool
1718
Icon string
1819
}
@@ -55,13 +56,20 @@ func (s *Selector) MarshalJSON() ([]byte, error) {
5556
for _, proxy := range s.GetProxies(false) {
5657
all = append(all, proxy.Name())
5758
}
59+
// When testurl is the default value
60+
// do not append a value to ensure that the web dashboard follows the settings of the dashboard
61+
var url string
62+
if s.testUrl != C.DefaultTestURL {
63+
url = s.testUrl
64+
}
5865

5966
return json.Marshal(map[string]any{
60-
"type": s.Type().String(),
61-
"now": s.Now(),
62-
"all": all,
63-
"hidden": s.Hidden,
64-
"icon": s.Icon,
67+
"type": s.Type().String(),
68+
"now": s.Now(),
69+
"all": all,
70+
"testUrl": url,
71+
"hidden": s.Hidden,
72+
"icon": s.Icon,
6573
})
6674
}
6775

@@ -114,6 +122,7 @@ func NewSelector(option *GroupCommonOption, providers []provider.ProxyProvider)
114122
}),
115123
selected: "COMPATIBLE",
116124
disableUDP: option.DisableUDP,
125+
testUrl: option.URL,
117126
Hidden: option.Hidden,
118127
Icon: option.Icon,
119128
}

0 commit comments

Comments
 (0)