Implement networks routed through wesher

This adds an option for specifying a routed network. Every node route
that belongs to that routed network will be announced to the cluster and
every other node will direct traffic to that node for said route.
This commit is contained in:
kaiyou
2020-05-18 10:42:32 +02:00
parent e9aae4dc3b
commit 8637377cec
6 changed files with 104 additions and 8 deletions

View File

@ -64,6 +64,7 @@ func main() {
}
// Main loop
routesc := common.Routes((*net.IPNet)(config.RoutedNet))
incomingSigs := make(chan os.Signal, 1)
signal.Notify(incomingSigs, syscall.SIGTERM, os.Interrupt)
logrus.Debug("waiting for cluster events")
@ -82,7 +83,7 @@ func main() {
nodes = append(nodes, node)
hosts[node.OverlayAddr.IP.String()] = []string{node.Name}
}
if err := wgstate.SetUpInterface(nodes); err != nil {
if err := wgstate.SetUpInterface(nodes, (*net.IPNet)(config.RoutedNet)); err != nil {
logrus.WithError(err).Error("could not up interface")
wgstate.DownInterface()
}
@ -91,6 +92,10 @@ func main() {
logrus.WithError(err).Error("could not write hosts entries")
}
}
case routes := <-routesc:
logrus.Info("announcing new routes...")
localNode.Routes = routes
cluster.Update(localNode)
case <-incomingSigs:
logrus.Info("terminating...")
cluster.Leave()