Browse Source

travelmate: update 2.0.8-2

* make vpn handling more reliable

Signed-off-by: Dirk Brenken <dev@brenken.org>
(cherry picked from commit 06784b4e32)
lilik-openwrt-22.03
Dirk Brenken 2 years ago
parent
commit
4c4ac1b583
No known key found for this signature in database GPG Key ID: 9D71CD547BFAE684
3 changed files with 9 additions and 12 deletions
  1. +1
    -1
      net/travelmate/Makefile
  2. +2
    -3
      net/travelmate/files/travelmate.sh
  3. +6
    -8
      net/travelmate/files/travelmate.vpn

+ 1
- 1
net/travelmate/Makefile View File

@ -7,7 +7,7 @@ include $(TOPDIR)/rules.mk
PKG_NAME:=travelmate PKG_NAME:=travelmate
PKG_VERSION:=2.0.8 PKG_VERSION:=2.0.8
PKG_RELEASE:=1
PKG_RELEASE:=2
PKG_LICENSE:=GPL-3.0-or-later PKG_LICENSE:=GPL-3.0-or-later
PKG_MAINTAINER:=Dirk Brenken <dev@brenken.org> PKG_MAINTAINER:=Dirk Brenken <dev@brenken.org>


+ 2
- 3
net/travelmate/files/travelmate.sh View File

