mirror of
https://github.com/cwinfo/yggdrasil-go.git
synced 2024-11-09 16:20:26 +00:00
Remove reconfiguration on SIGHUP - it didn't work reliably anyway
This commit is contained in:
parent
e12c639c21
commit
57ea61b338
@ -323,31 +323,10 @@ func main() {
|
||||
logger.Infof("Your IPv6 subnet is %s", subnet.String())
|
||||
// Catch interrupts from the operating system to exit gracefully.
|
||||
c := make(chan os.Signal, 1)
|
||||
r := make(chan os.Signal, 1)
|
||||
signal.Notify(c, os.Interrupt, syscall.SIGTERM)
|
||||
signal.Notify(r, os.Interrupt, syscall.SIGHUP)
|
||||
// Capture the service being stopped on Windows.
|
||||
minwinsvc.SetOnExit(n.shutdown)
|
||||
defer n.shutdown()
|
||||
// Wait for the terminate/interrupt signal. Once a signal is received, the
|
||||
// deferred Stop function above will run which will shut down TUN/TAP.
|
||||
for {
|
||||
select {
|
||||
case <-c:
|
||||
goto exit
|
||||
case <-r:
|
||||
if *useconffile != "" {
|
||||
cfg = readConfig(useconf, useconffile, normaliseconf)
|
||||
logger.Infoln("Reloading configuration from", *useconffile)
|
||||
n.core.UpdateConfig(cfg)
|
||||
n.tuntap.UpdateConfig(cfg)
|
||||
n.multicast.UpdateConfig(cfg)
|
||||
} else {
|
||||
logger.Errorln("Reloading config at runtime is only possible with -useconffile")
|
||||
}
|
||||
}
|
||||
}
|
||||
exit:
|
||||
n.shutdown()
|
||||
}
|
||||
|
||||
func (n *node) shutdown() {
|
||||
|
@ -8,6 +8,7 @@ import (
|
||||
"net"
|
||||
"net/url"
|
||||
"os"
|
||||
|
||||
//"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
@ -70,17 +71,6 @@ func (a *AdminSocket) Init(c *yggdrasil.Core, state *config.NodeState, log *log.
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a *AdminSocket) UpdateConfig(config *config.NodeConfig) {
|
||||
a.log.Debugln("Reloading admin configuration...")
|
||||
if a.listenaddr != config.AdminListen {
|
||||
a.listenaddr = config.AdminListen
|
||||
if a.IsStarted() {
|
||||
a.Stop()
|
||||
}
|
||||
a.Start()
|
||||
}
|
||||
}
|
||||
|
||||
func (a *AdminSocket) SetupAdminHandlers(na *AdminSocket) {
|
||||
/* TODO
|
||||
a.AddHandler("getSelf", []string{}, func(in Info) (Info, error) {
|
||||
|
@ -14,7 +14,6 @@ type Module interface {
|
||||
Init(core *yggdrasil.Core, state *config.NodeState, log *log.Logger, options interface{}) error
|
||||
Start() error
|
||||
Stop() error
|
||||
UpdateConfig(config *config.NodeConfig)
|
||||
SetupAdminHandlers(a *admin.AdminSocket)
|
||||
IsStarted() bool
|
||||
}
|
||||
|
@ -129,32 +129,6 @@ func (m *Multicast) _stop() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// UpdateConfig updates the multicast module with the provided config.NodeConfig
|
||||
// and then signals the various module goroutines to reconfigure themselves if
|
||||
// needed.
|
||||
func (m *Multicast) UpdateConfig(config *config.NodeConfig) {
|
||||
m.Act(nil, func() { m._updateConfig(config) })
|
||||
}
|
||||
|
||||
func (m *Multicast) _updateConfig(config *config.NodeConfig) {
|
||||
m.log.Infoln("Reloading multicast configuration...")
|
||||
if m.isOpen {
|
||||
if len(config.MulticastInterfaces) == 0 || config.LinkLocalTCPPort != m.listenPort {
|
||||
if err := m._stop(); err != nil {
|
||||
m.log.Errorln("Error stopping multicast module:", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
m.config.Replace(*config)
|
||||
m.listenPort = config.LinkLocalTCPPort
|
||||
if !m.isOpen && len(config.MulticastInterfaces) > 0 {
|
||||
if err := m._start(); err != nil {
|
||||
m.log.Errorln("Error starting multicast module:", err)
|
||||
}
|
||||
}
|
||||
m.log.Debugln("Reloaded multicast configuration successfully")
|
||||
}
|
||||
|
||||
func (m *Multicast) _updateInterfaces() {
|
||||
interfaces := make(map[string]interfaceInfo)
|
||||
intfs := m.getAllowedInterfaces()
|
||||
|
@ -40,7 +40,6 @@ type TunAdapter struct {
|
||||
store keyStore
|
||||
config *config.NodeState
|
||||
log *log.Logger
|
||||
reconfigure chan chan error
|
||||
addr address.Address
|
||||
subnet address.Subnet
|
||||
ckr cryptokey
|
||||
@ -197,25 +196,6 @@ func (tun *TunAdapter) _stop() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// UpdateConfig updates the TUN module with the provided config.NodeConfig
|
||||
// and then signals the various module goroutines to reconfigure themselves if
|
||||
// needed.
|
||||
func (tun *TunAdapter) UpdateConfig(config *config.NodeConfig) {
|
||||
tun.log.Debugln("Reloading TUN configuration...")
|
||||
|
||||
// Replace the active configuration with the supplied one
|
||||
tun.config.Replace(*config)
|
||||
|
||||
// If the MTU has changed in the TUN module then this is where we would
|
||||
// tell the router so that updated session pings can be sent. However, we
|
||||
// don't currently update the MTU of the adapter once it has been created so
|
||||
// this doesn't actually happen in the real world yet.
|
||||
// tun.core.SetMaximumSessionMTU(...)
|
||||
|
||||
// Notify children about the configuration change
|
||||
tun.Act(nil, tun.ckr.configure)
|
||||
}
|
||||
|
||||
func (tun *TunAdapter) oobHandler(fromKey, toKey ed25519.PublicKey, data []byte) {
|
||||
if len(data) != 1+ed25519.SignatureSize {
|
||||
return
|
||||
|
@ -90,23 +90,6 @@ func (c *Core) _addPeerLoop() {
|
||||
})
|
||||
}
|
||||
|
||||
// UpdateConfig updates the configuration in Core with the provided
|
||||
// config.NodeConfig and then signals the various module goroutines to
|
||||
// reconfigure themselves if needed.
|
||||
func (c *Core) UpdateConfig(config *config.NodeConfig) {
|
||||
c.Act(nil, func() {
|
||||
c.log.Debugln("Reloading node configuration...")
|
||||
|
||||
// Replace the active configuration with the supplied one
|
||||
c.config.Replace(*config)
|
||||
|
||||
// Notify the router and switch about the new configuration
|
||||
panic("TODO")
|
||||
//c.router.Act(c, c.router.reconfigure)
|
||||
//c.switchTable.Act(c, c.switchTable.reconfigure)
|
||||
})
|
||||
}
|
||||
|
||||
// Start starts up Yggdrasil using the provided config.NodeConfig, and outputs
|
||||
// debug logging through the provided log.Logger. The started stack will include
|
||||
// TCP and UDP sockets, a multicast discovery socket, an admin socket, router,
|
||||
|
Loading…
Reference in New Issue
Block a user