Improve: Dial
would reset proxy alive status
This commit is contained in:
@ -1,7 +1,6 @@
|
||||
package executor
|
||||
|
||||
import (
|
||||
adapters "github.com/Dreamacro/clash/adapters/outbound"
|
||||
"github.com/Dreamacro/clash/config"
|
||||
C "github.com/Dreamacro/clash/constant"
|
||||
"github.com/Dreamacro/clash/dns"
|
||||
@ -66,14 +65,9 @@ func updateProxies(proxies map[string]C.Proxy) {
|
||||
tunnel := T.Instance()
|
||||
oldProxies := tunnel.Proxies()
|
||||
|
||||
// close old goroutine
|
||||
// close proxy group goroutine
|
||||
for _, proxy := range oldProxies {
|
||||
switch raw := proxy.(type) {
|
||||
case *adapters.URLTest:
|
||||
raw.Close()
|
||||
case *adapters.Fallback:
|
||||
raw.Close()
|
||||
}
|
||||
proxy.Destroy()
|
||||
}
|
||||
|
||||
tunnel.UpdateProxies(proxies)
|
||||
|
@ -81,12 +81,11 @@ func updateProxy(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
proxy := r.Context().Value(CtxKeyProxy).(C.Proxy)
|
||||
|
||||
selector, ok := proxy.(*A.Selector)
|
||||
proxy := r.Context().Value(CtxKeyProxy).(*A.Proxy)
|
||||
selector, ok := proxy.ProxyAdapter.(*A.Selector)
|
||||
if !ok {
|
||||
render.Status(r, http.StatusBadRequest)
|
||||
render.JSON(w, r, ErrBadRequest)
|
||||
render.JSON(w, r, newError("Must be a Selector"))
|
||||
return
|
||||
}
|
||||
|
||||
@ -113,7 +112,7 @@ func getProxyDelay(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
sigCh := make(chan int16)
|
||||
go func() {
|
||||
t, err := A.DelayTest(proxy, url)
|
||||
t, err := proxy.URLTest(url)
|
||||
if err != nil {
|
||||
sigCh <- 0
|
||||
}
|
||||
|
Reference in New Issue
Block a user