mirror of
https://github.com/AdguardTeam/AdGuardHome.git
synced 2025-02-17 18:39:53 +03:00
+ "dhcp_available"
This commit is contained in:
parent
82bd8dbbf2
commit
4f0a4173b5
4 changed files with 21 additions and 10 deletions
|
@ -388,6 +388,7 @@ Response:
|
||||||
"language":"en",
|
"language":"en",
|
||||||
"protection_enabled":true,
|
"protection_enabled":true,
|
||||||
"running":true,
|
"running":true,
|
||||||
|
"dhcp_available":true,
|
||||||
"version":"undefined"
|
"version":"undefined"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -56,6 +56,7 @@ func handleStatus(w http.ResponseWriter, r *http.Request) {
|
||||||
|
|
||||||
"protection_enabled": c.ProtectionEnabled,
|
"protection_enabled": c.ProtectionEnabled,
|
||||||
}
|
}
|
||||||
|
data["dhcp_available"] = (Context.dhcpServer != nil)
|
||||||
|
|
||||||
jsonVal, err := json.Marshal(data)
|
jsonVal, err := json.Marshal(data)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -211,11 +211,13 @@ func run(args options) {
|
||||||
config.DHCP.WorkDir = Context.workDir
|
config.DHCP.WorkDir = Context.workDir
|
||||||
config.DHCP.HTTPRegister = httpRegister
|
config.DHCP.HTTPRegister = httpRegister
|
||||||
config.DHCP.ConfigModified = onConfigModified
|
config.DHCP.ConfigModified = onConfigModified
|
||||||
|
if runtime.GOOS != "windows" {
|
||||||
Context.dhcpServer = dhcpd.Create(config.DHCP)
|
Context.dhcpServer = dhcpd.Create(config.DHCP)
|
||||||
if Context.dhcpServer == nil {
|
if Context.dhcpServer == nil {
|
||||||
log.Error("Failed to initialize DHCP server, exiting")
|
log.Error("Failed to initialize DHCP server, exiting")
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
Context.autoHosts.Init("")
|
Context.autoHosts.Init("")
|
||||||
Context.clients.Init(config.Clients, Context.dhcpServer, &Context.autoHosts)
|
Context.clients.Init(config.Clients, Context.dhcpServer, &Context.autoHosts)
|
||||||
config.Clients = nil
|
config.Clients = nil
|
||||||
|
@ -296,11 +298,13 @@ func run(args options) {
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
|
if Context.dhcpServer != nil {
|
||||||
err = Context.dhcpServer.Start()
|
err = Context.dhcpServer.Start()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Context.web.Start()
|
Context.web.Start()
|
||||||
|
|
||||||
|
@ -447,10 +451,13 @@ func cleanup() {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error("Couldn't stop DNS server: %s", err)
|
log.Error("Couldn't stop DNS server: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if Context.dhcpServer != nil {
|
||||||
err = Context.dhcpServer.Stop()
|
err = Context.dhcpServer.Stop()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error("Couldn't stop DHCP server: %s", err)
|
log.Error("Couldn't stop DHCP server: %s", err)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Context.autoHosts.Close()
|
Context.autoHosts.Close()
|
||||||
|
|
||||||
|
|
|
@ -1049,6 +1049,8 @@ definitions:
|
||||||
maximum: 65535
|
maximum: 65535
|
||||||
protection_enabled:
|
protection_enabled:
|
||||||
type: "boolean"
|
type: "boolean"
|
||||||
|
dhcp_available:
|
||||||
|
type: "boolean"
|
||||||
querylog_enabled:
|
querylog_enabled:
|
||||||
type: "boolean"
|
type: "boolean"
|
||||||
running:
|
running:
|
||||||
|
|
Loading…
Add table
Reference in a new issue