From: Dirk Brenken Date: Mon, 7 Sep 2026 17:10:31 +0000 (+0200) Subject: travelmate: update 2.4.9-1 X-Git-Url: http://git.99rst.org/?a=commitdiff_plain;h=900d31c6c514d641a62fd43cae9b73807e6d47bb;p=openwrt-packages.git travelmate: update 2.4.9-1 - do not set trm_action in the function library; the library is sourced by the init script, reported by @sch-m - fixed the uplink ssid comparison for fancy essids with quotes - added a new optional per uplink revive option; an uplink disabled by the retry limit is set back to enabled after n run cycles, default off, minimum 10, number of revivals capped by trm_maxretry. Counters live in a runtime file, no extra config writes - update the wifibahn login script, support the new CNA portal API - LuCI: rework the wireless scan dialog; card list instead of the result table, mobile friendly - LuCI: add the per uplink revive option to the uplink dialog (off / 10 / 30 / 60 run cycles) - readme update Signed-off-by: Dirk Brenken --- diff --git a/net/travelmate/Makefile b/net/travelmate/Makefile index 2a1574c1f..efb086605 100644 --- a/net/travelmate/Makefile +++ b/net/travelmate/Makefile @@ -6,7 +6,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=travelmate -PKG_VERSION:=2.4.8 +PKG_VERSION:=2.4.9 PKG_RELEASE:=1 PKG_LICENSE:=GPL-3.0-or-later PKG_MAINTAINER:=Dirk Brenken diff --git a/net/travelmate/files/README.md b/net/travelmate/files/README.md index e31ee1e95..9603780fd 100644 --- a/net/travelmate/files/README.md +++ b/net/travelmate/files/README.md @@ -199,6 +199,7 @@ A stopped service does not report a state at all, it truncates the runtime file | Option | Default | Description/Valid Values | | :----------------- | :--------------------------------- | :---------------------------------------------------------------------------------------------------- | | enabled | 1, enabled | enable or disable the uplink, automatically set if the retry limit was reached | +| revive | 0, disabled | re-enable this uplink after n run cycles if the retry limit disabled it, minimum '10' | | device | -, not set | match the 'device' 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 | @@ -292,6 +293,8 @@ If your router has more than one radio, keep the AP and the uplink on separate r **Retry behaviour** `trm_maxretry` (default 3) limits the connection attempts per uplink. When the limit is reached, the affected uplink is disabled in the travelmate config and has to be re-enabled manually - which is intentional for permanently broken credentials, but worth keeping in mind in combination with `trm_netcheck`. Set `trm_maxretry` to '0' for unlimited retries if you never want an uplink to be disabled automatically. +Per uplink, `revive` softens that. With a value of n, an uplink disabled by the retry limit is set back to 'enabled' after n run cycles, so a network that was only temporarily unavailable comes back on its own. Values below 10 are raised to 10, since a run cycle is roughly `trm_timeout` seconds long and shorter intervals only produce needless reconnect attempts. The number of revivals is capped by the global `trm_maxretry`, which also means that `revive` has no effect with `trm_maxretry` set to '0'. The cycle and round counters are kept in the runtime file '/var/run/travelmate/travelmate.revive', they are never written to the config and are cleared when the service is stopped. The enable and disable itself is still recorded in the travelmate config, so the LuCI station list always shows the real state. + **Open uplinks** `trm_autoadd` adds open networks to your wireless config on the fly, which is handy in hotels and on trains. Keep `trm_maxautoadd` at a sane value so that a busy location doesn't flood your config, and use `trm_ssidfilter` to skip the usual noise, e.g. `Chromecast*` or printer and camera SSIDs. diff --git a/net/travelmate/files/travelmate-functions.sh b/net/travelmate/files/travelmate-functions.sh index 6b3b331a1..d04873082 100644 --- a/net/travelmate/files/travelmate-functions.sh +++ b/net/travelmate/files/travelmate-functions.sh @@ -49,9 +49,9 @@ trm_pidfile="${trm_rundir}/travelmate.pid" trm_scanfile="${trm_rundir}/travelmate.scan" trm_tmpfile="${trm_rundir}/travelmate.tmp" trm_rtfile="${trm_rundir}/travelmate.runtime.json" +trm_revivefile="${trm_rundir}/travelmate.revive" trm_captiveurl="http://detectportal.firefox.com" trm_useragent="Mozilla/5.0 (X11; Linux x86_64; rv:144.0) Gecko/20100101 Firefox/144.0" -trm_action="${1}" trm_runmode="" trm_active="0" @@ -572,6 +572,67 @@ f_getcfg() { done } +# load the revive counter of an uplink that has been disabled by the retry limit +# +f_reviveload() { + local cnt rounds radio bssid essid load_radio="${1}" load_essid="${2}" load_bssid="${3}" found="0" revive="" + + revive="$(f_getval "revive" "0")" + revive="${revive//[!0-9]/}" + [ -z "${revive}" ] || [ "${revive}" = "0" ] && return 0 + [ "${revive}" -lt "10" ] && revive="10" + + : >"${trm_revivefile}.tmp" + if [ -s "${trm_revivefile}" ]; then + while IFS="|" read -r cnt rounds radio bssid essid; do + if [ "${radio}" = "${load_radio}" ] && [ "${essid}" = "${load_essid}" ] && [ "${bssid}" = "${load_bssid}" ]; then + found="1" + rounds="$((rounds + 1))" + if [ "${rounds}" -gt "${trm_maxretry}" ]; then + cnt="0" + f_log "info" "uplink stays disabled '${load_radio}/${load_essid}/${load_bssid:-"-"}', revive limit reached" + else + cnt="${revive}" + fi + fi + printf "%s|%s|%s|%s|%s\n" "${cnt}" "${rounds}" "${radio}" "${bssid}" "${essid}" >>"${trm_revivefile}.tmp" + done <"${trm_revivefile}" + fi + [ "${found}" = "0" ] && printf "%s|%s|%s|%s|%s\n" "${revive}" "1" "${load_radio}" "${load_bssid}" "${load_essid}" >>"${trm_revivefile}.tmp" + mv -f "${trm_revivefile}.tmp" "${trm_revivefile}" + + f_log "debug" "f_reviveload ::: radio: ${load_radio}, essid: ${load_essid}, bssid: ${load_bssid:-"-"}, revive: ${revive}, max_rounds: ${trm_maxretry}" +} + +# count down the loaded uplinks and re-enable them at the end of their revive cycle +# +f_revive() { + local cnt rounds radio bssid essid + + [ ! -s "${trm_revivefile}" ] && return 0 + + : >"${trm_revivefile}.tmp" + while IFS="|" read -r cnt rounds radio bssid essid; do + if [ "${cnt}" -gt "0" ]; then + cnt="$((cnt - 1))" + if [ "${cnt}" = "0" ]; then + f_getcfg "${radio}" "${essid}" "${bssid}" + if [ -z "${trm_uplinkcfg}" ]; then + continue + fi + if [ "$(uci_get "travelmate" "${trm_uplinkcfg}" "enabled")" = "0" ]; then + uci_set "travelmate" "${trm_uplinkcfg}" "enabled" "1" + uci_commit "travelmate" + [ ! -f "${trm_refreshfile}" ] && printf "%s" "cfg_reload" >"${trm_refreshfile}" + f_log "info" "uplink has been re-enabled '${radio}/${essid}/${bssid:-"-"}' (${rounds}/${trm_maxretry})" + fi + fi + fi + printf "%s|%s|%s|%s|%s\n" "${cnt}" "${rounds}" "${radio}" "${bssid}" "${essid}" >>"${trm_revivefile}.tmp" + done <"${trm_revivefile}" + mv -f "${trm_revivefile}.tmp" "${trm_revivefile}" +} + # get travelmate option value in 'uplink' sections # f_getval() { @@ -1406,13 +1467,17 @@ f_scan() { # f_main() { local radio cnt retrycnt scan_list scan_essid scan_bssid scan_rsn scan_wpa scan_quality scan_open station_id retry_display - local section sta sta_essid sta_bssid sta_radio sta_mac open_sta open_essid config_radio config_essid config_bssid + local section sta sta_essid sta_bssid sta_radio sta_mac open_sta open_essid esc_essid config_radio config_essid config_bssid # mark the run cycle as active, e.g. to distinguish 'processing' from an # idle daemon in f_genstatus # trm_active="1" + # re-enable uplinks whose revive cycle has expired + # + f_revive + # initial check # f_check "initial" "false" @@ -1466,6 +1531,7 @@ f_main() { section="${sta%%-*}" sta_radio="$(uci_get "wireless" "${section}" "device")" sta_essid="$(uci_get "wireless" "${section}" "ssid")" + esc_essid="\"${sta_essid//\"/\\\"}\"" sta_bssid="$(uci_get "wireless" "${section}" "bssid")" f_normbssid "${sta_bssid}" sta_bssid="${trm_normbssid}" @@ -1511,17 +1577,19 @@ f_main() { fi open_essid="${scan_essid%?}" open_essid="${open_essid:1}" + open_essid="${open_essid//\\\"/\"}" open_sta="$(f_addsta "${radio}" "${open_essid}")" if [ -n "${open_sta}" ]; then section="${open_sta%%-*}" sta_radio="$(uci_get "wireless" "${section}" "device")" sta_essid="$(uci_get "wireless" "${section}" "ssid")" + esc_essid="\"${sta_essid//\"/\\\"}\"" sta_bssid="" sta_mac="" fi fi if [ -n "${sta_bssid}" ] && [ "${radio}" = "${sta_radio}" ] && - [ "${scan_bssid}" != "${sta_bssid}" ] && [ "${scan_essid}" = "\"${sta_essid}\"" ]; then + [ "${scan_bssid}" != "${sta_bssid}" ] && [ "${scan_essid}" = "${esc_essid}" ]; then if [ -n "${trm_uplinkcfg}" ]; then uci_set "travelmate" "${trm_uplinkcfg}" "enabled" "0" uci_commit "travelmate" @@ -1530,7 +1598,7 @@ f_main() { f_log "info" "bssid mismatch (evil-twin) '${sta_radio}/${sta_essid}/${sta_bssid} => ${scan_bssid}'" continue fi - if { { [ "${scan_essid}" = "\"${sta_essid}\"" ] && { [ -z "${sta_bssid}" ] || [ "${scan_bssid}" = "${sta_bssid}" ]; }; } || + if { { [ "${scan_essid}" = "${esc_essid}" ] && { [ -z "${sta_bssid}" ] || [ "${scan_bssid}" = "${sta_bssid}" ]; }; } || { [ "${scan_bssid}" = "${sta_bssid}" ] && [ "${scan_essid}" = "hidden" ]; }; } && [ "${radio}" = "${sta_radio}" ]; then if [ "${trm_eviltwin}" = "1" ] && [ -z "${sta_bssid}" ] && [ "${scan_essid}" != "hidden" ]; then if [ "$((0x${scan_bssid%%:*} & 2))" != "0" ]; then @@ -1570,6 +1638,7 @@ f_main() { uci_set "travelmate" "${trm_uplinkcfg}" "enabled" "0" uci_commit "travelmate" [ ! -f "${trm_refreshfile}" ] && printf "%s" "cfg_reload" >"${trm_refreshfile}" + f_reviveload "${sta_radio}" "${sta_essid}" "${sta_bssid}" fi f_log "info" "uplink has been disabled '${sta_radio}/${sta_essid}/${sta_bssid:-"-"}' (${retrycnt}/${retry_display})" continue 2 diff --git a/net/travelmate/files/travelmate-service.sh b/net/travelmate/files/travelmate-service.sh index 441bcd178..65384b485 100755 --- a/net/travelmate/files/travelmate-service.sh +++ b/net/travelmate/files/travelmate-service.sh @@ -30,6 +30,7 @@ while :; do if [ -s "${trm_pidfile}" ]; then f_log "info" "travelmate instance stopped ::: action: ${trm_action}, pid: $("${trm_catcmd}" "${trm_pidfile}")" : >"${trm_rtfile}" + : >"${trm_revivefile}" : >"${trm_pidfile}" fi break diff --git a/net/travelmate/files/wifibahn.login b/net/travelmate/files/wifibahn.login index e0a3c8f6c..0090a2048 100755 --- a/net/travelmate/files/wifibahn.login +++ b/net/travelmate/files/wifibahn.login @@ -23,14 +23,19 @@ if ! "${trm_lookupcmd}" "${trm_domain}" >/dev/null 2>&1; then fi fi -# get security token +# current cna portal api +# +raw_html="$("${trm_fetchcmd}" ${trm_fetchparm} --user-agent "${trm_useragent}" --header "Content-Type: application/json" --header "X-Requested-With: XMLHttpRequest" --header "X-Csrf-Token: csrf" --header "Referer: https://${trm_domain}/cna/" --data "{}" "https://${trm_domain}/cna/logon")" +printf "%s" "${raw_html}" | "${trm_grepcmd}" -qF "success" && exit 0 + +# legacy portal api, get security token # "${trm_fetchcmd}" ${trm_fetchparm} --user-agent "${trm_useragent}" --cookie-jar "/tmp/${trm_domain}.cookie" --output /dev/null "https://${trm_domain}/en/" [ "${?}" = "0" ] && sec_token="$("${trm_awkcmd}" '/csrf/{print $7}' "/tmp/${trm_domain}.cookie" 2>/dev/null)" rm -f "/tmp/${trm_domain}.cookie" [ -z "${sec_token}" ] && exit 2 -# final post request +# legacy portal api, final post request # "${trm_fetchcmd}" ${trm_fetchparm} --user-agent "${trm_useragent}" --header "Cookie: csrf=${sec_token}" --data "login=true&CSRFToken=${sec_token}" --output /dev/null "https://${trm_domain}/en/" [ "${?}" = "0" ] && exit 0 || exit 255