chore: force set SelectAble when start load cache
This commit is contained in:
parent
c2af8cebf7
commit
23a7aaeeed
5 changed files with 14 additions and 1 deletions
|
@ -138,6 +138,10 @@ func (f *Fallback) Set(name string) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (f *Fallback) ForceSet(name string) {
|
||||||
|
f.selected = name
|
||||||
|
}
|
||||||
|
|
||||||
func NewFallback(option *GroupCommonOption, providers []provider.ProxyProvider) *Fallback {
|
func NewFallback(option *GroupCommonOption, providers []provider.ProxyProvider) *Fallback {
|
||||||
return &Fallback{
|
return &Fallback{
|
||||||
GroupBase: NewGroupBase(GroupBaseOption{
|
GroupBase: NewGroupBase(GroupBaseOption{
|
||||||
|
|
|
@ -78,6 +78,10 @@ func (s *Selector) Set(name string) error {
|
||||||
return errors.New("proxy not exist")
|
return errors.New("proxy not exist")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *Selector) ForceSet(name string) {
|
||||||
|
s.selected = name
|
||||||
|
}
|
||||||
|
|
||||||
// Unwrap implements C.ProxyAdapter
|
// Unwrap implements C.ProxyAdapter
|
||||||
func (s *Selector) Unwrap(metadata *C.Metadata, touch bool) C.Proxy {
|
func (s *Selector) Unwrap(metadata *C.Metadata, touch bool) C.Proxy {
|
||||||
return s.selectedProxy(touch)
|
return s.selectedProxy(touch)
|
||||||
|
|
|
@ -53,6 +53,10 @@ func (u *URLTest) Set(name string) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (u *URLTest) ForceSet(name string) {
|
||||||
|
u.selected = name
|
||||||
|
}
|
||||||
|
|
||||||
// DialContext implements C.ProxyAdapter
|
// DialContext implements C.ProxyAdapter
|
||||||
func (u *URLTest) DialContext(ctx context.Context, metadata *C.Metadata, opts ...dialer.Option) (c C.Conn, err error) {
|
func (u *URLTest) DialContext(ctx context.Context, metadata *C.Metadata, opts ...dialer.Option) (c C.Conn, err error) {
|
||||||
proxy := u.fast(true)
|
proxy := u.fast(true)
|
||||||
|
|
|
@ -14,4 +14,5 @@ func tcpKeepAlive(c net.Conn) {
|
||||||
|
|
||||||
type SelectAble interface {
|
type SelectAble interface {
|
||||||
Set(string) error
|
Set(string) error
|
||||||
|
ForceSet(name string)
|
||||||
}
|
}
|
||||||
|
|
|
@ -413,7 +413,7 @@ func patchSelectGroup(proxies map[string]C.Proxy) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
selector.Set(selected)
|
selector.ForceSet(selected)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue