gamedig / node-gamedig

Query game servers and not only! Node.JS/Deno/Bun or Bash (via the CLI).
https://www.npmjs.com/package/gamedig
MIT License
606 stars 147 forks source link

bug: Post Scriptum query not working #421

Closed a-sync closed 10 months ago

a-sync commented 10 months ago

Describe the bug Attempting to query a post scriptum server return unexpected errors. (gamedig version 4.2.0)

Steps To Reproduce Example server: battlemetrics.com/servers/postscriptum/24677356 Host + port is 92.118.18.92:24000. Query port is 24001

Expected behavior Returning the server details and the player list.

Screenshots or Data expected to work like this:

$ gamedig --type ps --port 24000 --host 92.118.18.92 --debug

``` Error: Failed all 1 attempts at QueryRunner.run (C:\bin\nvm\v20.5.0\node_modules\gamedig\lib\QueryRunner.js:95:21) at async Gamedig.query (C:\bin\nvm\v20.5.0\node_modules\gamedig\lib\index.js:11:16) Attempt #1 - Port=24000 Retry=0: ReferenceError: type is not defined at ProtocolResolver.create (C:\bin\nvm\v20.5.0\node_modules\gamedig\lib\ProtocolResolver.js:16:89) at QueryRunner._attempt (C:\bin\nvm\v20.5.0\node_modules\gamedig\lib\QueryRunner.js:103:44) at QueryRunner.run (C:\bin\nvm\v20.5.0\node_modules\gamedig\lib\QueryRunner.js:87:39) at Gamedig.query (C:\bin\nvm\v20.5.0\node_modules\gamedig\lib\index.js:11:39) at Object. (C:\bin\nvm\v20.5.0\node_modules\gamedig\bin\gamedig.js:45:9) at Module._compile (node:internal/modules/cjs/loader:1233:14) at Module._extensions..js (node:internal/modules/cjs/loader:1287:10) at Module.load (node:internal/modules/cjs/loader:1091:32) at Module._load (node:internal/modules/cjs/loader:938:12) at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:83:12) ```

Additional context If i switch the type to squad (which has the same query protocol) it sort of works.

$ gamedig --type squad --port 24000 --host 92.118.18.92 --debug

``` Q#0 Starting Q#0 Protocol: Valve Q#0 Options: { socketTimeout: 2000, attemptTimeout: 10000, maxAttempts: 1, port: 24000, protocol: 'valve', requestRules: false, type: 'squad', host: '92.118.18.92', debug: true } Q#0 DNS Lookup: 92.118.18.92 Q#0 Raw IP Address: 92.118.18.92 Q#0 Requesting info ... 92.118.18.92:24000 UDP(61218)--> Buffer length: 25 bytes ff ff ff ff 54 53 6f 75 72 63 65 20 45 6e 67 69 6e 65 20 51 75 T S o u r c e E n g i n e Q u 65 72 79 00 e r y Q#0 UDP timeout detected Q#0 Query failed with error Error: UDP - Timed out after 2000ms at Timeout. (C:\bin\nvm\v20.5.0\node_modules\gamedig\lib\Promises.js:7:25) at listOnTimeout (node:internal/timers:573:17) at process.processTimers (node:internal/timers:514:7) Error: Failed all 1 attempts at QueryRunner.run (C:\bin\nvm\v20.5.0\node_modules\gamedig\lib\QueryRunner.js:95:21) at async Gamedig.query (C:\bin\nvm\v20.5.0\node_modules\gamedig\lib\index.js:11:16) Attempt #1 - Port=24000 Retry=0: Error: UDP - Timed out after 2000ms at Timeout. (C:\bin\nvm\v20.5.0\node_modules\gamedig\lib\Promises.js:7:25) at listOnTimeout (node:internal/timers:573:17) at process.processTimers (node:internal/timers:514:7) ```

Notice it only attempted to check the defined port and not port+1, even without --givenPortOnly flag. But if i define the query port it works with the exception of player numbers. (always returns 0)

$ gamedig --type squad --port 24001 --host 92.118.18.92 --debug

