]> git.99rst.org Git - openwrt-packages.git/commitdiff
travelmate: update 2.4.7-3
authorDirk Brenken <redacted>
Sat, 8 Aug 2026 15:50:24 +0000 (17:50 +0200)
committerDirk Brenken <redacted>
Sat, 8 Aug 2026 15:50:42 +0000 (17:50 +0200)
- fixed the shipped captive portal login scripts,
  corrected the curl call to 'trm_fetchcmd'
- fixed the return code handling within the login scripts
- added a generic portal login script recipe to the readme

Signed-off-by: Dirk Brenken <redacted>
net/travelmate/Makefile
net/travelmate/files/README.md
net/travelmate/files/generic-user-pass.login
net/travelmate/files/telekom.login
net/travelmate/files/vodafone.login
net/travelmate/files/wifibahn.login

index f5b50dd05e1e74218fb44270f77ca085bef3a51e..6eeba80b98dac7a18de59513c8258a144ed8e2a0 100644 (file)
@@ -7,7 +7,7 @@ include $(TOPDIR)/rules.mk
 
 PKG_NAME:=travelmate
 PKG_VERSION:=2.4.7
-PKG_RELEASE:=2
+PKG_RELEASE:=3
 PKG_LICENSE:=GPL-3.0-or-later
 PKG_MAINTAINER:=Dirk Brenken <dev@brenken.org>
 
index 663ecdb886201e7cf867224c2135b7f790ff096d..20675dec7d95726bf5a9ecfada553ef0ac995427 100644 (file)
@@ -226,7 +226,7 @@ password        zzz
 Finally enable e-mail support in travelmate and add a valid e-mail receiver address.
 
 **Captive portal auto-logins**  
-For automated captive portal logins you can reference an external shell script per uplink. All login scripts have to be executable and located in `/etc/travelmate` with the extension `.login`. The package ships multiple ready to run auto-login scripts:
+For automated captive portal logins you can reference an external shell script per uplink. All login scripts have to be executable and located in `/etc/travelmate` with the extension `.login`. A login script signals its result via the exit code: `0` means the login succeeded, any other value means it failed. Only `0` makes travelmate re-check the connectivity right away, every other value is just logged. The package ships multiple ready to run auto-login scripts:
 
 * 'wifibahn.login' for german DB railway hotspots
 * 'telekom.login' for telekom hotspots (DE)
