diff --git a/adapter/outboundgroup/fallback.go b/adapter/outboundgroup/fallback.go index c79d9871..1f4e1580 100644 --- a/adapter/outboundgroup/fallback.go +++ b/adapter/outboundgroup/fallback.go @@ -138,6 +138,10 @@ func (f *Fallback) Set(name string) error { return nil } +func (f *Fallback) ForceSet(name string) { + f.selected = name +} + func NewFallback(option *GroupCommonOption, providers []provider.ProxyProvider) *Fallback { return &Fallback{ GroupBase: NewGroupBase(GroupBaseOption{ diff --git a/adapter/outboundgroup/selector.go b/adapter/outboundgroup/selector.go index b5b1cfa3..96934f0c 100644 --- a/adapter/outboundgroup/selector.go +++ b/adapter/outboundgroup/selector.go @@ -78,6 +78,10 @@ func (s *Selector) Set(name string) error { return errors.New("proxy not exist") } +func (s *Selector) ForceSet(name string) { + s.selected = name +} + // Unwrap implements C.ProxyAdapter func (s *Selector) Unwrap(metadata *C.Metadata, touch bool) C.Proxy { return s.selectedProxy(touch) diff --git a/adapter/outboundgroup/urltest.go b/adapter/outboundgroup/urltest.go index 6f10f78b..5b0d2a17 100644 --- a/adapter/outboundgroup/urltest.go +++ b/adapter/outboundgroup/urltest.go @@ -53,6 +53,10 @@ func (u *URLTest) Set(name string) error { return nil } +func (u *URLTest) ForceSet(name string) { + u.selected = name +} + // DialContext implements C.ProxyAdapter func (u *URLTest) DialContext(ctx context.Context, metadata *C.Metadata, opts ...dialer.Option) (c C.Conn, err error) { proxy := u.fast(true) diff --git a/adapter/outboundgroup/util.go b/adapter/outboundgroup/util.go index adcda1aa..85373a1f 100644 --- a/adapter/outboundgroup/util.go +++ b/adapter/outboundgroup/util.go @@ -14,4 +14,5 @@ func tcpKeepAlive(c net.Conn) { type SelectAble interface { Set(string) error + ForceSet(name string) } diff --git a/hub/executor/executor.go b/hub/executor/executor.go index 3598d873..724150e7 100644 --- a/hub/executor/executor.go +++ b/hub/executor/executor.go @@ -413,7 +413,7 @@ func patchSelectGroup(proxies map[string]C.Proxy) { continue } - selector.Set(selected) + selector.ForceSet(selected) } }