mirror of
https://github.com/MetaCubeX/ClashMetaForAndroid.git
synced 2024-11-16 04:42:17 +08:00
Improve: should not reload profile on network changed
This commit is contained in:
parent
e1a35f8b2d
commit
b07f70ab0b
|
@ -1,15 +1,20 @@
|
|||
package app
|
||||
|
||||
import "strings"
|
||||
import (
|
||||
"strings"
|
||||
|
||||
var systemDns []string
|
||||
"github.com/Dreamacro/clash/dns"
|
||||
)
|
||||
|
||||
func NotifyDnsChanged(dnsList string) {
|
||||
dns := strings.Split(dnsList, ",")
|
||||
dL := strings.Split(dnsList, ",")
|
||||
|
||||
systemDns = dns
|
||||
ns := make([]dns.NameServer, 0, len(dnsList))
|
||||
for _, d := range dL {
|
||||
ns = append(ns, dns.NameServer{Addr: d})
|
||||
}
|
||||
|
||||
dns.UpdateSystemDNS(dL)
|
||||
dns.FlushCacheWithDefaultResolver()
|
||||
}
|
||||
|
||||
func SystemDns() []string {
|
||||
return systemDns
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ package config
|
|||
import (
|
||||
"io/ioutil"
|
||||
P "path"
|
||||
"runtime"
|
||||
"strings"
|
||||
|
||||
"gopkg.in/yaml.v2"
|
||||
|
@ -81,6 +82,8 @@ func Load(path string) error {
|
|||
|
||||
app.ApplySubtitlePattern(rawCfg.ClashForAndroid.UiSubtitlePattern)
|
||||
|
||||
runtime.GC()
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
|
@ -10,7 +10,6 @@ import (
|
|||
"github.com/Dreamacro/clash/log"
|
||||
"github.com/dlclark/regexp2"
|
||||
|
||||
"cfa/app"
|
||||
"cfa/common"
|
||||
|
||||
"github.com/Dreamacro/clash/config"
|
||||
|
@ -76,7 +75,7 @@ func patchDns(cfg *config.RawConfig, _ string) error {
|
|||
}
|
||||
|
||||
if cfg.ClashForAndroid.AppendSystemDNS {
|
||||
cfg.DNS.NameServer = append(cfg.DNS.NameServer, app.SystemDns()...)
|
||||
cfg.DNS.NameServer = append(cfg.DNS.NameServer, "dhcp://" + dns.SystemDNSPlaceholder)
|
||||
}
|
||||
|
||||
return nil
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit a918699140e9169f76600f2e7837ec6d69957fb5
|
||||
Subproject commit 006bce4436065b2173dad16ac154cc3824a34c79
|
|
@ -13,6 +13,21 @@ require (
|
|||
gopkg.in/yaml.v2 v2.4.0
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/Dreamacro/go-shadowsocks2 v0.1.7 // indirect
|
||||
github.com/gofrs/uuid v4.0.0+incompatible // indirect
|
||||
github.com/gorilla/websocket v1.4.2 // indirect
|
||||
github.com/insomniacslk/dhcp v0.0.0-20210827173440-b95caade3eac // indirect
|
||||
github.com/oschwald/maxminddb-golang v1.8.0 // indirect
|
||||
github.com/sirupsen/logrus v1.8.1 // indirect
|
||||
github.com/u-root/uio v0.0.0-20210528114334-82958018845c // indirect
|
||||
go.uber.org/atomic v1.9.0 // indirect
|
||||
golang.org/x/crypto v0.0.0-20210817164053-32db794688a5 // indirect
|
||||
golang.org/x/net v0.0.0-20210903162142-ad29c8ab022f // indirect
|
||||
golang.org/x/sys v0.0.0-20210906170528-6f6e22806c34 // indirect
|
||||
golang.org/x/text v0.3.6 // indirect
|
||||
)
|
||||
|
||||
replace github.com/Dreamacro/clash => ./core/foss
|
||||
|
||||
replace cfa/blob => ../../../build/intermediates/golang_blob
|
||||
|
|
|
@ -3,7 +3,8 @@ package tun
|
|||
import (
|
||||
"net"
|
||||
|
||||
"github.com/Dreamacro/clash/component/resolver"
|
||||
"github.com/Dreamacro/clash/dns"
|
||||
|
||||
D "github.com/miekg/dns"
|
||||
)
|
||||
|
||||
|
@ -21,7 +22,7 @@ func relayDns(payload []byte) ([]byte, error) {
|
|||
return nil, err
|
||||
}
|
||||
|
||||
r, err := resolver.ServeMsg(msg)
|
||||
r, err := dns.ServeDNSWithDefaultServer(msg)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
|
@ -54,8 +54,6 @@ class ClashService : BaseService() {
|
|||
true
|
||||
}
|
||||
network.onEvent {
|
||||
config.reload()
|
||||
|
||||
false
|
||||
}
|
||||
}
|
||||
|
|
|
@ -65,8 +65,6 @@ class TunService : VpnService(), CoroutineScope by CoroutineScope(Dispatchers.De
|
|||
setUnderlyingNetworks(e.network?.let { arrayOf(it) })
|
||||
}
|
||||
|
||||
config.reload()
|
||||
|
||||
false
|
||||
}
|
||||
}
|
||||
|
|
|
@ -73,8 +73,4 @@ class ConfigurationModule(service: Service) : Module<ConfigurationModule.LoadExc
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun reload() {
|
||||
reload.trySend(Unit)
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user