From 9b4a5d1cb40319df7b3a2b5632d4555e3d2e23b9 Mon Sep 17 00:00:00 2001 From: Matthias Radestock Date: Wed, 13 Jan 2016 12:49:38 +0000 Subject: [PATCH] tiny refactor: just move around some code The router name derivation uses the result of createOverlay, so move it closer to that. --- prog/weaver/main.go | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/prog/weaver/main.go b/prog/weaver/main.go index 4a20bec9..53aa8d26 100644 --- a/prog/weaver/main.go +++ b/prog/weaver/main.go @@ -133,6 +133,21 @@ func main() { overlay, bridge := createOverlay(datapathName, ifaceName, config.Port, bufSzMB) networkConfig.Bridge = bridge + if routerName == "" { + iface := bridge.Interface() + if iface == nil { + Log.Fatal("Either an interface must be specified with --datapath or --iface, or a name with --name") + } + routerName = iface.HardwareAddr.String() + } + name, err := mesh.PeerNameFromUserInput(routerName) + checkFatal(err) + + if nickName == "" { + nickName, err = os.Hostname() + checkFatal(err) + } + if password == "" { password = os.Getenv("WEAVE_PASSWORD") } @@ -143,22 +158,6 @@ func main() { Log.Println("Communication between peers via untrusted networks is encrypted.") } - if routerName == "" { - iface := networkConfig.Bridge.Interface() - if iface == nil { - Log.Fatal("Either an interface must be specified with --datapath or --iface, or a name with --name") - } - routerName = iface.HardwareAddr.String() - } - - name, err := mesh.PeerNameFromUserInput(routerName) - checkFatal(err) - - if nickName == "" { - nickName, err = os.Hostname() - checkFatal(err) - } - if prof != "" { p := *profile.CPUProfile p.ProfilePath = prof