break;
case "connect":
var gw = getDefaultGateway();
- // 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)
- // We also need to work around the fact that
- // INTERNAL_IP4_{NETMASK,NETADDR} are not always set for
- // all protocols.
+ // Use INTERNAL_IP4_ADDRESS as the "gateway" address for the
+ // VPN tunnel connection. As noted in the OpenConnect source,
+ // "It's a tunnel; having a gateway is meaningless." Setting
+ // the gateway to match the INTERNAL_IP4_ADDRESS seems like
+ // the simplest way to behave correctly in all cases,
+ // including when the INTERNAL_IP4_NETMASK is /0 or /32.
var internal_ip4_netmask = env("INTERNAL_IP4_NETMASK") || "255.255.255.255";
- var internal_ip4_netaddr = env("INTERNAL_IP4_NETADDR") || env("INTERNAL_IP4_ADDRESS");
- var internal_gw_array = internal_ip4_netaddr.split(".");
- if (internal_ip4_netmask.trim() != "255.255.255.255" && env("INTERNAL_IP4_NETMASKLEN") != 32)
- internal_gw_array[3]++;
- var internal_gw = internal_gw_array.join(".");
+ var internal_gw = env("INTERNAL_IP4_ADDRESS");
echo("VPN Gateway: " + env("VPNGATEWAY"));
echo("Internal Address: " + env("INTERNAL_IP4_ADDRESS"));