Skip to content

Commit

Permalink
tiny refactor: just move around some code
Browse files Browse the repository at this point in the history
The router name derivation uses the result of createOverlay, so move
it closer to that.
  • Loading branch information
rade committed Jan 13, 2016
1 parent 9f79e5b commit 9b4a5d1
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions prog/weaver/main.go
Expand Up @@ -133,24 +133,13 @@ func main() {
overlay, bridge := createOverlay(datapathName, ifaceName, config.Port, bufSzMB)
networkConfig.Bridge = bridge

if password == "" {
password = os.Getenv("WEAVE_PASSWORD")
}
if password == "" {
Log.Println("Communication between peers is unencrypted.")
} else {
config.Password = []byte(password)
Log.Println("Communication between peers via untrusted networks is encrypted.")
}

if routerName == "" {
iface := networkConfig.Bridge.Interface()
iface := bridge.Interface()

This comment has been minimized.

Copy link
@awh

awh Jan 13, 2016

Contributor

Does it make sense to move the networkConfig.Bridge = bridge statement to be immediately after the if routerName = "" { ... } block now? Create the overlay (and bridge), check the bridge interface, if all is good then assign it...

This comment has been minimized.

Copy link
@rade

rade Jan 13, 2016

Author Member

The job of the above code block is the create the overlay and bridge. The job of this code block is to determine the peer name. Setting networkConfig.Bridge fits naturally into the former, not the latter.

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)

Expand All @@ -159,6 +148,16 @@ func main() {
checkFatal(err)
}

if password == "" {
password = os.Getenv("WEAVE_PASSWORD")
}
if password == "" {
Log.Println("Communication between peers is unencrypted.")
} else {
config.Password = []byte(password)
Log.Println("Communication between peers via untrusted networks is encrypted.")
}

if prof != "" {
p := *profile.CPUProfile
p.ProfilePath = prof
Expand Down

0 comments on commit 9b4a5d1

Please sign in to comment.