Stop using wireguard in cluster.go

The wireguard is mostly used to compute metadata.
Metadata is now computed by main.go and encoded in
node.go, the cluster only receives a function generating
the binary metadata.
This commit is contained in:
kaiyou
2020-05-06 19:14:33 +02:00
committed by Leo Antunes
parent 0d93439d0d
commit 97525f4b10
3 changed files with 24 additions and 12 deletions

12
main.go
View File

@ -2,6 +2,7 @@ package main // import "github.com/costela/wesher"
import (
"fmt"
"net"
"os"
"os/signal"
"syscall"
@ -34,10 +35,19 @@ func main() {
logrus.WithError(err).Fatal("could not instantiate wireguard controller")
}
cluster, err := newCluster(config, wg)
getMeta := func(limit int) []byte {
return encodeNodeMeta(nodeMeta{
OverlayAddr: wg.OverlayAddr,
PubKey: wg.PubKey.String(),
}, limit)
}
cluster, err := newCluster(config, getMeta)
if err != nil {
logrus.WithError(err).Fatal("could not create cluster")
}
wg.assignOverlayAddr((*net.IPNet)(config.OverlayNet), cluster.localName)
cluster.update()
nodec, errc := cluster.members() // avoid deadlocks by starting before join
if err := backoff.RetryNotify(