1
0
Fork 0
mirror of https://github.com/aclist/dztui.git synced 2024-12-27 21:02:36 +01:00

fix: fallback logic for network traversal (#128)

This commit is contained in:
aclist 2024-09-13 11:42:47 +09:00
parent 523ff2c32d
commit 3e1170ffd8
3 changed files with 44 additions and 4 deletions

View file

@ -1,8 +1,12 @@
# Changelog
## [5.4.1-beta.2] 2024-09-12
### Fixed
- Use fallback logic for modlist queries when user traverses networks
## [5.4.1-beta.2] 2024-09-10
### Fixed
- Checkbox toggle signal handling control flow
- Fix signal handling control flow for checkbox toggles
## [5.4.1-beta.1] 2024-09-10
### Added

View file

@ -1,7 +1,7 @@
#!/usr/bin/env bash
set -o pipefail
version=5.4.1-beta.1
version=5.4.1-beta.3
#CONSTANTS
aid=221100
@ -569,7 +569,7 @@ fetch_helpers_by_sum(){
["ui.py"]="9cac4d3b87ef292e7d30b25ca86cc438"
["query_v2.py"]="55d339ba02512ac69de288eb3be41067"
["vdf2json.py"]="2f49f6f5d3af919bebaab2e9c220f397"
["funcs"]="b73289e0aa71a91da539c28707a6405c"
["funcs"]="4a06a823b6240c518687d2a8ec20e914"
["lan"]="c62e84ddd1457b71a85ad21da662b9af"
)
local author="aclist"

View file

@ -285,7 +285,15 @@ a2s(){
local qport="$2"
local mode="$3"
logger INFO "Querying '$ip:$qport' with mode '$mode'"
python3 "$query_helper" "$ip" "$qport" "$mode"
local res
res=$(python3 "$query_helper" "$ip" "$qport" "$mode")
if [[ $? -eq 1 ]]; then
res=$(try_fallback "$ip" "$qport" "$mode")
if [[ $? -eq 1 ]]; then
return 1
fi
fi
printf "%s\n" "$res"
}
is_in_favs(){
shift
@ -1064,6 +1072,34 @@ update_symlinks(){
legacy_symlinks
symlinks
}
try_fallback(){
local ip="$1"
local qport="$2"
local mode="$3"
if [[ $mode != "rules" ]] && [[ $mode != "names" ]]; then
return 1
fi
[[ -z $api_key ]] && return 1
local res=$(curl -s "$bm_api" -H "Authorization: Bearer "$api_key"" \
-G -d "filter[game]=$game" \
-d "filter[search]=%22${ip}:${qport}%22")
[[ -z $res ]] && return 1
local len=$(<<< "$res" jq '.data|length')
[[ $len -eq 0 ]] && return 1
local record=$(<<< "$res" jq -r '
.data[].attributes
|select(.status != "removed").details')
case "$mode" in
"rules")
<<< "$record" jq '.modIds[]'
;;
"names")
<<< "$record" jq '
[.modNames, .modIds] as [$n, $i]
| {names: $n, ids: $i}'
;;
esac
}
try_connect(){
local record="$1"
local ip=$(<<< $record awk -F: '{print $1}')