travelmate: minor cp fixes

- handle captive portals failing after the redirect,
  fixes #30709
- Strip the port from the effective url host and, for a consistent
  foreign host comparison, from the probe host as well

Signed-off-by: Dirk Brenken <dev@brenken.org>
This commit is contained in:
Dirk Brenken committed 2026-10-06 21:11:36 +02:00
1 parent 13ac2fde62
commit 990a9071f8
2 files changed
+8 -5

No files matched your search

+1 -1
View File
@@ -7,7 +7,7 @@ include $(TOPDIR)/rules.mk
PKG_NAME:=travelmate
PKG_VERSION:=2.4.9
PKG_RELEASE:=2
PKG_RELEASE:=3
PKG_LICENSE:=GPL-3.0-or-later
PKG_MAINTAINER:=Dirk Brenken <dev@brenken.org>
+7 -4
View File
@@ -872,11 +872,11 @@ f_addsta() {
f_net() {
local parse err_msg raw marker probe_host json_raw html_raw html_cp js_cp json_ec json_rc json_cp json_cp_url json_ed result="net nok"
# host of the configured probe url, used to spot foreign redirect targets
# host of the configured probe url without port, used to spot foreign redirect targets
#
probe_host="${trm_captiveurl#*://}"
probe_host="${probe_host%%/*}"
probe_host="$(printf "%s" "${probe_host}" | "${trm_awkcmd}" '{printf "%s",tolower($0)}')"
probe_host="$(printf "%s" "${probe_host}" | "${trm_awkcmd}" '{h=tolower($0);if(h~/^\[/)sub(/\].*$/,"]",h);else sub(/:[0-9]*$/,"",h);printf "%s",h}')"
# fetch captive-detection url, curl appends '%{json}' metadata behind a unique
# marker - splitting on the first curly brace would break on any response body
@@ -900,9 +900,10 @@ f_net() {
${parse}
EOF
# extract lowercased host portion of the effective url
# extract lowercased host portion of the effective url, strip the port as
# the host ends up in the dnsmasq rebind allowlist
#
json_cp="$(printf "%s" "${json_cp_url}" | "${trm_awkcmd}" 'BEGIN{FS="/"}{printf "%s",tolower($3)}')"
json_cp="$(printf "%s" "${json_cp_url}" | "${trm_awkcmd}" 'BEGIN{FS="/"}{h=tolower($3);if(h~/^\[/)sub(/\].*$/,"]",h);else sub(/:[0-9]*$/,"",h);printf "%s",h}')"
if [ "${json_ec}" = "0" ]; then
# request ended up on a foreign host: captive portal at that host
@@ -935,6 +936,8 @@ f_net() {
if [ -n "${json_ed}" ] && [ "${json_ed}" != "${probe_host}" ]; then
result="net cp '${json_ed}'"
fi
elif [ -n "${json_cp}" ] && [ "${json_cp}" != "${probe_host}" ]; then
result="net cp '${json_cp}'"
fi
fi
fi