FailoverApp: minor code refactoring changes done.

This commit is contained in:
Shreyas Zare
2023-02-05 16:11:49 +05:30
parent b1d0432979
commit d099080ec4
2 changed files with 12 additions and 5 deletions

View File

@@ -1,6 +1,6 @@
/*
Technitium DNS Server
Copyright (C) 2022 Shreyas Zare (shreyas@technitium.com)
Copyright (C) 2023 Shreyas Zare (shreyas@technitium.com)
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -333,9 +333,16 @@ namespace Failover
foreach (JsonElement jsonNetwork in jsonUnderMaintenance.EnumerateArray())
{
string network = jsonNetwork.GetProperty("network").GetString();
bool enable = jsonNetwork.GetProperty("enable").GetBoolean();
bool enabled;
_underMaintenance.TryAdd(NetworkAddress.Parse(network), enable);
if (jsonNetwork.TryGetProperty("enabled", out JsonElement jsonEnabled))
enabled = jsonEnabled.GetBoolean();
else if (jsonNetwork.TryGetProperty("enable", out JsonElement jsonEnable))
enabled = jsonEnable.GetBoolean();
else
enabled = true;
_underMaintenance.TryAdd(NetworkAddress.Parse(network), enabled);
}
}
}

View File

@@ -89,11 +89,11 @@
"underMaintenance": [
{
"network": "192.168.10.2/32",
"enable": false
"enabled": false
},
{
"network": "10.1.1.0/24",
"enable": false
"enabled": false
}
]
}