querying master server

Everything that has to do with coding, designs and graphics.
Post Reply
User avatar
stevomitric
Posts: 52
Joined: Mon Apr 01, 2013 6:35 pm
Location: Bosnia And Herzegovina ( bosna i hercegovina ( BIH ))

querying master server

Post by stevomitric » Thu Jan 08, 2015 12:53 am

Well, like the topic says, i wont to query master server (client -> master Server ) to get server list.

So far i've been good. Sent request and received one. ( received server list ).
I saw you made the similar program in JAVA but since i'm not very good fan of JAVA can you just show me in 'English' =)

So lets get down to my problem. When i receive data, its in unknown format. Basically its like this:

Code: Select all

"\xff\xff\xff\xffgetserversResponse\\\xd8V\x9b\xads\xec\\B\xa0\xb3\xd4\x85A\\\xd8V\x9b\xa0mj\\B\xa0\xb3\x18\x86i\\\xb09\x8f-mO\\B\xa0\xb3\x17\x8d\x16\\\xd8\xe7\x84sn\x1c\\B\xa0\xb3\x17\x94:\\\xb9\x0e\x1e\xe1y \\\xd8V\x9b\xaaq\x99\\\xb9\x0e\x1e\xe1u5\\X\xd6\xe6\x8dm=\\\xd8V\x9b\xabn\xfb\\\xd8V\x9b\xa6n\xc6\\\xd8V\x9b\xa8u\x19\\Q\x04d\xd7ix\\S\xf3I\xdcm8\\6\xe3\xbc\xcam8\\\xd8\xe7\x84oo\xb2\\\xd8V\x9b\xadmo\\\x1f\x06F\xa5m;\\B\x96y\x80'\x10\\\xb0\t\x1e\x05m8\\\xb9\x0e\x1e\xe1}c\\\xb9\x0e\x1e\xe1\x84\xe8\\k\xb5\xaeZ}\x12\\l=z\x19m:\\k\xb5\xaeZ\x80\xfe\\\x18\xbb\x16lh,\\U\xd6p\x97m8\\B\x96y\x80U\xf0\\k\xb5\xaeZ\x84\xd3\\m\xe6\xe6\x0fa\xa8\\\xb9\x0e\x1e\xe1\x80\xfd\\\x05\x87\xb4\xb4m;\\k\xb5\xaeZy\x1a\\\xd0.\xbc\xd4\xe8]\\VR\xcd\xf2n\x99\\Q\x00\xce\xf4m:\\\xbc\x8a0jm9\\D\xe8\xb8@m8\\ST\xbe\xa4m9\\M\xef\xe1M\x94K\\\xd4\xbb\xd1{m=\\N\x8a\x87\rm8\\\xb0w'lmA\\Xj\xa1\x11m:\\O\x8ejcm8\\\xb09\x8f-mA\\\xc6\x00*=m8\\\xd9\xa3\x17\xcdm:\\V9\x89\x19m8\\\xc2a\xa5\x8cm8\\\x1f\x06F\xa5m8\\\x17\xfe\x81\xccqI\\X\xd6\xe6wm9\\Xj\xa1\x11m8\\\xc3z\x87\xd5m8\\\x05\x87\xb4\xb4m6\\X\xc6\xddcm8\\\xcb\x1a^\x80m8\\V,\xa8;m9\\J[z\x19m8\\\xb09\x8f-mP\\P=\x80\xd3n\x99\\l=\xc0nqI\\l=z\xf7m8\\\xad<%\xb0m8\\\xad\xff\xcb,m@\\\xb09\x8f-mB\\\xb91\x0c\xe4m;\\\xd9\xac\xbc\x0fm:\\.\xe4\xc9\x03m8\\\xd0.\xbc\xd4EW\\\xbc(G\xd5m8\\\xc9\xb0\xa5\x0em8\\\xb91\x0c\xe4m\x1d\\S\xf3I\xdcm9\\\x18\xa6\xdc\xa8\xef\\\\\xb2|\xb0Jm8\\\x08\x02y\xafm8\\G13\xa3m9\\ST\xbe\xa4m8\\_U\x15cm8\\>\x9c\xa3_m8\\\x18\xa6\xdc\xa8\xef\xd0\\%\x80\x92\xddm9\\%\x9d\xc4BmV\\X\xc6\xddcm=\\g\x04\x12\x9bm8\\\x05\x87\xb4\xb4m:\\O\xa5\xbd\x16m8\\\x05'^\xbcm8\\\xbc\x8a0jm:\\\xd4*&Xm?\\%\x9d\xc4Bm8\\mF\x94\x18m8\\M\xef\xe1M\x94H\\\x18\xa6\xdc\xa8\xf0G\\EOT"


I get few packets like this one.

If my code will help, here it is (in Python):

Code: Select all

