This would be the second post in a series. You might want to read the first in the series if you haven’t already done so. Here, I continue with the work related to redirecting the game’s server traffic to my own website so that I can discover the interface.
I first install Dnsmasq on my MacBook, add a single entry to its
/etc/hosts file to redirect traffic for
m.agar.io to my MacBook’s private IP address. Starting up Dnsmasq I then have a DNS server which will redirect game traffic to my own website. Make sure that the program is running by entering
ps aux|grep dnsmasq|grep -v grep. You should see an entry for this program.
It’s probably a good idea to test your DNS server to verify that it returns the expected information.
> server myip
After entering the third line above you should see a DNS lookup which returns your server’s private IP address.
~/sites folder, I run the following command to use Express to generate a generic website:
express agar. As is usual for Express, I change into the newly-created agar directory and then run
npm install to bring in the dependencies. Since the default installation binds to an upper TCP port and we want the standard port 80 instead, I then edit the
bin/www file in this folder and replace the port number 3000 with 80 on a single line.
Note that Node.js, the underlying program that serves up an Express website, will not be able to bind to port 80 since it’s reserved unless I’m running as the root user. If your own user is setup to run the su command then you should be able to start this website with the command
su npm start in the
agar folder. Otherwise, you’ll have to run just
su to become the root user, navigate back into your user folder area to find this folder and then just run
npm start instead.
It’s probably a good idea to test the website by bringing up Safari and entering the address http://myip/ (substituting my private IP address) to see if it works.
Configuring the iPad
At this step, I’ll need to tell the iPad’s Wi-Fi configuration to use my own DNS server first and then the existing set of DNS servers next. You’ll find this under Settings -> Wi-Fi -> select the
i button next to your own connected Wi-Fi network -> DHCP -> DNS -> prepend your own server’s private IP address and a comma at the beginning of the list.
This is the initial preparation for redirecting the game traffic to your own website. Note that the Node.js website while running will write to its log file and this will be our method of discovering the interface for Agar.io.
By now attempting to play the Agar.io game on the iPad, it makes requests to what it thinks is the server. Only these requests are now being sent to my website instead. As each attempt is logged as a failure on my own website, I then make this call manually in another computer to the actual Agar.io website to see what it’s supposed to return.
For example, the game makes a request to the game server’s interface with just
/info as the URL.
As you can see, this is a fair bit of information. The format is known as json in case it’s not familiar to you. As of my writing this, there appear to be over 61,000 players in the game right now and well over 700 servers with almost half of those enabled. So this would be why it’s difficult to get a simultaneous FFA game with your friends—the odds are against you.
Without further ado, here are the other queries which I discovered.
This appears to be your issued server and port on the first line and what is likely its instance alias from whichever cloud-based company they’re using.
I know, not very impressive. But it appears to be the highest user ID for your issued server.
Another json response, this appears to also be issuing you a server and port. It’s possible that the first home query is asked at the beginning of the game and then /findServer is called each time your die in the game.
So far, this appears to be everything I’ve learned from this redirection technique.
At this point, I now have the game interface which the Agar.io app uses to communicate with the server. It likely makes more requests but that’s good for now. I could have enough to go on in order to work up something so that multiple iOS people could join the same FFA game, for example, since we know this issuing mechanism.