From ac9c3bdc1a958c9404ffda4c1fa6f2626f72ffa2 Mon Sep 17 00:00:00 2001 From: Shreyas Zare Date: Sat, 11 Jan 2025 18:03:34 +0530 Subject: [PATCH] logs.js: added support for export query logs feature. --- DnsServerCore/www/js/logs.js | 39 +++++++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/DnsServerCore/www/js/logs.js b/DnsServerCore/www/js/logs.js index cae16eac..30ce2053 100644 --- a/DnsServerCore/www/js/logs.js +++ b/DnsServerCore/www/js/logs.js @@ -1,6 +1,6 @@ /* Technitium DNS Server -Copyright (C) 2024 Shreyas Zare (shreyas@technitium.com) +Copyright (C) 2025 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 @@ -447,3 +447,40 @@ function showQueryLogs(domain, clientIp) { refreshQueryLogsTab(true); } + +function exportQueryLogsCsv() { + var name = $("#optQueryLogsAppName").val(); + if (name == null) { + showAlert("warning", "Missing!", "Please install the 'Query Logs (Sqlite)' DNS App or any other DNS app that supports query logging feature."); + $("#optQueryLogsAppName").focus(); + return false; + } + + var classPath = $("#optQueryLogsClassPath").val(); + if (classPath == null) { + showAlert("warning", "Missing!", "Please select a Class Path to query logs."); + $("#optQueryLogsClassPath").focus(); + return false; + } + + var start = $("#txtQueryLogStart").val(); + if (start != "") + start = moment(start).toISOString(); + + var end = $("#txtQueryLogEnd").val(); + if (end != "") + end = moment(end).toISOString(); + + var clientIpAddress = $("#txtQueryLogClientIpAddress").val(); + var protocol = $("#optQueryLogsProtocol").val(); + var responseType = $("#optQueryLogsResponseType").val(); + var rcode = $("#optQueryLogsResponseCode").val(); + var qname = $("#txtQueryLogQName").val(); + var qtype = $("#txtQueryLogQType").val(); + var qclass = $("#optQueryLogQClass").val(); + + window.open("/api/logs/export?token=" + sessionData.token + "&name=" + encodeURIComponent(name) + "&classPath=" + encodeURIComponent(classPath) + + "&start=" + encodeURIComponent(start) + "&end=" + encodeURIComponent(end) + "&clientIpAddress=" + encodeURIComponent(clientIpAddress) + + "&protocol=" + protocol + "&responseType=" + responseType + "&rcode=" + rcode + "&qname=" + encodeURIComponent(qname) + "&qtype=" + qtype + "&qclass=" + qclass + , "_blank"); +}