Feature: move hosts to the top

This commit is contained in:
Dreamacro
2019-09-11 17:00:55 +08:00
parent 16e3090ee8
commit 96a4abf46c
6 changed files with 164 additions and 122 deletions

View File

@ -2,6 +2,7 @@ package executor
import (
"github.com/Dreamacro/clash/component/auth"
trie "github.com/Dreamacro/clash/component/domain-trie"
"github.com/Dreamacro/clash/config"
C "github.com/Dreamacro/clash/constant"
"github.com/Dreamacro/clash/dns"
@ -30,6 +31,7 @@ func ApplyConfig(cfg *config.Config, force bool) {
updateProxies(cfg.Proxies)
updateRules(cfg.Rules)
updateDNS(cfg.DNS)
updateHosts(cfg.Hosts)
updateExperimental(cfg.Experimental)
}
@ -68,7 +70,6 @@ func updateDNS(c *config.DNS) {
Main: c.NameServer,
Fallback: c.Fallback,
IPv6: c.IPv6,
Hosts: c.Hosts,
EnhancedMode: c.EnhancedMode,
Pool: c.FakeIPRange,
})
@ -83,6 +84,10 @@ func updateDNS(c *config.DNS) {
}
}
func updateHosts(tree *trie.Trie) {
dns.DefaultHosts = tree
}
func updateProxies(proxies map[string]C.Proxy) {
tunnel := T.Instance()
oldProxies := tunnel.Proxies()