@@ -242,6 +242,19 @@ user.info trm-2.4.7-1[26222]: captive portal login script for 'www.wifibahn.de'
 user.info trm-2.4.7-1[26222]: connected to uplink 'radio1/WIFI@DB/-' with mac 'B2:9D:F5:96:86:A4' (1/3)
 [...]
 ```
+**Building your own login script**  
+The fastest way to a working script is to record the login once by hand and then replay it with curl. Any browser's developer tools can do the recording:
+
+1. Connect a client to the hotspot - either directly, or through travelmate's own AP while the uplink is up - and open the portal page.
+2. Open the developer tools (usually `F12`) and switch to the `Network` tab. Enable `Preserve log` (Chromium, Edge, Safari) resp. `Persist Logs` (Firefox, behind the gear icon) and `Disable cache`. A portal login almost always ends in a redirect, and without these options the recorded entries are dropped at that point.
+3. Perform the login manually and watch which requests are sent.
+4. Right-click the request that carries your credentials and choose `Copy` -> `Copy as cURL`. You now have the exact URL, method, headers, cookies and form fields as the browser sent them. `Save All As HAR` resp. `Export HAR` records the whole session if you want to study it later - note that recent Chromium versions strip cookies and authorization headers from the export unless you allow sensitive data in the devtools settings.
+5. Strip the copied command down: the browser adds a lot of `Accept*`, `Sec-*` and `Priority` headers that no portal cares about. Keep the request body, the `Content-Type` and whatever the portal actually validates, then replace curl's flags with travelmate's `${trm_fetchcmd} ${trm_fetchparm}` and `--user-agent "${trm_useragent}"`.
+6. Look for values that are only valid for one session - CSRF tokens, session ids, `sid` parameters. Those must not be copied into the script but fetched at runtime, see `wifibahn.login` (cookie jar plus awk) or `vodafone.login` (json response plus jsonfilter) for the two usual patterns.
+7. Never hardcode credentials. Pass them via the uplink's `script_args` option and read them as `${1}` and `${2}`, like `generic-user-pass.login` does.
+8. Test the script on the router while the portal is actually in the way: `sh -x /etc/travelmate/my.login user pass; echo "rc: ${?}"`. Make sure it only exits `0` when the login really succeeded - a script that reports success too eagerly is worse than one that fails, because travelmate will happily keep the uplink.
+
+The portal domain travelmate detected is in the system log: `logread -e "trm-"` shows it as `captive portal domain '<domain>' added to dhcp rebind allowlist`.
 
 Hopefully more scripts for different captive portals will be provided by the community!
 
index f605539bda587f680e7bf1b1835a5f8d5251293f..455db46dd63b2ff51ec8defaf7902c635aed3aab 100755 (executable)
@@ -24,6 +24,5 @@ fi
 
 # login with credentials
 #
-raw_html="$("${trm_fetch}" ${trm_fetchparm} --user-agent "${trm_useragent}" --header "Content-Type:application/x-www-form-urlencoded" --data "username=${user}&password=${password}" "http://${trm_domain}")"
-[ -z "${raw_html}" ] && exit 0 || exit 255
-
+"${trm_fetchcmd}" ${trm_fetchparm} --user-agent "${trm_useragent}" --header "Content-Type:application/x-www-form-urlencoded" --data "username=${user}&password=${password}" --output /dev/null "http://${trm_domain}"
+[ "${?}" = "0" ] && exit 0 || exit 255
index 124db172567ab51ac6b3ad8a9c3c46f291fe9d41..1830bbfe75beb6b430a7f2d17000c36c7dc74721 100755 (executable)
@@ -8,25 +8,24 @@
 
 # url encoding function
 #
-urlencode()
-{
+urlencode() {
        local chr str="${1}" len="${#1}" pos=0
 
        while [ "${pos}" -lt "${len}" ]; do
                chr="${str:pos:1}"
                case "${chr}" in
-                       [a-zA-Z0-9.~_-])
-                               printf "%s" "${chr}"
-                               ;;
-                       " ")
-                               printf "%%20"
-                               ;;
-                       *)
-                               printf "%%%02X" "'${chr}"
-                               ;;
+               [a-zA-Z0-9.~_-])
+                       printf "%s" "${chr}"
+                       ;;
+               " ")
+                       printf "%%20"
+                       ;;
+               *)
+                       printf "%%%02X" "'${chr}"
+                       ;;
                esac
                pos=$((pos + 1))
-               done
+       done
 }
 
 export LC_ALL=C
@@ -47,12 +46,12 @@ fi
 
 # get redirect url
 #
-raw_html="$("${trm_fetch}" ${trm_fetchparm} --user-agent "${trm_useragent}" "${trm_captiveurl}")"
+raw_html="$("${trm_fetchcmd}" ${trm_fetchparm} --user-agent "${trm_useragent}" "${trm_captiveurl}")"
 redirect_url="$(printf "%s" "${raw_html}" | "${trm_awkcmd}" 'match(tolower($0),/<loginurl>.*<\/loginurl>/){printf "%s",substr($0,RSTART+10,RLENGTH-21)}' 2>/dev/null | "${trm_awkcmd}" '{gsub("&amp;","\\&");printf "%s",$0}' 2>/dev/null)"
 [ -z "${redirect_url}" ] && exit 1
 
 # final login request
 #
-raw_html="$("${trm_fetch}" ${trm_fetchparm} --user-agent "${trm_useragent}" --referer "https://${trm_domain}/wlan/rest/freeLogin" --header "content-type: application/x-www-form-urlencoded" --data "UserName=${username}&Password=${password}&FNAME=0&button=Login&OriginatingServer=http%3A%2F%2F${trm_captiveurl}" "${redirect_url}")"
+raw_html="$("${trm_fetchcmd}" ${trm_fetchparm} --user-agent "${trm_useragent}" --referer "https://${trm_domain}/wlan/rest/freeLogin" --header "content-type: application/x-www-form-urlencoded" --data "UserName=${username}&Password=${password}&FNAME=0&button=Login&OriginatingServer=http%3A%2F%2F${trm_captiveurl}" "${redirect_url}")"
 login_url="$(printf "%s" "${raw_html}" | "${trm_awkcmd}" 'match(tolower($0),/<logoffurl>.*<\/logoffurl>/){printf "%s",substr($0,RSTART+11,RLENGTH-23)}' 2>/dev/null)"
 [ -n "${login_url}" ] && exit 0 || exit 255
index f578525f6d0938f28e39fa7b48cd04268b217e7c..6979ca938b37bf56a9482c3da99de652ab465ef1 100755 (executable)
@@ -24,13 +24,13 @@ fi
 
 # get sid
 #
-redirect_url="$("${trm_fetch}" ${trm_fetchparm} --user-agent "${trm_useragent}" --write-out "%{redirect_url}" --output /dev/null "${trm_captiveurl}")"
+redirect_url="$("${trm_fetchcmd}" ${trm_fetchparm} --user-agent "${trm_useragent}" --write-out "%{redirect_url}" --output /dev/null "${trm_captiveurl}")"
 sid="$(printf "%s" "${redirect_url}" 2>/dev/null | "${trm_awkcmd}" 'BEGIN{FS="[=&]"}{printf "%s",$2}')"
 [ -z "${sid}" ] && exit 1
 
 # get session
 #
-raw_html="$("${trm_fetch}" ${trm_fetchparm} --user-agent "${trm_useragent}" --referer "http://${trm_domain}/portal/?sid=${sid}" "https://${trm_domain}/api/v4/session?sid=${sid}")"
+raw_html="$("${trm_fetchcmd}" ${trm_fetchparm} --user-agent "${trm_useragent}" --referer "http://${trm_domain}/portal/?sid=${sid}" "https://${trm_domain}/api/v4/session?sid=${sid}")"
 session="$(printf "%s" "${raw_html}" 2>/dev/null | "${trm_jsoncmd}" -q -l1 -e '@.session')"
 [ -z "${session}" ] && exit 2
 
@@ -48,7 +48,7 @@ done
 # final login request
 #
 if [ "${login_id}" = "4" ] && [ -n "${username}" ] && [ -n "${password}" ]; then
-       raw_html="$("${trm_fetch}" ${trm_fetchparm} --user-agent "${trm_useragent}" --referer "http://${trm_domain}/portal/?sid=${sid}" --data "loginProfile=${login_id}&accessType=${access_type}&accountType=${account_type}&password=${password}&session=${session}&username=${username}" "https://${trm_domain}/api/v4/login?sid=${sid}")"
+       raw_html="$("${trm_fetchcmd}" ${trm_fetchparm} --user-agent "${trm_useragent}" --referer "http://${trm_domain}/portal/?sid=${sid}" --data "loginProfile=${login_id}&accessType=${access_type}&accountType=${account_type}&password=${password}&session=${session}&username=${username}" "https://${trm_domain}/api/v4/login?sid=${sid}")"
 fi
 success="$(printf "%s" "${raw_html}" 2>/dev/null | "${trm_jsoncmd}" -q -l1 -e '@.success')"
 [ "${success}" = "true" ] && exit 0 || exit 255
index 52e8e951e39d565065ff7bd5287be6682a7b730d..e0a3c8f6c43b5d24e6afe079384f3e04d4c398be 100755 (executable)
@@ -25,12 +25,12 @@ fi
 
 # get security token
 #
-"${trm_fetch}" ${trm_fetchparm} --user-agent "${trm_useragent}" --cookie-jar "/tmp/${trm_domain}.cookie" --output /dev/null "https://${trm_domain}/en/"
-sec_token="$("${trm_awkcmd}" '/csrf/{print $7}' "/tmp/${trm_domain}.cookie" 2>/dev/null)"
+"${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
 #
-raw_html="$("${trm_fetch}" ${trm_fetchparm} --user-agent "${trm_useragent}" --header "Cookie: csrf=${sec_token}" --data "login=true&CSRFToken=${sec_token}" "https://${trm_domain}/en/")"
-[ -z "${raw_html}" ] && exit 0 || exit 255
+"${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