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:
1 parent
1fcd521f67
commit
79f77f94f4
1 file changed
+5
-1
+5
-1
@@ -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) {
|
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)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user