Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a special handling for fs_manifest key-value pair #117

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

ostrosablin
Copy link

Some servers return fs_manifest key-value pair, which has it's value
split by newline, followed by a space. qstat breaks on such servers (at
least, it can't fetch the rules and players, because it treats newline
as beginning of player data, an unexpected data causes qstat to break
with error).

One such example is server run by my colleague, at 52.59.239.15:57131

Raw data from socket:

b'\xff\xff\xff\xffstatusResponse\n\\fs_cdn\\84.252.132.60:9000\\dmflags\\0\\fraglimit\\25\\timelimit\\15\\g_gametype\\4\\sv_privateClients\\0\\sv_hostname\\The Quake CTF (VQ3)\\sv_maxclients\\24\\sv_minRate\\0\\sv_maxRate\\30000\\sv_dlRate\\2000\\sv_minPing\\0\\sv_maxPing\\0\\sv_floodProtect\\0\\sv_allowDownload\\1\\sv_dlURL\\http://84.252.132.60:8000\\g_maxGameClients\\0\\sv_fps\\30\\server_gameplay\\VQ3\\version\\ioq3 1.36 linux-x86_64 Apr 23 2021\\com_gamename\\Quake3Arena\\com_protocol\\71\\mapname\\q3wcp18\\fs_manifest\\baseq3/pak100.pk3@2388798635@16506992\n baseq3/pak101.pk3@2206768903@2657563\n baseq3/pak102.pk3@2076841188@3024290\n baseq3/q3wcp18.pk3@2233822267@7704683\n cpma/z-cpma-pak152.pk3@3054920672@8135165\n linuxq3ademo-1.11-6.x86.gz.sh@857908472@49289300\n linuxq3apoint-1.32b-3.x86.run@296843703@30923961\n \\game\\CPMA\\gamename\\cpma\\gamedate\\Apr 03 2019\\gameversion\\1.52\\sv_arenas\\1\\Score_Time\\Warmup\\Score_Red\\0\\Score_Blue\\0\\Players_Blue\\1 \\GTV_CN\\1\\g_needpass\\0\\mode_current\\PUBCTF\n0 34 "UltraBloxX"\n'

Example of qstat run:

qstat -P -q3s 52.59.239.15:57131
ADDRESS           PLAYERS      MAP   RESPONSE TIME    NAME
52.59.239.15:57131    ERROR < baseq3/pak101.pk3@2206768903@2657563>

Following patch implements special handling for fs_manifest key, that ignores newline as a separator, while keeping all other parsing intact, so it fixes qstat to handle this server correctly, while it shouldn't break anything else.

Some servers return fs_manifest key-value pair, which has it's value
split by newline, followed by a space. qstat breaks on such servers (at
least, it can't fetch the rules and players, because it treats newline
as beginning of player data, an unexpected data causes qstat to break
with error).

Following patch makes special handling for fs_manifest key, that doesn't
treat newline as a separator, while keeping all other parsing intact.

Signed-off-by: Vitaly Ostrosablin <[email protected]>
@ostrosablin
Copy link
Author

This key-value pair (fs_manifest) seems to be related to QuakeJS (Emscripten support related). If I understand correctly, it contains list of maps and resources that QuakeJS web clients need to download to be able to join game. That's why it's subvalues are separated by newline + space.

It's defined here in upstream ioquake code

https://github.com/ioquake/ioq3/blob/4f7d7bf2159aa0a18b79bb417aa760abac817b2a/code/qcommon/files.c#L261

Related to commit 4f70920, allowing multiline rule values from server
cause JSON output mode to produce illegal JSON with unescaped newlines.
This commit enables json_escape function to properly escape such values,
translating newlines to \n.

Signed-off-by: Vitaly Ostrosablin <[email protected]>
@ostrosablin
Copy link
Author

I've also corrected display_json.c (function json_escape) to properly escape newlines because otherwise JSON would be invalid and useless for further processing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant