diff --git a/LoadBalancerProject-DONT-IMPORT-INTO-UNITY/Dockerfile b/LoadBalancerProject-DONT-IMPORT-INTO-UNITY/Dockerfile new file mode 100644 index 0000000..372617c --- /dev/null +++ b/LoadBalancerProject-DONT-IMPORT-INTO-UNITY/Dockerfile @@ -0,0 +1,16 @@ +FROM mcr.microsoft.com/dotnet/sdk:5.0-alpine AS builder +WORKDIR /lrm +COPY . . +RUN [\ + "dotnet", "publish", \ + "--output", "/build/", \ + "--configuration", "Release",\ + "--no-self-contained", \ + "." ] + +FROM mcr.microsoft.com/dotnet/runtime:5.0-alpine +WORKDIR /lrm-lb +COPY --from=builder /build/ . +ENV LRM_LB_CONFIG_PATH="/config/config-load-balancer.json" +CMD [ "./LRM_LoadBalancer" ] +ENTRYPOINT [ "./LRM_LoadBalancer" ] \ No newline at end of file diff --git a/LoadBalancerProject-DONT-IMPORT-INTO-UNITY/LRM_LoadBalancer/Program.cs b/LoadBalancerProject-DONT-IMPORT-INTO-UNITY/LRM_LoadBalancer/Program.cs index 782c8c8..a0c8047 100644 --- a/LoadBalancerProject-DONT-IMPORT-INTO-UNITY/LRM_LoadBalancer/Program.cs +++ b/LoadBalancerProject-DONT-IMPORT-INTO-UNITY/LRM_LoadBalancer/Program.cs @@ -1,4 +1,4 @@ -using Newtonsoft.Json; +using Newtonsoft.Json; using System; using System.Collections.Generic; using System.IO; @@ -19,7 +19,7 @@ namespace LightReflectiveMirror.LoadBalancing private int _pingDelay = 10000; public static bool showDebugLogs = false; const string API_PATH = "/api/stats"; - const string CONFIG_PATH = "config.json"; + readonly string CONFIG_PATH = System.Environment.GetEnvironmentVariable("LRM_LB_CONFIG_PATH") ?? "config.json"; public static Config conf; public static Program instance; diff --git a/ServerProject-DONT-IMPORT-INTO-UNITY/Dockerfile b/ServerProject-DONT-IMPORT-INTO-UNITY/Dockerfile new file mode 100644 index 0000000..96f3186 --- /dev/null +++ b/ServerProject-DONT-IMPORT-INTO-UNITY/Dockerfile @@ -0,0 +1,17 @@ +FROM mcr.microsoft.com/dotnet/sdk:5.0-alpine AS builder +WORKDIR /lrm +COPY . . +RUN [\ + "dotnet", "publish", \ + "--output", "/build/", \ + "--configuration", "Release",\ + "--no-self-contained", \ + "." ] + +FROM mcr.microsoft.com/dotnet/runtime:5.0-alpine +WORKDIR /lrm +COPY --from=builder /build/ . +COPY ./MultiCompiled.dll . +ENV LRM_CONFIG_PATH="/config/config.json" +CMD [ "./LRM" ] +ENTRYPOINT [ "./LRM" ] \ No newline at end of file diff --git a/ServerProject-DONT-IMPORT-INTO-UNITY/LRM/Program/Program.cs b/ServerProject-DONT-IMPORT-INTO-UNITY/LRM/Program/Program.cs index b173120..87570a3 100644 --- a/ServerProject-DONT-IMPORT-INTO-UNITY/LRM/Program/Program.cs +++ b/ServerProject-DONT-IMPORT-INTO-UNITY/LRM/Program/Program.cs @@ -15,6 +15,30 @@ namespace LightReflectiveMirror { partial class Program { + public static Transport transport; + public static Program instance; + public static Config conf; + + private RelayHandler _relay; + private MethodInfo _awakeMethod; + private MethodInfo _startMethod; + private MethodInfo _updateMethod; + private MethodInfo _lateUpdateMethod; + + private DateTime _startupTime; + public static string publicIP; + private List _currentConnections = new List(); + public Dictionary NATConnections = new Dictionary(); + private BiDictionary _pendingNATPunches = new BiDictionary(); + private int _currentHeartbeatTimer = 0; + + private byte[] _NATRequest = new byte[500]; + private int _NATRequestPosition = 0; + + private UdpClient _punchServer; + + private readonly string CONFIG_PATH = System.Environment.GetEnvironmentVariable("LRM_CONFIG_PATH") ?? "config.json"; + public static void Main(string[] args) => new Program().MainAsync().GetAwaiter().GetResult(); public List GetRooms() => _relay.rooms; @@ -39,7 +63,7 @@ namespace LightReflectiveMirror WriteLogMessage("Loading Assembly... ", ConsoleColor.White, true); try { - var asm = Assembly.LoadFile(Directory.GetCurrentDirectory() + @"\" + conf.TransportDLL); + var asm = Assembly.LoadFile(Path.GetFullPath(conf.TransportDLL)); WriteLogMessage($"OK", ConsoleColor.Green); WriteLogMessage("\nLoading Transport Class... ", ConsoleColor.White, true);