Skip to content

Feature request: Provide a way to configure CISCO_SPLIT_INC

After digging through the source code of vpnc-script.js, it should be possible for us to alter the behavior by using environment variables CISCO_SPLIT_INC_XXX.

At first, I just wrap the executable with a .bat such that it works on window environment.

@echo off

:: BatchGotAdmin
:-------------------------------------
REM  --> Check for permissions
    IF "%PROCESSOR_ARCHITECTURE%" EQU "amd64" (
>nul 2>&1 "%SYSTEMROOT%\SysWOW64\cacls.exe" "%SYSTEMROOT%\SysWOW64\config\system"
) ELSE (
>nul 2>&1 "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system"
)

REM --> If error flag set, we do not have admin.
if '%errorlevel%' NEQ '0' (
    echo Requesting administrative privileges...
    goto UACPrompt
) else ( goto gotAdmin )

:UACPrompt
    echo Set UAC = CreateObject^("Shell.Application"^) > "%temp%\getadmin.vbs"
    set params= %*
    echo UAC.ShellExecute "cmd.exe", "/c ""%~s0"" %params:"=""%", "", "runas", 1 >> "%temp%\getadmin.vbs"

    "%temp%\getadmin.vbs"
    del "%temp%\getadmin.vbs"
    exit /B

:gotAdmin
    pushd "%CD%"
    CD /D "%~dp0"
:--------------------------------------   

set CISCO_SPLIT_INC=4
set CISCO_SPLIT_INC_0_ADDR=192.168.36.0
set CISCO_SPLIT_INC_0_MASK=255.255.255.0
set CISCO_SPLIT_INC_0_MASKLEN=24
set CISCO_SPLIT_INC_1_ADDR=10.230.0.0
set CISCO_SPLIT_INC_1_MASK=255.255.0.0
set CISCO_SPLIT_INC_1_MASKLEN=16
set CISCO_SPLIT_INC_2_ADDR=10.1.0.0
set CISCO_SPLIT_INC_2_MASK=255.255.0.0
set CISCO_SPLIT_INC_2_MASKLEN=16
set CISCO_SPLIT_INC_3_ADDR=10.240.0.0
set CISCO_SPLIT_INC_3_MASK=255.255.0.0
set CISCO_SPLIT_INC_3_MASKLEN=16
set OPENCONNECT_DIR=C:\Program Files (x86)\OpenConnect-GUI

"%OPENCONNECT_DIR%\openconnect-gui.exe"

But, the variables are being overwaited by script.c in openconnect.

https://github.com/openconnect/openconnect/blob/master/script.c#L254

It seems gpst.c:gpst_parse_config_xml provide a way to configure via xml. However, there are no ways for gui to run with any xml. Moreover, I cannot see an example for xml.

At last, I have no choices but changing the environments in vpnc-script.js to achieve my goal.

Still, I am wondering how to do this properly

Edited by Mond WAN