Update for vpnc-script.js
Following fixies and new features in update:
- fixed routing when host ip address is first from subnet;
- added routes for DNS a WINS server;
- added VPN domain to DNS suffix search list;
- added connection-specific DNS suffix for vPN tunnel interface;
- added complete clean-up after disconnect;
@afl1 could you add this as a pull request?
OK
Hi @afl1 pls. create a commit with your file (attached here) and create a pull request agains right branch (devel -> devel OR master -> master), depending where u start comimting your changes, thanks in advance.
Just a suggestion: you might want to capture STDERR in addition to STDOUT in the 'exec' subroutine. ws.Run("cmd.exe /c " +cmd+" 2>&1 > " + tmpdir + "vpnc.out", 0, true);
Also, the last line
WScript.Quit(0);
seems to indicate you want to notify "open-connect" that the script always worked. Wouldn't it be better to send back a non-zero RC when any of the "exec"s fail to tell us we coded something wrong?
yaep, the script itself an communication with may be improved, I agree....
Time for more testing. Oh incidentally, the 2>&1 seems to fix (bug #59) the missing command output in the GUI log (except for Disconnect; not sure why only that is missing).
I found a problem with these lines. They cause the APPs that go thru the tunnel (by default) not to connect. If I comment them out, default APPs connect as before.
//// echo("VPN host: " + ((address_array[3] & netmask_array[0])+ 0)); // if (internal_gw_array[3] == address_array[3]){ // internal_gw_array[3] = (address_array[3] & netmask_array[3] ) + 2 // }
var internal_gw = internal_gw_array.join(".");
// if (searchList.search(env("CISCO_DEF_DOMAIN")) != 0) {
// searchList = env("CISCO_DEF_DOMAIN") + "," + searchList;
// WshShell.RegWrite ("HKLM\System\CurrentControlSet\Services\TCPIP\Parameters\SearchList",
// searchList, "REG_SZ");
// exec("ipconfig /registerdns");
// }
// if (tunReg != "") {
// WshShell.RegWrite ("HKLM\System\CurrentControlSet\Services\TCPIP\Parameters\Interfaces" + tunReg + "\Domain",
// env("CISCO_DEF_DOMAIN"), "REG_SZ");
// }