]> www.infradead.org Git - users/dwmw2/vpnc-scripts.git/commitdiff
Ensure that vpnc-script-win.js picks a legal "internal gateway" address even for...
authorDaniel Lenski <dlenski@gmail.com>
Tue, 31 Aug 2021 21:30:38 +0000 (21:30 +0000)
committerDaniel Lenski <dlenski@gmail.com>
Fri, 3 Sep 2021 21:27:47 +0000 (21:27 +0000)
Attempted fix for https://gitlab.com/openconnect/vpnc-scripts/-/issues/26
(formerly https://gitlab.com/openconnect/openconnect/-/issues/306).

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
vpnc-script-win.js

index 129bb93eeca5e5436cd6e215b676c7615761b301..56f85edf07cd76de8992dd82edac552048dc3639 100644 (file)
@@ -60,9 +60,12 @@ case "pre-init":
     break;
 case "connect":
     var gw = getDefaultGateway();
-    // Calculate the first usable address in subnet
+    // Calculate the first legal host address in subnet
+    // (identical to the INTERNAL_IP4_ADDRESS if the netmask is
+    // 255.255.255.255, otherwise increment the last octet)
     var internal_gw_array = env("INTERNAL_IP4_NETADDR").split(".");
-    internal_gw_array[3]++;
+    if (env("INTERNAL_IP4_NETMASK").trim() != "255.255.255.255" && env("INTERNAL_IP4_NETMASKLEN") != 32)
+        internal_gw_array[3]++;
     var internal_gw = internal_gw_array.join(".");
 
     echo("VPN Gateway: " + env("VPNGATEWAY"));