From 1b005d0345ec24709c7cd8915cdb30cb30f59c91 Mon Sep 17 00:00:00 2001 From: kaotisk Date: Tue, 18 Mar 2025 01:42:44 +0200 Subject: [api] exported function checkIfAllowedIP --- api/lib/checkIfAllowedIP/index.js | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 api/lib/checkIfAllowedIP/index.js (limited to 'api/lib/checkIfAllowedIP') 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; +}; + -- cgit v1.2.3