// DNS Things - Whois Module // Initialize Whois lookup form function initWhoisForm() { const form = document.getElementById('whois-form'); const input = document.getElementById('whois-input'); const results = document.getElementById('whois-results'); const loader = document.getElementById('whois-loader'); if (!form || !input || !results || !loader) return; form.addEventListener('submit', async (e) => { e.preventDefault(); const domain = input.value.trim(); if (!domain) return; // Show loader loader.classList.remove('hidden'); results.innerHTML = ''; try { // Use DNS-based domain information lookup as a free alternative const recordTypes = ['A', 'AAAA', 'MX', 'TXT', 'NS', 'SOA']; const queries = recordTypes.map(type => fetch(`https://dns.google/resolve?name=${encodeURIComponent(domain)}&type=${type}`) .then(response => response.json()) .then(data => ({ type, data })) .catch(error => ({ type, error })) ); const responses = await Promise.all(queries); // Process DNS data const dnsData = {}; const ipAddresses = { ipv4: [], ipv6: [] }; responses.forEach(({ type, data, error }) => { if (!error && data.Answer && data.Answer.length > 0) { dnsData[type] = data.Answer.map(record => record.data); if (type === 'A') { ipAddresses.ipv4.push(...data.Answer.map(record => record.data)); } else if (type === 'AAAA') { ipAddresses.ipv6.push(...data.Answer.map(record => record.data)); } } }); // Determine TLD registry const tld = domain.split('.').pop().toLowerCase(); const tldRegistries = { 'com': 'Verisign', 'net': 'Verisign', 'org': 'Public Interest Registry (PIR)', 'info': 'Afilias', 'biz': 'NeuStar', 'name': 'Verisign', 'mobi': 'Afilias', 'travel': 'Tralliance', 'museum': 'MuseDoma', 'coop': 'DotCooperation', 'aero': 'SITA', 'pro': 'RegistryPro', 'edu': 'Educause', 'gov': 'General Services Administration', 'mil': 'DoD Network Information Center', 'int': 'IANA' }; // Build results let resultsHTML = '
'; // Domain Information resultsHTML += `

Domain Information

Domain: ${domain}
TLD Registry: ${tldRegistries[tld] || 'Unknown'}
Website: ${dnsData.A || dnsData.AAAA ? '✅ Available' : '❌ Not available'}
Email: ${dnsData.MX ? '✅ Supported' : '❌ Not supported'}

Note: This is a DNS-based lookup providing practical domain information. For detailed registration data, use official whois services.

`; // Name Servers if (dnsData.NS) { resultsHTML += `

Name Servers (${dnsData.NS.length})

'; } // DNS Records Summary resultsHTML += `

DNS Records Summary

`; recordTypes.forEach(type => { const hasRecord = dnsData[type] && dnsData[type].length > 0; resultsHTML += `
${type}
${hasRecord ? '✅' : '❌'}
`; }); resultsHTML += '
'; // IP Addresses if (ipAddresses.ipv4.length > 0 || ipAddresses.ipv6.length > 0) { resultsHTML += `

IP Addresses

`; ipAddresses.ipv4.forEach(ip => { resultsHTML += `
${ip}
`; }); ipAddresses.ipv6.forEach(ip => { resultsHTML += `
${ip}
`; }); resultsHTML += '
'; } resultsHTML += '
'; results.innerHTML = resultsHTML; } catch (error) { console.error('Whois lookup error:', error); results.innerHTML = `

Error

Failed to lookup domain information. Please try again.

`; } finally { loader.classList.add('hidden'); } }); // Auto-submit on paste input.addEventListener('paste', () => { setTimeout(() => { if (input.value.trim()) { form.dispatchEvent(new Event('submit')); } }, 100); }); }