From 5b8200f4a4e5bb0c1576d7ddf0ba2e7da932034d Mon Sep 17 00:00:00 2001 From: Shreyas Zare Date: Sun, 17 Jan 2021 17:54:25 +0530 Subject: [PATCH] WebService: implemented maxStatFileDays settings option and API. --- DnsServerCore/WebService.cs | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/DnsServerCore/WebService.cs b/DnsServerCore/WebService.cs index 557ce071..0be53f46 100644 --- a/DnsServerCore/WebService.cs +++ b/DnsServerCore/WebService.cs @@ -1,6 +1,6 @@ /* Technitium DNS Server -Copyright (C) 2020 Shreyas Zare (shreyas@technitium.com) +Copyright (C) 2021 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 @@ -1098,6 +1098,9 @@ namespace DnsServerCore jsonWriter.WritePropertyName("maxLogFileDays"); jsonWriter.WriteValue(_log.MaxLogFileDays); + jsonWriter.WritePropertyName("maxStatFileDays"); + jsonWriter.WriteValue(_dnsServer.StatsManager.MaxStatFileDays); + jsonWriter.WritePropertyName("allowRecursion"); jsonWriter.WriteValue(_dnsServer.AllowRecursion); @@ -1444,6 +1447,10 @@ namespace DnsServerCore if (!string.IsNullOrEmpty(strMaxLogFileDays)) _log.MaxLogFileDays = int.Parse(strMaxLogFileDays); + string strMaxStatFileDays = request.QueryString["maxStatFileDays"]; + if (!string.IsNullOrEmpty(strMaxStatFileDays)) + _dnsServer.StatsManager.MaxStatFileDays = int.Parse(strMaxStatFileDays); + string strAllowRecursion = request.QueryString["allowRecursion"]; if (!string.IsNullOrEmpty(strAllowRecursion)) _dnsServer.AllowRecursion = bool.Parse(strAllowRecursion); @@ -5218,6 +5225,7 @@ namespace DnsServerCore case 11: case 12: case 13: + case 14: _dnsServer.ServerDomain = bR.ReadShortString(); _webServiceHttpPort = bR.ReadInt32(); @@ -5265,6 +5273,9 @@ namespace DnsServerCore if (bR.ReadBoolean()) //logQueries _dnsServer.QueryLogManager = _log; + if (version >= 14) + _dnsServer.StatsManager.MaxStatFileDays = bR.ReadInt32(); + _dnsServer.AllowRecursion = bR.ReadBoolean(); if (version >= 4) @@ -5504,7 +5515,7 @@ namespace DnsServerCore BinaryWriter bW = new BinaryWriter(mS); bW.Write(Encoding.ASCII.GetBytes("DS")); //format - bW.Write((byte)13); //version + bW.Write((byte)14); //version bW.WriteShortString(_dnsServer.ServerDomain); bW.Write(_webServiceHttpPort); @@ -5533,6 +5544,7 @@ namespace DnsServerCore bW.Write(_dnsServer.PreferIPv6); bW.Write(_dnsServer.QueryLogManager != null); //logQueries + bW.Write(_dnsServer.StatsManager.MaxStatFileDays); bW.Write(_dnsServer.AllowRecursion); bW.Write(_dnsServer.AllowRecursionOnlyForPrivateNetworks);