Simplify reconfiguration

This commit is contained in:
Neil Alexander 2019-08-28 19:31:04 +01:00
parent 764f9c8e11
commit fc9a1c6c31
No known key found for this signature in database
GPG key ID: A02A2019A2BB0944
13 changed files with 64 additions and 141 deletions

View file

@ -13,6 +13,7 @@ import (
"errors"
"fmt"
"net"
//"sync"
"github.com/Arceliar/phony"
@ -200,29 +201,11 @@ func (tun *TunAdapter) _stop() error {
func (tun *TunAdapter) UpdateConfig(config *config.NodeConfig) {
tun.log.Debugln("Reloading TUN/TAP configuration...")
// Replace the active configuration with the supplied one
tun.config.Replace(*config)
errors := 0
components := []chan chan error{
tun.reconfigure,
tun.ckr.reconfigure,
}
for _, component := range components {
response := make(chan error)
component <- response
if err := <-response; err != nil {
tun.log.Errorln(err)
errors++
}
}
if errors > 0 {
tun.log.Warnln(errors, "TUN/TAP module(s) reported errors during configuration reload")
} else {
tun.log.Infoln("TUN/TAP configuration reloaded successfully")
}
// Notify children about the configuration change
tun.Act(nil, tun.ckr.configure)
}
func (tun *TunAdapter) handler() error {