Author Topic: Tremulous Snapshots  (Read 6022 times)

Syntac

  • Posts: 841
  • Turrets: +118/-104
    • Syntac's Stuff
Tremulous Snapshots
« on: October 13, 2008, 01:02:15 am »
I've been thinking of writing a PHP script that takes a snapshot of the entire Tremulous "network" (not sure what you'd call it; every server and every player). It would go something like this:

1] Query the master server.
2] Using the list obtained from that, query each server for information like the current map, number of players, each player's status, etc.
3] Save the resulting massive quantity of data into some sort of database (probably multi-file).
4] Allow visitors to browse the snapshot archive.

Should be pretty easy. However, I don't know how to implement steps 1-2. Does anyone have any ideas?

Bissig

  • Posts: 1309
  • Turrets: +103/-131
Re: Tremulous Snapshots
« Reply #1 on: October 13, 2008, 01:10:15 am »
You mean something like the thing called "tremstats"?

http://tremstats.dasprids.de/

Syntac

  • Posts: 841
  • Turrets: +118/-104
    • Syntac's Stuff
Re: Tremulous Snapshots
« Reply #2 on: October 13, 2008, 01:17:52 am »
Not exactly. The idea behind this is to retrieve a list from the master server, then get information for each server on that list (without having access to its log files). Ideally, retrieving information from a server would work the same way the master does it.

Bissig

  • Posts: 1309
  • Turrets: +103/-131
Re: Tremulous Snapshots
« Reply #3 on: October 13, 2008, 01:19:01 am »
Too bad this one is not open source:

http://www.qtracker.com/

But this one:

http://www.linuxgames.com/xqf/index.shtml

is based on this:

http://www.qstat.org/

It is open source!

Syntac

  • Posts: 841
  • Turrets: +118/-104
    • Syntac's Stuff
Re: Tremulous Snapshots
« Reply #4 on: October 13, 2008, 01:48:28 am »
Thanks.

Although, all I really need is some sort of PHP code that sends and receives messages (and then parses the response into something recognizable). Do you know how I'd do that? For example, sending something via fsockopen(), to which a server would then respond with data?

I'm afraid you're going to be hearing a lot of questions from me, because I've never even attempted something like this before.

[EDIT] Ah... Found something that may be of use. http://tremulous.net/forum/index.php?topic=8750.0 Now I just need to know how to query the master server.
« Last Edit: October 13, 2008, 02:48:47 am by Syntac »

Undeference

  • Tremulous Developers
  • *
  • Posts: 1254
  • Turrets: +122/-45
Re: Tremulous Snapshots
« Reply #5 on: October 13, 2008, 03:44:21 am »
Now I just need to know how to query the master server.
send (to master.tremulous.net:30710)
Code: [Select]
\xff\xff\xff\xffgetservers <protocol> [keywords]
\xff\xff\xff\xffgetserversExt <gamename> [keywords]
protocol is 69 for old, 70 for new
keywords is optionally "empty" and/or "full" (and/or "ipv6")

receive
Code: [Select]
\xff\xff\xff\xffgetserversResponse\\addrport...EOT\0\0\0
\xff\xff\xff\xffgetserversExtResponse/addrport...EOT\0\0\0
addr is packed (4 (or 16) bytes), port is packed (2 bytes) -- in php, you should able to use inet_ntop(addr), unpack("n",port)
packet ends with EOT\0\0\0, more packets may follow

(the master doesn't currently support IPv6 and when it does, there's no guarantee that the Ext forms will work as mentioned)

e.g.,
Code: [Select]
c->s \xff\xff\xff\xffgetservers 70 full empty
s->c \xff\xff\xff\xffgetserversResponse\x5cT\x9dc\x85x\x00\x5cb\xc1\xe5\xc4x\x00\x5cEOT\x00\x00\x00
« Last Edit: October 13, 2008, 03:47:10 am by Undeference »
Need help? Ask intelligently. Please share solutions you find.

Thats what we need, helpful players, not more powerful admins.

Syntac

  • Posts: 841
  • Turrets: +118/-104
    • Syntac's Stuff
Re: Tremulous Snapshots
« Reply #6 on: October 13, 2008, 03:50:07 am »
Cool, thanks. I'll give that a try.

[EDIT] I definitely got a response. However, I have no idea how to turn it into something I can use. Does anyone have some code I could take a look at?

[EDIT#2] Working on it...

[EDIT#3] Woot, figured it out. Expect something called TremSnaps in the near future.
« Last Edit: October 13, 2008, 06:47:48 am by Syntac »

David

  • Spam Killer
  • *
  • Posts: 3543
  • Turrets: +249/-273
Re: Tremulous Snapshots
« Reply #7 on: October 13, 2008, 12:11:40 pm »
I already have C++ classes that do all this, including keeping a list in memory up-to-date and concurrent connections etc etc.
If you want I can slap a GPL sticker on it and upload it all someplace.
Also if you have any questions about the connectionless protocols feel free to ask me, I know that shit like the back of my hand.
Any maps not in the MG repo?  Email me or come to irc.freenode.net/#mg.
--
My words are mine and mine alone.  I can't speak for anyone else, and there is no one who can speak for me.  If I ever make a post that gives the opinions or positions of other users or groups, then they will be clearly labeled as such.
I'm disappointed that people's past actions have forced me to state what should be obvious.
I am not a dev.  Nothing I say counts for anything.

Syntac

  • Posts: 841
  • Turrets: +118/-104
    • Syntac's Stuff
Re: Tremulous Snapshots
« Reply #8 on: October 13, 2008, 03:46:51 pm »
If something weird happens with my code, I'll be sure to ask you. Not sure I'll need the C++ stuff, though. Thanks for offering!