From 9e89b3a201e51f30b6ee8f96af1639e90935ed47 Mon Sep 17 00:00:00 2001 From: kr328 Date: Sun, 13 Jun 2021 14:16:25 +0800 Subject: [PATCH] Chore: update clash core --- core/src/main/golang/clash | 2 +- core/src/main/golang/config/process.go | 14 +++++++++++++- core/src/main/golang/proxy/http.go | 6 +++--- core/src/main/golang/tun/udp.go | 4 ++-- core/src/main/golang/tunnel/connectivity.go | 8 ++++---- core/src/main/golang/tunnel/providers.go | 2 +- core/src/main/golang/tunnel/providers_premium.go | 2 +- core/src/main/golang/tunnel/proxies.go | 16 ++++++++-------- core/src/main/golang/tunnel/suspend.go | 2 +- 9 files changed, 34 insertions(+), 22 deletions(-) diff --git a/core/src/main/golang/clash b/core/src/main/golang/clash index 043e34f7..e175b59b 160000 --- a/core/src/main/golang/clash +++ b/core/src/main/golang/clash @@ -1 +1 @@ -Subproject commit 043e34f7006d74b68dbb308ca8a43704be3f6712 +Subproject commit e175b59bc0bb1f01c688f6ac3dc3bf8cf01e1a30 diff --git a/core/src/main/golang/config/process.go b/core/src/main/golang/config/process.go index 3c850a4c..8244e2bf 100644 --- a/core/src/main/golang/config/process.go +++ b/core/src/main/golang/config/process.go @@ -5,6 +5,7 @@ import ( "errors" "fmt" "strings" + "time" "github.com/Dreamacro/clash/log" "github.com/dlclark/regexp2" @@ -16,6 +17,11 @@ import ( "github.com/Dreamacro/clash/dns" ) +const ( + defaultHealthCheckUrl = "https://www.gstatic.com/generate_204" + defaultHealthCheckInterval = time.Hour +) + var processors = []processor{ patchOverride, patchGeneral, @@ -88,7 +94,13 @@ func patchProviders(cfg *config.RawConfig, profileDir string) error { func patchProxyGroup(cfg *config.RawConfig, _ string) error { for _, g := range cfg.ProxyGroup { - g["lazy"] = false + if _, exist := g["url"]; !exist { + g["url"] = defaultHealthCheckUrl + } + + if _, exist := g["interval"]; !exist { + g["interval"] = int(defaultHealthCheckInterval.Seconds()) + } } return nil diff --git a/core/src/main/golang/proxy/http.go b/core/src/main/golang/proxy/http.go index 4b6d94ee..280d5e95 100644 --- a/core/src/main/golang/proxy/http.go +++ b/core/src/main/golang/proxy/http.go @@ -7,7 +7,7 @@ import ( "sync" "time" - adapters "github.com/Dreamacro/clash/adapters/inbound" + "github.com/Dreamacro/clash/adapter/inbound" "github.com/Dreamacro/clash/log" "github.com/Dreamacro/clash/tunnel" ) @@ -102,9 +102,9 @@ func (l *httpListener) handleConn(conn net.Conn) { if err != nil { return } - tunnel.Add(adapters.NewHTTPS(request, conn)) + tunnel.Add(inbound.NewHTTPS(request, conn)) return } - tunnel.Add(adapters.NewHTTP(request, conn)) + tunnel.Add(inbound.NewHTTP(request, conn)) } diff --git a/core/src/main/golang/tun/udp.go b/core/src/main/golang/tun/udp.go index 535f9fa5..6357282b 100644 --- a/core/src/main/golang/tun/udp.go +++ b/core/src/main/golang/tun/udp.go @@ -7,7 +7,7 @@ import ( "github.com/Dreamacro/clash/transport/socks5" "github.com/kr328/tun2socket" - adapters "github.com/Dreamacro/clash/adapters/inbound" + "github.com/Dreamacro/clash/adapter/inbound" "github.com/Dreamacro/clash/common/pool" C "github.com/Dreamacro/clash/constant" "github.com/Dreamacro/clash/tunnel" @@ -74,7 +74,7 @@ read: data: buf[:n], } - adapter := adapters.NewPacket(socks5.ParseAddrToSocksAddr(tAddr), pkt, C.SOCKS) + adapter := inbound.NewPacket(socks5.ParseAddrToSocksAddr(tAddr), pkt, C.SOCKS) tunnel.AddPacket(adapter) } diff --git a/core/src/main/golang/tunnel/connectivity.go b/core/src/main/golang/tunnel/connectivity.go index de94850f..76817310 100644 --- a/core/src/main/golang/tunnel/connectivity.go +++ b/core/src/main/golang/tunnel/connectivity.go @@ -3,9 +3,9 @@ package tunnel import ( "sync" - "github.com/Dreamacro/clash/adapters/outbound" - "github.com/Dreamacro/clash/adapters/outboundgroup" - "github.com/Dreamacro/clash/adapters/provider" + "github.com/Dreamacro/clash/adapter" + "github.com/Dreamacro/clash/adapter/outboundgroup" + "github.com/Dreamacro/clash/adapter/provider" "github.com/Dreamacro/clash/log" "github.com/Dreamacro/clash/tunnel" ) @@ -19,7 +19,7 @@ func HealthCheck(name string) { return } - g, ok := p.(*outbound.Proxy).ProxyAdapter.(outboundgroup.ProxyGroup) + g, ok := p.(*adapter.Proxy).ProxyAdapter.(outboundgroup.ProxyGroup) if !ok { log.Warnln("Request health check for `%s`: invalid type %s", name, p.Type().String()) diff --git a/core/src/main/golang/tunnel/providers.go b/core/src/main/golang/tunnel/providers.go index 7b06ba60..86dbacde 100644 --- a/core/src/main/golang/tunnel/providers.go +++ b/core/src/main/golang/tunnel/providers.go @@ -7,7 +7,7 @@ import ( "fmt" "time" - "github.com/Dreamacro/clash/adapters/provider" + "github.com/Dreamacro/clash/adapter/provider" "github.com/Dreamacro/clash/tunnel" ) diff --git a/core/src/main/golang/tunnel/providers_premium.go b/core/src/main/golang/tunnel/providers_premium.go index 146cd6e7..f86bc776 100644 --- a/core/src/main/golang/tunnel/providers_premium.go +++ b/core/src/main/golang/tunnel/providers_premium.go @@ -7,7 +7,7 @@ import ( "fmt" "time" - "github.com/Dreamacro/clash/adapters/provider" + "github.com/Dreamacro/clash/adapter/provider" "github.com/Dreamacro/clash/log" "github.com/Dreamacro/clash/tunnel" ) diff --git a/core/src/main/golang/tunnel/proxies.go b/core/src/main/golang/tunnel/proxies.go index 55fa7873..d729f617 100644 --- a/core/src/main/golang/tunnel/proxies.go +++ b/core/src/main/golang/tunnel/proxies.go @@ -4,11 +4,11 @@ import ( "sort" "strings" + "github.com/Dreamacro/clash/adapter" "github.com/dlclark/regexp2" - "github.com/Dreamacro/clash/adapters/outbound" - "github.com/Dreamacro/clash/adapters/outboundgroup" - "github.com/Dreamacro/clash/adapters/provider" + "github.com/Dreamacro/clash/adapter/outboundgroup" + "github.com/Dreamacro/clash/adapter/provider" C "github.com/Dreamacro/clash/constant" "github.com/Dreamacro/clash/log" "github.com/Dreamacro/clash/tunnel" @@ -60,7 +60,7 @@ func QueryProxyGroupNames(excludeNotSelectable bool) []string { return []string{} } - global := tunnel.Proxies()["GLOBAL"].(*outbound.Proxy).ProxyAdapter.(outboundgroup.ProxyGroup) + global := tunnel.Proxies()["GLOBAL"].(*adapter.Proxy).ProxyAdapter.(outboundgroup.ProxyGroup) proxies := global.Providers()[0].Proxies() result := make([]string, 0, len(proxies)+1) @@ -69,7 +69,7 @@ func QueryProxyGroupNames(excludeNotSelectable bool) []string { } for _, p := range proxies { - if _, ok := p.(*outbound.Proxy).ProxyAdapter.(outboundgroup.ProxyGroup); ok { + if _, ok := p.(*adapter.Proxy).ProxyAdapter.(outboundgroup.ProxyGroup); ok { if !excludeNotSelectable || p.Type() == C.Selector { result = append(result, p.Name()) } @@ -88,7 +88,7 @@ func QueryProxyGroup(name string, sortMode SortMode, uiSubtitlePattern *regexp2. return nil } - g, ok := p.(*outbound.Proxy).ProxyAdapter.(outboundgroup.ProxyGroup) + g, ok := p.(*adapter.Proxy).ProxyAdapter.(outboundgroup.ProxyGroup) if !ok { log.Warnln("Query group `%s`: invalid type %s", name, p.Type().String()) @@ -136,7 +136,7 @@ func PatchSelector(selector, name string) bool { return false } - g, ok := p.(*outbound.Proxy).ProxyAdapter.(outboundgroup.ProxyGroup) + g, ok := p.(*adapter.Proxy).ProxyAdapter.(outboundgroup.ProxyGroup) if !ok { log.Warnln("Patch selector `%s`: invalid type %s", selector, p.Type().String()) @@ -171,7 +171,7 @@ func collectProviders(providers []provider.ProxyProvider, uiSubtitlePattern *reg subtitle := px.Type().String() if uiSubtitlePattern != nil { - if _, ok := px.(*outbound.Proxy).ProxyAdapter.(outboundgroup.ProxyGroup); !ok { + if _, ok := px.(*adapter.Proxy).ProxyAdapter.(outboundgroup.ProxyGroup); !ok { runes := []rune(name) match, err := uiSubtitlePattern.FindRunesMatch(runes) if err == nil && match != nil { diff --git a/core/src/main/golang/tunnel/suspend.go b/core/src/main/golang/tunnel/suspend.go index 0ad70852..b8c5c3ad 100644 --- a/core/src/main/golang/tunnel/suspend.go +++ b/core/src/main/golang/tunnel/suspend.go @@ -1,6 +1,6 @@ package tunnel -import "github.com/Dreamacro/clash/adapters/provider" +import "github.com/Dreamacro/clash/adapter/provider" func Suspend(s bool) { provider.Suspend(s)