@ -185,9 +185,8 @@ f_vpn() {
vpn="$(f_getval "vpn")" vpn="$(f_getval "vpn")"
vpn_service="$(f_getval "vpnservice")" vpn_service="$(f_getval "vpnservice")"
vpn_iface="$(f_getval "vpniface")" vpn_iface="$(f_getval "vpniface")"
[ -z "${vpn_action}" ] && { [ "${vpn}" = "1" ] && vpn_action="enable" || vpn_action="disable"; }
if [ -x "${trm_vpnpgm}" ] && [ -n "${vpn_service}" ] && [ -n "${vpn_iface}" ] && [ -f "${trm_ntpfile}" ]; then
if [ -x "${trm_vpnpgm}" ] && [ -n "${vpn}" ] && [ -n "${vpn_service}" ] && [ -n "${vpn_iface}" ] && [ -f "${trm_ntpfile}" ]; then
if { [ "${vpn_action}" = "disable" ] && [ -f "${trm_vpnfile}" ]; } || if { [ "${vpn_action}" = "disable" ] && [ -f "${trm_vpnfile}" ]; } ||
{ [ "${vpn}" = "1" ] && [ "${vpn_action}" = "enable" ] && [ ! -f "${trm_vpnfile}" ]; } || { [ "${vpn}" = "1" ] && [ "${vpn_action}" = "enable" ] && [ ! -f "${trm_vpnfile}" ]; } ||
{ [ "${vpn}" != "1" ] && [ "${vpn_action}" = "enable" ] && [ -f "${trm_vpnfile}" ]; }; then { [ "${vpn}" != "1" ] && [ "${vpn_action}" = "enable" ] && [ -f "${trm_vpnfile}" ]; }; then
@ -792,7 +791,7 @@ f_main() {
[ "${sta_essid}" = "${config_essid}" ] && [ "${sta_bssid}" = "${config_bssid}" ]; then [ "${sta_essid}" = "${config_essid}" ] && [ "${sta_bssid}" = "${config_bssid}" ]; then
f_ctrack "refresh" f_ctrack "refresh"
f_log "info" "uplink still in range '${config_radio}/${config_essid}/${config_bssid:-"-"}' with mac '${sta_mac:-"-"}'" f_log "info" "uplink still in range '${config_radio}/${config_essid}/${config_bssid:-"-"}' with mac '${sta_mac:-"-"}'"
f_vpn
f_vpn "enable"
return 0 return 0
fi fi
f_log "debug" "f_main-4 ::: sta_radio: ${sta_radio}, sta_essid: \"${sta_essid}\", sta_bssid: ${sta_bssid:-"-"}" f_log "debug" "f_main-4 ::: sta_radio: ${sta_radio}, sta_essid: \"${sta_essid}\", sta_bssid: ${sta_bssid:-"-"}"


+ 6
- 8
net/travelmate/files/travelmate.vpn View File

@ -1,6 +1,6 @@
#!/bin/sh #!/bin/sh
# vpn handler called by travelmate # vpn handler called by travelmate
# Copyright (c) 2020-2021 Dirk Brenken (dev@brenken.org)
# Copyright (c) 2020-2022 Dirk Brenken (dev@brenken.org)
# This is free software, licensed under the GNU General Public License v3. # This is free software, licensed under the GNU General Public License v3.
# set (s)hellcheck exceptions # set (s)hellcheck exceptions
@ -37,20 +37,18 @@ f_net() {
vpn_status="$(ubus -S call network.interface."${vpn_iface}" status 2>/dev/null | jsonfilter -q -l1 -e '@.up')" vpn_status="$(ubus -S call network.interface."${vpn_iface}" status 2>/dev/null | jsonfilter -q -l1 -e '@.up')"
case "${vpn_service}" in case "${vpn_service}" in
"wireguard") "wireguard")
if [ "${vpn_action}" = "enable" ] && [ "${vpn_status:-"false"}" != "true" ]; then
if [ "${vpn}" = "1" ] && [ "${vpn_action}" = "enable" ] && [ "${vpn_status:-"false"}" != "true" ]; then
ubus call network.interface."${vpn_iface}" up ubus call network.interface."${vpn_iface}" up
fi
if { [ "${vpn}" = "0" ] && [ "${vpn_action}" = "enable" ]; } || { [ "${vpn_action}" = "disable" ] && [ "${vpn_status}" = "true" ]; }; then
elif { [ "${vpn}" = "0" ] && [ "${vpn_action}" = "enable" ]; } || [ "${vpn_action}" = "disable" ]; then
ubus call network.interface."${vpn_iface}" down ubus call network.interface."${vpn_iface}" down
"${trm_logger}" -p "info" -t "trm-vpn [${$}]" "${vpn_service} client connection disabled" 2>/dev/null "${trm_logger}" -p "info" -t "trm-vpn [${$}]" "${vpn_service} client connection disabled" 2>/dev/null
fi fi
;; ;;
"openvpn") "openvpn")
if [ "${vpn_action}" = "enable" ] && [ "${vpn_status:-"false"}" != "true" ]; then
if [ "${vpn}" = "1" ] && [ "${vpn_action}" = "enable" ] && [ "${vpn_status:-"false"}" != "true" ]; then
ubus call network.interface."${vpn_iface}" up ubus call network.interface."${vpn_iface}" up
/etc/init.d/openvpn restart >/dev/null 2>&1 /etc/init.d/openvpn restart >/dev/null 2>&1
fi
if { [ "${vpn}" = "0" ] && [ "${vpn_action}" = "enable" ]; } || { [ "${vpn_action}" = "disable" ] && [ "${vpn_status}" = "true" ]; }; then
elif { [ "${vpn}" = "0" ] && [ "${vpn_action}" = "enable" ]; } || [ "${vpn_action}" = "disable" ]; then
ubus call network.interface."${vpn_iface}" down ubus call network.interface."${vpn_iface}" down
/etc/init.d/openvpn stop >/dev/null 2>&1 /etc/init.d/openvpn stop >/dev/null 2>&1
"${trm_logger}" -p "info" -t "trm-vpn [${$}]" "${vpn_service} client connection disabled" 2>/dev/null "${trm_logger}" -p "info" -t "trm-vpn [${$}]" "${vpn_service} client connection disabled" 2>/dev/null
@ -78,7 +76,7 @@ if [ "${vpn}" = "1" ] && [ "${vpn_action}" = "enable" ] && [ "${vpn_status:-"fal
cnt="$((cnt + 1))" cnt="$((cnt + 1))"
done done
fi fi
if [ "${vpn_action}" = "enable" ] && [ "${vpn_status}" = "true" ]; then
if [ "${vpn}" = "1" ] && [ "${vpn_action}" = "enable" ] && [ "${vpn_status}" = "true" ]; then
if [ -f "/etc/init.d/sysntpd" ]; then if [ -f "/etc/init.d/sysntpd" ]; then
/etc/init.d/sysntpd restart >/dev/null 2>&1 /etc/init.d/sysntpd restart >/dev/null 2>&1
fi fi


Loading…
Cancel
Save