Break out multicast into a separate package

This commit is contained in:
Neil Alexander 2019-03-28 16:13:14 +00:00
parent 03bc7bbcd6
commit 7ea4e9575e
No known key found for this signature in database
GPG key ID: A02A2019A2BB0944
10 changed files with 103 additions and 71 deletions

View file

@ -19,6 +19,7 @@ import (
"github.com/mitchellh/mapstructure"
"github.com/yggdrasil-network/yggdrasil-go/src/config"
"github.com/yggdrasil-network/yggdrasil-go/src/multicast"
"github.com/yggdrasil-network/yggdrasil-go/src/tuntap"
"github.com/yggdrasil-network/yggdrasil-go/src/yggdrasil"
)
@ -27,8 +28,9 @@ type nodeConfig = config.NodeConfig
type Core = yggdrasil.Core
type node struct {
core Core
tun tuntap.TunAdapter
core Core
tun tuntap.TunAdapter
multicast multicast.Multicast
}
func readConfig(useconf *bool, useconffile *string, normaliseconf *bool) *nodeConfig {
@ -254,6 +256,11 @@ func main() {
logger.Errorln("An error occurred during startup")
panic(err)
}
// Start the multicast interface
n.multicast.Init(&n.core, cfg, logger)
if err := n.multicast.Start(); err != nil {
logger.Errorln("An error occurred starting multicast:", err)
}
// The Stop function ensures that the TUN/TAP adapter is correctly shut down
// before the program exits.
defer func() {