Browse Source

More

master
peter 2 months ago
parent
commit
fe46648aa2
  1. 11
      include/generate-name-index.js
  2. 1
      main/.gitignore
  3. 6
      main/live-demo/ipv6things_override.json
  4. 25
      main/live-demo/runtimeConfig.json
  5. 14
      main/page.js
  6. 2
      main/scp-aliases.json
  7. 11
      main/static.js

11
include/generate-name-index.js

@ -26,18 +26,21 @@ for (var x of database) {
var n = name.replace(/\.aliases\.peterjin\.org$/, "");
if (!n.startsWith("retired-")) randomDB["-a3k"].values.push(n);
if (n.startsWith("xn--") || ((n.indexOf("-") === -1) && n !== "undefined")) {
var nCap = null;
if (n.startsWith("xn--")) {
var newName = punycode.decode(n.replace(/^xn--/, ""));
n = "";
newName = newName.substring(0, 1).toUpperCase() + newName.substring(1);
nCap = "";
for (let c of newName) {
if (c > '\u0080') {
n += `&#${c.charCodeAt(0)};`;
nCap += `&#${c.charCodeAt(0)};`;
} else {
n += c;
nCap += c;
}
}
} else {
nCap = n.substring(0, 1).toUpperCase() + n.substring(1);
}
var nCap = n.substring(0, 1).toUpperCase() + n.substring(1);
if (ip.match(/^2602:806:a003:40e::3001:[0-9a-f]+$/)) {
formalName = ["My name is Peter Jin (.org),", "but you can call me Mr. " + nCap + "."];
} else {

1
main/.gitignore

@ -7,3 +7,4 @@ live-demo/ipv6things_db.json
/randomBibleVerse.json
/ipv6things_db.json
/runtimeConfig.json
/ipv6things_override.json

6
main/live-demo/ipv6things_override.json

@ -0,0 +1,6 @@
{
"2602:806:a003:40e::3001:21d1": {
"force_caption": ["My name is Peter Jin (.org)", "but you can call me Mr. McKay."],
"force_auxtext": "<div style=\"background-color: #dff\" class=\"auxtext-common\">Due to limitations in the IPAM code, it is currently not possible to make the 'K' in the caption above captialized without overriding it.</div>"
}
}

25
main/live-demo/runtimeConfig.json

@ -14,7 +14,10 @@
"ip": "2602:806:a003:40f::121:25",
"expectedDomain": ["mountain.t.rdns.peterjin.org"],
"path": "/rw_disk/ttgen-videos/mountain/",
"defaultURLPath": "/index2.html"
"defaultURLPath": "/index2.html",
"headers": [
["Content-Security-Policy", "default-src 'self'; style-src 'unsafe-inline' 'self'; frame-src www.youtube.com 'self'"]
]
},
{
"ip": "2602:806:a003:40f::4:25",
@ -34,6 +37,24 @@
"path": "/rw_disk/ttgen-videos/daniel/",
"defaultURLPath": "/damn_daniel.html"
},
{
"ip": "2602:806:a003:40e::5c50:614",
"expectedDomain": ["scp-614.scp.rdns.peterjin.org"],
"path": "/rw_disk/ttgen-videos/scp-614/",
"defaultURLPath": "/index2.html"
},
{
"ip": "2602:806:a003:40e::5c50:914",
"expectedDomain": ["scp-914.scp.rdns.peterjin.org"],
"path": "/rw_disk/ttgen-videos/scp-914/",
"defaultURLPath": "/index2.html"
},
{
"ip": "2602:806:a003:40e::5c50:2211",
"expectedDomain": ["scp-2211.scp.rdns.peterjin.org"],
"path": "/rw_disk/ttgen-videos/scp-2211/",
"defaultURLPath": "/eyee(79).wav"
},
{
"ip": "2602:806:a003:40e::1",
"expectedDomain": ["ipv6-things.srv.peterjin.org"],
@ -42,7 +63,7 @@
},
{
"ip": "2602:806:a003:40e::5c50:5789",
"expectedDomain": ["scp-5789.scp.rdns.peterjin.org", "xn--scp-j430c.scp.rdns.peterjin.org"],
"expectedDomain": ["scp-5789.scp.rdns.peterjin.org", "xn--scp--j430c.scp.rdns.peterjin.org", "scp-\ud835\udd50.scp.rdns.peterjin.org"],
"path": "/rw_disk/ttgen-videos/scp-5789/",
"defaultURLPath": "/rgu-y.html"
},

14
main/page.js

@ -1,4 +1,10 @@
var database = require("./ipv6things_db.json"); // get this from the IPAM repository build artifacts archive
var database2 = {};
try {
database2 = require("./ipv6things_override.json");
} catch (e) {
}
var randomBibleVerse = null;
try {
randomBibleVerse = require("./randomBibleVerse.json"); // get this from ipv6bible
@ -300,7 +306,13 @@ function lookupByIP(ip, remoteIP, localBuffer, hasStatic) {
}
}
}
return [200, generateHTML(ip, result.domain, result.caption, auxtext_b, remoteIP, color, f, hasStatic)];
let overrideObj = database2.hasOwnProperty(ip) ? database2[ip] : {force_domain: null, domain: null, force_caption: null, caption: null, force_auxtext: null, auxtext: null};
return [200, generateHTML(
ip,
overrideObj.force_domain || result.domain || overrideObj.domain,
overrideObj.force_caption || result.caption || overrideObj.caption,
overrideObj.force_auxtext || auxtext_b || overrideObj.auxtext,
remoteIP, color, f, hasStatic)];
}
function generateRandom(group, persistRandomState) {
let randomState = persistRandomState || newRandomState();

2
main/scp-aliases.json

@ -1,6 +1,6 @@
{
"!": "These aliases were taken from the SCP Wiki, which is licensed CC-BY-SA 3.0.",
"2602:806:a003:40e::5c50:426": "I, SCP-426, have breached containment!",
"2602:806:a003:40e::5c50:426": ["I am SCP-426 and I have breached containment!"],
"2602:806:a003:40e::5c50:1764": "SPC-1764",
"2602:806:a003:40e::5c50:2521": "&#9679;&#9679;|&#9679;&#9679;&#9679;&#9679;&#9679;|&#9679;&#9679;|&#9679;",
"2602:806:a003:40e::5c50:2602": ["SCP-2602, which used to be a library,", "has breached containment!"],

11
main/static.js

@ -6,10 +6,18 @@ for (let x of (runtimeConfig.staticSites || [])) {
if (String(x.path).startsWith('/') === false) {
throw new Error("Must use an absolute path for static directory");
}
let options = x.static_options || {};
if (Array.isArray(x.headers)) {
options.setHeaders = function(res, path, stat) {
for (let header of x.headers) {
res.set(header[0], header[1]);
}
};
}
staticMap.set(x.ip, {
expectedDomain: x.expectedDomain || null,
defaultURLPath: x.hasOwnProperty("defaultURLPath") ? x.defaultURLPath : "/index2.html",
middleware: express.static(x.path)
middleware: express.static(x.path, options)
});
}
@ -39,6 +47,7 @@ function getMiddlewareForIP(ip, hostHeader) {
let domain_match = false;
let host_header_str_domain = host_header_str.replace(/\.?(:[^]:]*)?$/, "");
for (let domain of candidate.expectedDomain) {
// console.log(host_header_str_domain);
if (host_header_str_domain === domain) {
domain_match = true;
break;

Loading…
Cancel
Save