From 9fdab652375ffa98af749b59d4b751d0d84806b8 Mon Sep 17 00:00:00 2001 From: kaiyou Date: Thu, 7 May 2020 09:58:31 +0200 Subject: [PATCH] Revert "Move the metadata parsing code to node.go" This reverts commit ac6289b5bf95e8903ea90ddf807832a2358371b0. --- main.go | 13 ++++++++++++- node.go | 16 ---------------- 2 files changed, 12 insertions(+), 17 deletions(-) diff --git a/main.go b/main.go index 4910346..38abb78 100644 --- a/main.go +++ b/main.go @@ -66,7 +66,18 @@ func main() { for { select { case rawNodes := <-nodec: - nodes := parseNodesMeta(rawNodes) + logrus.Info("cluster members:\n") + nodes := make([]node, 0, len(rawNodes)) + for _, node := range rawNodes { + meta, err := decodeNodeMeta(node.Meta) + if err != nil { + logrus.Warnf("\t addr: %s, could not decode metadata", node.Addr) + continue + } + node.nodeMeta = meta + nodes = append(nodes, node) + logrus.Infof("\taddr: %s, overlay: %s, pubkey: %s", node.Addr, node.OverlayAddr, node.PubKey) + } if err := wg.setUpInterface(nodes); err != nil { logrus.WithError(err).Error("could not up interface") wg.downInterface() diff --git a/node.go b/node.go index 53a096e..49da3fc 100644 --- a/node.go +++ b/node.go @@ -49,19 +49,3 @@ func decodeNodeMeta(b []byte) (nodeMeta, error) { } return nm, nil } - -func parseNodesMeta(rawNodes []node) []node { - logrus.Info("cluster members:\n") - nodes := make([]node, 0, len(rawNodes)) - for _, node := range rawNodes { - meta, err := decodeNodeMeta(node.Meta) - if err != nil { - logrus.Warnf("\t addr: %s, could not decode metadata", node.Addr) - continue - } - node.nodeMeta = meta - nodes = append(nodes, node) - logrus.Infof("\taddr: %s, overlay: %s, pubkey: %s", node.Addr, node.OverlayAddr, node.PubKey) - } - return nodes -}