Here's a thread about a Python master server and the code.
http://www.torquepowered.com/community/ ... view/14666
I'll also post the code files on my little archive.Python Master Server
by Andy Rollins · 04/28/2008 (4:55 am) · 53 comments
Download Code File
When a game client wants to connect to a game server it can scan the network to look for servers on a particular port, this is quite an effective solution when on a small network such as a Home/Office LAN but consider trying to scan the entire Internet looking for a game server, you'd be there for quite some time!!
Instead we employ a Master Server which is hosted at a fixed known address, for example the standard Garagegames master server used in the Starter FPS can be found at master.garagegames.com on port 28002. As each game server starts up it registers itself with the master server which then maintains a list of known servers, when a game client wishes to connect it requests the list of available servers from the master server.
The basic process flow for game servers is:
1. Game server sends a heartbeat to the master server to register itself (packet type 22)
2. Master server sends an Info Request (packet type 10) to the game server requesting more information i.e. game type, mission, number of players, number of bots, etc.
3. Game server Responds with info data and is added to the list of available servers. (packet type 12)
4. Master server drops server from it's list if it hasn't had a heartbeat in about 180 seconds.
5. About every 180 seconds game server sends another heartbeat and the process starts from step 1.
The basic flow for game clients is:
1. Game client sends a list request to the master server (packet type:6)
2. Master server responds with the list of available servers (packet type:8)
3. Game client then pings the game server
4. game server responds to ping request
5. Game client sends request for information to game server
6. Game server responds to information request.
7. The list of available game servers appears in the GUI (see script joinServerGui.gui in the starter.fps)
Ideally the master server filters the results based on game type, mission, num players, etc before responding to the client in step 2 - this is currently not implemented in this version of the master server although I do store all the data so you could easily add a function to do it.
I've tested this version using Python 2.5 and both TGE 1.5.2 and TGEA 1.7 so you should have any problems with those versions, to use it you should just edit the Configuration section at the top of the Masterserver.py and set the port to whichever number you require.
Then in your game edit the server\defaults.cs file where you should see a line that looks like:
view plainprint?
$pref::Master0 = "2:master.garagegames.com:28002";
to point at your master server (remember to alter the port number to also match the one you set in the masterserver.py file. Examples:
view plainprint?
using the local machine i.e. your own pc/laptop:
$pref::Master0 = "2:localhost:28002";
or via IP address:
$pref::Master0 = "2:192.168.0.200:28666";
or even an external site:
$pref::Master0 = "2:my_cool_domain.com:27531";
Note the "2:" before the hostname/ip address needs to be there it's an old thing from tribes and the engine expects it to be there.
I've been coding Python for the sum total of 4 days now so there are no doubt bugs within the code, let me know if/as you find them and I'll endeavour to update the resource with any fixes or improvements that people come up with.
Please feel free to use the code however you wish without restriction, although it would be nice to receive some credit if you do use it.
The download has a master server and shutdown server file in Python. I don't know anything about it, but there it is.