Fixed: the configuration can now be updated correctly

This commit is contained in:
Dreamacro
2018-06-19 20:31:36 +08:00
parent 330a3391e3
commit c2c8f82f96
2 changed files with 28 additions and 8 deletions

View File

@ -48,7 +48,7 @@ func (t *Tunnel) UpdateConfig() (err error) {
return
}
// clear proxys and rules
// empty proxys and rules
proxys := make(map[string]C.Proxy)
rules := []C.Rule{}
@ -78,10 +78,6 @@ func (t *Tunnel) UpdateConfig() (err error) {
}
}
// init proxy
proxys["DIRECT"] = adapters.NewDirect(t.traffic)
proxys["REJECT"] = adapters.NewReject()
// parse rules
for _, key := range rulesConfig.Keys() {
rule := strings.Split(key.Name(), ",")
@ -130,9 +126,21 @@ func (t *Tunnel) UpdateConfig() (err error) {
}
}
// init proxy
proxys["DIRECT"] = adapters.NewDirect(t.traffic)
proxys["REJECT"] = adapters.NewReject()
t.configLock.Lock()
defer t.configLock.Unlock()
// stop url-test
for _, elm := range t.proxys {
urlTest, ok := elm.(*adapters.URLTest)
if ok {
urlTest.Close()
}
}
t.proxys = proxys
t.rules = rules