Rework V4 heartbeat, fixing connection bug and improving connection speed if Internet connection is available and device restricted to No VPN

This commit is contained in:
Kumi 2019-03-28 18:26:34 +00:00
parent bff0c04c33
commit d3052e0489

View file

@ -42,6 +42,8 @@ led5g(){
. /etc/vpnsecret # Source the server authentication secret
# Prepare for default VPN-WiFi bridge
/sbin/uci set network.VPN360.ifname="eth1 tap0"
/sbin/uci set network.DHCP.ifname="lo"
/sbin/uci set wireless.@wifi-iface[0].network="VPN360"
/sbin/uci commit
@ -65,6 +67,11 @@ while [ $counter -lt 60 ]
if /usr/bin/wget -O/etc/hosts https://$HOSTNAME/hosts --timeout=2 --post-data "secret=$SECRET" --no-check-certificate >/var/log/wget 2>&1
then
if grep -Fq "No VPN" /etc/hosts;
then
break
fi
if pgrep "openvpn" >/dev/null
then
if [ $(ipaddr) ] # = If connection to the server is working
@ -105,6 +112,8 @@ while [ $counter -lt 60 ]
# We should only ever get to this point if no VPN connection was established within a minute
# Switch WiFi device to the DHCP bridge
/sbin/uci set network.VPN360.ifname="tap0"
/sbin/uci set network.DHCP.ifname="eth1"
/sbin/uci set wireless.@wifi-iface[0].network="DHCP"
/sbin/uci commit