From 8b6e9ef5f9fe0ca27131128a8ebd4bec1a0e25af Mon Sep 17 00:00:00 2001 From: Simon Zolin Date: Wed, 3 Apr 2019 15:49:55 +0300 Subject: [PATCH] * /control/dhcp/find_active_dhcp: new JSON response format --- dhcp.go | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/dhcp.go b/dhcp.go index ac9c36c5..dc91a10c 100644 --- a/dhcp.go +++ b/dhcp.go @@ -147,13 +147,22 @@ func handleDHCPFindActiveServer(w http.ResponseWriter, r *http.Request) { http.Error(w, errorText, http.StatusBadRequest) return } + found, err := dhcpd.CheckIfOtherDHCPServersPresent(interfaceName) - result := map[string]interface{}{} - if err != nil { - result["error"] = err.Error() - } else { - result["found"] = found + + othSrv := map[string]interface{}{} + foundVal := "no" + if found { + foundVal = "yes" + } else if err != nil { + foundVal = "error" + othSrv["error"] = err.Error() } + othSrv["found"] = foundVal + + result := map[string]interface{}{} + result["other-server"] = othSrv + w.Header().Set("Content-Type", "application/json") err = json.NewEncoder(w).Encode(result) if err != nil {