Closed maplepy closed 2 years ago
I'm glad it helped you.
Short answer: I made you a small helper script for now. I think this is the functionality you are looking for (query by static IP, add server into your whitelist).
Longer answer: (proper searching) is a limitation of the current API being used, which does not let you query directly by IP or name. While it is possible to fetch the entire list of servers, and "browse" them, it exceeds 60 pages, so the request would get rate limited. I would like to eventually add a more full-featured custom query API to fetch info from servers directly. It would also add to the number of files necessary to run/install this, so it couldn't be packaged as a standalone file.
For now, I have a simple hack for you. WARNING: it contains absolutely no error handling. It will make a backup of your current dztui script; in case anything goes wrong, you can revert it.
Place this script adjacent to your dztui file and run it. Then, simply enter the full IP with port as
Once you test it for me a bit, I could definitely build this up into a function and put it in the main script with additional error handling if there is a need for adding servers by IP into your list on the fly, but it's more of a workaround, since we are just crawling the top page of the site with a plaintext query. Maybe it could be added into the table as a│add server by IP
.
#!/bin/bash
file=dztui.bk
newfile=dztui
old_whitelist(){
awk -F\" '/whitelist=/ {print $2}' $file
}
fetch_id(){
encode=$(echo $input | sed 's/:/%3A/')
url="https://www.battlemetrics.com/servers/search?q=%22$encode%22&game=dayz"
temp=$(mktemp)
curl -Ls "$url" > $temp
id=$(awk -F"<a title=" '{print $2}' $temp | awk -F\" '{print $4}' | awk -F/ '{print $4}' | awk 'NF')
name=$(awk -F"<a title=" '{print $2}' $temp | awk -F\" '{print $2}' | awk 'NF')
}
main(){
fetch_id
printf "[INFO] Fetching ID...\n"
printf "[INFO] Added $id, $name\n"
awk -v old=$(old_whitelist) -v new=$id 'NR==14 {$0= sprintf("whitelist=\"%s,%s\"", old,new)}1' $file > $newfile
chmod +x $newfile
}
mv $newfile $file
read -p "Enter IP as <IP:port> " input
main
"Add server by ID" is now supported in the DZGUI branch: https://github.com/aclist/dztui/tree/dzgui
This is now live on the stable branch.
Hey!
Love the project so far but whenever I need to connect to a friend, I'll ask him for the ip since you can't really connect to him with steam directly as you won't get the mods. So what I have been doing is to modify the script every time to put the server id after looking up the ip or the name he told me.
Is there a way to fetch the server directly with a name or an ip and maybe get the mods and connect to it? That'd be very nice :)
Thank you