From 2cc7e443fce2a7a3a2f2a8fd2a64815750ab04be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20K=C3=BCthe?= Date: Sat, 23 Sep 2023 17:09:59 +0200 Subject: [PATCH 1/3] Outsource JavaScript into seperate file In general, JS and CSS resources should be in separate files. This improves clarity and security (for example, when using CSP). --- wwwroot/assets/js/myip.js | 45 +++++++++++++++++++++++++++++++++++++ wwwroot/index.html | 47 +-------------------------------------- 2 files changed, 46 insertions(+), 46 deletions(-) create mode 100644 wwwroot/assets/js/myip.js diff --git a/wwwroot/assets/js/myip.js b/wwwroot/assets/js/myip.js new file mode 100644 index 0000000..3b75ec6 --- /dev/null +++ b/wwwroot/assets/js/myip.js @@ -0,0 +1,45 @@ +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://v4.myip.dn42/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://v6.myip.dn42/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(); +} diff --git a/wwwroot/index.html b/wwwroot/index.html index 48c4ba0..5387ec6 100644 --- a/wwwroot/index.html +++ b/wwwroot/index.html @@ -16,53 +16,8 @@ - +
From cf815240fe2417bd28965ddbf8721f18c15c19b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20K=C3=BCthe?= Date: Sat, 23 Sep 2023 17:10:20 +0200 Subject: [PATCH 2/3] Remove integrity for CSS This is unnecessary when using resources that are loaded from your own site. This technique should rather be used in connection with CDNs. --- wwwroot/index.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/wwwroot/index.html b/wwwroot/index.html index 5387ec6..328a97c 100644 --- a/wwwroot/index.html +++ b/wwwroot/index.html @@ -14,8 +14,8 @@ - - + + From fa21bcfa43c5bb51b3ba66fe1815ace34f46dcb5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20K=C3=BCthe?= Date: Sat, 23 Sep 2023 17:11:48 +0200 Subject: [PATCH 3/3] 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. --- wwwroot/assets/js/myip.js | 4 ++-- wwwroot/index.html | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/wwwroot/assets/js/myip.js b/wwwroot/assets/js/myip.js index 3b75ec6..745bf8b 100644 --- a/wwwroot/assets/js/myip.js +++ b/wwwroot/assets/js/myip.js @@ -14,7 +14,7 @@ function getdefault() { } function getipv4() { - fetch('http://v4.myip.dn42/api') + fetch('http://172.20.0.81/api') .then(function (response) { return response.json(); }) @@ -26,7 +26,7 @@ function getipv4() { } function getipv6() { - fetch('http://v6.myip.dn42/api') + fetch('http://[fd42:d42:d42:81::1]/api') .then(function (response) { return response.json(); }) diff --git a/wwwroot/index.html b/wwwroot/index.html index 328a97c..f66fa53 100644 --- a/wwwroot/index.html +++ b/wwwroot/index.html @@ -32,9 +32,9 @@

Remote Node

- The node's ip address is fetching from api.
- The node's ipv4 address is fetching from api.
- The node's ipv6 address is fetching from api.
+ The node's ip address is fetching from api.
+ The node's ipv4 address is fetching from api.
+ The node's ipv6 address is fetching from api.
You have reached the myip.dn42 service of ASfetching from api. The server is located in fetching from api . The server has the ID/name fetching from api.