refactor: make encryption status part of router status
This commit is contained in:
1 parent
34e3f0ba3f
commit
16410d6014
4 files changed
+10
-11
No files matched your search
+3
-3
@@ -6,10 +6,10 @@ import (
|
||||
"time"
|
||||
)
|
||||
|
||||
func (router *Router) StatusJSON(version, encryption string) ([]byte, error) {
|
||||
func (router *Router) StatusJSON(version string) ([]byte, error) {
|
||||
return json.Marshal(struct {
|
||||
Version string
|
||||
Encryption string
|
||||
Encryption bool
|
||||
Name string
|
||||
NickName string
|
||||
Interface string
|
||||
@@ -17,7 +17,7 @@ func (router *Router) StatusJSON(version, encryption string) ([]byte, error) {
|
||||
Peers *Peers
|
||||
Routes *Routes
|
||||
ConnectionMakerStatus
|
||||
}{version, encryption, router.Ourself.Name.String(), router.Ourself.NickName, fmt.Sprintf("%v", router.Iface), router.Macs, router.Peers, router.Routes, router.ConnectionMaker.Status()})
|
||||
}{version, router.UsingPassword(), router.Ourself.Name.String(), router.Ourself.NickName, fmt.Sprintf("%v", router.Iface), router.Macs, router.Peers, router.Routes, router.ConnectionMaker.Status()})
|
||||
}
|
||||
|
||||
func (cache *MacCache) MarshalJSON() ([]byte, error) {
|
||||
|
||||
@@ -112,8 +112,13 @@ func (router *Router) UsingPassword() bool {
|
||||
}
|
||||
|
||||
func (router *Router) Status() string {
|
||||
encryption := "off"
|
||||
if router.UsingPassword() {
|
||||
encryption = "on"
|
||||
}
|
||||
var buf bytes.Buffer
|
||||
fmt.Fprintln(&buf, "Our name is", router.Ourself)
|
||||
fmt.Fprintln(&buf, "Encryption", encryption)
|
||||
fmt.Fprintln(&buf, "Sniffing traffic on", router.Iface)
|
||||
fmt.Fprintf(&buf, "MACs:\n%s", router.Macs)
|
||||
fmt.Fprintf(&buf, "Peers:\n%s", router.Peers)
|
||||
|
||||
Reference in new issue
Block a user