In the last 12 years I have made lot of research about the protocols used by this infrastructure and you can find all my code here:
http://aluigi.org/papers.htm#distrust
The same Gamespy released an open source SDK in 2011:
http://zenhax.com/download/file.php?mode=view&id=2
Now this thread is dedicated to ALL the currently available solutions created by the community to emulate the Gamespy network.
It's difficult to find all these projects so feel free to add any resource of which you are aware.
Additionally hosting a public server is ever a big security risk and it's difficult to know what the security status of these projects.
OpenSpy (Masaq fork)
https://github.com/Masaq-/Openspy-Core
OpenSpy was the first project to emulate the GS network, it started as an online-only project and later its code was released publicly.
The old OpenSpy code is no longer supported from 2 years (afaik) and currently there is a fork maintained by Masaq that is fully active.
As far as I know it should support almost all the services.
Written in C++.
PowerServer
https://github.com/Poweruser/PowerServer
It supports only the master server part of the network and doesn't seem to support enctypeX.
Written in Java.
Project Reality MasterServer
https://github.com/AncientMan2002/PRMasterServer
Battlefield 2 only.
nwn2dev-public
https://github.com/SkywingvL/nwn2dev-public
Neverwinter Nights 2 only.
dwc_network_server_emulator
https://github.com/polaris-/dwc_network_server_emulator
DS and Wii games, I don't know what network protocols are supported, probably login and master server (enctypeX).
gs_login_server and peerchat_server
http://aluigi.altervista.org/papers.htm#distrust
They are only proof-of-concepts but they did the job to run the game in LAN without master server.
I remember that some people used them to play online with fake names and values
A third-party SQL fork is available on https://code.google.com/p/gsloginserver/
BF2DRevive
https://github.com/cokencorn/BF2DRevive
Battlefield 2 Demo Revive Project - GameSpy Profile and Master Server Emulation for Battlefield 2 Demo
---
Gamespy online substitutes.
Online-only servers (no code to use by yourself) that can be used by modifying the hosts file to change the DNS resolution.
OpenSpy
http://www.openspy.org
Qtracker
http://www.qtracker.com/master-gamespy.php
Master server and limited login support.
Epic Games Unreal Tournament 3
Epic Games have their own Gamespy replacement for UT3.
---
A quick explanation of the "enctype" words you have seen referred to the master server code:
- enctype 0: no encryption, used by old games probably before 2003
- enctype 1: used only by the Gamespy3D tool (who used that?!?)
- enctype 2: used by many games like Battlefield 2
- enctype X: used by the recent games
For example Halo1 was released in 2003 and used enctypeX while Battlefield 2 released in 2005 uses enctype 2.