* control,dhcp: use dhcpServerConfigJSON struct
This commit is contained in:
parent
cc366495d3
commit
626c1ae753
10
dhcp.go
10
dhcp.go
|
@ -47,9 +47,13 @@ func handleDHCPStatus(w http.ResponseWriter, r *http.Request) {
|
|||
}
|
||||
}
|
||||
|
||||
type dhcpServerConfigJSON struct {
|
||||
dhcpd.ServerConfig `json:",inline"`
|
||||
}
|
||||
|
||||
func handleDHCPSetConfig(w http.ResponseWriter, r *http.Request) {
|
||||
log.Tracef("%s %v", r.Method, r.URL)
|
||||
newconfig := dhcpd.ServerConfig{}
|
||||
newconfig := dhcpServerConfigJSON{}
|
||||
err := json.NewDecoder(r.Body).Decode(&newconfig)
|
||||
if err != nil {
|
||||
httpError(w, http.StatusBadRequest, "Failed to parse new DHCP config json: %s", err)
|
||||
|
@ -72,14 +76,14 @@ func handleDHCPSetConfig(w http.ResponseWriter, r *http.Request) {
|
|||
}
|
||||
}
|
||||
|
||||
err = dhcpServer.Start(&newconfig)
|
||||
err = dhcpServer.Start(&newconfig.ServerConfig)
|
||||
if err != nil {
|
||||
httpError(w, http.StatusBadRequest, "Failed to start DHCP server: %s", err)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
config.DHCP = newconfig
|
||||
config.DHCP = newconfig.ServerConfig
|
||||
httpUpdateConfigReloadDNSReturnOK(w, r)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue