diff options
author | Dirk Brenken <dev@brenken.org> | 2022-07-17 13:12:21 +0200 |
---|---|---|
committer | Dirk Brenken <dev@brenken.org> | 2022-07-17 13:14:05 +0200 |
commit | 3ae7a46b822967f728da6164558f181a0700eff5 (patch) | |
tree | d9dd0190115ee3cad4918c449e17c7cb4370db3b /net/travelmate/files/travelmate.sh | |
parent | 736117d2d2775a1c68607f52806b8f6df955fb18 (diff) |
travelmate: update 2.0.9-2
* fix another vpn corner case
* add support for javascript based captive portals (location.href)
Signed-off-by: Dirk Brenken <dev@brenken.org>
Diffstat (limited to 'net/travelmate/files/travelmate.sh')
-rwxr-xr-x | net/travelmate/files/travelmate.sh | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/net/travelmate/files/travelmate.sh b/net/travelmate/files/travelmate.sh index 17cb27a0d..c1b52fd80 100755 --- a/net/travelmate/files/travelmate.sh +++ b/net/travelmate/files/travelmate.sh @@ -213,10 +213,10 @@ f_vpn() { fi done fi - if [ -x "${trm_vpnpgm}" ] && [ -n "${vpn_service}" ] && [ -n "${vpn_iface}" ] && [ -f "${trm_ntpfile}" ]; then + if [ -x "${trm_vpnpgm}" ] && [ -n "${vpn_service}" ] && [ -n "${vpn_iface}" ]; then if { [ "${vpn_action}" = "disable" ] && [ -f "${trm_vpnfile}" ]; } || - { [ "${vpn}" = "1" ] && [ "${vpn_action%_*}" = "enable" ] && [ ! -f "${trm_vpnfile}" ]; } || - { [ "${vpn}" != "1" ] && [ "${vpn_action%_*}" = "enable" ] && [ -f "${trm_vpnfile}" ]; }; then + { [ -f "${trm_ntpfile}" ] && { [ "${vpn}" = "1" ] && [ "${vpn_action%_*}" = "enable" ] && [ ! -f "${trm_vpnfile}" ]; } || + { [ "${vpn}" != "1" ] && [ "${vpn_action%_*}" = "enable" ] && [ -f "${trm_vpnfile}" ]; }; }; then result="$(f_net)" if [ "${result}" = "net ok" ] || [ "${vpn_action}" = "disable" ]; then f_log "info" "vpn call '${vpn:-"0"}/${vpn_action}/${vpn_service}/${vpn_iface}'" @@ -224,11 +224,6 @@ f_vpn() { rc="${?}" fi fi - if [ "${vpn}" = "1" ] && [ "${vpn_action%_*}" = "enable" ] && [ "${rc}" = "0" ]; then - : >"${trm_vpnfile}" - elif [ "${vpn}" != "1" ] || [ "${vpn_action}" = "disable" ]; then - rm -f "${trm_vpnfile}" - fi [ -n "${rc}" ] && f_jsnup fi f_log "debug" "f_vpn ::: enabled: ${vpn:-"-"}, action: ${vpn_action}, service: ${vpn_service:-"-"}, iface: ${vpn_iface:-"-"}, rc: ${rc:-"-"}" @@ -519,7 +514,7 @@ f_addsta() { # check net status # f_net() { - local err_msg raw html_raw html_cp json_raw json_ec json_rc json_cp json_ed result="net nok" + local err_msg raw json_raw html_raw html_cp js_cp json_ec json_rc json_cp json_ed result="net nok" raw="$(${trm_fetch} --user-agent "${trm_useragent}" --referer "http://www.example.com" --header "Cache-Control: no-cache, no-store, must-revalidate, max-age=0" --write-out "%{json}" --silent --max-time $((trm_maxwait / 6)) "${trm_captiveurl}")" json_raw="${raw#*\{}" @@ -534,8 +529,11 @@ f_net() { else if [ "${json_rc}" = "200" ] || [ "${json_rc}" = "204" ]; then html_cp="$(printf "%s" "${html_raw}" | awk 'match(tolower($0),/^.*<meta[ \t]+http-equiv=['\''"]*refresh.*[ \t;]url=/){print substr(tolower($0),RLENGTH+1)}' | awk 'BEGIN{FS="[:/]"}{printf "%s",$4;exit}')" + js_cp="$(printf "%s" "${html_raw}" | awk 'match(tolower($0),/^.*location\.href=['\''"]*/){print substr(tolower($0),RLENGTH+1)}' | awk 'BEGIN{FS="[:/]"}{printf "%s",$4;exit}')" if [ -n "${html_cp}" ]; then result="net cp '${html_cp}'" + elif [ -n "${js_cp}" ]; then + result="net cp '${js_cp}'" else result="net ok" fi @@ -556,7 +554,7 @@ f_net() { fi fi printf "%s" "${result}" - f_log "debug" "f_net ::: fetch: ${trm_fetch}, timeout: $((trm_maxwait / 6)), cp (json/html): ${json_cp:-"-"}/${html_cp:-"-"}, result: ${result}, error (rc/msg): ${json_ec}/${err_msg:-"-"}, url: ${trm_captiveurl}, user_agent: ${trm_useragent}" + f_log "debug" "f_net ::: fetch: ${trm_fetch}, timeout: $((trm_maxwait / 6)), cp (json/html/js): ${json_cp:-"-"}/${html_cp:-"-"}/${js_cp:-"-"}, result: ${result}, error (rc/msg): ${json_ec}/${err_msg:-"-"}, url: ${trm_captiveurl}, user_agent: ${trm_useragent}" } # check interface status @@ -642,12 +640,14 @@ f_check() { fi fi fi - if [ "${trm_netcheck}" = "1" ] && [ "${result}" = "net nok" ]; then - f_log "info" "uplink has no internet" + if [ "${result}" = "net nok" ]; then f_vpn "disable" - trm_ifstatus="${status}" - f_jsnup - break + if [ "${trm_netcheck}" = "1" ]; then + f_log "info" "uplink has no internet" + trm_ifstatus="${status}" + f_jsnup + break + fi fi trm_connection="${result:-"-"}/${trm_ifquality}" f_jsnup |