aboutsummaryrefslogtreecommitdiff
path: root/api/lib/checkIfAllowedIP
diff options
context:
space:
mode:
authorkaotisk <kaotisk@arching-kaos.org>2025-03-18 01:42:44 +0200
committerkaotisk <kaotisk@arching-kaos.org>2025-03-18 01:42:44 +0200
commit1b005d0345ec24709c7cd8915cdb30cb30f59c91 (patch)
tree86257ec2a882ee064c1bd91d5057a4ea2e9c9e5c /api/lib/checkIfAllowedIP
parent95b1364f4aa1bafdcfcbae99387555c9d06c8ce2 (diff)
downloadarching-kaos-tools-1b005d0345ec24709c7cd8915cdb30cb30f59c91.tar.gz
arching-kaos-tools-1b005d0345ec24709c7cd8915cdb30cb30f59c91.tar.bz2
arching-kaos-tools-1b005d0345ec24709c7cd8915cdb30cb30f59c91.zip
[api] exported function checkIfAllowedIP
Diffstat (limited to 'api/lib/checkIfAllowedIP')
-rw-r--r--api/lib/checkIfAllowedIP/index.js8
1 files changed, 8 insertions, 0 deletions
diff --git a/api/lib/checkIfAllowedIP/index.js b/api/lib/checkIfAllowedIP/index.js
new file mode 100644
index 0000000..d9693d9
--- /dev/null
+++ b/api/lib/checkIfAllowedIP/index.js
@@ -0,0 +1,8 @@
+
+module.exports = (address) => {
+ var test_cjdns = /^fc[0-9a-z]{1,2}:([0-9a-z]{1,4}:){1,6}[0-9a-z]{1,4}/
+ var test_yggdrasil = /^2[0-9a-z]{1,2}:([0-9a-z]{1,4}:){1,6}[0-9a-z]{1,4}/
+ var test_yggdrasil_sub = /^3[0-9a-z]{1,2}:([0-9a-z]{1,4}:){1,6}[0-9a-z]{1,4}/
+ return (test_cjdns.test(address) || test_yggdrasil.test(address) || test_yggdrasil_sub.test(address)) ? true : false;
+};
+