mirror of
https://git.dn42.dev/lare/myip.dn42.git
synced 2024-10-24 03:11:33 +02:00
add static html site with clientside js
This commit is contained in:
parent
7feff33885
commit
eb09c13ce0
4 changed files with 127 additions and 7 deletions
10
README.md
10
README.md
|
@ -1,11 +1,17 @@
|
||||||
# myip.dn42
|
# myip.dn42
|
||||||
|
|
||||||
[http://myip.dn42](http://myip.dn42): shows current ipv4 or ipv6 address
|
[http://myip.dn42](http://myip.dn42/): shows current ipv4 or ipv6 address
|
||||||
|
|
||||||
[http://v4.myip.dn42](http://v4.myip.dn42/): shows ipv4 address
|
[http://v4.myip.dn42](http://v4.myip.dn42/): shows ipv4 address
|
||||||
|
|
||||||
[http://v6.myip.dn42](http://v6.myip.dn42): shows ipv6 address
|
[http://v6.myip.dn42](http://v6.myip.dn42/): shows ipv6 address
|
||||||
|
|
||||||
|
|
||||||
|
[specs](specs.md)
|
||||||
|
|
||||||
|
|
||||||
- [source code](wwwroot)
|
- [source code](wwwroot)
|
||||||
|
- [nginx config](nginx-config) (preferred)
|
||||||
|
- [rust implementation](https://git.dn42.dev/famfo/myip-rs) by [famfo](https://git.dn42.dev/famfo/)
|
||||||
- [apache2 config](apache2-config)
|
- [apache2 config](apache2-config)
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,11 @@ server {
|
||||||
server_name *.myip.dn42;
|
server_name *.myip.dn42;
|
||||||
server_name 172.22.0.81;
|
server_name 172.22.0.81;
|
||||||
server_name [fd42:d42:d42:81::1];
|
server_name [fd42:d42:d42:81::1];
|
||||||
location /raw {
|
|
||||||
|
root /path/to/myip-wwwroot;
|
||||||
|
index index.html;
|
||||||
|
|
||||||
|
location /raw {
|
||||||
return 200 '$remote_addr\n';
|
return 200 '$remote_addr\n';
|
||||||
add_header Content-Type text/plain;
|
add_header Content-Type text/plain;
|
||||||
}
|
}
|
||||||
|
@ -17,9 +21,9 @@ server {
|
||||||
return 200 '{"version": "1.0", "ip": "$remote_addr", "server": "$server_addr","node_as": "<yourAS-without-AS>", "node_location": "<node country code>", "node_id": "<nodename or so>"}';
|
return 200 '{"version": "1.0", "ip": "$remote_addr", "server": "$server_addr","node_as": "<yourAS-without-AS>", "node_location": "<node country code>", "node_id": "<nodename or so>"}';
|
||||||
}
|
}
|
||||||
|
|
||||||
location = / {
|
#location = / {
|
||||||
root /path/to/myip-wwwroot;
|
#
|
||||||
index index.html;
|
#}
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
18
specs.md
Normal file
18
specs.md
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
# specs for myip.dn42
|
||||||
|
|
||||||
|
## subdomains
|
||||||
|
- myip.dn42: reachable both with ipv4 and ipv6
|
||||||
|
- v4.myip.dn42: reachable with ipv4 only
|
||||||
|
- v6.myip.dn42: raachable with ipv6 only
|
||||||
|
|
||||||
|
## endpoints
|
||||||
|
|
||||||
|
- / and /index.[fileextension]: "fancy" human readable version with either serverside or clientside rendering
|
||||||
|
- /raw returns the ip address of the client
|
||||||
|
- /api returns json with
|
||||||
|
- version: string, "1.0"
|
||||||
|
- ip: string, client ip
|
||||||
|
- server: string, ip of the server/node connected to,
|
||||||
|
- node_as: string, ASN of node without "AS" prefix
|
||||||
|
- node_location: string, ISO 3166-1 alpha-2 of node
|
||||||
|
- node_id: string, nodename the operator chooses for his node
|
92
wwwroot/index.html
Normal file
92
wwwroot/index.html
Normal file
|
@ -0,0 +1,92 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
|
||||||
|
<title>myip.dn42</title>
|
||||||
|
|
||||||
|
<meta name="author" content="dn42 community">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<meta name="robots" content="index, follow">
|
||||||
|
<meta name="description" content="This service can tell you your IP address in dn42.">
|
||||||
|
<meta name="keywords" content="what is my ip,my ip">
|
||||||
|
|
||||||
|
<link rel="icon" type="image/png" href="/favicon.png">
|
||||||
|
<link rel="shortcut icon" type="image/png" href="/favicon.png">
|
||||||
|
|
||||||
|
<link rel="stylesheet" href="/assets/css/normalize.css" integrity="sha384-M86HUGbBFILBBZ9ykMAbT3nVb0+2C7yZlF8X2CiKNpDOQjKroMJqIeGZ/Le8N2Qp">
|
||||||
|
<link rel="stylesheet" href="/assets/css/simple.min.css" integrity="sha384-ZLDMtZ+NjwNE3nk4wWLGpX4atVTD4fql9ruaAw2xFz7CLPlFcwrifgX2HgkdX6X7">
|
||||||
|
<script>
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<header>
|
||||||
|
<h1>myip.dn42</h1>
|
||||||
|
</header>
|
||||||
|
<main>
|
||||||
|
<div>
|
||||||
|
<h2>Your IP address</h2>
|
||||||
|
Your default IP address is <strong><span id=defaultip>fetching from <a href="/api">api</a></span></strong>.<br>
|
||||||
|
Your IPv4 address is <strong><span id=ipv4>fetching from <a href="http://v4.myip.dn42/api">api</a></span></strong>.<br>
|
||||||
|
Your IPv6 address is <strong><span id=ipv6>fetching from <a href="http://v6.myip.dn42/api">api</a></span></strong>.<br>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<h2>Remote Node</h2>
|
||||||
|
The node's ip address is <span id="serverdefault">fetching from <a href="/api">api</a></span>. <br>
|
||||||
|
The node's ipv4 address is <span id="serveripv4">fetching from <a href="http://v4.myip.dn42/api">api</a></span>.<br>
|
||||||
|
The node's ipv6 address is <span id="serveripv6">fetching from <a href="http://v6.myip.dn42/api">api</a></span>.<br>
|
||||||
|
You have reached the myip.dn42 service of AS<span id="node_as">fetching from <a href="/api">api</a></span>. The server is located in <span id="node_location">fetching from <a href="/api">api</a></span> . The server has the ID/name <code id="node_id">fetching from <a href="/api">api</a></code>.
|
||||||
|
</div>
|
||||||
|
</main>
|
||||||
|
<footer>
|
||||||
|
<p>
|
||||||
|
This service is provided by the dn42 community. Anycast is used to ensure the reliability of the service. Bugs or feedback about the service can be submitted via the Mailling list or the <a href="https://git.dn42.dev/lare/myip.dn42/issues">issue tracker</a>.
|
||||||
|
</p>
|
||||||
|
</footer>
|
||||||
|
</body>
|
||||||
|
</html>
|
Loading…
Add table
Reference in a new issue