From eddfd8fb5ab7b3500a5e1130fa43d35d203c698f Mon Sep 17 00:00:00 2001 From: pizzaboxer <41478239+pizzaboxer@users.noreply.github.com> Date: Thu, 6 Oct 2022 07:54:18 +0100 Subject: [PATCH] Initial code --- .gitignore | 350 ++++++++++++++++++++ LICENSE | 21 ++ PolygonGSArbiter.sln | 25 ++ PolygonGSArbiter/App.config | 17 + PolygonGSArbiter/ArbiterService.cs | 119 +++++++ PolygonGSArbiter/Config.cs | 18 + PolygonGSArbiter/ConsoleEx.cs | 34 ++ PolygonGSArbiter/Job.cs | 95 ++++++ PolygonGSArbiter/JobManager.cs | 173 ++++++++++ PolygonGSArbiter/PlayerBetaServer.ico | Bin 0 -> 102134 bytes PolygonGSArbiter/PolygonGSArbiter.csproj | 99 ++++++ PolygonGSArbiter/PolygonGSP.cs | 18 + PolygonGSArbiter/Program.cs | 51 +++ PolygonGSArbiter/Properties/AssemblyInfo.cs | 36 ++ PolygonGSArbiter/WebManager.cs | 73 ++++ PolygonGSArbiter/packages.config | 4 + README.md | 10 + 17 files changed, 1143 insertions(+) create mode 100644 .gitignore create mode 100644 LICENSE create mode 100644 PolygonGSArbiter.sln create mode 100644 PolygonGSArbiter/App.config create mode 100644 PolygonGSArbiter/ArbiterService.cs create mode 100644 PolygonGSArbiter/Config.cs create mode 100644 PolygonGSArbiter/ConsoleEx.cs create mode 100644 PolygonGSArbiter/Job.cs create mode 100644 PolygonGSArbiter/JobManager.cs create mode 100644 PolygonGSArbiter/PlayerBetaServer.ico create mode 100644 PolygonGSArbiter/PolygonGSArbiter.csproj create mode 100644 PolygonGSArbiter/PolygonGSP.cs create mode 100644 PolygonGSArbiter/Program.cs create mode 100644 PolygonGSArbiter/Properties/AssemblyInfo.cs create mode 100644 PolygonGSArbiter/WebManager.cs create mode 100644 PolygonGSArbiter/packages.config create mode 100644 README.md diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..dfcfd56 --- /dev/null +++ b/.gitignore @@ -0,0 +1,350 @@ +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. +## +## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore + +# User-specific files +*.rsuser +*.suo +*.user +*.userosscache +*.sln.docstates + +# User-specific files (MonoDevelop/Xamarin Studio) +*.userprefs + +# Mono auto generated files +mono_crash.* + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +[Aa][Rr][Mm]/ +[Aa][Rr][Mm]64/ +bld/ +[Bb]in/ +[Oo]bj/ +[Ll]og/ +[Ll]ogs/ + +# Visual Studio 2015/2017 cache/options directory +.vs/ +# Uncomment if you have tasks that create the project's static files in wwwroot +#wwwroot/ + +# Visual Studio 2017 auto generated files +Generated\ Files/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +# NUnit +*.VisualState.xml +TestResult.xml +nunit-*.xml + +# Build Results of an ATL Project +[Dd]ebugPS/ +[Rr]eleasePS/ +dlldata.c + +# Benchmark Results +BenchmarkDotNet.Artifacts/ + +# .NET Core +project.lock.json +project.fragment.lock.json +artifacts/ + +# StyleCop +StyleCopReport.xml + +# Files built by Visual Studio +*_i.c +*_p.c +*_h.h +*.ilk +*.meta +*.obj +*.iobj +*.pch +*.pdb +*.ipdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*_wpftmp.csproj +*.log +*.vspscc +*.vssscc +.builds +*.pidb +*.svclog +*.scc + +# Chutzpah Test files +_Chutzpah* + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opendb +*.opensdf +*.sdf +*.cachefile +*.VC.db +*.VC.VC.opendb + +# Visual Studio profiler +*.psess +*.vsp +*.vspx +*.sap + +# Visual Studio Trace Files +*.e2e + +# TFS 2012 Local Workspace +$tf/ + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# AxoCover is a Code Coverage Tool +.axoCover/* +!.axoCover/settings.json + +# Visual Studio code coverage results +*.coverage +*.coveragexml + +# NCrunch +_NCrunch_* +.*crunch*.local.xml +nCrunchTemp_* + +# MightyMoose +*.mm.* +AutoTest.Net/ + +# Web workbench (sass) +.sass-cache/ + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.[Pp]ublish.xml +*.azurePubxml +# Note: Comment the next line if you want to checkin your web deploy settings, +# but database connection strings (with potential passwords) will be unencrypted +*.pubxml +*.publishproj + +# Microsoft Azure Web App publish settings. Comment the next line if you want to +# checkin your Azure Web App publish settings, but sensitive information contained +# in these scripts will be unencrypted +PublishScripts/ + +# NuGet Packages +*.nupkg +# NuGet Symbol Packages +*.snupkg +# The packages folder can be ignored because of Package Restore +**/[Pp]ackages/* +# except build/, which is used as an MSBuild target. +!**/[Pp]ackages/build/ +# Uncomment if necessary however generally it will be regenerated when needed +#!**/[Pp]ackages/repositories.config +# NuGet v3's project.json files produces more ignorable files +*.nuget.props +*.nuget.targets + +# Microsoft Azure Build Output +csx/ +*.build.csdef + +# Microsoft Azure Emulator +ecf/ +rcf/ + +# Windows Store app package directories and files +AppPackages/ +BundleArtifacts/ +Package.StoreAssociation.xml +_pkginfo.txt +*.appx +*.appxbundle +*.appxupload + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!?*.[Cc]ache/ + +# Others +ClientBin/ +~$* +*~ +*.dbmdl +*.dbproj.schemaview +*.jfm +*.pfx +*.publishsettings +orleans.codegen.cs + +# Including strong name files can present a security risk +# (https://github.com/github/gitignore/pull/2483#issue-259490424) +#*.snk + +# Since there are multiple workflows, uncomment next line to ignore bower_components +# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) +#bower_components/ + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file +# to a newer Visual Studio version. Backup files are not needed, +# because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm +ServiceFabricBackup/ +*.rptproj.bak + +# SQL Server files +*.mdf +*.ldf +*.ndf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings +*.rptproj.rsuser +*- [Bb]ackup.rdl +*- [Bb]ackup ([0-9]).rdl +*- [Bb]ackup ([0-9][0-9]).rdl + +# Microsoft Fakes +FakesAssemblies/ + +# GhostDoc plugin setting file +*.GhostDoc.xml + +# Node.js Tools for Visual Studio +.ntvs_analysis.dat +node_modules/ + +# Visual Studio 6 build log +*.plg + +# Visual Studio 6 workspace options file +*.opt + +# Visual Studio 6 auto-generated workspace file (contains which files were open etc.) +*.vbw + +# Visual Studio LightSwitch build output +**/*.HTMLClient/GeneratedArtifacts +**/*.DesktopClient/GeneratedArtifacts +**/*.DesktopClient/ModelManifest.xml +**/*.Server/GeneratedArtifacts +**/*.Server/ModelManifest.xml +_Pvt_Extensions + +# Paket dependency manager +.paket/paket.exe +paket-files/ + +# FAKE - F# Make +.fake/ + +# CodeRush personal settings +.cr/personal + +# Python Tools for Visual Studio (PTVS) +__pycache__/ +*.pyc + +# Cake - Uncomment if you are using it +# tools/** +# !tools/packages.config + +# Tabs Studio +*.tss + +# Telerik's JustMock configuration file +*.jmconfig + +# BizTalk build output +*.btp.cs +*.btm.cs +*.odx.cs +*.xsd.cs + +# OpenCover UI analysis results +OpenCover/ + +# Azure Stream Analytics local run output +ASALocalRun/ + +# MSBuild Binary and Structured Log +*.binlog + +# NVidia Nsight GPU debugger configuration file +*.nvuser + +# MFractors (Xamarin productivity tool) working folder +.mfractor/ + +# Local History for Visual Studio +.localhistory/ + +# BeatPulse healthcheck temp database +healthchecksdb + +# Backup folder for Package Reference Convert tool in Visual Studio 2017 +MigrationBackup/ + +# Ionide (cross platform F# VS Code tools) working folder +.ionide/ diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..53ff9c6 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2022 pizzaboxer + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/PolygonGSArbiter.sln b/PolygonGSArbiter.sln new file mode 100644 index 0000000..eb0517d --- /dev/null +++ b/PolygonGSArbiter.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.30114.105 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PolygonGSArbiter", "PolygonGSArbiter\PolygonGSArbiter.csproj", "{E317FEAE-B541-493C-8DB3-F6662B66FA92}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {E317FEAE-B541-493C-8DB3-F6662B66FA92}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E317FEAE-B541-493C-8DB3-F6662B66FA92}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E317FEAE-B541-493C-8DB3-F6662B66FA92}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E317FEAE-B541-493C-8DB3-F6662B66FA92}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {D2EEBC59-B040-4497-9B16-49274FD675F1} + EndGlobalSection +EndGlobal diff --git a/PolygonGSArbiter/App.config b/PolygonGSArbiter/App.config new file mode 100644 index 0000000..db89d76 --- /dev/null +++ b/PolygonGSArbiter/App.config @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/PolygonGSArbiter/ArbiterService.cs b/PolygonGSArbiter/ArbiterService.cs new file mode 100644 index 0000000..ae1acb9 --- /dev/null +++ b/PolygonGSArbiter/ArbiterService.cs @@ -0,0 +1,119 @@ +using System; +using System.Net; +using System.Net.Sockets; +using System.IO; +using System.Threading.Tasks; +using Newtonsoft.Json; + +namespace PolygonGSArbiter +{ + class ArbiterService + { + private static TcpListener Service = new TcpListener(IPAddress.Any, Config.ServicePort); + + public static int Start() + { + Service.Start(); + Task.Run(() => ListenForConnections()); + return Config.ServicePort; + } + + public static void Stop() + { + Service.Stop(); + } + + private static void ListenForConnections() + { + while (true) + { + TcpClient Client = Service.AcceptTcpClient(); + string ClientAddress = GetClientAddress(Client); + //ConsoleEx.WriteLine($"[ArbiterService] Service received a new connection from '{ClientAddress}'", ConsoleColor.Blue); + + Task.Run(() => HandleConnection(Client, ClientAddress)); + } + } + + private static void HandleConnection(TcpClient Client, string ClientAddress) + { + NetworkStream Stream = Client.GetStream(); + StreamReader Reader = new StreamReader(Stream); + + try + { + while (Client.Connected) + { + string IncomingCommand = Reader.ReadLine(); + + if (IncomingCommand == null) + { + //ConsoleEx.WriteLine($"[ArbiterService/{ClientAddress}] Client disconnected", ConsoleColor.Blue); + Stream.Close(); + Client.Close(); + } + else + { + //ConsoleEx.WriteLine($"[ArbiterService/{ClientAddress}] Received command '{IncomingCommand}'", ConsoleColor.Blue); + ProcessCommand(Stream, ClientAddress, IncomingCommand); + } + } + } + catch (IOException) + { + //ConsoleEx.WriteLine($"$[ArbiterService/{ClientAddress}] Client disconnected", ConsoleColor.Blue); + } + } + + private static void WriteToClient(NetworkStream Stream, string ClientAddress, string Response) + { + //ConsoleEx.WriteLine($"[ArbiterService/{ClientAddress}] Writing to client with '{Response}'", ConsoleColor.Blue); + StreamWriter Writer = new StreamWriter(Stream); + Writer.WriteLine(Response); + Writer.Flush(); + } + + private static void ProcessCommand(NetworkStream Stream, string ClientAddress, string Message) + { + PolygonGSP Request = JsonConvert.DeserializeObject(Message); + + switch (Request.Operation) + { + case "OpenJob": + if (JobManager.GetJobFromID(Request.JobID) != null) + { + WriteToClient(Stream, ClientAddress, "{\"Operation\":\"CloseJob\", \"Status\":\"Error\", \"Message\":\"Job already exists\"}"); + } + else + { + Task.Run(() => JobManager.OpenJob(Request.JobID, Request.Version, Request.PlaceID)); + WriteToClient(Stream, ClientAddress, "{\"Operation\":\"OpenJob\", \"Status\":\"OK\"}"); + } + + break; + + case "CloseJob": + if (JobManager.GetJobFromID(Request.JobID) == null) + { + WriteToClient(Stream, ClientAddress, "{\"Operation\":\"CloseJob\", \"Status\":\"Error\", \"Message\":\"Job does not exist\"}"); + } + else + { + Task.Run(() => JobManager.CloseJob(Request.JobID)); + WriteToClient(Stream, ClientAddress, "{\"Operation\":\"CloseJob\", \"Status\":\"OK\"}"); + } + + break; + + default: + ConsoleEx.WriteLine($"[ArbiterService/{ClientAddress}] Invalid command received", ConsoleColor.Blue); + break; + } + } + + private static string GetClientAddress(TcpClient Client) + { + return Client.Client.RemoteEndPoint.ToString(); + } + } +} diff --git a/PolygonGSArbiter/Config.cs b/PolygonGSArbiter/Config.cs new file mode 100644 index 0000000..3b8f7c6 --- /dev/null +++ b/PolygonGSArbiter/Config.cs @@ -0,0 +1,18 @@ +using System; +using System.Configuration; + +namespace PolygonGSArbiter +{ + class Config + { + public static int GameserverID = Int32.Parse(ConfigurationManager.AppSettings.Get("GameserverID")); + public static string MachineAddress = ConfigurationManager.AppSettings.Get("MachineAddress"); + public static string BaseUrl = ConfigurationManager.AppSettings.Get("BaseUrl"); + public static string BaseUrlHTTP = ConfigurationManager.AppSettings.Get("BaseUrlHTTP"); + public static string AccessKey = ConfigurationManager.AppSettings.Get("AccessKey"); + public static int ServicePort = Int32.Parse(ConfigurationManager.AppSettings.Get("ServicePort")); + public static int InternalBasePort = Int32.Parse(ConfigurationManager.AppSettings.Get("InternalBasePort")); + public static int ExternalPortOffset = Int32.Parse(ConfigurationManager.AppSettings.Get("ExternalPortOffset")); + public static int MaximumJobs = Int32.Parse(ConfigurationManager.AppSettings.Get("MaximumJobs")); + } +} diff --git a/PolygonGSArbiter/ConsoleEx.cs b/PolygonGSArbiter/ConsoleEx.cs new file mode 100644 index 0000000..ec9f402 --- /dev/null +++ b/PolygonGSArbiter/ConsoleEx.cs @@ -0,0 +1,34 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace PolygonGSArbiter +{ + public static class ConsoleEx + { + // would race conditions be an issue here? + + public static void Write(string Message, ConsoleColor Color = ConsoleColor.Gray) + { + Console.ForegroundColor = Color; + Console.Write(Message); + Console.ForegroundColor = ConsoleColor.Gray; + } + + public static void WriteLine(string Message, ConsoleColor Color = ConsoleColor.Gray) + { + Console.ForegroundColor = Color; + Console.WriteLine(Message); + Console.ForegroundColor = ConsoleColor.Gray; + } + + public static void Error(string Message) + { + ConsoleEx.WriteLine(Message, ConsoleColor.Red); + Console.ReadLine(); + Environment.Exit(0); + } + } +} diff --git a/PolygonGSArbiter/Job.cs b/PolygonGSArbiter/Job.cs new file mode 100644 index 0000000..b063552 --- /dev/null +++ b/PolygonGSArbiter/Job.cs @@ -0,0 +1,95 @@ +using System; +using System.Diagnostics; + +namespace PolygonGSArbiter +{ + public enum JobStatus + { + Pending = 0, + Started = 1, + Monitored = 2, + Closed = 3, + Crashed = 4, + } + + public class Job + { + public string ID { get; set; } + public int Version { get; set; } + public int PlaceID { get; set; } + public int Port { get; set; } + public JobStatus Status { get; set; } + public int TimeCreated { get; set; } + public int TimeStarted { get; set; } + public bool HasShutdown { get; set; } + public Process Process { get; set; } + + public Job(string JobID, int Version, int PlaceID, int Port) + { + this.ID = JobID; + this.Version = Version; + this.PlaceID = PlaceID; + this.Port = Port; + this.Status = JobStatus.Pending; + this.HasShutdown = false; + this.TimeCreated = UnixTime.GetTimestamp(); + } + + internal void Start() + { + ConsoleEx.WriteLine($"[Job] Starting '{ID}' on port {Port}...", ConsoleColor.Yellow); + + // ExternalPortOffset is used for the connection port that is declared in the joinscript + // the internal port is the port networkserver should listen on + + WebManager.UpdateJob(ID, "Loading", Port + Config.ExternalPortOffset); + + string GameserverScript = WebManager.GetGameserverScript(ID, PlaceID, Port); + string[] CommandLine = JobManager.GetCommandLine(ID, Version, GameserverScript); + + Process = new Process(); + Process.StartInfo.FileName = CommandLine[0]; + Process.StartInfo.Arguments = CommandLine[1]; + Process.Start(); + Process.WaitForInputIdle(); + + Status = JobStatus.Started; + this.TimeStarted = UnixTime.GetTimestamp(); + + ConsoleEx.WriteLine($"[Job] Started '{ID}'!", ConsoleColor.Green); + } + + internal void Close() + { + try + { + if (HasShutdown || Process.HasExited) + { + if (HasShutdown) Process.CloseMainWindow(); + Process.Close(); + ConsoleEx.WriteLine($"[Job] Closed '{ID}'! (Job closed by game:Shutdown())", ConsoleColor.Green); + WebManager.UpdateJob(ID, "Closed"); + } + else if (Status == JobStatus.Crashed || !Process.Responding) + { + Process.Kill(); + Process.Close(); + ConsoleEx.WriteLine($"[Job] Closed '{ID}'! (Job encountered a soft crash)", ConsoleColor.Red); + WebManager.UpdateJob(ID, "Crashed"); + } + else + { + Process.CloseMainWindow(); + Process.Close(); + ConsoleEx.WriteLine($"[Job] Closed '{ID}'! (Job closed by request)", ConsoleColor.Green); + WebManager.UpdateJob(ID, "Closed"); + } + } + catch (InvalidOperationException) + { + ConsoleEx.WriteLine($"[Job] Closed '{ID}'! (Job encountered a hard crash)", ConsoleColor.Red); + WebManager.UpdateJob(ID, "Crashed"); + } + } + } +} diff --git a/PolygonGSArbiter/JobManager.cs b/PolygonGSArbiter/JobManager.cs new file mode 100644 index 0000000..973032a --- /dev/null +++ b/PolygonGSArbiter/JobManager.cs @@ -0,0 +1,173 @@ +using System; +using System.Collections.Generic; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +using System.Diagnostics; +using System.Runtime.InteropServices; + +namespace PolygonGSArbiter +{ + class JobManager + { + public static List OpenJobs = new List(); + + [DllImport("User32.dll")] + static extern IntPtr FindWindow(string lpClassName, string lpWindowName); + + [DllImport("User32.dll")] + static extern uint GetWindowThreadProcessId(IntPtr hWnd, out uint processId); + + [DllImport("User32.dll")] + static extern int GetWindowText(IntPtr hWnd, StringBuilder lpString, int nMaxCount); + + [DllImport("User32.dll")] + static extern int GetWindowTextLength(IntPtr hWnd); + + public static string GetWindowTitle(IntPtr hWnd) + { + var length = GetWindowTextLength(hWnd) + 1; + var title = new StringBuilder(length); + GetWindowText(hWnd, title, length); + return title.ToString(); + } + + public static string[] GetCommandLine(string jobId, int Version, string ScriptUrl) + { + switch (Version) + { + case 2010: + return new string[] { "Gameservers\\2010\\PolygonServer.exe", $"-a https://polygon.pizzaboxer.xyz/Login/Negotiate.ashx -t 0 -j {ScriptUrl} -jobId {jobId}" }; + + case 2011: + return new string[] { "Gameservers\\2011\\PolygonServer.exe", $"-a https://polygon.pizzaboxer.xyz/Login/Negotiate.ashx -t 0 -j {ScriptUrl} -jobId {jobId}" }; + + case 2012: + return new string[] { "Gameservers\\2012\\PolygonServer.exe", $"-a https://polygon.pizzaboxer.xyz/Login/Negotiate.ashx -t 0 -j {ScriptUrl} -jobId {jobId}" }; + + default: + return new string[] { }; + } + } + + public static int GetAvailablePort() + { + int Port = Config.InternalBasePort; + + for (int i = 0; i < Config.MaximumJobs; i++) + { + if (OpenJobs.Find(Job => Job.Port == Port) == null) + break; + else + Port++; + } + + return Port; + } + + public static Job OpenJob(string JobID, int Version, int PlaceID) + { + ConsoleEx.WriteLine($"[JobManager] Opening Job for '{JobID}' ({Version})", ConsoleColor.Blue); + Job NewJob = new Job(JobID, Version, PlaceID, GetAvailablePort()); + OpenJobs.Add(NewJob); + NewJob.Start(); + + return NewJob; + } + + public static void CloseJob(string JobID) + { + Job JobToClose = GetJobFromID(JobID); + if (JobToClose == null) return; + + JobToClose.Close(); + OpenJobs.Remove(JobToClose); + } + + public static Job GetJobFromID(string JobID) + { + return OpenJobs.Find(Job => Job.ID == JobID); + } + + public static bool CheckIfJobExists(string JobID) + { + foreach (Job OpenJob in OpenJobs) + { + if (OpenJob.ID == JobID) + return true; + } + + return false; + } + + public static void MonitorUnresponsiveJobs() + { + while (true) + { + try + { + foreach (Job OpenJob in OpenJobs) + { + if (OpenJob.Status == JobStatus.Pending || OpenJob.Status == JobStatus.Monitored) continue; + + if (OpenJob.HasShutdown || OpenJob.Process.HasExited) + { + OpenJob.Close(); + OpenJobs.Remove(OpenJob); + continue; + } + + if (OpenJob.Process.Responding) continue; + + Task.Run(() => MonitorUnresponsiveJob(OpenJob)); + } + } + catch (InvalidOperationException) + { + + } + + Thread.Sleep(5000); + } + } + + public static void CloseAllJobs() + { + foreach (Job OpenJob in OpenJobs) + { + OpenJob.Close(); + } + + OpenJobs.Clear(); + } + + public static void MonitorUnresponsiveJob(Job UnresponsiveJob) + { + ConsoleEx.WriteLine($"[JobManager] '{UnresponsiveJob.ID}' is not responding! Monitoring...", ConsoleColor.Yellow); + UnresponsiveJob.Status = JobStatus.Monitored; + + for (int i = 1; i <= 30; i++) + { + Thread.Sleep(1000); + + if (UnresponsiveJob.Process.Responding) + { + ConsoleEx.WriteLine($"[JobManager] '{UnresponsiveJob.ID}' has recovered from its unresponsive status!", ConsoleColor.Green); + UnresponsiveJob.Status = JobStatus.Started; + break; + } + else if (i == 30) + { + ConsoleEx.WriteLine($"[JobManager] '{UnresponsiveJob.ID}' has been unresponsive for over 30 seconds. Closing Job...", ConsoleColor.Yellow); + UnresponsiveJob.Status = JobStatus.Crashed; + UnresponsiveJob.Close(); + + OpenJobs.Remove(UnresponsiveJob); + break; + } + } + + return; + } + } +} diff --git a/PolygonGSArbiter/PlayerBetaServer.ico b/PolygonGSArbiter/PlayerBetaServer.ico new file mode 100644 index 0000000000000000000000000000000000000000..907a6c74d31695aa29070dcafc3c3c7789c3c936 GIT binary patch literal 102134 zcmeI534B%6wf`@oMeA6#)~c^qYv;+<&aW+6>uc?(ZLR;;`r5wg(^jn$f&((hB#I0& z$sjYxJkKBynMueTNFYE0A&`&+!VCej|G)1(ci)_Qb8m8Q2th69lbv(UJ?HFUt+m%) zd#$zC4g{J7J`%XCe<~2T;|}ls3qJ`2-uY=D(5X}K{^DkVwC;hx7nG+yRSDkjIt2pC_nJ$+Wbb|d zj4^?gd-n!*9y!r`=FXI>Cl{{z`q=GD|JWn@?N_^H4IVQnZ|aZrPP6&DvwUB9mxoWD z4ou&f9GJ5!<14*4jv4(z>Z{3JG6(G*xpm>Or;^*7f39s~l*f))MX66H-^)gCT@s)? zcZ}M)Fz{C1w9DTqSU$D)rm^OcHP4#oQo5LN+ut>vGW(jRl3zA2roN{8r6*p`9xS1{hGanfknG>0)f7PK-bJck9W=-P&GV%p6S17l-X3d&Fnl-YElcb&9;L@W<|*c zGofI)>5@56d3WC0GiT(_+HU9;crAN)pnvY9+ghi*Qt+?!?ab_=HKyYDL1k~u+BIv; z$Ppv$_37$rv-M!98Mi^!}9apH#$$b0frs1aic%^-xe|`J*HSfLm zUg*ABR~z>inCCZiqkT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%f)!5y;0)p9xYFrq6-xUzL4`!I;o(F5($=wGtthw)KYZQ9yW$3D}pKXnO z_qG66eLc4|4pmn_ke~m)mF`2;*YlRTFVxu`6j11Hbf$o$i2F|U-1{E$y|20!XOZ{5 z>f7i3>Vo6Qdw=z5aG}4vDECPb&pXw1FM#$wl_j?i-?eTUtvKZM<@e?{IO_t#JTIqY8jz0Uhq5zjjs6Gm{6_a^)~ z{KrpF-1`Z@GC&^!U@v|E*?V6FEx+?spe677GW6~{g<9N-$G!|Z+WQ&^dG|FL+Q&6D zw$;^dE<<R>p#p4m^}egIyLScH>QhFrf-Sk`@CtC*yBc@2&-iC+9QxXWan0Kv dj9Z1?)mY{{sa=HXHx| literal 0 HcmV?d00001 diff --git a/PolygonGSArbiter/PolygonGSArbiter.csproj b/PolygonGSArbiter/PolygonGSArbiter.csproj new file mode 100644 index 0000000..44ab0c5 --- /dev/null +++ b/PolygonGSArbiter/PolygonGSArbiter.csproj @@ -0,0 +1,99 @@ + + + + + Debug + AnyCPU + {E317FEAE-B541-493C-8DB3-F6662B66FA92} + Exe + PolygonGSArbiter + PolygonGSArbiter + v4.7.2 + 512 + true + true + publish\ + true + Disk + false + Foreground + 7 + Days + false + false + true + 0 + 1.0.0.%2a + false + false + true + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + PlayerBetaServer.ico + + + + ..\packages\Newtonsoft.Json.13.0.1\lib\net45\Newtonsoft.Json.dll + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + False + Microsoft .NET Framework 4.7.2 %28x86 and x64%29 + true + + + False + .NET Framework 3.5 SP1 + false + + + + + + + \ No newline at end of file diff --git a/PolygonGSArbiter/PolygonGSP.cs b/PolygonGSArbiter/PolygonGSP.cs new file mode 100644 index 0000000..729833c --- /dev/null +++ b/PolygonGSArbiter/PolygonGSP.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace PolygonGSArbiter +{ + public class PolygonGSP + { + public string Operation { get; set; } + public string JobID { get; set; } + public int Version { get; set; } + public int PlaceID { get; set; } + public string Status { get; set; } + public string Message { get; set; } + } +} diff --git a/PolygonGSArbiter/Program.cs b/PolygonGSArbiter/Program.cs new file mode 100644 index 0000000..57e8870 --- /dev/null +++ b/PolygonGSArbiter/Program.cs @@ -0,0 +1,51 @@ +using System; +using System.Threading; +using System.Threading.Tasks; + +namespace PolygonGSArbiter +{ + class Program + { + static void Main(string[] args) + { + ConsoleEx.WriteLine($"Access Key read: {Config.AccessKey}"); + ConsoleEx.WriteLine($"Current Access key: {Config.AccessKey}"); + + ConsoleEx.WriteLine("Service starting..."); + + Task.Run(() => JobManager.MonitorUnresponsiveJobs()); + Task.Run(() => WebManager.StartResourceReporter()); + + WebManager.SetMarker(true); + + ConsoleEx.WriteLine("Initializing Project Polygon Arbiter Service"); + int ServicePort = ArbiterService.Start(); + ConsoleEx.WriteLine($"Service Started on port {ServicePort}"); + + Console.CancelKeyPress += delegate + { + Console.WriteLine("Service shutting down..."); + + ArbiterService.Stop(); + WebManager.SetMarker(false); + JobManager.CloseAllJobs(); + + // wait for web requests to finish + Thread.Sleep(10000); + }; + + while (true) + { + Thread.Sleep(1000); + } + } + } + + public class UnixTime + { + public static int GetTimestamp() + { + return (Int32)(DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1))).TotalSeconds; + } + } +} diff --git a/PolygonGSArbiter/Properties/AssemblyInfo.cs b/PolygonGSArbiter/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..1a726d1 --- /dev/null +++ b/PolygonGSArbiter/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("PolygonGSArbiter")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("PolygonGSArbiter")] +[assembly: AssemblyCopyright("Copyright © 2021")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("e317feae-b541-493c-8db3-f6662b66fa92")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/PolygonGSArbiter/WebManager.cs b/PolygonGSArbiter/WebManager.cs new file mode 100644 index 0000000..17fa1e4 --- /dev/null +++ b/PolygonGSArbiter/WebManager.cs @@ -0,0 +1,73 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Threading; +using System.Net.Http; + +namespace PolygonGSArbiter +{ + class WebManager + { + private static readonly HttpClient WebClient = new HttpClient(); + + public static string GetGameserverScript(string JobID, int PlaceID, int Port) + { + return $"{Config.BaseUrlHTTP}/gameserver?jobId={JobID}&placeId={PlaceID}&port={Port}&maxPlayers=10&{Config.AccessKey}"; + } + + static int GetAvailableMemory() + { + PerformanceCounter performance = new PerformanceCounter("Memory", "Available MBytes"); + return (int)performance.NextValue(); + } + + static int GetCpuUsage() + { + PerformanceCounter performance = new PerformanceCounter("Processor", "% Processor Time", "_Total"); + performance.NextValue(); // this is always gonna be zero + Thread.Sleep(500); + return (int)Math.Round(performance.NextValue()); + } + + public static void SetMarker(bool Online) + { + int OnlineInt = Online ? 1 : 0; + WebClient.GetAsync($"{Config.BaseUrl}/set-marker?{Config.AccessKey}&GameserverID={Config.GameserverID}&Online={OnlineInt}"); + } + + public static void StartResourceReporter() + { + while (true) + { + string AvailableMemory = GetAvailableMemory().ToString(); + string CpuUsage = GetCpuUsage().ToString(); + + Dictionary FormData = new Dictionary + { + { "GameserverID", Config.GameserverID.ToString() }, + { "CpuUsage", CpuUsage }, + { "AvailableMemory", AvailableMemory }, + }; + + FormUrlEncodedContent FormContent = new FormUrlEncodedContent(FormData); + + WebClient.PostAsync($"{Config.BaseUrl}/report-gameserver-resources?{Config.AccessKey}", FormContent); + + Thread.Sleep(60000); + } + } + + public static void UpdateJob(string JobID, string Status, int Port = 0) + { + if (Port == 0) + { + WebClient.GetAsync($"{Config.BaseUrl}/update-job?{Config.AccessKey}&JobID={JobID}&Status={Status}"); + } + else + { + WebClient.GetAsync($"{Config.BaseUrl}/update-job?{Config.AccessKey}&JobID={JobID}&Status={Status}&MachineAddress={Config.MachineAddress}&ServerPort={Port}"); + + } + } + } +} diff --git a/PolygonGSArbiter/packages.config b/PolygonGSArbiter/packages.config new file mode 100644 index 0000000..5eaa239 --- /dev/null +++ b/PolygonGSArbiter/packages.config @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..396e307 --- /dev/null +++ b/README.md @@ -0,0 +1,10 @@ +# polygon-arbiter +Manages gameserver requests sent from the Project Polygon website + +This is the backend service that was used to handle the launching and shutdown of dedicated gameservers on Project Polygon, with development having started in December 2021 and subsequently used in production in February 2022. + +While developing the gameserver system, I recorded a few demo videos of the arbiter in action, which I've linked below: + - [Proof of concept demo](https://youtu.be/bszlNpBIRTo) + - [Website integration demo](https://youtu.be/XF-MD0K5IOA) + +I've published this here purely for archival purposes, however I've had to omit the commit history from this release due to sensitive info being contained in the configs. I don't recommend that you use this in your work, but I won't stop you.