ipam: Do not deref nil in GET /ipinfo/tracker if tracker doesn't exist

In some cases, we do not create any IPAM tracker, which leads
to a panic when GET'ing /ipinfo/tracker.
This commit is contained in:
Martynas Pumputis committed 2018-09-21 13:29:03 +03:00
1 parent 1fcd521f67
commit 79f77f94f4
1 file changed
+5 -1
+5 -1
View File
@@ -199,6 +199,10 @@ func (alloc *Allocator) HandleHTTP(router *mux.Router, defaultSubnet address.CID
})
router.Methods("GET").Path("/ipinfo/tracker").HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, alloc.tracker.String())
tracker := ""
if alloc.tracker != nil {
tracker = alloc.tracker.String()
}
fmt.Fprintf(w, tracker)
})
}