myip.dn42/wwwroot/assets/js/myip.js
Marek Küthe fa21bcfa43
Replace dns with ip addresses
This ensures that people without a working DNS but with working IP connections to the dn42 can use the JavaScript page.
2023-09-23 17:13:58 +02:00

45 lines
1.2 KiB
JavaScript

function getdefault() {
fetch('/api')
.then(function (response) {
return response.json();
})
.then(function (data) {
document.getElementById("defaultip").innerHTML=data.ip;
document.getElementById("serverdefault").innerHTML=data.server;
document.getElementById("node_as").innerHTML=data.node_as;
document.getElementById("node_location").innerHTML=data.node_location;
document.getElementById("node_id").innerHTML=data.node_id;
})
}
function getipv4() {
fetch('http://172.20.0.81/api')
.then(function (response) {
return response.json();
})
.then(function (data) {
document.getElementById("ipv4").innerHTML=data.ip;
document.getElementById("serveripv4").innerHTML=data.server;
})
}
function getipv6() {
fetch('http://[fd42:d42:d42:81::1]/api')
.then(function (response) {
return response.json();
})
.then(function (data) {
document.getElementById("ipv6").innerHTML=data.ip;
document.getElementById("serveripv6").innerHTML=data.server;
})
}
window.onload = function () {
getdefault();
getipv4();
getipv6();
}