fix: 热重载Tun配置

This commit is contained in:
adlyq
2022-05-19 19:19:19 +08:00
parent 7aff9aac82
commit c787bbe0e5
10 changed files with 136 additions and 91 deletions

View File

@ -85,7 +85,7 @@ func ApplyConfig(cfg *config.Config, force bool) {
loadRuleProvider(cfg.RuleProviders)
updateGeneral(cfg.General, force)
updateIPTables(cfg)
updateTun(cfg.Tun, cfg.DNS)
updateTun(cfg.Tun)
updateExperimental(cfg)
log.SetLevel(cfg.General.LogLevel)
@ -244,12 +244,8 @@ func loadProxyProvider(proxyProviders map[string]provider.ProxyProvider) {
wg.Wait()
}
func updateTun(tun *config.Tun, dns *config.DNS) {
var tunAddressPrefix *netip.Prefix
if dns.FakeIPRange != nil {
tunAddressPrefix = dns.FakeIPRange.IPNet()
}
P.ReCreateTun(tun, tunAddressPrefix, tunnel.TCPIn(), tunnel.UDPIn())
func updateTun(tun *config.Tun) {
P.ReCreateTun(tun, tunnel.TCPIn(), tunnel.UDPIn())
}
func updateSniffer(sniffer *config.Sniffer) {
@ -428,7 +424,7 @@ func updateIPTables(cfg *config.Config) {
}
func Shutdown() {
P.Cleanup()
P.Cleanup(false)
tproxy.CleanupTProxyIPTables()
resolver.StoreFakePoolState()