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
+1
-7
@@ -226,11 +226,6 @@ func determineQuorum(initPeerCountFlag int, peers []string) uint {
|
||||
}
|
||||
|
||||
func handleHTTP(router *weave.Router, httpAddr string, allocator *ipam.Allocator) {
|
||||
encryption := "off"
|
||||
if router.UsingPassword() {
|
||||
encryption = "on"
|
||||
}
|
||||
|
||||
muxRouter := mux.NewRouter()
|
||||
|
||||
if allocator != nil {
|
||||
@@ -239,7 +234,6 @@ func handleHTTP(router *weave.Router, httpAddr string, allocator *ipam.Allocator
|
||||
|
||||
muxRouter.Methods("GET").Path("/status").HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
fmt.Fprintln(w, "weave router", version)
|
||||
fmt.Fprintln(w, "Encryption", encryption)
|
||||
fmt.Fprintln(w, router.Status())
|
||||
if allocator != nil {
|
||||
fmt.Fprintln(w, allocator.String())
|
||||
@@ -247,7 +241,7 @@ func handleHTTP(router *weave.Router, httpAddr string, allocator *ipam.Allocator
|
||||
})
|
||||
|
||||
muxRouter.Methods("GET").Path("/status-json").HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
json, _ := router.StatusJSON(version, encryption)
|
||||
json, _ := router.StatusJSON(version)
|
||||
w.Write(json)
|
||||
})
|
||||
|
||||
|
||||
+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)
|
||||
|
||||
@@ -61,8 +61,8 @@ This produces output like:
|
||||
|
||||
````
|
||||
weave router 0.7.0
|
||||
Encryption off
|
||||
Our name is 7a:f4:56:87:76:3b(weave01)
|
||||
Encryption off
|
||||
Sniffing traffic on &{39 65535 ethwe ae:e3:07:9c:8c:d4 up|broadcast|multicast}
|
||||
MACs:
|
||||
ba:8c:b9:dc:e1:c9 -> 7a:f4:56:87:76:3b(weave01) (2014-10-23 16:39:19.482338935 +0000 UTC)
|
||||
|
||||
Reference in new issue
Block a user