openconnect: fix a couple of minor things and add an interface option
Signed-off-by: Daniel Gimpelevich <daniel@gimpelevich.san-francisco.ca.us>
This commit is contained in:
parent
a904a173ed
commit
41f8d54650
3 changed files with 10 additions and 5 deletions
|
@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk
|
||||||
|
|
||||||
PKG_NAME:=openconnect
|
PKG_NAME:=openconnect
|
||||||
PKG_VERSION:=7.04
|
PKG_VERSION:=7.04
|
||||||
PKG_RELEASE:=1
|
PKG_RELEASE:=2
|
||||||
|
|
||||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
|
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
|
||||||
PKG_SOURCE_URL:=ftp://ftp.infradead.org/pub/openconnect/
|
PKG_SOURCE_URL:=ftp://ftp.infradead.org/pub/openconnect/
|
||||||
|
|
|
@ -4,6 +4,7 @@ To setup a VPN connection, add the following to /etc/config/network:
|
||||||
|
|
||||||
config interface 'MYVPN'
|
config interface 'MYVPN'
|
||||||
option proto 'openconnect'
|
option proto 'openconnect'
|
||||||
|
option interface 'wan'
|
||||||
option server 'vpn.example.com'
|
option server 'vpn.example.com'
|
||||||
option port '4443'
|
option port '4443'
|
||||||
option username 'test'
|
option username 'test'
|
||||||
|
|
|
@ -10,6 +10,9 @@ proto_openconnect_init_config() {
|
||||||
proto_config_add_string "serverhash"
|
proto_config_add_string "serverhash"
|
||||||
proto_config_add_string "authgroup"
|
proto_config_add_string "authgroup"
|
||||||
proto_config_add_string "password"
|
proto_config_add_string "password"
|
||||||
|
proto_config_add_string "token_mode"
|
||||||
|
proto_config_add_string "token_secret"
|
||||||
|
proto_config_add_string "interface"
|
||||||
no_device=1
|
no_device=1
|
||||||
available=1
|
available=1
|
||||||
}
|
}
|
||||||
|
@ -17,14 +20,14 @@ proto_openconnect_init_config() {
|
||||||
proto_openconnect_setup() {
|
proto_openconnect_setup() {
|
||||||
local config="$1"
|
local config="$1"
|
||||||
|
|
||||||
json_get_vars server port username serverhash authgroup password vgroup token_mode token_secret
|
json_get_vars server port username serverhash authgroup password interface token_mode token_secret
|
||||||
|
|
||||||
grep -q tun /proc/modules || insmod tun
|
grep -q tun /proc/modules || insmod tun
|
||||||
|
|
||||||
logger -t openconnect "initializing..."
|
logger -t openconnect "initializing..."
|
||||||
serv_addr=
|
serv_addr=
|
||||||
for ip in $(resolveip -t 10 "$server"); do
|
for ip in $(resolveip -t 10 "$server"); do
|
||||||
( proto_add_host_dependency "$config" "$ip" )
|
( proto_add_host_dependency "$config" "$ip" $interface )
|
||||||
serv_addr=1
|
serv_addr=1
|
||||||
done
|
done
|
||||||
[ -n "$serv_addr" ] || {
|
[ -n "$serv_addr" ] || {
|
||||||
|
@ -57,7 +60,8 @@ proto_openconnect_setup() {
|
||||||
[ -n "$username" ] && append cmdline "-u $username"
|
[ -n "$username" ] && append cmdline "-u $username"
|
||||||
[ -n "$password" ] && {
|
[ -n "$password" ] && {
|
||||||
umask 077
|
umask 077
|
||||||
pwfile="/var/run/openconnect-$config.passwd"
|
mkdir -p /var/etc
|
||||||
|
pwfile="/var/etc/openconnect-$config.passwd"
|
||||||
echo "$password" > "$pwfile"
|
echo "$password" > "$pwfile"
|
||||||
append cmdline "--passwd-on-stdin"
|
append cmdline "--passwd-on-stdin"
|
||||||
}
|
}
|
||||||
|
@ -78,7 +82,7 @@ proto_openconnect_setup() {
|
||||||
proto_openconnect_teardown() {
|
proto_openconnect_teardown() {
|
||||||
local config="$1"
|
local config="$1"
|
||||||
|
|
||||||
pwfile="/var/run/openconnect-$config.passwd"
|
pwfile="/var/etc/openconnect-$config.passwd"
|
||||||
|
|
||||||
rm -f $pwfile
|
rm -f $pwfile
|
||||||
logger -t openconnect "bringing down openconnect"
|
logger -t openconnect "bringing down openconnect"
|
||||||
|
|
Loading…
Reference in a new issue