Server Status Query Protocol?

NOTE: this is an informal bug post place ONLY. Real bugs should be posted on GitHub
Post Reply
beporter
Private
Private
Posts: 3
Joined: Sat Nov 12, 2005 9:16 pm

Server Status Query Protocol?

Post by beporter » Mon Nov 28, 2005 2:55 pm

This is a copy of a post in the Developers forum of the SF bzflag project. (It didn't seem to be attracting any attention over there so I thought I'd bring it up here as well. Please ignore the post in whichever place is less appropriate.)

----------------

I've been trying to put together a PHP script that queries my bzfag server for the purpose of displaying the server name, style, players connected, etc. I've started out by examining the example scripts that live in the misc/ directory of the bzflag distribution (bzfquery.php and bzfquery_example.php), but for one thing they appear to only work for PHP 5+ (I'd like a 4.x compatible version), and for another, even with a PHP5 enabled webserver, the script doesn't output anything sensible.

Just to save some time, I've already checked the all the usual configurations, that the correct IP is being used, etc.; the whole kit and caboodle. I *am* getting data back from bzfs, but it's totally unintelligible: it doesn't match the format that the example scripts seem to expect.

For example, after sending MsgQueryGame (0x7167) to the server, one is supposed to receive 46 bytes back in the form of 23 16-bit unsigned integers. The first three values are supposed to be the length of the packet, the response code, and server's "style" bitmask. However, the 3 shorts I am getting from my server are either {8, 26484, 4} (Big-Endian interpretation), or just for giggles {2048, 29799, 1024} (Little-Endian interpretation). Either way these numbers don't make sense. The packet length isn't 8 bytes *or* 2048 bytes.

What's really weird is that the perl script (bzfquery.pl) in the same misc/ folder also dies due to "invalid responses" from bzfs. This problem doesn't seem to be isolated to just the PHP scripts.

I've been pouring through the C++ source for bzfs trying to determine what exactly the server is returning to me, but I'm not familiar enough with the code to get anywhere.

What I'd really like is a protocol specification document that describes the data being returned from the server for the two messages: MsgQueryGame and MsgQueryPlayers (line 91 of protocol.h). Ideally I could use something along the same lines as this:

http://dev.kquery.com/index.php?article=31

Just what bytes belong to which field, etc. The existing documentation both here and in the bzflag.org wiki is woefully lacking for a project that seems as mature as this one.

I would greatly appreciate any help somebody familiar with the netcode for this project can provide, and I'd be more than happy to contribute my (working) scripts back to the project. (I also maintain the HL Who's Online package here on SF, and there's a good chance I'll end up incorporating a bzflag query class into that project as well.

For reference, the bzflag server is running at icabbit.csreloaded.com:5154 and is running v2.0.4.

beporter
Private
Private
Posts: 3
Joined: Sat Nov 12, 2005 9:16 pm

Post by beporter » Mon Nov 28, 2005 10:04 pm

Okay.... nobody develops for bzflag anymore, gotcha.

Well anyway, just to get somebody's juices going, take a look at this output from the Perl script included in the 2.0.4 distribution:

Code: Select all

[MacNally:/Library/WebServer/Documents/bz]% perl bzfquery.pl icabbit.csreloaded.com:5154
style:
maxPlayers: 1703
maxShots: 15690
team sizes: 13678 42 29031 250 10 2 (rogue red green blue purple observer)
max sizes:  0 0 0 0 0 0
max player score: 0
max team score: 5
max time: 0
time elapsed: 0.3

Died at bzfquery.pl line 122.
That quite clearly doesn't make sense. What's more, you can't even rearrange the values so that they do make sense. What the heck is the server sending me?!?

Here's my raw PHP script output:

Code: Select all

string(9) "BZFS0026"   <-- server response to tcp connection
string(46) "gt§	lè\*qgú
"    <-- server response to 0x7167

008076470040607a90c68ec500a2177600af00a0002000  <-- response as a hex string


Array   <-- response as a Big-Endian array of shorts (16-bit unsigned ints)
(
    [len] => 2048
    [co-de] => 29799
    [style] => 1024
    [maxPlayers] => 42758
    [maxShots] => 27657
    [rogueSize] => 23784
    [redSize] => 10752
    [greenSize] => 26481
    [blueSize] => 64000
    [purpleSize] => 2560
    [observerSize] => 512
    [rogueMax] => 0
    [redMax] => 0
    [greenMax] => 0
    [blueMax] => 0
    [purpleMax] => 0
    [observerMax] => 0
    [shakeWins] => 0
    [shakeTimeout] => 1280
    [maxPlayerScore] => 0
    [maxTeamScore] => 1280
    [maxTime] => 0
    [timeElapsed] => 768
)

Array   <-- response as a Little-Endian array of shorts (16-bit unsigned ints)
(
    [len] => 8
    [co-de] => 26484
    [style] => 4
    [maxPlayers] => 1703
    [maxShots] => 2412
    [rogueSize] => 59484
    [redSize] => 42
    [greenSize] => 29031
    [blueSize] => 250
    [purpleSize] => 10
    [observerSize] => 2
    [rogueMax] => 0
    [redMax] => 0
    [greenMax] => 0
    [blueMax] => 0
    [purpleMax] => 0
    [observerMax] => 0
    [shakeWins] => 0
    [shakeTimeout] => 5
    [maxPlayerScore] => 0
    [maxTeamScore] => 5
    [maxTime] => 0
    [timeElapsed] => 3
)
Obviously I'm not getting back what I'm supposed to be getting back-- in PHP and Perl!

Any ideas anyone?? :?

User avatar
RPG
Lieutenant, Junior Grade
Lieutenant, Junior Grade
Posts: 2015
Joined: Fri Sep 17, 2004 2:37 am
Location: Chicago, Illinois
Contact:

Post by RPG » Mon Nov 28, 2005 10:38 pm

Hmm, I wrote a PHP script that did what you're trying to do- extract player information from a server. I tried it today, and it only worked on some servers. One of the servers it worked on was bzflag0.gamesunited.de:5154. I'm guessing some servers are running the CVS version of BZFS, and CVS must have different code that responds to the query string. :gross:

Try querying bzflag0.gamesunited.de:5154.

beporter
Private
Private
Posts: 3
Joined: Sat Nov 12, 2005 9:16 pm

Post by beporter » Tue Nov 29, 2005 1:36 am

That's pretty odd that they would include scripts with the 2.0.4 release that couldn't query the version of bzfs in the same package. I sure would love to get one of the developer's input on this. :|

User avatar
The Red Baron
Sergeant First Class
Sergeant First Class
Posts: 987
Joined: Sat Dec 07, 2002 6:21 am
Contact:

Post by The Red Baron » Tue Nov 29, 2005 2:28 am

beporter - contact them via IRC irc.freenode.net #bzflag. That is where you will find the devs.
Beware! I'm going to clone myself and spread those clones all over the world!

Post Reply