>>> ================================ RESTART ================================
>>> import socket
>>> sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
>>> sock.settimeout(3)
>>> server = ('master.quake3arena.com',27950)
>>> sock.connect(server)
>>> data_to_send = '\xff\xff\xff\xffgetservers 68 "empty"'
>>> sock.sendto(data_to_send, server)
25
>>> received_data, address = sock.recvfrom(7000)
>>> received_data
"\xff\xff\xff\xffgetserversResponse\\\x95\xd2\xac\x9am8\\\x02e|\x8em9\\%\x99\x01,m9\\l=\xff\x17m8\\l=\xfe\x86m8\\^\xbe\xb3\xd2m8\\h!+\x0em9\\V9\x89\x19m9\\\xbcM\x9a+m9\\l=\xb3;qI\\\xc1\xf3\xae1m8\\\x18\xa6\xdc\xa8\xf1s\\\x8e\xa7\\\xfdm9\\^\xbe\xb3\xd2m9\\X\xd6\xe6wm8\\\x05\x87\xb4\xb4m9\\\xd0.\xbc\xd4.\xd3\\\xd4*&Xm;\\\xd9\xac\xbc\x0fm9\\\xa7Xuym8\\\xb91\x0c\xe4mG\\U\x83\xa3\xc4m8\\%\x9d\xc4Bm.\\\xad\xa0\x7fJm9\\\xb09\x8f-mM\\`'\xe0\xe2m8\\%\xbbnnm8\\>\x95\xc5\x9fm8\\\xb91\x0c\xe4m=\\%\x80\x92\xddm8\\\xbczX\xc5m8\\\x18\xabDCm8\\\xb2\x04\xef\xcbm8\\\xb9\x0e\xb8\x9fmL\\T\xc9\x01>m8\\\x05'^\xbcm9\\D\xe8\xb3\xc1m8\\\xbe\xd75\xf4m=\\\xbc\x8a0jm;\\\xd4*&Xm<\\ST\xbe\xa4m;\\M\xef\xe1M\x94I\\\xb9\x0e\x1e\xe1\x88\xbc\\\xa7Xu\x1em8\\\xd0\xa7\xf3Bm8\\N\x8a\x87\rm:\\\xbe\xa2\xca$m8\\\x95\xd2\xac\x9am9\\%\x99\x01,m8\\Q\xea\x04\xfdm8\\.\xe4\xc9\xc4m8\\\xd4*&XmA\\h!+\x0em8\\X\xd6\xe6\x8dm<\\6\xe3\xbc\xcam9\\\xbcM\x9a+m8\\W\xe5x\xdcm^\\\xb91\x0c\xe4m8\\h\x94\xb1qm8\\S\x1a\xb0\xc5m9\\\x96e\xacCm8\\\x18\xa6\xdc\xa8\xf1z\\l=\xc0nq-\\\xad\xc7S\x8bm8\\R\xc7\x9b9m8\\\xbc\x1a~,m8\\\x05\x87\xb4\xb4m8\\\xd9L\xb7Jm8\\\xc8V=|m8\\%\x9d\xc4BmB\\\xbc\x8a0jm8\\M\xef\xe1M\x94J\\l=\xc0nqG\\N\x8a\x87\rm9\\\xd5\xa3@sm8\\\x1f\xdf\x00\xb3b\xd4\\\xd4*&Xm8\\\xd9\xac\xbc\x0fm8\\k\xb5\xaeZ\x88\xbb\\\xb2\x19\xe7\x1dm8\\k\xb5\xaeZu7\\\x02e|\x8em8\\R\xe4\x9f[m9\\\xbcM\x9a+m:\\\\\xde\t\x19m:\\\x1f\x06F\xa5m>\\.\x95\xb0\xedm8\\l=\xb3;q-\\A;\xbd\xc6m8\\Wb\x89\xcfm8\\\x05\x87\xb4\xb4m7\\\x18\xabDCm9\\;\xa7\xf18m8\\X\xc6\xddcm?\\\xbei\xbe\x08m8\\\x17\\C\x10m8\\\xd4*&Xm=\\ST\xbe\xa4m:\\%\x9d\xc4BmL\\EOT"
>>> 

hmm. ?

Image

User avatar
Mitch
Site Admin
Posts: 192
Joined: Sat Mar 02, 2013 10:45 pm

Re: querying master server

Post by Mitch » Sat Jan 10, 2015 10:01 pm

You can skip the first 24 bytes. (ÿÿÿÿgetserversResponse\) and the last 4 (/EOT or /EOF).
Between these bytes you can read each 7 bytes like this: / (1 byte) ip (4 bytes) port (2 bytes)
You might need to convert the port value to big endian.

Code: Select all

// skip ÿÿÿÿgetserversResponse and /EOT
for (int j = 24; j < data.length - 4; j += 7) { // parse each 7 bytes / (1) ip(4) port(2)
	byte[] ip = new byte[4];
	byte[] port = new byte[2];

	System.arraycopy(data, j + 1, ip, 0, 4);
	System.arraycopy(data, j + 5, port, 0, 2);

	InetAddress addr = InetAddress.getByAddress(ip);
	int p = (port[0] << 8) + port[1];
	Server s = new Server(addr.getHostAddress(), p);
}
Image

Post Reply