introduce OnOff helper, for consistency in status output
This commit is contained in:
1 parent
1c14660ed5
commit
c10f1dacad
3 files changed
+12
-15
No files matched your search
@@ -0,0 +1,8 @@
|
|||||||
|
package common
|
||||||
|
|
||||||
|
func OnOff(b bool) string {
|
||||||
|
if b {
|
||||||
|
return "on"
|
||||||
|
}
|
||||||
|
return "off"
|
||||||
|
}
|
||||||
+2
-10
@@ -119,16 +119,8 @@ func (proxy *Proxy) Status() string {
|
|||||||
default:
|
default:
|
||||||
fmt.Fprintln(&buf, "TLS off")
|
fmt.Fprintln(&buf, "TLS off")
|
||||||
}
|
}
|
||||||
if proxy.WithDNS {
|
fmt.Fprintln(&buf, "DNS", OnOff(proxy.WithDNS))
|
||||||
fmt.Fprintln(&buf, "DNS on")
|
fmt.Fprintln(&buf, "IPAM", OnOff(proxy.WithIPAM))
|
||||||
} else {
|
|
||||||
fmt.Fprintln(&buf, "DNS off")
|
|
||||||
}
|
|
||||||
if proxy.WithIPAM {
|
|
||||||
fmt.Fprintln(&buf, "IPAM on")
|
|
||||||
} else {
|
|
||||||
fmt.Fprintln(&buf, "IPAM off")
|
|
||||||
}
|
|
||||||
return buf.String()
|
return buf.String()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+2
-5
@@ -11,6 +11,7 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"code.google.com/p/gopacket/layers"
|
"code.google.com/p/gopacket/layers"
|
||||||
|
. "github.com/weaveworks/weave/common"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@@ -112,13 +113,9 @@ func (router *Router) UsingPassword() bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (router *Router) Status() string {
|
func (router *Router) Status() string {
|
||||||
encryption := "off"
|
|
||||||
if router.UsingPassword() {
|
|
||||||
encryption = "on"
|
|
||||||
}
|
|
||||||
var buf bytes.Buffer
|
var buf bytes.Buffer
|
||||||
fmt.Fprintln(&buf, "Our name is", router.Ourself)
|
fmt.Fprintln(&buf, "Our name is", router.Ourself)
|
||||||
fmt.Fprintln(&buf, "Encryption", encryption)
|
fmt.Fprintln(&buf, "Encryption", OnOff(router.UsingPassword()))
|
||||||
fmt.Fprintln(&buf, "Sniffing traffic on", router.Iface)
|
fmt.Fprintln(&buf, "Sniffing traffic on", router.Iface)
|
||||||
fmt.Fprintf(&buf, "MACs:\n%s", router.Macs)
|
fmt.Fprintf(&buf, "MACs:\n%s", router.Macs)
|
||||||
fmt.Fprintf(&buf, "Peers:\n%s", router.Peers)
|
fmt.Fprintf(&buf, "Peers:\n%s", router.Peers)
|
||||||
|
|||||||
Reference in new issue
Block a user