Giving all players routable IP addresses
A few months ago, my partner and I purchased Chron X, the original online collectible card game. It was first written in 1995-1997, and brought a lot of ideas to the table which were later implemented by Magic the Gathering Online, and other collectible card games.
We’re working to make a new version of the game, that’s web-based, free to play, and easier for anyone.. But until it’s done, we had the question of “How to we keep the old game going long enough to transition?”
One of the key problems with the old game is that games are peer to peer. While the game server authenticates users, the actual card battles have one client connect directly to the other, and play directly.
This worked out well in 1997, in the age of dialup and open ports, but today almost everyone has a firewall, either in software or as a Linksys router.. They just can’t get through to play, and the popularity has taken a corresponding hit. We’re excited to work toward the new web version, but until we do, we want to help the player base grow, which means we needed to slay the firewall demon.
I had started looking into Hamachi, which creates a direct machine to machine VPN, and lets users connect to one another. Sounds pretty decent… The problem is, it’s free for up to 16 users, but after that, users would need to pay $5/month, just to be able to connect… Given that they’d be paying a monthly fee, and we wouldn’t even see it, that’s a pretty big negative. The second problem is that since it puts everyone on a VPN, BOTH players would need to have it installed to play, not just the player behind a firewall.
Instead, I put together a hack that I’m rather proud of.. I hacked together OpenVPN to put together a quick click-and-run installer, which creates a VPN into our servers.. Unlike the Hamachi VPN, however, our VPN assigns each user a public, routable, IP address, on the outside world, such as 72.10.x.y.z.
Then, we set their default gateway to go through the VPN, and block all ports except for our game.
What this does is give them a public, routable, real IP address, which can only be used for contacting other Chron X clients.
What I really like about this solution is that it’s expandable to any other game system.. If you wanted to run a Diablo 2 tunnel, it’d be just a few configuration changes to open up those ports, and bam, it’d just work.
Players each have a public ip and can play against each other, and we get keep the old client workable for a while longer, while we get more done on Chron X 2.
I just enjoyed this hack 😉