import package uanytun

Signed-off-by: Christian Pointner <equinox@spreadspace.org>
This commit is contained in:
Christian Pointner
2014-06-14 23:41:49 +02:00
parent 87d5136edf
commit 4e682f03ef
4 changed files with 515 additions and 0 deletions
+88
View File
@@ -0,0 +1,88 @@
config "client1"
option disabled 0
option username 'nobody'
option groupname 'nogroup'
# option chroot "/var/run/uanytun"
# option interface '<ip-address>'
# option port '4444'
# option sender_id '1'
# option dev 'anytun0'
option type 'tun'
option ifconfig '192.168.123.1/24'
# option post-up-script '/etc/uanytun/client1-post-up.sh'
option remote_host 'example.com'
option remote_port '4444'
option window_size 0
option mux 1
option log 'syslog:3,anytun-client1,daemon'
config "client2"
option disabled 1
option username 'nobody'
option groupname 'nogroup'
option type 'tun'
option ifconfig '192.168.123.2/24'
option remote_host 'example.com'
option remote_port '4444'
option window_size 0
option mux 2
option log 'syslog:3,anytun-client2,daemon'
config "client3"
option disabled 1
option username 'nobody'
option groupname 'nogroup'
option type 'tun'
option ifconfig '192.168.123.3/24'
option remote_host 'example.com'
option remote_port '4444'
option window_size 0
option mux 3
option log 'syslog:3,anytun-client3,daemon'
config "p2p-a"
option disabled 1
option username 'nobody'
option groupname 'nogroup'
option type 'tun'
option ifconfig '192.168.223.1/24'
option remote_host 'p2p-b.example.com'
option remote_port '4444'
option window_size 0
option log 'syslog:3,anytun-p2p-a,daemon'
config "p2p-b"
option disabled 1
option username 'nobody'
option groupname 'nogroup'
option type 'tun'
option ifconfig '192.168.223.2/24'
option remote_host 'p2p-a.example.com'
option remote_port '4444'
option window_size 0
option log 'syslog:3,anytun-p2p-b,daemon'
+116
View File
@@ -0,0 +1,116 @@
config "client1"
option disabled 0
# option username 'nobody'
# option groupname 'nogroup'
# option chroot "/var/run/uanytun"
# option interface '<ip-address>'
# option port '4444'
# option sender_id '1'
option cipher 'aes-ctr'
# option cipher 'null'
# option cipher 'aes-ctr-128'
# option cipher 'aes-ctr-192'
# option cipher 'aes-ctr-256'
option auth_algo 'sha1'
# option auth_algo 'null'
# option auth_tag_length 10
# option dev 'anytun0'
option type 'tun'
option ifconfig '192.168.123.1/24'
# option post-up-script '/etc/uanytun/client1-post-up.sh'
option remote_host 'example.com'
option remote_port '4444'
option window_size 0
option mux 1
option role 'client'
# option kd_prf 'null'
# option kd_prf 'aes-ctr'
# option kd_prf 'aes-ctr-128'
# option kd_prf 'aes-ctr-192'
# option kd_prf 'aes-ctr-256'
# option ld_kdr '0'
# option key '0123456789ABCDEF0123456789ABCDEF'
# option salt '0123456789ABCD0123456789ABCD'
option passphrase 'Creating_VPN_Tunnels_With_Anytun_Is_Easy'
option log 'syslog:3,anytun-client1,daemon'
config "client2"
option disabled 1
option cipher 'aes-ctr'
option auth_algo 'sha1'
option type 'tun'
option ifconfig '192.168.123.2/24'
option remote_host 'example.com'
option remote_port '4444'
option window_size 0
option mux 2
option role 'client'
option passphrase 'Creating_VPN_Tunnels_With_Anytun_Is_Easy'
option log 'syslog:3,anytun-client2,daemon'
config "client3"
option disabled 1
option cipher 'aes-ctr'
option auth_algo 'sha1'
option type 'tun'
option ifconfig '192.168.123.3/24'
option remote_host 'example.com'
option remote_port '4444'
option window_size 0
option mux 3
option role 'client'
option passphrase 'Creating_VPN_Tunnels_With_Anytun_Is_Easy'
option log 'syslog:3,anytun-client3,daemon'
config "p2p-a"
option disabled 1
option cipher 'aes-ctr'
option auth_algo 'sha1'
option type 'tun'
option ifconfig '192.168.223.1/24'
option remote_host 'p2p-b.example.com'
option remote_port '4444'
option window_size 0
option role 'alice'
option passphrase 'Creating_P2P_VPN_Tunnels_With_Anytun_Is_Easy'
option log 'syslog:3,anytun-p2p-a,daemon'
config "p2p-b"
option disabled 1
option cipher 'aes-ctr'
option auth_algo 'sha1'
option type 'tun'
option ifconfig '192.168.223.2/24'
option remote_host 'p2p-a.example.com'
option remote_port '4444'
option window_size 0
option role 'bob'
option passphrase 'Creating_P2P_VPN_Tunnels_With_Anytun_Is_Easy'
option log 'syslog:3,anytun-p2p-b,daemon'
+104
View File
@@ -0,0 +1,104 @@
#!/bin/sh /etc/rc.common
START=50
BIN=uanytun
DAEMON=/usr/sbin/$BIN
DESC=$BIN
RUN_D=/var/run
option_cb() {
local varname="$1"
local value="$2"
if ! echo "$CONFIG_OPTIONS" | grep " $varname " > /dev/null; then
CONFIG_OPTIONS="$CONFIG_OPTIONS $varname "
fi
}
foreach_config_forced() {
foreach_config $1 "forced"
}
foreach_config() {
local cfg="$1"
local name
local option
local value
local args=""
local forced=0
if [ -n "$2" ] && [ "x$2" == "xforced" ]; then
forced=1
fi
config_get name "$cfg" TYPE
for option in $CONFIG_OPTIONS
do
config_get value "$cfg" "$option"
if [ "x$option" == "xdisabled" ]; then
if [ $forced -eq 0 ] && [ $value -eq 1 ]; then
echo -n " $name(disabled)"
return
fi
continue
fi
option=`echo $option | tr '_' '-'`
if [ -n "$value" ]; then
args="$args --$option $value"
fi
done
echo -n " $name"
local status="OK"
$DAEMON --write-pid "$RUN_D/$BIN.$name.pid" $args || status="failed"
echo -n "($status)"
}
stop_vpn() {
local name=$1
local pidfile=$RUN_D/$BIN.$name.pid
echo -n " $name"
local status="OK"
if [ ! -f "$pidfile" ]; then
status="tunnel not active"
else
kill `cat $pidfile` > /dev/null 2>&1 || status="failed"
rm -f $pidfile
fi
echo -n "($status)"
}
start() {
echo -n "Starting $DESC:"
config_load $BIN
if [ $# -gt 0 ]; then
while [ $# -gt 0 ]; do
config_foreach foreach_config_forced "$1"
shift
done
else
config_foreach foreach_config ""
fi
echo "."
}
stop() {
echo -n "Stopping $DESC:"
local name
local pidfile
if [ $# -gt 0 ]; then
while [ $# -gt 0 ]; do
stop_vpn $1
shift
done
else
for pidfile in `ls $RUN_D/$BIN.*.pid 2> /dev/null`; do
name=${pidfile%%.pid}
name=${name##$RUN_D/$BIN.}
stop_vpn $name
done
fi
echo "."
}