refactor: extract password determination
This commit is contained in:
1 parent
6261ce0865
commit
d50975a185
1 file changed
+13
-9
+13
-9
@@ -141,15 +141,7 @@ 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.")
|
||||
}
|
||||
config.Password = determinePassword(password)
|
||||
|
||||
if prof != "" {
|
||||
p := *profile.CPUProfile
|
||||
@@ -371,6 +363,18 @@ func determineQuorum(initPeerCountFlag int, peers []string) uint {
|
||||
return quorum
|
||||
}
|
||||
|
||||
func determinePassword(password string) []byte {
|
||||
if password == "" {
|
||||
password = os.Getenv("WEAVE_PASSWORD")
|
||||
}
|
||||
if password == "" {
|
||||
Log.Println("Communication between peers is unencrypted.")
|
||||
return nil
|
||||
}
|
||||
Log.Println("Communication between peers via untrusted networks is encrypted.")
|
||||
return []byte(password)
|
||||
}
|
||||
|
||||
func peerName(routerName string, iface *net.Interface) mesh.PeerName {
|
||||
if routerName == "" {
|
||||
if iface == nil {
|
||||
|
||||
Reference in new issue
Block a user