``` Q#0 Starting Q#0 Protocol: Valve Q#0 Options: { socketTimeout: 2000, attemptTimeout: 10000, maxAttempts: 1, port: 24001, protocol: 'valve', requestRules: false, type: 'squad', host: '92.118.18.92', debug: true } Q#0 DNS Lookup: 92.118.18.92 Q#0 Raw IP Address: 92.118.18.92 Q#0 Requesting info ... 92.118.18.92:24001 UDP(57127)--> Buffer length: 25 bytes ff ff ff ff 54 53 6f 75 72 63 65 20 45 6e 67 69 6e 65 20 51 75 T S o u r c e E n g i n e Q u 65 72 79 00 e r y 92.118.18.92:24001 <--UDP(57127) Buffer length: 9 bytes ff ff ff ff 41 2b a7 6f c9 A + o Q#0 Registered RTT: 133ms Q#0 Received full packet Q#0 Received 0x41 expected 0x49 Q#0 Received new challenge key: 0xc96fa72b Q#0 UDP send finished by callback 92.118.18.92:24001 UDP(57127)--> Buffer length: 29 bytes ff ff ff ff 54 53 6f 75 72 63 65 20 45 6e 67 69 6e 65 20 51 75 T S o u r c e E n g i n e Q u 65 72 79 00 2b a7 6f c9 e r y + o 92.118.18.92:24001 <--UDP(57127) Buffer length: 261 bytes ff ff ff ff 49 11 47 6c 6f 77 27 73 20 42 61 74 74 6c 65 67 72 I G l o w ' s B a t t l e g r 6f 75 6e 64 73 20 3a 3a 20 55 53 20 45 61 73 74 20 3a 3a 20 64 o u n d s : : U S E a s t : : d 69 73 63 6f 72 64 2e 67 67 2f 67 6c 6f 77 73 00 56 65 67 68 65 i s c o r d . g g / g l o w s V e g h e 6c 20 4f 66 66 65 6e 73 69 76 65 20 30 33 00 70 6f 73 74 73 63 l O f f e n s i v e 0 3 p o s t s c 72 69 70 74 75 6d 00 70 6f 73 74 73 63 72 69 70 74 75 6d 00 00 r i p t u m p o s t s c r i p t u m 00 00 50 00 64 77 00 00 33 2e 30 2e 38 35 2e 35 33 33 37 00 b1 P d w 3 . 0 . 8 5 . 5 3 3 7 c0 5d 03 5c f8 dd b3 60 40 01 42 55 49 4c 44 49 44 3a 30 2c 4f ] \ ` @ B U I L D I D : 0 , O 57 4e 49 4e 47 49 44 3a 39 30 31 37 38 33 31 38 31 38 36 38 36 W N I N G I D : 9 0 1 7 8 3 1 8 1 8 6 8 6 33 36 31 39 2c 4f 57 4e 49 4e 47 4e 41 4d 45 3a 47 6c 6f 77 27 3 6 1 9 , O W N I N G N A M E : G l o w ' 73 20 42 61 74 74 6c 65 67 72 6f 75 6e 64 73 20 3a 3a 20 55 53 s B a t t l e g r o u n d s : : U S 20 45 61 73 74 20 3a 3a 20 64 69 73 63 6f 72 64 2e 67 67 2f 67 E a s t : : d i s c o r d . g g / g 6c 6f 77 73 2c 53 45 53 53 49 4f 4e 46 4c 41 47 53 3a 31 37 31 l o w s , S E S S I O N F L A G S : 1 7 1 00 dc 3b 0b 00 00 00 00 00 ; Q#0 Registered RTT: 147ms Q#0 Received full packet Q#0 Received 0x49 expected 0x49 Q#0 UDP send finished by callback Q#0 INFO: { protocol: 17, folder: 'postscriptum', game: 'postscriptum', appId: 736220, numplayers: 0, numbots: 0, listentype: 'd', environment: 'w', secure: 0, version: '3.0.85.5337', steamid: '90178318186863619', tags: [ 'BUILDID:0', 'OWNINGID:90178318186863619', "OWNINGNAME:Glow's Battlegrounds :: US East :: discord.gg/glows", 'SESSIONFLAGS:171' ] } Q#0 Requesting player list ... 92.118.18.92:24001 UDP(57127)--> Buffer length: 9 bytes ff ff ff ff 55 2b a7 6f c9 U + o 92.118.18.92:24001 <--UDP(57127) Buffer length: 6 bytes ff ff ff ff 44 00 D Q#0 Registered RTT: 146ms Q#0 Received full packet Q#0 Received 0x44 expected 0x44 Q#0 UDP send finished by callback Q#0 Size of players array: 0 Q#0 Size of bots array: 0 Q#0 Query was successful { "name": "Glow's Battlegrounds :: US East :: discord.gg/glows", "map": "Veghel Offensive 03", "password": false, "raw": { "protocol": 17, "folder": "postscriptum", "game": "postscriptum", "appId": 736220, "numplayers": 0, "numbots": 0, "listentype": "d", "environment": "w", "secure": 0, "version": "3.0.85.5337", "steamid": "90178318186863619", "tags": [ "BUILDID:0", "OWNINGID:90178318186863619", "OWNINGNAME:Glow's Battlegrounds :: US East :: discord.gg/glows", "SESSIONFLAGS:171" ] }, "maxplayers": 80, "players": [], "bots": [], "connect": "92.118.18.92:24000", "ping": 133 } ```
CosminPerRam commented 10 months ago

Apparently Post Scriptum got its protocol changed multiple times from squad to valve and reversed over the years, on the last change the squad protocol was removed (had only some custom cleanups, the rest is already in valve protocol) and ps was left on the squad protocol. The easy fix here is to change the protocol to valve (I will make a release in the upcoming days), you can query it like this gamedig --type protocol-valve 92.118.18.92:24001.

But if i define the query port it works with the exception of player numbers.

Apparently the game responds with 0x00 on the players query, not sure if there is any other way to get them, will do separately.

CosminPerRam commented 10 months ago

Solved in the soon-to-be-released 4.3.0

darekrebellion commented 10 months ago

When can we expect this to be released?

CosminPerRam commented 10 months ago

As of writing, it is released! Link to 4.3.0 here.

darekrebellion commented 10 months ago

Thank you! When will the player querying be fixed?

CosminPerRam commented 10 months ago

Not sure of it, as I mentioned in my first comment the game doesn't seem to send any data for the players query, there could be other methods to get current online players but currently, we don't know of others.