Browse Source

Merge pull request #13506 from dibdot/trm-2.0.1

travelmate: update to 2.0.1
lilik-openwrt-22.03
Dirk Brenken 4 years ago
committed by GitHub
parent
commit
7c3554df34
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 91 additions and 76 deletions
  1. +1
    -1
      net/travelmate/Makefile
  2. +8
    -3
      net/travelmate/files/README.md
  3. +4
    -4
      net/travelmate/files/db-bahn.login
  4. +8
    -14
      net/travelmate/files/travelmate.mail
  5. +46
    -35
      net/travelmate/files/travelmate.sh
  6. +23
    -18
      net/travelmate/files/travelmate.vpn
  7. +1
    -1
      net/travelmate/files/wifionice.login

+ 1
- 1
net/travelmate/Makefile View File

@ -6,7 +6,7 @@
include $(TOPDIR)/rules.mk include $(TOPDIR)/rules.mk
PKG_NAME:=travelmate PKG_NAME:=travelmate
PKG_VERSION:=2.0.0
PKG_VERSION:=2.0.1
PKG_RELEASE:=1 PKG_RELEASE:=1
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>


+ 8
- 3
net/travelmate/files/README.md View File

@ -1,3 +1,5 @@
<!-- markdownlint-disable -->
# travelmate, a wlan connection manager for travel router # travelmate, a wlan connection manager for travel router
## Description ## Description
@ -40,7 +42,10 @@ To avoid these kind of deadlocks, travelmate will set all station interfaces to
* optional: 'msmtp' to send out travelmate related status messages via email * optional: 'msmtp' to send out travelmate related status messages via email
## Installation & Usage ## Installation & Usage
* before you start with travelmate you should setup at least one Access Point, ideally on a separate radio
* **Please note:** before you start with travelmate ...
* you should setup at least one Access Point, ideally on a separate radio,
* if you're updating from a former 1.x release, please use the '--force-reinstall --force-maintainer' options in opkg,
* and remove any existing travelmate related uplink stations in your wireless config manually
* download [travelmate](https://downloads.openwrt.org/snapshots/packages/x86_64/packages) * download [travelmate](https://downloads.openwrt.org/snapshots/packages/x86_64/packages)
* download [luci-app-travelmate](https://downloads.openwrt.org/snapshots/packages/x86_64/luci) * download [luci-app-travelmate](https://downloads.openwrt.org/snapshots/packages/x86_64/luci)
* install both packages (_opkg install travelmate_, _opkg install luci-app-travelmate_) * install both packages (_opkg install travelmate_, _opkg install luci-app-travelmate_)
@ -86,7 +91,7 @@ To avoid these kind of deadlocks, travelmate will set all station interfaces to
| Option | Default | Description/Valid Values | | Option | Default | Description/Valid Values |
| :----------------- | :--------------------------------- | :---------------------------------------------------------------------------------------------------- | | :----------------- | :--------------------------------- | :---------------------------------------------------------------------------------------------------- |
| enabled | 1, enabled | enable or disable the uplink in travelmate |
| enabled | 1, enabled | enable or disable the uplink, automatically set if the retry limit or the conn. expiry was reached |
| device | -, not set | match the 'device' in the wireless config section | | device | -, not set | match the 'device' in the wireless config section |
| ssid | -, not set | match the 'ssid' in the wireless config section | | ssid | -, not set | match the 'ssid' in the wireless config section |
| bssid | -, not set | match the 'bssid' in the wireless config section | | bssid | -, not set | match the 'bssid' in the wireless config section |
@ -166,7 +171,7 @@ root@2go_ar750s:~# /etc/init.d/travelmate status
+ system : GL.iNet GL-AR750S (NOR/NAND), OpenWrt SNAPSHOT r14430-2dda301d40 + system : GL.iNet GL-AR750S (NOR/NAND), OpenWrt SNAPSHOT r14430-2dda301d40
</code></pre> </code></pre>
To debug travelmate runtime problems, please always enable the 'trm\_debug' flag, restart travelmate and scan the system log (_logread -e "trm-"_)
To debug travelmate runtime problems, please always enable the 'trm\_debug' flag, restart travelmate and check the system log afterwards (_logread -e "trm-"_)
## Support ## Support
Please join the travelmate discussion in this [forum thread](https://forum.lede-project.org/t/travelmate-support-thread/5155) or contact me by [mail](mailto:dev@brenken.org) Please join the travelmate discussion in this [forum thread](https://forum.lede-project.org/t/travelmate-support-thread/5155) or contact me by [mail](mailto:dev@brenken.org)


+ 4
- 4
net/travelmate/files/db-bahn.login View File

@ -3,14 +3,14 @@
# Copyright (c) 2020 Dirk Brenken (dev@brenken.org) # Copyright (c) 2020 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.
trm_fetch="$(command -v curl)"
trm_domain="wifi.bahn.de" trm_domain="wifi.bahn.de"
trm_useragent="$(uci_get travelmate global trm_useragent "Mozilla/5.0 (Linux x86_64; rv:80.0) Gecko/20100101 Firefox/80.0")" trm_useragent="$(uci_get travelmate global trm_useragent "Mozilla/5.0 (Linux x86_64; rv:80.0) Gecko/20100101 Firefox/80.0")"
trm_maxwait="$(uci_get travelmate global trm_maxwait "30")" trm_maxwait="$(uci_get travelmate global trm_maxwait "30")"
trm_fetch="$(command -v curl)"
# initial get request to receive all header information # initial get request to receive all header information
# #
"${trm_fetch}" -A "${trm_useragent}" "https://${trm_domain}" -si > "/tmp/${trm_domain}.cookie"
"${trm_fetch}" --user-agent "${trm_useragent}" --referer "http://www.example.com" --silent --connect-timeout $((trm_maxwait/6)) --include --cookie-jar "/tmp/${trm_domain}.cookie" --output /dev/null "http://${trm_domain}"
# extract the session cookie and the hotspot location # extract the session cookie and the hotspot location
# #
@ -27,7 +27,7 @@ fi
# #
if [ -n "${php_token}" ] && [ -n "${location}" ] if [ -n "${php_token}" ] && [ -n "${location}" ]
then then
"${trm_fetch}" -A "${trm_useragent}" "https://${trm_domain}/portal_api.php" -H "Connection: keep-alive" -H "Referer: ${location}" -H "Cookie: ${php_token}" --data "action=subscribe&type=one&connect_policy_accept=false&user_login=&user_password=&user_password_confirm=&email_address=&prefix=&phone=&policy_accept=false&gender=&interests=" -si > "/tmp/${trm_domain}.cookie"
"${trm_fetch}" --user-agent "${trm_useragent}" --referer "${location}" --silent --connect-timeout $((trm_maxwait/6)) --include --cookie-jar "/tmp/${trm_domain}.cookie" --header "Cookie: ${php_token}" --data "action=subscribe&type=one&connect_policy_accept=false&user_login=&user_password=&user_password_confirm=&email_address=&prefix=&phone=&policy_accept=false&gender=&interests=" --output /dev/null "https://${trm_domain}/portal_api.php"
else else
exit 3 exit 3
fi fi
@ -47,7 +47,7 @@ fi
# #
if [ -n "${login}" ] && [ -n "${password}" ] if [ -n "${login}" ] && [ -n "${password}" ]
then then
"${trm_fetch}" -A "${trm_useragent}" "https://${trm_domain}/portal_api.php" -H "Connection: keep-alive" -H "Referer: ${location}" -H "Cookie: ${php_token}" --data "action=authenticate&login=${login}&password=${password}&policy_accept=false&from_ajax=true&wispr_mode=false"
"${trm_fetch}" --user-agent "${trm_useragent}" --referer "${location}" --silent --connect-timeout $((trm_maxwait/6)) --header "Cookie: ${php_token}" --data "action=authenticate&login=${login}&password=${password}&policy_accept=false&from_ajax=true&wispr_mode=false" "https://${trm_domain}/portal_api.php"
else else
exit 5 exit 5
fi fi

+ 8
- 14
net/travelmate/files/travelmate.mail View File

@ -13,13 +13,12 @@ PATH="/usr/sbin:/usr/bin:/sbin:/bin"
. "/lib/functions.sh" . "/lib/functions.sh"
trm_debug="$(uci_get travelmate global trm_debug "0")" trm_debug="$(uci_get travelmate global trm_debug "0")"
trm_mailsender="$(uci_get travelmate global trm_mailsender "no-reply@travelmate")"
trm_mailreceiver="$(uci_get travelmate global trm_mailreceiver)" trm_mailreceiver="$(uci_get travelmate global trm_mailreceiver)"
trm_mailprofile="$(uci_get travelmate global trm_mailprofile "trm_notify")" trm_mailprofile="$(uci_get travelmate global trm_mailprofile "trm_notify")"
trm_mail="$(command -v msmtp)"
trm_mailsender="$(uci_get travelmate global trm_mailsender "no-reply@travelmate")"
trm_rtfile="$(uci_get travelmate global trm_rtfile "/tmp/trm_runtime.json")" trm_rtfile="$(uci_get travelmate global trm_rtfile "/tmp/trm_runtime.json")"
trm_mailpgm="$(command -v msmtp)"
trm_logger="$(command -v logger)" trm_logger="$(command -v logger)"
trm_rc=1
f_log() f_log()
{ {
@ -36,10 +35,10 @@ f_log()
if [ -z "${trm_mailreceiver}" ] if [ -z "${trm_mailreceiver}" ]
then then
f_log "err" "please set the mail receiver with the 'trm_mailreceiver' option" f_log "err" "please set the mail receiver with the 'trm_mailreceiver' option"
exit ${trm_rc}
exit 1
fi fi
if [ "${trm_debug}" -eq 1 ]
if [ "${trm_debug}" -eq "1" ]
then then
debug="--debug" debug="--debug"
fi fi
@ -61,12 +60,7 @@ trm_mailtext="${trm_mailtext}</pre></body></html>"
# send mail # send mail
# #
if [ -x "${trm_mail}" ]
then
printf "%b" "${trm_mailhead}${trm_mailtext}" 2>/dev/null | "${trm_mail}" ${debug} -a "${trm_mailprofile}" "${trm_mailreceiver}" >/dev/null 2>&1
trm_rc=${?}
f_log "info" "mail sent to '${trm_mailreceiver}' with rc '${trm_rc}'"
else
f_log "err" "msmtp mail daemon not found"
fi
exit ${trm_rc}
printf "%b" "${trm_mailhead}${trm_mailtext}" 2>/dev/null | "${trm_mailpgm}" ${debug} -a "${trm_mailprofile}" "${trm_mailreceiver}" >/dev/null 2>&1
mail_rc="${?}"
f_log "info" "mail sent to '${trm_mailreceiver}' with rc '${mail_rc}'"
exit ${mail_rc}

+ 46
- 35
net/travelmate/files/travelmate.sh View File

@ -11,7 +11,7 @@
export LC_ALL=C export LC_ALL=C
export PATH="/usr/sbin:/usr/bin:/sbin:/bin" export PATH="/usr/sbin:/usr/bin:/sbin:/bin"
set -o pipefail set -o pipefail
trm_ver="2.0.0"
trm_ver="2.0.1"
trm_enabled=0 trm_enabled=0
trm_debug=0 trm_debug=0
trm_iface="" trm_iface=""
@ -42,7 +42,9 @@ trm_wpa="$(command -v wpa_supplicant)"
trm_captiveurl="http://captive.apple.com" trm_captiveurl="http://captive.apple.com"
trm_useragent="Mozilla/5.0 (Linux x86_64; rv:80.0) Gecko/20100101 Firefox/80.0" trm_useragent="Mozilla/5.0 (Linux x86_64; rv:80.0) Gecko/20100101 Firefox/80.0"
trm_ntpfile="/var/state/travelmate.ntp" trm_ntpfile="/var/state/travelmate.ntp"
trm_vpnfile="/var/state/travelmate.vpn"
trm_mailfile="/var/state/travelmate.mail" trm_mailfile="/var/state/travelmate.mail"
trm_refreshfile="/var/state/travelmate.refresh"
trm_pidfile="/var/run/travelmate.pid" trm_pidfile="/var/run/travelmate.pid"
trm_action="${1:-"start"}" trm_action="${1:-"start"}"
@ -72,20 +74,7 @@ f_env()
# #
if [ ! -r "/etc/config/travelmate" ] || [ -z "$(uci -q show travelmate.global.trm_vpn)" ] if [ ! -r "/etc/config/travelmate" ] || [ -z "$(uci -q show travelmate.global.trm_vpn)" ]
then then
if { [ -r "/etc/config/travelmate-opkg" ] && [ -n "$(uci -q show travelmate.global.trm_vpn)" ]; } || \
{ [ -r "/rom/etc/config/travelmate" ] && [ -n "$(uci -q show /rom/etc/config/travelmate.global.trm_vpn)" ]; }
then
if [ -r "/etc/config/travelmate-opkg" ]
then
cp -pf "/etc/config/travelmate-opkg" "/etc/config/travelmate"
elif [ -r "/rom/etc/config/travelmate" ]
then
cp -pf "/rom/etc/config/travelmate" "/etc/config/travelmate"
fi
f_log "info" "missing or old travelmate config replaced with a new one"
else
f_log "err" "unrecoverable travelmate config error, please re-install the package via opkg with the '--force-reinstall --force-maintainer' options"
fi
f_log "err" "no valid travelmate config found, please re-install the package via opkg with the '--force-reinstall --force-maintainer' options"
fi fi
# load travelmate config # load travelmate config
@ -241,16 +230,27 @@ f_reconf()
# #
f_vpn() f_vpn()
{ {
local IFS action="${1}"
local IFS rc action="${1}"
if [ "${trm_vpn}" -eq "1" ] && [ -x "${trm_vpnpgm}" ] if [ "${trm_vpn}" -eq "1" ] && [ -x "${trm_vpnpgm}" ]
then then
"${trm_vpnpgm}" "${action}" >/dev/null 2>&1
if [ "${action}" = "disable" ] || { [ "${action}" = "enable" ] && [ ! -f "${trm_vpnfile}" ]; }
then
"${trm_vpnpgm}" "${action}" >/dev/null 2>&1
rc="${?}"
fi
if [ "${action}" = "enable" ] && [ "${rc}" -eq "0" ]
then
> "${trm_vpnfile}"
elif [ "${action}" = "disable" ] && [ -f "${trm_vpnfile}" ]
then
rm -f "${trm_vpnfile}"
fi
fi fi
f_log "debug" "f_vpn ::: vpn: ${trm_vpn}, vpnservice: ${trm_vpnservice:-"-"}, vpnpgm: ${trm_vpnpgm}, action: ${action}"
f_log "debug" "f_vpn ::: vpn: ${trm_vpn}, vpnservice: ${trm_vpnservice:-"-"}, vpnpgm: ${trm_vpnpgm}, action: ${action}, rc: ${rc:-"-"}"
} }
# mac helper function
# mac randomizer helper function
# #
f_mac() f_mac()
{ {
@ -343,9 +343,9 @@ f_contrack()
if [ -n "$(uci -q changes "travelmate")" ] if [ -n "$(uci -q changes "travelmate")" ]
then then
uci_commit "travelmate" uci_commit "travelmate"
if [ ! -f "/var/run/travelmate.refresh" ]
if [ ! -f "${trm_refreshfile}" ]
then then
printf "%s" "cfg_reload" > "/var/run/travelmate.refresh"
printf "%s" "cfg_reload" > "${trm_refreshfile}"
fi fi
fi fi
fi fi
@ -450,9 +450,9 @@ f_addif()
uci_commit "travelmate" uci_commit "travelmate"
uci_commit "wireless" uci_commit "wireless"
f_reconf f_reconf
if [ ! -f "/var/run/travelmate.refresh" ]
if [ ! -f "${trm_refreshfile}" ]
then then
printf "%s" "ui_reload" > "/var/run/travelmate.refresh"
printf "%s" "ui_reload" > "${trm_refreshfile}"
fi fi
f_log "info" "open uplink '${radio}/${essid}' added to wireless config" f_log "info" "open uplink '${radio}/${essid}' added to wireless config"
fi fi
@ -637,7 +637,7 @@ f_check()
then then
login_script_args="$(f_uplink "script_args" "${sta_radio}" "${sta_essid}" "${sta_bssid}")" login_script_args="$(f_uplink "script_args" "${sta_radio}" "${sta_essid}" "${sta_bssid}")"
"${login_script}" ${login_script_args} >/dev/null 2>&1 "${login_script}" ${login_script_args} >/dev/null 2>&1
rc=${?}
rc="${?}"
f_log "info" "captive portal login '${login_script:0:40} ${login_script_args:0:20}' for '${cp_domain}' has been executed with rc '${rc}'" f_log "info" "captive portal login '${login_script:0:40} ${login_script_args:0:20}' for '${cp_domain}' has been executed with rc '${rc}'"
if [ "${rc}" -eq "0" ] if [ "${rc}" -eq "0" ]
then then
@ -713,7 +713,7 @@ f_check()
# #
f_jsnup() f_jsnup()
{ {
local IFS section bg_pid last_date last_station sta_iface sta_radio sta_essid sta_bssid sta_mac dev_status last_status status="${trm_ifstatus}" ntp_sync="0"
local IFS section last_date last_station sta_iface sta_radio sta_essid sta_bssid sta_mac dev_status last_status status="${trm_ifstatus}" ntp_done="0" vpn_done="0" mail_done="0"
if [ "${status}" = "true" ] if [ "${status}" = "true" ]
then then
@ -757,12 +757,18 @@ f_jsnup()
then then
last_date="$(date "+%Y.%m.%d-%H:%M:%S")" last_date="$(date "+%Y.%m.%d-%H:%M:%S")"
fi fi
if [ -s "${trm_ntpfile}" ] if [ -s "${trm_ntpfile}" ]
then then
ntp_sync="1"
ntp_done="1"
fi
if [ "${trm_vpn}" -eq "1" ] && [ -f "${trm_vpnfile}" ]
then
vpn_done="1"
fi
if [ "${trm_mail}" -eq "1" ] && [ -f "${trm_mailfile}" ]
then
mail_done="1"
fi fi
json_add_string "travelmate_status" "${status}" json_add_string "travelmate_status" "${status}"
json_add_string "travelmate_version" "${trm_ver}" json_add_string "travelmate_version" "${trm_ver}"
json_add_string "station_id" "${sta_radio:-"-"}/${sta_essid:-"-"}/${sta_bssid:-"-"}" json_add_string "station_id" "${sta_radio:-"-"}/${sta_essid:-"-"}/${sta_bssid:-"-"}"
@ -770,7 +776,7 @@ f_jsnup()
json_add_string "station_interface" "${sta_iface:-"-"}" json_add_string "station_interface" "${sta_iface:-"-"}"
json_add_string "wpa_flags" "${trm_wpaflags:-"-"}" json_add_string "wpa_flags" "${trm_wpaflags:-"-"}"
json_add_string "run_flags" "captive: $(f_char ${trm_captive}), proactive: $(f_char ${trm_proactive}), netcheck: $(f_char ${trm_netcheck}), autoadd: $(f_char ${trm_autoadd}), randomize: $(f_char ${trm_randomize})" json_add_string "run_flags" "captive: $(f_char ${trm_captive}), proactive: $(f_char ${trm_proactive}), netcheck: $(f_char ${trm_netcheck}), autoadd: $(f_char ${trm_autoadd}), randomize: $(f_char ${trm_randomize})"
json_add_string "ext_hooks" "ntp: $(f_char ${ntp_sync}), vpn: $(f_char ${trm_vpn}), mail: $(f_char ${trm_mail})"
json_add_string "ext_hooks" "ntp: $(f_char ${ntp_done}), vpn: $(f_char ${vpn_done}), mail: $(f_char ${mail_done})"
json_add_string "last_run" "${last_date}" json_add_string "last_run" "${last_date}"
json_add_string "system" "${trm_sysver}" json_add_string "system" "${trm_sysver}"
json_dump > "${trm_rtfile}" json_dump > "${trm_rtfile}"
@ -778,16 +784,18 @@ f_jsnup()
if [ "${status%% (net ok/*}" = "connected" ] if [ "${status%% (net ok/*}" = "connected" ]
then then
f_vpn "enable" f_vpn "enable"
if [ "${trm_mail}" -eq "1" ] && [ -x "${trm_mailpgm}" ] && [ -s "${trm_ntpfile}" ] && [ ! -f "${trm_mailfile}" ]
if [ "${trm_mail}" -eq "1" ] && [ -x "${trm_mailpgm}" ] && [ "${ntp_done}" = "1" ] && [ "${mail_done}" = "0" ]
then then
> "${trm_mailfile}"
( "${trm_mailpgm}" >/dev/null 2>&1 )&
bg_pid="${!}"
if [ "${trm_vpn}" -eq "0" ] || [ "${vpn_done}" -eq "1" ]
then
> "${trm_mailfile}"
"${trm_mailpgm}" >/dev/null 2>&1
fi
fi fi
else else
f_vpn "disable" f_vpn "disable"
fi fi
f_log "debug" "f_jsnup ::: section: ${section:-"-"}, status: ${status:-"-"}, sta_iface: ${sta_iface:-"-"}, sta_radio: ${sta_radio:-"-"}, sta_essid: ${sta_essid:-"-"}, sta_bssid: ${sta_bssid:-"-"}, vpn: ${trm_vpn}, mail: ${trm_mail}, mail_pid: ${bg_pid:-"-"}"
f_log "debug" "f_jsnup ::: section: ${section:-"-"}, status: ${status:-"-"}, sta_iface: ${sta_iface:-"-"}, sta_radio: ${sta_radio:-"-"}, sta_essid: ${sta_essid:-"-"}, sta_bssid: ${sta_bssid:-"-"}, ntp: ${ntp_done}, vpn: ${trm_vpn}/${vpn_done}, mail: ${trm_mail}/${mail_done}"
} }
# write to syslog # write to syslog
@ -994,7 +1002,10 @@ fi
# control travelmate actions # control travelmate actions
# #
f_env
if [ "${trm_action}" != "stop" ]
then
f_env
fi
while true while true
do do
if [ -z "${trm_action}" ] if [ -z "${trm_action}" ]


+ 23
- 18
net/travelmate/files/travelmate.vpn View File

@ -12,7 +12,7 @@ LC_ALL=C
PATH="/usr/sbin:/usr/bin:/sbin:/bin" PATH="/usr/sbin:/usr/bin:/sbin:/bin"
. "/lib/functions.sh" . "/lib/functions.sh"
trm_action="${1}"
vpn_action="${1}"
trm_vpnservice="$(uci_get travelmate global trm_vpnservice)" trm_vpnservice="$(uci_get travelmate global trm_vpnservice)"
trm_vpniface="$(uci_get travelmate global trm_vpniface)" trm_vpniface="$(uci_get travelmate global trm_vpniface)"
trm_landevice="$(uci_get travelmate global trm_landevice)" trm_landevice="$(uci_get travelmate global trm_landevice)"
@ -58,40 +58,40 @@ if [ -n "${trm_vpnservice}" ] && [ -n "${trm_vpniface}" ] && [ -n "${trm_landevi
then then
status="$(jsonfilter -i "/tmp/trm_runtime.json" -l1 -e '@.data.travelmate_status' 2>/dev/null)" status="$(jsonfilter -i "/tmp/trm_runtime.json" -l1 -e '@.data.travelmate_status' 2>/dev/null)"
vpn_status="$(ubus -S call network.interface."${trm_vpniface}" status 2>/dev/null | jsonfilter -l1 -e '@.up')" vpn_status="$(ubus -S call network.interface."${trm_vpniface}" status 2>/dev/null | jsonfilter -l1 -e '@.up')"
if [ "${trm_action}" = "disable" ] && [ "${vpn_status}" = "true" ]
if [ "${vpn_action}" = "disable" ] && [ "${vpn_status}" = "true" ]
then then
if [ -n "$("${trm_iptables}" "-w $((trm_maxwait/6))" -C ${trm_iptrule_drop} 2>&1)" ] if [ -n "$("${trm_iptables}" "-w $((trm_maxwait/6))" -C ${trm_iptrule_drop} 2>&1)" ]
then then
"${trm_iptables}" "-w $((trm_maxwait/6))" -I ${trm_iptrule_drop} 2>&1 "${trm_iptables}" "-w $((trm_maxwait/6))" -I ${trm_iptrule_drop} 2>&1
f_log "info" "lan forward blocked for device '${trm_landevice}'" f_log "info" "lan forward blocked for device '${trm_landevice}'"
fi fi
if [ "${status%% (net cp *}" = "connected" ]
fi
if [ "${vpn_action}" = "disable" ] && [ "${status%% (net cp *}" = "connected" ]
then
if [ -n "$("${trm_iptables}" "-w $((trm_maxwait/6))" -C ${trm_iptrule_accept} 2>&1)" ]
then then
if [ -n "$("${trm_iptables}" "-w $((trm_maxwait/6))" -C ${trm_iptrule_accept} 2>&1)" ]
then
"${trm_iptables}" "-w $((trm_maxwait/6))" -I ${trm_iptrule_accept} 2>&1
f_log "info" "lan forward on ports 80/443 freed for device '${trm_landevice}'"
fi
"${trm_iptables}" "-w $((trm_maxwait/6))" -I ${trm_iptrule_accept} 2>&1
f_log "info" "lan forward on ports 80/443 freed for device '${trm_landevice}'"
fi fi
fi fi
case "${trm_vpnservice}" in case "${trm_vpnservice}" in
"wireguard") "wireguard")
if [ "${trm_action}" = "enable" ] && [ "${vpn_status}" != "true" ]
if [ "${vpn_action}" = "enable" ] && [ "${vpn_status}" != "true" ]
then then
ubus call network.interface."${trm_vpniface}" up ubus call network.interface."${trm_vpniface}" up
elif [ "${trm_action}" = "disable" ] && [ "${vpn_status}" = "true" ]
elif [ "${vpn_action}" = "disable" ] && [ "${vpn_status}" = "true" ]
then then
ubus call network.interface."${trm_vpniface}" down ubus call network.interface."${trm_vpniface}" down
f_log "info" "${trm_vpnservice} client connection disabled" f_log "info" "${trm_vpnservice} client connection disabled"
fi fi
;; ;;
"openvpn") "openvpn")
if [ "${trm_action}" = "enable" ] && [ "${vpn_status}" != "true" ]
if [ "${vpn_action}" = "enable" ] && [ "${vpn_status}" != "true" ]
then then
ubus call network.interface."${trm_vpniface}" up ubus call network.interface."${trm_vpniface}" up
/etc/init.d/openvpn restart >/dev/null 2>&1 /etc/init.d/openvpn restart >/dev/null 2>&1
elif [ "${trm_action}" = "disable" ] && [ "${vpn_status}" = "true" ]
elif [ "${vpn_action}" = "disable" ] && [ "${vpn_status}" = "true" ]
then then
ubus call network.interface."${trm_vpniface}" down ubus call network.interface."${trm_vpniface}" down
/etc/init.d/openvpn stop >/dev/null 2>&1 /etc/init.d/openvpn stop >/dev/null 2>&1
@ -100,7 +100,7 @@ then
;; ;;
esac esac
if [ "${trm_action}" = "enable" ] && [ "${vpn_status}" != "true" ]
if [ "${vpn_action}" = "enable" ] && [ "${vpn_status}" != "true" ]
then then
cnt=0 cnt=0
while true while true
@ -121,10 +121,6 @@ then
fi fi
f_log "info" "lan forward freed for device '${trm_landevice}'" f_log "info" "lan forward freed for device '${trm_landevice}'"
fi fi
if [ -f "/etc/init.d/sysntpd" ]
then
/etc/init.d/sysntpd restart >/dev/null 2>&1
fi
break break
fi fi
fi fi
@ -132,10 +128,19 @@ then
then then
f_log "info" "${trm_vpnservice} restart failed, lan forward for device '${trm_landevice}' still blocked" f_log "info" "${trm_vpnservice} restart failed, lan forward for device '${trm_landevice}' still blocked"
ubus call network.interface."${trm_vpniface}" down ubus call network.interface."${trm_vpniface}" down
break
exit 2
fi fi
sleep 1 sleep 1
cnt="$((cnt+1))" cnt="$((cnt+1))"
done done
fi fi
if [ "${vpn_action}" = "enable" ] && [ "${vpn_status}" = "true" ]
then
if [ -f "/etc/init.d/sysntpd" ]
then
/etc/init.d/sysntpd restart >/dev/null 2>&1
fi
fi
exit 0
fi fi
exit 1

+ 1
- 1
net/travelmate/files/wifionice.login View File

@ -3,10 +3,10 @@
# Copyright (c) 2020 Dirk Brenken (dev@brenken.org) # Copyright (c) 2020 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.
trm_fetch="$(command -v curl)"
trm_domain="www.wifionice.de" trm_domain="www.wifionice.de"
trm_useragent="$(uci_get travelmate global trm_useragent "Mozilla/5.0 (Linux x86_64; rv:80.0) Gecko/20100101 Firefox/80.0")" trm_useragent="$(uci_get travelmate global trm_useragent "Mozilla/5.0 (Linux x86_64; rv:80.0) Gecko/20100101 Firefox/80.0")"
trm_maxwait="$(uci_get travelmate global trm_maxwait "30")" trm_maxwait="$(uci_get travelmate global trm_maxwait "30")"
trm_fetch="$(command -v curl)"
# initial get request to receive & extract a valid security token # initial get request to receive & extract a valid security token
# #


Loading…
Cancel
Save