145 lines
5.4 KiB
HTML
145 lines
5.4 KiB
HTML
{{template "base.html" .}}
|
|
|
|
{{define "title"}}DNS Tools - HeaderAnalyzer{{end}}
|
|
|
|
{{define "head"}}
|
|
<style>
|
|
.dns-tools-container { max-width: 900px; margin: 0 auto; }
|
|
.dns-query-form { display: flex; gap: 10px; margin-bottom: 10px; }
|
|
.dns-query-form input, .dns-query-form select { padding: 7px; border-radius: 4px; border: 1px solid #444; background: #232323; color: #e0e0e0; }
|
|
.dns-query-form button { padding: 7px 16px; }
|
|
.dns-results { margin-top: 10px; }
|
|
.dns-result-block { background: #232323; border-radius: 6px; margin-bottom: 12px; padding: 12px; box-shadow: 0 2px 4px rgba(0,0,0,0.12); }
|
|
.dns-result-block pre { white-space: pre-wrap; word-break: break-word; font-size: 1em; }
|
|
.save-btns { margin-bottom: 10px; }
|
|
</style>
|
|
{{end}}
|
|
|
|
{{define "content"}}
|
|
<div class="dns-tools-container">
|
|
<h1>DNS Tools</h1>
|
|
<form class="dns-query-form" id="dnsForm" onsubmit="return false;">
|
|
<input type="text" id="dnsInput" placeholder="Enter domain or IP" required>
|
|
<select id="dnsType">
|
|
<option value="A">A</option>
|
|
<option value="AAAA">AAAA</option>
|
|
<option value="MX">MX</option>
|
|
<option value="TXT">TXT</option>
|
|
<option value="NS">NS</option>
|
|
<option value="CNAME">CNAME</option>
|
|
<option value="PTR">PTR</option>
|
|
<option value="SOA">SOA</option>
|
|
<option value="SPF">SPF</option>
|
|
<option value="DKIM">DKIM</option>
|
|
<option value="DMARC">DMARC</option>
|
|
<option value="WHOIS">WHOIS</option>
|
|
</select>
|
|
<input type="text" id="dnsServer" placeholder="Custom DNS server (optional)" style="width:180px;" autocomplete="off">
|
|
<button type="submit">Query</button>
|
|
</form>
|
|
<div class="save-btns">
|
|
<button onclick="saveResults('csv')">Save as CSV</button>
|
|
<button onclick="saveResults('txt')">Save as TXT</button>
|
|
</div>
|
|
<div class="dns-results" id="dnsResults"></div>
|
|
</div>
|
|
{{end}}
|
|
|
|
{{define "scripts"}}
|
|
<script>
|
|
let results = [];
|
|
|
|
document.getElementById('dnsForm').addEventListener('submit', function() {
|
|
const query = document.getElementById('dnsInput').value.trim();
|
|
const type = document.getElementById('dnsType').value;
|
|
const server = document.getElementById('dnsServer').value.trim();
|
|
|
|
if (!query) return;
|
|
|
|
let url = `/api/dns?query=${encodeURIComponent(query)}&type=${encodeURIComponent(type)}`;
|
|
if (server) {
|
|
url += `&server=${encodeURIComponent(server)}`;
|
|
}
|
|
|
|
// Add selector field for DKIM queries
|
|
if (type === 'DKIM' && !query.includes(':')) {
|
|
const selector = prompt('Enter DKIM selector (e.g., "selector1", "default"):');
|
|
if (selector) {
|
|
url = `/api/dns?query=${encodeURIComponent(query + ':' + selector)}&type=${encodeURIComponent(type)}`;
|
|
if (server) {
|
|
url += `&server=${encodeURIComponent(server)}`;
|
|
}
|
|
}
|
|
}
|
|
|
|
fetch(url)
|
|
.then(response => response.text())
|
|
.then(data => {
|
|
const timestamp = new Date().toLocaleString();
|
|
const result = {
|
|
timestamp: timestamp,
|
|
query: query,
|
|
type: type,
|
|
server: server || 'Default',
|
|
result: data
|
|
};
|
|
results.push(result);
|
|
|
|
const resultDiv = document.createElement('div');
|
|
resultDiv.className = 'dns-result-block';
|
|
resultDiv.innerHTML = `
|
|
<h3>${type} query for ${query}</h3>
|
|
<p><small>Time: ${timestamp} | Server: ${server || 'Default'}</small></p>
|
|
<pre>${data}</pre>
|
|
`;
|
|
document.getElementById('dnsResults').insertBefore(resultDiv, document.getElementById('dnsResults').firstChild);
|
|
})
|
|
.catch(error => {
|
|
console.error('Error:', error);
|
|
const resultDiv = document.createElement('div');
|
|
resultDiv.className = 'dns-result-block';
|
|
resultDiv.innerHTML = `
|
|
<h3>Error querying ${query}</h3>
|
|
<pre>Error: ${error.message}</pre>
|
|
`;
|
|
document.getElementById('dnsResults').insertBefore(resultDiv, document.getElementById('dnsResults').firstChild);
|
|
});
|
|
});
|
|
|
|
function saveResults(format) {
|
|
if (results.length === 0) {
|
|
alert('No results to save');
|
|
return;
|
|
}
|
|
|
|
let content = '';
|
|
let filename = '';
|
|
|
|
if (format === 'csv') {
|
|
content = 'Timestamp,Query,Type,Server,Result\n';
|
|
results.forEach(r => {
|
|
const escapedResult = '"' + r.result.replace(/"/g, '""') + '"';
|
|
content += `"${r.timestamp}","${r.query}","${r.type}","${r.server}",${escapedResult}\n`;
|
|
});
|
|
filename = 'dns-results.csv';
|
|
} else if (format === 'txt') {
|
|
results.forEach(r => {
|
|
content += `=== ${r.type} query for ${r.query} ===\n`;
|
|
content += `Time: ${r.timestamp}\n`;
|
|
content += `Server: ${r.server}\n`;
|
|
content += `Result:\n${r.result}\n\n`;
|
|
});
|
|
filename = 'dns-results.txt';
|
|
}
|
|
|
|
const blob = new Blob([content], { type: 'text/plain' });
|
|
const url = URL.createObjectURL(blob);
|
|
const a = document.createElement('a');
|
|
a.href = url;
|
|
a.download = filename;
|
|
a.click();
|
|
URL.revokeObjectURL(url);
|
|
}
|
|
</script>
|
|
{{end}}
|