]> git.99rst.org Git - openwrt-packages.git/commitdiff
travelmate: update 2.4.9-1
authorDirk Brenken <redacted>
Mon, 7 Sep 2026 17:10:31 +0000 (19:10 +0200)
committerDirk Brenken <redacted>
Mon, 7 Sep 2026 17:11:00 +0000 (19:11 +0200)
- 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 <redacted>
net/travelmate/Makefile
net/travelmate/files/README.md
net/travelmate/files/travelmate-functions.sh
net/travelmate/files/travelmate-service.sh
net/travelmate/files/wifibahn.login

index 2a1574c1fda648eb9f8418037870e05ea42b1157..efb08660580bcba7b01717e493e2c328e2cba1c0 100644 (file)
@@ -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 <dev@brenken.org>
index e31ee1e950383a557700fc81d32a7823768b2795..9603780fd716ebfb08e15e5f317176c9cbb540f7 100644 (file)
@@ -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.
 
index 6b3b331a18d623677be9217f02203e9a8e395834..d04873082c368ecb44060694aaee6f75baf3c783 100644 (file)
@@ -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
index 441bcd178d9b21d61211892b427d36c78946799d..65384b485a481eb4b66ad23ff971a500d09d47ef 100755 (executable)
@@ -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
index e0a3c8f6c43b5d24e6afe079384f3e04d4c398be..0090a20480d6ba20242a290b629c96b1b920a176 100755 (executable)
@@ -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
git clone https://git.99rst.org/PROJECT