From 016ecf887fa238164fa12eeecc77fd0479306e74 Mon Sep 17 00:00:00 2001 From: mcfly722 <7221798@gmail.com> Date: Sun, 15 Sep 2024 01:30:48 +0300 Subject: [PATCH] ip address check for client and server --- cloak-wg-helper/config.js | 52 ++++++++++++++++++++++++++++++++----- cloak-wg-helper/index.html | Bin 21362 -> 21532 bytes 2 files changed, 46 insertions(+), 6 deletions(-) diff --git a/cloak-wg-helper/config.js b/cloak-wg-helper/config.js index c0ee6af..c001963 100644 --- a/cloak-wg-helper/config.js +++ b/cloak-wg-helper/config.js @@ -29,6 +29,49 @@ function fill(){ } } +function isValidIPaddress(ipaddress) { + return (/^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/.test(ipaddress)) +} + +/* +function zeroPad(num, places) { + return String(num).padStart(places, '0') +} + +function linesNumbers(str) { + var n = str.split(/\r\n|\r|\n/).length + return [...Array(n).keys()].map((i)=> zeroPad(i+1,3)).join("\n") +} +*/ + +function cloakClientUpdate(value){ + if (isValidIPaddress(value)) { + document.getElementById("cloakClient").style.color="green" + onChange("cloakClient", value); + } else { + document.getElementById("cloakClient").style.color="red" + } +} + +function cloakGatewayUpdate(value){ + if (isValidIPaddress(value)) { + document.getElementById("cloakGateway").style.color="green" + onChange("cloakGateway", value); + } else { + document.getElementById("cloakGateway").style.color="red" + } +} + +function cloakServerUpdate(value){ + if (isValidIPaddress(value)) { + document.getElementById("cloakServer").style.color="green" + onChange("cloakServer", value); + } else { + document.getElementById("cloakServer").style.color="red" + } +} + + function subst(string, data) { return string.replace(/:([a-zA-Z]+)/g, (m, i) => i in data ? ""+data[i]+"" : m) } @@ -200,8 +243,7 @@ sudo sysctl -p ` let server = ` -

-# ----------------- 2.1 Install Cloak Server binary ----------------------
+
# ----------------- 2.1 Install Cloak Server binary ----------------------
 wget https://github.com/cbeuw/Cloak/releases/download/v2.7.0/ck-server-:serverOS-:serverArch-v2.7.0 -O ck-server
 chmod +x ck-server
 sudo mv ck-server /usr/bin/ck-server
@@ -289,7 +331,6 @@ sudo systemctl restart wg-quick@wg0.service
 sudo systemctl status wg-quick@wg0.service
 sudo wg
` - document.getElementById("client").innerHTML = subst(client, params); document.getElementById("server").innerHTML = subst(server, params); } @@ -298,6 +339,5 @@ window.onload = function() { regenerateWireguard(); regenerateCloak(); fill(); - update(); -}; - + update(); +}; \ No newline at end of file diff --git a/cloak-wg-helper/index.html b/cloak-wg-helper/index.html index b8e26ad05a71e77342cc80fae2ede00a344e62e5..1da7de2175d1715ec1fa36f14df8f014d9ecdfd7 100644 GIT binary patch delta 473 zcmZuuO-lk%6g>lNN-|9(NCmoQnOey*sciYBIv}j?@ zKKcu_4uXC`^b0!kY9(@c_r81I{W#~op9k&!Q5&6V+P2rwHs_a8&~c6~Iy^ljd2BQ# zoQ@aDV>x70MUA#jzW_^~g9&*FE(a>OL=z44 zVaw-6OwQtY*-yCgvG5+7#L!YGY`8uSc@0_e6^c&pFxwd~R-<8^IBxyktaLf0CF-1q7H+r(Zn~