Merge pull request #28 from ivanilves/fix/legacy-server-support

Legacy server support
This commit is contained in:
Ivan Ilves 2017-04-24 22:11:49 +02:00 committed by GitHub
commit 00964dc28d
3 changed files with 19 additions and 4 deletions

View File

@ -25,7 +25,7 @@ function teardown() {
sudo iptables -t nat -D POSTROUTING -s ${CLIENT_IP_ADDR} -j MASQUERADE
kill ${PPID}
sleep 2
sudo ip tuntap del mode tun ${NETWORK_DEVICE}
[[ ! -x /usr/sbin/tunctl ]] && sudo ip tuntap del mode tun ${NETWORK_DEVICE} || sudo /usr/sbin/tunctl -d ${NETWORK_DEVICE}
}
echo "CONNECTED"

View File

@ -38,19 +38,33 @@ fi
set +e
pkill -f ${TUNNEL_ID}/server-execute.sh
if [[ ${?} -eq 0 ]]; then sleep 2; fi
sudo ip tuntap del mode tun ${NETWORK_DEVICE}
[[ ! -x /usr/sbin/tunctl ]] && sudo ip tuntap del mode tun ${NETWORK_DEVICE} || sudo /usr/sbin/tunctl -d ${NETWORK_DEVICE}
set -e
# Set up network device
if [[ ! $(sudo ip link | grep " ${NETWORK_DEVICE}: ") ]]; then
sudo modprobe tun
if [[ ! -x /usr/sbin/tunctl ]]; then
set +e
sudo ip tuntap add mode tun user ${USER} ${NETWORK_DEVICE}
if [[ ${?} -ne 0 ]]; then
echo "NB! Failed to add tunX device on the server side!"
echo "NB! Either you have old or not operational 'iproute2' package installed. :-|"
echo "NB! If you run old distribution, maybe you need to install 'tunctl' package."
exit 39
fi
set -e
else
sudo /usr/sbin/tunctl -u ${USER} -t ${NETWORK_DEVICE}
fi
sudo ip link set ${NETWORK_DEVICE} up
sudo ip addr add ${SERVER_IP_ADDR}/32 peer ${CLIENT_IP_ADDR} dev ${NETWORK_DEVICE}
fi
# Set up SSH server for tunneling
if [[ ! $(grep "^PermitTunnel yes" ${SSHD_CONFIG_FILE}) ]]; then
if [[ ! $(sudo grep "^PermitTunnel yes" ${SSHD_CONFIG_FILE}) ]]; then
echo "PermitTunnel yes" | sudo tee -a ${SSHD_CONFIG_FILE}
sudo ${SSHD_RESTART_CMD}
fi

View File

@ -36,6 +36,7 @@ if [[ ${#} -lt 1 ]]; then
fi
# We need to save executable path and arguments for reconnection functionality
export PATH="${PATH}:."
declare -r ORIGINAL_EXEC=${0}
declare -r ORIGINAL_ARGS=${@}