From 3b0ae50517692918d0d3059b453a8a4a32090b2f Mon Sep 17 00:00:00 2001 From: Quacky Date: Mon, 7 Aug 2017 18:23:30 -0500 Subject: [PATCH] portmapper integration --- .../RBXLegacyLauncher/GlobalVars.cs | 1 + .../RBXLegacyLauncher/MainForm.cs | 35 +++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/RBXLegacyLauncher/RBXLegacyLauncher/GlobalVars.cs b/RBXLegacyLauncher/RBXLegacyLauncher/GlobalVars.cs index 460d5ff..6bd0c70 100644 --- a/RBXLegacyLauncher/RBXLegacyLauncher/GlobalVars.cs +++ b/RBXLegacyLauncher/RBXLegacyLauncher/GlobalVars.cs @@ -18,6 +18,7 @@ public static int ServerPort = 53640; public static int DefaultRobloxPort = 53640; public static int PlayerLimit = 12; + public static string MyIP = "localhost"; // player settings public static int UserID = 0; public static string PlayerName = "Player"; diff --git a/RBXLegacyLauncher/RBXLegacyLauncher/MainForm.cs b/RBXLegacyLauncher/RBXLegacyLauncher/MainForm.cs index dc77743..81d2fce 100644 --- a/RBXLegacyLauncher/RBXLegacyLauncher/MainForm.cs +++ b/RBXLegacyLauncher/RBXLegacyLauncher/MainForm.cs @@ -112,6 +112,12 @@ namespace RBXLegacyLauncher void Button2Click(object sender, EventArgs e) { + Process pmap = new Process(); + pmap.StartInfo.FileName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + "\\Java -jar portmapper.jar"; + pmap.StartInfo.Arguments = "-add -externalPort" + GlobalVars.ServerPort + " -internalPort" + GlobalVars.ServerPort + "-ip" + GlobalVars.MyIP + " -protocol udp"; + pmap.StartInfo.UseShellExecute = false; + pmap.StartInfo.CreateNoWindow = true; + pmap.Start(); WriteConfigValues(); StartServer(); @@ -187,6 +193,17 @@ namespace RBXLegacyLauncher label11.Text = version; GlobalVars.Version = version; ReadConfigValues(); + using (WebClient wc = new WebClient()) + { + try + { + GlobalVars.MyIP = wc.DownloadString("http://ipv4.icanhazip.com"); + } + catch (Exception) + { + GlobalVars.MyIP = "localhost" + Environment.NewLine; + } + } } void ReadConfigValues() @@ -868,14 +885,32 @@ namespace RBXLegacyLauncher string important = SecurityFuncs.Base64Decode("cmJ4bGVnYWN5IGthbnJpc2hh"); if (command.Equals("rbxlegacy server")) { + Process pmap = new Process(); + pmap.StartInfo.FileName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + "\\Java -jar portmapper.jar"; + pmap.StartInfo.Arguments = "-add -externalPort" + GlobalVars.ServerPort + " -internalPort" + GlobalVars.ServerPort + "-ip" + GlobalVars.MyIP + " -protocol udp"; + pmap.StartInfo.UseShellExecute = false; + pmap.StartInfo.CreateNoWindow = true; + pmap.Start(); StartServer(); } else if (command.Equals("rbxlegacy server no3d")) { + Process pmap = new Process(); + pmap.StartInfo.FileName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + "\\Java -jar portmapper.jar"; + pmap.StartInfo.Arguments = "-add -externalPort" + GlobalVars.ServerPort + " -internalPort" + GlobalVars.ServerPort + "-ip" + GlobalVars.MyIP + " -protocol udp"; + pmap.StartInfo.UseShellExecute = false; + pmap.StartInfo.CreateNoWindow = true; + pmap.Start(); StartServerNo3D(); } else if (command.Equals("rbxlegacy no3d")) { + Process pmap = new Process(); + pmap.StartInfo.FileName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + "\\Java -jar portmapper.jar"; + pmap.StartInfo.Arguments = "-add -externalPort" + GlobalVars.ServerPort + " -internalPort" + GlobalVars.ServerPort + "-ip" + GlobalVars.MyIP + " -protocol udp"; + pmap.StartInfo.UseShellExecute = false; + pmap.StartInfo.CreateNoWindow = true; + pmap.Start(); StartServerNo3D(); } else if (command.Equals("rbxlegacy client"))