2024-04-24 02:24:00 +00:00
|
|
|
#include utility.js
|
|
|
|
#include xhr.js
|
2024-05-30 19:47:26 +00:00
|
|
|
#include elems/sidelist.jsx
|
2024-04-24 02:24:00 +00:00
|
|
|
|
|
|
|
const MakaiWHOIS = () => {
|
2023-10-13 20:33:17 +00:00
|
|
|
let locked = false;
|
2024-05-30 19:47:26 +00:00
|
|
|
const input = $q('.js-whois-input');
|
|
|
|
const submit = $q('.js-whois-submit');
|
|
|
|
const result = $q('.js-whois-body');
|
|
|
|
const tabs = $q('.js-whois-tabs');
|
|
|
|
|
|
|
|
const historic = [];
|
|
|
|
const history = (() => {
|
|
|
|
const element = $q('.js-whois-sidelist');
|
|
|
|
if(element instanceof Element)
|
|
|
|
return new MakaiSideListElement(element);
|
|
|
|
})();
|
2022-09-27 01:58:32 +00:00
|
|
|
|
2024-04-24 02:24:00 +00:00
|
|
|
const lock = () => {
|
2022-09-27 01:58:32 +00:00
|
|
|
if(locked)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
document.body.classList.add('whois-locked');
|
|
|
|
input.disabled = true;
|
|
|
|
locked = true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2024-04-24 02:24:00 +00:00
|
|
|
const unlock = () => {
|
2022-09-27 01:58:32 +00:00
|
|
|
if(!locked)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
document.body.classList.remove('whois-locked');
|
|
|
|
input.disabled = false;
|
|
|
|
locked = false;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2024-04-24 02:24:00 +00:00
|
|
|
const lookup = target => {
|
2022-09-27 01:58:32 +00:00
|
|
|
if(!lock())
|
|
|
|
return;
|
|
|
|
|
2024-05-30 19:47:26 +00:00
|
|
|
$x.post('/tools/whois/lookup', {}, { _csrfp: $csrfp.get(), target: target }).then(output => {
|
2023-10-13 20:33:17 +00:00
|
|
|
let headers = output.headers();
|
|
|
|
if(headers.has('x-csrfp'))
|
|
|
|
$csrfp.set(headers.get('x-csrfp'));
|
2022-09-27 01:58:32 +00:00
|
|
|
|
2023-10-13 20:33:17 +00:00
|
|
|
let resp = output.json();
|
2022-09-29 22:27:07 +00:00
|
|
|
if(resp.error)
|
2022-09-27 01:58:32 +00:00
|
|
|
alert(resp.text);
|
|
|
|
|
2023-10-13 20:33:17 +00:00
|
|
|
let count = 0;
|
|
|
|
|
2024-05-30 19:47:26 +00:00
|
|
|
$rc(tabs);
|
|
|
|
|
|
|
|
if(resp.result && Array.isArray(resp.result.responses) && resp.result.responses.length > 0) {
|
|
|
|
if(!historic.includes(resp.result.target)) {
|
|
|
|
historic.push(resp.result.target);
|
|
|
|
history.prependItem(resp.result.target, '←', `#${resp.result.target}`);
|
|
|
|
}
|
|
|
|
|
2023-10-13 20:33:17 +00:00
|
|
|
for(const response of resp.result.responses) {
|
2024-05-30 19:47:26 +00:00
|
|
|
const tab = $e({tag: 'a'});
|
|
|
|
const tabHeader = $e();
|
|
|
|
const tabServer = $e();
|
2023-10-13 20:33:17 +00:00
|
|
|
|
|
|
|
tab.href = 'javascript:;';
|
|
|
|
tab.className = 'whois-result-tab';
|
|
|
|
if(count === 0) tab.className += ' whois-result-tab-active';
|
|
|
|
|
2024-04-24 02:24:00 +00:00
|
|
|
tab.onclick = () => {
|
2023-10-13 20:33:17 +00:00
|
|
|
const active = $q('.whois-result-tab-active');
|
|
|
|
if(active) active.classList.remove('whois-result-tab-active');
|
|
|
|
tab.classList.add('whois-result-tab-active');
|
|
|
|
result.textContent = response.lines.join("\r\n").trim();
|
|
|
|
};
|
|
|
|
|
|
|
|
tabHeader.className = 'whois-result-tab-header';
|
|
|
|
tabHeader.textContent = count === 0 ? 'Result' : ('Hop #' + (resp.result.responses.length - count).toString());
|
|
|
|
|
|
|
|
tabServer.className = 'whois-result-tab-server';
|
|
|
|
tabServer.textContent = response.server;
|
|
|
|
|
|
|
|
tab.appendChild(tabHeader);
|
|
|
|
tab.appendChild(tabServer);
|
|
|
|
tabs.appendChild(tab);
|
|
|
|
|
|
|
|
++count;
|
2022-09-27 01:58:32 +00:00
|
|
|
}
|
2024-05-30 19:47:26 +00:00
|
|
|
}
|
2022-09-27 01:58:32 +00:00
|
|
|
|
2022-09-29 22:27:07 +00:00
|
|
|
if(tabs.firstChild)
|
|
|
|
tabs.firstChild.click();
|
|
|
|
|
2022-09-27 01:58:32 +00:00
|
|
|
unlock();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2024-04-24 02:24:00 +00:00
|
|
|
const readHash = () => {
|
2022-09-27 01:58:32 +00:00
|
|
|
if(location.hash.length < 2) {
|
|
|
|
result.textContent = 'Enter a domain or IP address!';
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2023-10-13 20:33:17 +00:00
|
|
|
const target = decodeURIComponent(location.hash.substring(1));
|
2022-09-27 01:58:32 +00:00
|
|
|
if(input.value !== target)
|
|
|
|
input.value = target;
|
|
|
|
lookup(target);
|
|
|
|
};
|
|
|
|
|
2024-04-24 02:24:00 +00:00
|
|
|
window.addEventListener('hashchange', ev => {
|
2022-09-27 01:58:32 +00:00
|
|
|
readHash();
|
|
|
|
}, false);
|
|
|
|
|
2024-04-24 02:24:00 +00:00
|
|
|
submit.addEventListener('click', ev => {
|
2022-09-27 01:58:32 +00:00
|
|
|
ev.preventDefault();
|
|
|
|
location.hash = encodeURIComponent(input.value);
|
|
|
|
});
|
|
|
|
|
|
|
|
readHash();
|
2024-04-24 02:24:00 +00:00
|
|
|
};
|