Crystal Seven AutoPatch Server
Image from the today´s stress test, connected in a infinite loop to it, checking the ressurce usage and for fails. Nothing happened in 20min :3
We moved away from the official TQ AutoPatch.exe so we have no use for this anymore. I thought, since it works perfectly fine (Distributed our first 5 Patches during 2 Weeks without restart / crash / leak across a load of players, I should release it for you guys. Its nothing fancy, I didnt even implement a own socket system - I´ve written it in around two hours because the ACME-EO one didnt run on our vps. More information below! Have fun!
- TQ´s Patch Protocol - Works with the official AutoPatch.exe
- Very little ressource usage
- From our observations: Stable
- Readable Code
How does it work?
Please... figure it out. I dont feel like explaining the obvious, i even let my data there so you can check for yourselfe.
Code preview
PHP Code:
class ConnectionThread
{
private TcpListener Client;
const string SERVERVERSION = "http://79.133.51.70/crystalseven/version.txt";
const string UPDATE = "UPDATE";
byte[] READY = { 52, 45, 41, 44, 59 };
const string HOST = "79.133.51.70";
const string PATH = "crystalseven/downloads/patches/";
const char JUNK = (char)0x0000;
static WebClient Web = new WebClient();
public ConnectionThread(TcpListener client)
{
Client = client;
}
public void HandleConnection()
{
byte[] buffer;
try
{
using (TcpClient client = Client.AcceptTcpClient())
{
using (NetworkStream ns = client.GetStream())
{
Console.WriteLine("{0} - Connection", DateTime.Now);
buffer = new byte[1024];
ns.Read(buffer, 0, buffer.Length);
int ClientVersion = int.Parse(Encoding.ASCII.GetString(buffer).Substring(0, 4).Trim(JUNK));
int ServerVersion = int.Parse(Web.DownloadString(SERVERVERSION));
if (ServerVersion == ClientVersion)
{
Console.WriteLine("{0} || Client @ {1} Version: {2} ==> READY", DateTime.Now, ((IPEndPoint)client.Client.RemoteEndPoint).Address.ToString(), ClientVersion);
client.Client.Send(Encoding.ASCII.GetBytes("READY"));
}
else if (ServerVersion > ClientVersion)
{
Console.WriteLine("{0} || Client @ {1} Version: {2} ==> UPDATE", DateTime.Now, ((IPEndPoint)client.Client.RemoteEndPoint).Address.ToString(), ClientVersion);
ClientVersion++;
client.Client.Send(Encoding.ASCII.GetBytes(UPDATE + " " + HOST + " " + PATH + ClientVersion + ".exe"));
}
}
}
}
catch (Exception e)
{
Console.WriteLine(e);
}
}
}
There is no config file! Everything is hardcoded! You might wanna change the values!