★ Maverick Posted June 7, 2010 Report Posted June 7, 2010 (edited) Hello, For the upcoming new statistics website I want to create a directory client in PHP. I already have a directory client in Java but running a java program from a PHP script isn't the most efficient and in this case the performance (or more specifically, the time of execution) is important. This is what I have so far. You can see I have followed the program structure of the PHP ping client by GoldEye (more or less). -- snip snap, see attachment below -- I haven't done much socket programming in PHP so this piece of code isn't working as it should. Basically, I need to make sure I'm going the right path. Given the following protocol and D1st0rt's protocol packets, can someone help me with the correct format parameters of the PHP pack method? CLIENT SERVER ------------------------------------ -------------------------------------------------- Encryption request 0x01 -------> <------ 0x02 Encryption response Server list request (reliable) 0x03 -------> Synchronization request 0x05 -------> <------ 0x03 Reliable Packet Reliable ACK 0x04 -------> <------ 0x0E Cluster <------ 0x03 Reliable Packet (contains 0x0A Massive Chunk) Reliable ACK 0x04 -------> (0x03 is received multiple times for the complete server list) Disconnect 0x07 -------> <------ 0x07 Confirm Disconnection For example, the Encryption request packet I need to send contains 0x00, 0x01 (type byte), client encryption key of 4 bytes and 2 bytes for the protocol version (0x00 and 0x01). Right now I have this done with $out=pack("vvVvv",0x00,0x01,$clientkey,0x01,0x00);but I doubt this is correct. Which format parameter do I need to use for packing 4 bytes? an unsigned short (v) or an unsigned long (V)? Edited June 25, 2010 by Maverick Check out your zone population statistics at stats.sshq.net! MaverickSubspace Statistics AdministratorRetired SSCU Trench Wars Super ModeratorTWCore Coordinator Administrator
★ doc flabby Posted June 7, 2010 Report Posted June 7, 2010 (edited) For example, the Encryption request packet I need to send contains 0x00, 0x01 (type byte), client encryption key of 4 bytes and 2 bytes for the protocol version (0x00 and 0x01). Right now I have this done with $out=pack("vvVvv",0x00,0x01,$clientkey,0x01,0x00);but I doubt this is correct. Which format parameter do I need to use for packing 4 bytes? an unsigned short (v) or an unsigned long (V)? You want this$out=pack("CCVCC",0x00,0x01,$clientkey,0x01,0x00);or$out=pack("vVv",0x0001,$clientkey,0x0100); http://php.net/manual/en/function.pack.php C = 1 bytes (byte)v = 2 bytes (short)V = 4 bytes (long) Edited June 7, 2010 by doc flabby Rediscover online gaming. Get Subspace.Owner of the PlaySubSpace Network (level 0 BanG) and PSSF server
★ Maverick Posted June 7, 2010 Author Report Posted June 7, 2010 C = 1 bytes (byte)v = 2 bytes (short)V = 4 bytes (long)awesome, that was exactly what I was missing thanks Check out your zone population statistics at stats.sshq.net! MaverickSubspace Statistics AdministratorRetired SSCU Trench Wars Super ModeratorTWCore Coordinator Administrator
★ Maverick Posted June 24, 2010 Author Report Posted June 24, 2010 (edited) I've completed the script. Attached is the script for anyone to use. These are the test results : Offline testing [Windows Vista x64]Catid's server : successSnrrrubs directory server : successDoc Flabby's Central : fail (no response after sending 0x01 encryption request, although directory server does receive it) Online testingsscentral.sscuservers.net : [offline]sscentral.com : successssdir.playsubspace.com : failnanavati.net : fail (does connect but only receives one reliable message then receives 0x07 disconnection)ds1.krslynx.com : success It's weird that the directory server at nanavati.net doesn't work, offline testing on Snrrrub's server works fine.Unfortunately sscentral.sscuservers.net was offline when testing so the most important directory server couldn't be tested.Note the script doesn't use any encryption. Sending a client key on the encryption request of 0 accomplishes this. Requirements: php_sockets module enableddirectoryclient.php Edited June 25, 2010 by Maverick Check out your zone population statistics at stats.sshq.net! MaverickSubspace Statistics AdministratorRetired SSCU Trench Wars Super ModeratorTWCore Coordinator Administrator
★ Maverick Posted June 27, 2010 Author Report Posted June 27, 2010 (edited) With a small modification (making the script identify itself as a Continuum client instead of a Subspace one) Doc Flabby's directory server works These are the test results : Offline testing [Windows Vista x64]Catid's server : successSnrrrubs directory server : successDoc Flabby's Central : success Online testingsscentral.sscuservers.net : [offline]sscentral.com : successssdir.playsubspace.com : successnanavati.net : fail (Continuum client and Snrrrubs directory server are also having trouble dowloading from it so I guess it's not working as it should or contains no zones)ds1.krslynx.com : success You can view the current online directory servers at http://directoryservers.sshq.net Update 29-june-2010: SSCentral has come back online and has successfully been tested.directoryclient.php Edited June 29, 2010 by Maverick Check out your zone population statistics at stats.sshq.net! MaverickSubspace Statistics AdministratorRetired SSCU Trench Wars Super ModeratorTWCore Coordinator Administrator
Cheese Posted June 28, 2010 Report Posted June 28, 2010 you could now make a zone list from the directory responses, then use your tw stats experience to make zone population graphs... would be unprecedented SSC Distension OwnerSSCU Trench Wars Developer3:JabJabJab> sometimes i feel like when im in this mood im like a productive form of CheeseDr Brain> Pretty much everything you said was wrong. Except where you called me a lazy jerk with no time. That was true.3:KrynetiX> do you ever open your web browser and type ?go google5:Ceiu> Wow. My colon decided that was a good time to evacuate itself.
★ Maverick Posted June 28, 2010 Author Report Posted June 28, 2010 (edited) That's pretty much what I've been working on Edited June 28, 2010 by Maverick Check out your zone population statistics at stats.sshq.net! MaverickSubspace Statistics AdministratorRetired SSCU Trench Wars Super ModeratorTWCore Coordinator Administrator
★ doc flabby Posted June 29, 2010 Report Posted June 29, 2010 Note the script doesn't use any encryption. Sending a client key on the encryption request of 0 accomplishes this. Requirements: php_sockets module enabled IIRC think prittks directory server only works with encryption turned on Rediscover online gaming. Get Subspace.Owner of the PlaySubSpace Network (level 0 BanG) and PSSF server
★ Maverick Posted June 29, 2010 Author Report Posted June 29, 2010 I hope you're wrong on that assumption According to CatId, this method of disabling encryption should work on original subspace-based software. We'll see as soon as it's back online (if it ever will). Check out your zone population statistics at stats.sshq.net! MaverickSubspace Statistics AdministratorRetired SSCU Trench Wars Super ModeratorTWCore Coordinator Administrator
★ Maverick Posted June 29, 2010 Author Report Posted June 29, 2010 Final update;few bugfixes in the function received_serverlistresponse()stores the zones in the multi-dimensional array in the DirectoryClient classdirectoryclient.php Check out your zone population statistics at stats.sshq.net! MaverickSubspace Statistics AdministratorRetired SSCU Trench Wars Super ModeratorTWCore Coordinator Administrator
Hakaku Posted June 30, 2010 Report Posted June 30, 2010 It generates invalid resource errors when calling socket_close(x) at line 85 if it fails to reconnect after the first time. You could cheat and check to see if it's a valid resource (is_resource(x)) before attempting to close it, but that doesn't really address the issue and defeats the purpose of trying to reconnect. Other than that, kudos on the work. http://img.photobucket.com/albums/v138/zacinu/SubSpacebannt2.pngPSPACE (SourceForge) - Alternative client (source) to Continuum
★ Maverick Posted July 1, 2010 Author Report Posted July 1, 2010 Yea I guess some socket_close() statements should be surrounded with an if(!$this->socket) for checking if it's a valid resource to be closed and thus preventing those warnings. Thanks for the appreciation Check out your zone population statistics at stats.sshq.net! MaverickSubspace Statistics AdministratorRetired SSCU Trench Wars Super ModeratorTWCore Coordinator Administrator
★ Maverick Posted July 2, 2010 Author Report Posted July 2, 2010 Another update due to a major bug I discovered.If the Directory Server sends the response in a 0x0E cluster, the containing 0x0A Huge Chunk (encapsulated in a 0x03 Reliable message) is the tail of the resulting zone list. The packet protocol does mention this but I didn't take notion of it while making the directory client because I didn't fully understand the note. I modified the directory client to handle this tail correctly.directoryclient.php Check out your zone population statistics at stats.sshq.net! MaverickSubspace Statistics AdministratorRetired SSCU Trench Wars Super ModeratorTWCore Coordinator Administrator
★ Maverick Posted July 7, 2010 Author Report Posted July 7, 2010 Another and hopefully the last update. This time another necessary bugfix as the script malfunctioned now and then. Sometimes the directory server doesn't respond/receive the acknowledgement packet it is send, resulting in the directory server resending a Huge Chunk packet. The PHP Directory client script didn't handle this properly and just concatenate the (duplicate) huge chunk data to the buffer, resulting in a corrupted server list.I've modified the script to properly handle huge chunk packets that are received more then once by putting all the huge chunk packets in an array using the ACK id of the reliable packet as key. From now on the script will be released as a command-line script and a web-script (one that can be executed in the browser). If you compare the two, you'll notice that the only difference is how the scripts receive the arguments from either the command-line or a GET parameter. Have fun.directoryclient-cmd.phpdirectoryclient-web.php Check out your zone population statistics at stats.sshq.net! MaverickSubspace Statistics AdministratorRetired SSCU Trench Wars Super ModeratorTWCore Coordinator Administrator
★ Maverick Posted August 10, 2010 Author Report Posted August 10, 2010 IIRC think prittks directory server only works with encryption turned on Unfortunately Doc Flabby is correct and sscentral.sscuservers.net doesn't support the unencrypted communication. Hopefully I can port the (subspace) encryption from my Java client to the PHP script. If someone can help me or give me some tips, please do PS. Doc Flabby, if you read this, your directory server isn't working anymore. It's online but it stops sending the zone list after it has send 22% of it. Check out your zone population statistics at stats.sshq.net! MaverickSubspace Statistics AdministratorRetired SSCU Trench Wars Super ModeratorTWCore Coordinator Administrator
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now