From 4f0a4173b5251e11381e9186eea27be6996fbad5 Mon Sep 17 00:00:00 2001 From: Simon Zolin Date: Fri, 29 May 2020 14:25:20 +0300 Subject: [PATCH] + "dhcp_available" --- AGHTechDoc.md | 1 + home/control.go | 1 + home/home.go | 27 +++++++++++++++++---------- openapi/openapi.yaml | 2 ++ 4 files changed, 21 insertions(+), 10 deletions(-) diff --git a/AGHTechDoc.md b/AGHTechDoc.md index 1562b354..002b6232 100644 --- a/AGHTechDoc.md +++ b/AGHTechDoc.md @@ -388,6 +388,7 @@ Response: "language":"en", "protection_enabled":true, "running":true, + "dhcp_available":true, "version":"undefined" } diff --git a/home/control.go b/home/control.go index 310b9f20..3cedcd87 100644 --- a/home/control.go +++ b/home/control.go @@ -56,6 +56,7 @@ func handleStatus(w http.ResponseWriter, r *http.Request) { "protection_enabled": c.ProtectionEnabled, } + data["dhcp_available"] = (Context.dhcpServer != nil) jsonVal, err := json.Marshal(data) if err != nil { diff --git a/home/home.go b/home/home.go index 496e95c2..a0e2ea1b 100644 --- a/home/home.go +++ b/home/home.go @@ -211,10 +211,12 @@ func run(args options) { config.DHCP.WorkDir = Context.workDir config.DHCP.HTTPRegister = httpRegister config.DHCP.ConfigModified = onConfigModified - Context.dhcpServer = dhcpd.Create(config.DHCP) - if Context.dhcpServer == nil { - log.Error("Failed to initialize DHCP server, exiting") - os.Exit(1) + if runtime.GOOS != "windows" { + Context.dhcpServer = dhcpd.Create(config.DHCP) + if Context.dhcpServer == nil { + log.Error("Failed to initialize DHCP server, exiting") + os.Exit(1) + } } Context.autoHosts.Init("") Context.clients.Init(config.Clients, Context.dhcpServer, &Context.autoHosts) @@ -296,9 +298,11 @@ func run(args options) { } }() - err = Context.dhcpServer.Start() - if err != nil { - log.Fatal(err) + if Context.dhcpServer != nil { + err = Context.dhcpServer.Start() + if err != nil { + log.Fatal(err) + } } } @@ -447,9 +451,12 @@ func cleanup() { if err != nil { log.Error("Couldn't stop DNS server: %s", err) } - err = Context.dhcpServer.Stop() - if err != nil { - log.Error("Couldn't stop DHCP server: %s", err) + + if Context.dhcpServer != nil { + err = Context.dhcpServer.Stop() + if err != nil { + log.Error("Couldn't stop DHCP server: %s", err) + } } Context.autoHosts.Close() diff --git a/openapi/openapi.yaml b/openapi/openapi.yaml index a9791c4d..bad7c601 100644 --- a/openapi/openapi.yaml +++ b/openapi/openapi.yaml @@ -1049,6 +1049,8 @@ definitions: maximum: 65535 protection_enabled: type: "boolean" + dhcp_available: + type: "boolean" querylog_enabled: type: "boolean" running: