chore: force set SelectAble when start load cache

This commit is contained in:
gVisor bot 2023-04-24 08:07:17 +08:00
parent c2af8cebf7
commit 23a7aaeeed
5 changed files with 14 additions and 1 deletions

View file

@ -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{

View file

@ -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)

View file

@ -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)

View file

@ -14,4 +14,5 @@ func tcpKeepAlive(c net.Conn) {
type SelectAble interface {
Set(string) error
ForceSet(name string)
}

View file

@ -413,7 +413,7 @@ func patchSelectGroup(proxies map[string]C.Proxy) {
continue
}
selector.Set(selected)
selector.ForceSet(selected)
}
}