trolled once again

This commit is contained in:
Minecon724 2024-10-11 12:54:19 +02:00
parent 5c8103e84e
commit 0db9f8e871
Signed by: Minecon724
GPG key ID: 3CCC4D267742C8E8
5 changed files with 62 additions and 71 deletions

19
src/calculator/index.html Normal file
View file

@ -0,0 +1,19 @@
<!DOCTYPE html>
<html lang="en">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>dn724</title>
<script src="./script.js" defer></script>
<style>
html {
background: black;
color: white;
}
</style>
<input type="number" min="0" placeholder="your ASN" oninput="calculate(this)">
<p>Port: <span id="result"></span></p>
</html>

32
src/calculator/script.js Normal file
View file

@ -0,0 +1,32 @@
const result = document.getElementById('result');
const isNumber = (s) => /^\d+$/.test(s);
function calculate(el) {
if (el.value == '') {
result.innerText = '';
return;
}
let cand = cyrb53(el.value).toString().slice(0, 5);
if (cand > 65535 || cand < 30000) {
cand = (cand % 3 + 3) * 10000 + (cand % 10000);
}
result.innerText = cand;
}
const cyrb53 = (str, seed = 0) => {
let h1 = 0xdeadbeef ^ seed, h2 = 0x41c6ce57 ^ seed;
for (let i = 0, ch; i < str.length; i++) {
ch = str.charCodeAt(i);
h1 = Math.imul(h1 ^ ch, 2654435761);
h2 = Math.imul(h2 ^ ch, 1597334677);
}
h1 = Math.imul(h1 ^ (h1 >>> 16), 2246822507);
h1 ^= Math.imul(h2 ^ (h2 >>> 13), 3266489909);
h2 = Math.imul(h2 ^ (h2 >>> 16), 2246822507);
h2 ^= Math.imul(h1 ^ (h1 >>> 13), 3266489909);
return 4294967296 * (2097151 & h2) + (h1 >>> 0);
};

View file

@ -44,7 +44,6 @@
<li>Rome. Italy</li>
<li>Nuremberg, Germany</li>
<li>Netherlands, Amsterdam</li>
<li><a href="./map/index.html">Network map</a> (uses thunderforest.com API)</li>
</ul>
<p>Peering requirements</p>
@ -60,7 +59,7 @@
<ul>
<li><a href="https://git.m724.eu/Minecon724/dn42-info/src/branch/master/nodes.md">Nodes with details</a></li>
<li>Port is last 5 digits of your ASN (2xxx), unless</li>
<li>your ASN is not 424242xxxx, then <a href="port-calc.html">use this</a></li>
<li>your ASN is not 424242xxxx, then <a href="./calculator/index.html">use this</a></li>
</ul>
<p>Contact</p>
@ -71,4 +70,10 @@
<li>Session: <span class=sel>05293535c0f0b5ae76a663f3f875582590edd77abd72ab9b12f3acbe4bb078aa49</span></li>
</ul>
<p>Other</p>
<ul>
<li><a href="./map/index.html">Network map</a> (uses thunderforest.com API)</li>
<li><a href="./services.html">Services</a></li>
</ul>
</html>

View file

@ -1,55 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>dn724</title>
<style>
html {
background: black;
color: white;
}
</style>
<input type="number" min="0" placeholder="your ASN" oninput="calculate(this)">
<p>Port: <span id="result"></span></p>
<script>
const result = document.getElementById('result');
const isNumber = (s) => /^\d+$/.test(s);
function calculate(el) {
console.log(el);
if (el.value == '') {
result.innerText = '';
return;
}
let cand = cyrb53(el.value).toString().slice(0, 5);
if (cand > 65535 || cand < 30000) {
cand = (cand % 3 + 3) * 10000 + (cand % 10000);
}
result.innerText = cand;
}
const cyrb53 = (str, seed = 0) => {
let h1 = 0xdeadbeef ^ seed, h2 = 0x41c6ce57 ^ seed;
for(let i = 0, ch; i < str.length; i++) {
ch = str.charCodeAt(i);
h1 = Math.imul(h1 ^ ch, 2654435761);
h2 = Math.imul(h2 ^ ch, 1597334677);
}
h1 = Math.imul(h1 ^ (h1 >>> 16), 2246822507);
h1 ^= Math.imul(h2 ^ (h2 >>> 13), 3266489909);
h2 = Math.imul(h2 ^ (h2 >>> 16), 2246822507);
h2 ^= Math.imul(h1 ^ (h1 >>> 13), 3266489909);
return 4294967296 * (2097151 & h2) + (h1 >>> 0);
};
</script>
</html>

View file

@ -42,22 +42,12 @@
<th>Description</th>
</tr>
<tr>
<td>Minetest</td>
<td>nodecode.pivipi.dn42<br></td>
<td>None yet</td>
<td>m724.dn42<br></td>
<td>
<ul>
<li>Game: NodeCore</li>
<li>Hosted in Netherlands</li>
</ul>
</td>
</tr>
<tr>
<td>Minecraft</td>
<td>fd11:ef8b:72ac::<br></td>
<td>
<ul>
<li>Running on Cuberite</li>
<li>Hosted in Poland</li>
<li>lorem ipsum</li>
<li>dolor sit amet</li>
</ul>
</td>
</tr>