mirror of
https://github.com/aclist/dztui.git
synced 2024-12-29 13:52:03 +01:00
Enforce Steam API
This commit is contained in:
parent
64eb4bff9d
commit
05af345a11
2 changed files with 66 additions and 9 deletions
17
changelog.md
17
changelog.md
|
@ -5,7 +5,22 @@
|
||||||
- Custom query API
|
- Custom query API
|
||||||
- Standardize dialogs
|
- Standardize dialogs
|
||||||
|
|
||||||
## [2.8.0-rc.2] 2022-10-11
|
## [2.8.0-rc.6] 2022-10-11
|
||||||
|
### Dropped
|
||||||
|
- Stop using BM for query ports
|
||||||
|
### Added
|
||||||
|
- Deprecation warning/enforced Steam API
|
||||||
|
|
||||||
|
## [2.8.0-rc.5] 2022-10-11
|
||||||
|
### Fixed
|
||||||
|
- Width of some popups on Steam Deck
|
||||||
|
|
||||||
|
## [2.8.0-rc.4] 2022-10-11
|
||||||
|
### Changed
|
||||||
|
- Abstract news urls
|
||||||
|
- Clarify dependency warning
|
||||||
|
|
||||||
|
## [2.8.0-rc.3] 2022-10-11
|
||||||
### Added
|
### Added
|
||||||
- Add forums link
|
- Add forums link
|
||||||
|
|
||||||
|
|
58
dzgui.sh
58
dzgui.sh
|
@ -1,7 +1,7 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
set -o pipefail
|
set -o pipefail
|
||||||
version=2.8.0-rc.5
|
version=2.8.0-rc.6
|
||||||
|
|
||||||
aid=221100
|
aid=221100
|
||||||
game="dayz"
|
game="dayz"
|
||||||
|
@ -93,7 +93,7 @@ init_items(){
|
||||||
#array order determines menu selector; this is destructive
|
#array order determines menu selector; this is destructive
|
||||||
items=(
|
items=(
|
||||||
"[Connect]"
|
"[Connect]"
|
||||||
" NEW: Server browser"
|
" Server browser"
|
||||||
" My servers"
|
" My servers"
|
||||||
" Quick connect to favorite server"
|
" Quick connect to favorite server"
|
||||||
"[Manage servers]"
|
"[Manage servers]"
|
||||||
|
@ -668,10 +668,11 @@ fetch_ip_metadata(){
|
||||||
test_steam_api(){
|
test_steam_api(){
|
||||||
local code=$(curl -ILs "https://api.steampowered.com/IGameServersService/GetServerList/v1/?filter=\appid\221100&limit=10&key=$steam_api" \
|
local code=$(curl -ILs "https://api.steampowered.com/IGameServersService/GetServerList/v1/?filter=\appid\221100&limit=10&key=$steam_api" \
|
||||||
| grep -E "^HTTP")
|
| grep -E "^HTTP")
|
||||||
[[ $code =~ 403 ]] && return 1
|
[[ $code =~ 403 ]] && echo 1
|
||||||
|
[[ $code =~ 200 ]] && echo 0
|
||||||
}
|
}
|
||||||
add_steam_api(){
|
add_steam_api(){
|
||||||
[[ ! $(test_steam_api) ]] && return 1
|
[[ $(test_steam_api) -eq 1 ]] && return 1
|
||||||
mv $config_file ${config_path}dztuirc.old
|
mv $config_file ${config_path}dztuirc.old
|
||||||
nr=$(awk '/steam_api=/ {print NR}' ${config_path}dztuirc.old)
|
nr=$(awk '/steam_api=/ {print NR}' ${config_path}dztuirc.old)
|
||||||
steam_api="steam_api=\"$steam_api\""
|
steam_api="steam_api=\"$steam_api\""
|
||||||
|
@ -685,7 +686,7 @@ check_steam_api(){
|
||||||
steam_api=$(zenity --entry --text="Key 'steam_api' not present in config file. Enter Steam API key:" --title="DZGUI" 2>/dev/null)
|
steam_api=$(zenity --entry --text="Key 'steam_api' not present in config file. Enter Steam API key:" --title="DZGUI" 2>/dev/null)
|
||||||
if [[ $? -eq 1 ]] ; then
|
if [[ $? -eq 1 ]] ; then
|
||||||
return
|
return
|
||||||
elif [[ ${#steam_api} -lt 32 ]] || [[ ! $(test_steam_api) ]]; then
|
elif [[ ${#steam_api} -lt 32 ]] || [[ $(test_steam_api) -eq 1 ]]; then
|
||||||
zenity --warning --title="DZGUI" --text="Check API key and try again." 2>/dev/null
|
zenity --warning --title="DZGUI" --text="Check API key and try again." 2>/dev/null
|
||||||
return 1
|
return 1
|
||||||
else
|
else
|
||||||
|
@ -847,10 +848,16 @@ delete_or_connect(){
|
||||||
else
|
else
|
||||||
#hotfix for bug #36
|
#hotfix for bug #36
|
||||||
local lookup_ip=$(echo "$sel" | awk -F%% '{print $1}')
|
local lookup_ip=$(echo "$sel" | awk -F%% '{print $1}')
|
||||||
local lookup_id="$(echo "$sel" | awk -F%% '{print $2}')"
|
local lookup_port=$(echo "$lookup_ip" | awk -F: '{print $2}')
|
||||||
local qport=$(echo "$response" | jq --arg id $lookup_id '.data[]|select(.id==$id).attributes.portQuery')
|
source $config_file
|
||||||
|
file=$(mktemp)
|
||||||
|
url="https://api.steampowered.com/IGameServersService/GetServerList/v1/?filter=\appid\221100\gameaddr\\$lookup_ip&key=$steam_api"
|
||||||
|
curl -Ls "$url" > $file
|
||||||
|
local qport_res=$(< $file jq -r --arg port $lookup_port '.response.servers[]|select(.gameport==($port|tonumber)).addr')
|
||||||
|
local qport=$(echo "$qport_res" | awk -F: '{print $2}')
|
||||||
qport_list="$lookup_ip%%$qport"
|
qport_list="$lookup_ip%%$qport"
|
||||||
connect "$sel" "ip"
|
echo "$response" > resp
|
||||||
|
connect "$qport_list" "ip"
|
||||||
|
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
@ -1628,6 +1635,40 @@ fetch_scmd_helper(){
|
||||||
[[ ! -f "$helpers_path/d.html" ]] && curl -Ls "$notify_url" > "$helpers_path/d.html"
|
[[ ! -f "$helpers_path/d.html" ]] && curl -Ls "$notify_url" > "$helpers_path/d.html"
|
||||||
[[ ! -f "$helpers_path/d.webp" ]] && curl -Ls "$notify_img_url" > "$helpers_path/d.webp"
|
[[ ! -f "$helpers_path/d.webp" ]] && curl -Ls "$notify_img_url" > "$helpers_path/d.webp"
|
||||||
}
|
}
|
||||||
|
deprecation_warning(){
|
||||||
|
warn(){
|
||||||
|
cat <<- HERE
|
||||||
|
IMPORTANT ANNOUNCEMENT
|
||||||
|
(Steam API key not found)
|
||||||
|
|
||||||
|
A Steam API key is now mandatory to run the app.
|
||||||
|
The BM API returns incorrect mod data on some servers
|
||||||
|
and cannot be relied upon for up to date information.
|
||||||
|
|
||||||
|
Going forward, we will only use the BM API as a convenience
|
||||||
|
function to manage server names and your favorite servers list,
|
||||||
|
and migrate to indexing servers on an IP basis.
|
||||||
|
|
||||||
|
This is a backend change. You can continue adding servers by ID,
|
||||||
|
but we will retrieve information from Valve instead, as we do for the
|
||||||
|
server browser and connect-by-ip methods.
|
||||||
|
|
||||||
|
Click [OK] to open the help page describing how to set up your key.
|
||||||
|
After you input a valid key, the app will resume.
|
||||||
|
HERE
|
||||||
|
}
|
||||||
|
if [[ -z $steam_api ]]; then
|
||||||
|
echo "100"
|
||||||
|
zenity --info --text="$(warn)"
|
||||||
|
key_setup_url="https://aclist.github.io/dzgui/dzgui.html#_api_key_server_ids"
|
||||||
|
browser "$key_setup_url" 2>/dev/null &
|
||||||
|
while true; do
|
||||||
|
if [[ $(check_steam_api) ]]; then
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
}
|
||||||
initial_setup(){
|
initial_setup(){
|
||||||
echo "# Initial setup"
|
echo "# Initial setup"
|
||||||
run_depcheck
|
run_depcheck
|
||||||
|
@ -1640,6 +1681,7 @@ initial_setup(){
|
||||||
run_varcheck
|
run_varcheck
|
||||||
init_items
|
init_items
|
||||||
setup
|
setup
|
||||||
|
deprecation_warning
|
||||||
echo "100"
|
echo "100"
|
||||||
}
|
}
|
||||||
main(){
|
main(){
|
||||||
|
|
Loading…
Reference in a new issue