Code: refresh code & rebase branch 'with-tun'

This commit is contained in:
yaling888
2022-03-21 09:03:47 +08:00
parent 2c0890854e
commit a45354fa08
21 changed files with 1832 additions and 115 deletions

View File

@ -16,6 +16,7 @@ import (
"github.com/Dreamacro/clash/component/profile"
"github.com/Dreamacro/clash/component/profile/cachefile"
"github.com/Dreamacro/clash/component/resolver"
S "github.com/Dreamacro/clash/component/script"
"github.com/Dreamacro/clash/component/trie"
"github.com/Dreamacro/clash/config"
C "github.com/Dreamacro/clash/constant"
@ -76,6 +77,7 @@ func ApplyConfig(cfg *config.Config, force bool) {
updateUsers(cfg.Users)
updateProxies(cfg.Proxies, cfg.Providers)
updateRules(cfg.Rules)
updateRuleProviders(cfg.RuleProviders)
updateHosts(cfg.Hosts)
updateProfile(cfg)
updateDNS(cfg.DNS, cfg.Tun)
@ -176,6 +178,10 @@ func updateRules(rules []C.Rule) {
tunnel.UpdateRules(rules)
}
func updateRuleProviders(providers map[string]C.Rule) {
S.UpdateRuleProviders(providers)
}
func updateTun(tun *config.Tun, tunAddressPrefix string) {
P.ReCreateTun(tun, tunAddressPrefix, tunnel.TCPIn(), tunnel.UDPIn())
}
@ -308,4 +314,5 @@ func Cleanup() {
if runtime.GOOS == "linux" {
tproxy.CleanUpTProxyLinuxIPTables()
}
S.Py_Finalize()
}