diff --git a/Novetus/NovetusCMD/NovetusCMD.cs b/Novetus/NovetusCMD/NovetusCMD.cs index 004444d..bf1a566 100644 --- a/Novetus/NovetusCMD/NovetusCMD.cs +++ b/Novetus/NovetusCMD/NovetusCMD.cs @@ -317,10 +317,9 @@ namespace NovetusCMD static void ServerExited(object sender, EventArgs e) { - string IP = SecurityFuncs.GetExternalIPAddress(); string pingURL = "http://" + GlobalVars.UserConfiguration.ServerBrowserServerAddress + "/query.php?name=" + GlobalVars.UserConfiguration.ServerBrowserServerName + - "&ip=" + (!string.IsNullOrWhiteSpace(GlobalVars.UserConfiguration.AlternateServerIP) ? GlobalVars.UserConfiguration.AlternateServerIP : IP) + + "&ip=" + (!string.IsNullOrWhiteSpace(GlobalVars.UserConfiguration.AlternateServerIP) ? GlobalVars.UserConfiguration.AlternateServerIP : GlobalVars.ExternalIP) + "&port=" + GlobalVars.UserConfiguration.RobloxPort + "&client=" + GlobalVars.UserConfiguration.SelectedClient + "&online=0"; diff --git a/Novetus/NovetusCore/StorageAndFunctions/GlobalFuncs.cs b/Novetus/NovetusCore/StorageAndFunctions/GlobalFuncs.cs index 6d1b677..f9f5c65 100644 --- a/Novetus/NovetusCore/StorageAndFunctions/GlobalFuncs.cs +++ b/Novetus/NovetusCore/StorageAndFunctions/GlobalFuncs.cs @@ -2059,13 +2059,12 @@ public class GlobalFuncs Console.Write(text); } - public static async void CreateTXT() + public static void CreateTXT() { if (GlobalVars.RequestToOutputInfo) { - string IP = await SecurityFuncs.GetExternalIPAddressAsync(); string[] lines1 = { - SecurityFuncs.Base64Encode((!string.IsNullOrWhiteSpace(GlobalVars.UserConfiguration.AlternateServerIP) ? GlobalVars.UserConfiguration.AlternateServerIP : IP)), + SecurityFuncs.Base64Encode((!string.IsNullOrWhiteSpace(GlobalVars.UserConfiguration.AlternateServerIP) ? GlobalVars.UserConfiguration.AlternateServerIP : GlobalVars.ExternalIP)), SecurityFuncs.Base64Encode(GlobalVars.UserConfiguration.RobloxPort.ToString()), SecurityFuncs.Base64Encode(GlobalVars.UserConfiguration.SelectedClient) }; @@ -2077,13 +2076,13 @@ public class GlobalFuncs }; string URI2 = "novetus://" + SecurityFuncs.Base64Encode(string.Join("|", lines2, true)); - string text = GlobalFuncs.MultiLine( + string text = MultiLine( "Process ID: " + (GlobalVars.ProcessID == 0 ? "N/A" : GlobalVars.ProcessID.ToString()), "Don't copy the Process ID when sharing the server.", "--------------------", "Server Info:", "Client: " + GlobalVars.UserConfiguration.SelectedClient, - "IP: " + (!string.IsNullOrWhiteSpace(GlobalVars.UserConfiguration.AlternateServerIP) ? GlobalVars.UserConfiguration.AlternateServerIP : IP), + "IP: " + (!string.IsNullOrWhiteSpace(GlobalVars.UserConfiguration.AlternateServerIP) ? GlobalVars.UserConfiguration.AlternateServerIP : GlobalVars.ExternalIP), "Port: " + GlobalVars.UserConfiguration.RobloxPort.ToString(), "Map: " + GlobalVars.UserConfiguration.Map, "Players: " + GlobalVars.UserConfiguration.PlayerLimit, @@ -2360,5 +2359,21 @@ public class GlobalFuncs color, width, style, color, width, style); } + + public static bool IsClientValid(string client) + { + string clientdir = GlobalPaths.ClientDir; + DirectoryInfo dinfo = new DirectoryInfo(clientdir); + DirectoryInfo[] Dirs = dinfo.GetDirectories(); + foreach (DirectoryInfo dir in Dirs) + { + if (dir.Name == client) + { + return true; + } + } + + return false; + } } #endregion diff --git a/Novetus/NovetusCore/StorageAndFunctions/GlobalVars.cs b/Novetus/NovetusCore/StorageAndFunctions/GlobalVars.cs index 8f2edbf..4e2506a 100644 --- a/Novetus/NovetusCore/StorageAndFunctions/GlobalVars.cs +++ b/Novetus/NovetusCore/StorageAndFunctions/GlobalVars.cs @@ -37,8 +37,9 @@ public static class GlobalVars public static List PartColorListConv; #endregion - #region Joining + #region Joining/Hosting public static string IP = "localhost"; + public static string ExternalIP = SecurityFuncs.GetExternalIPAddress(); public static int DefaultRobloxPort = 53640; public static int JoinPort = DefaultRobloxPort; #endregion diff --git a/Novetus/NovetusCore/StorageAndFunctions/ScriptFuncs.cs b/Novetus/NovetusCore/StorageAndFunctions/ScriptFuncs.cs index 54f0a62..3a58222 100644 --- a/Novetus/NovetusCore/StorageAndFunctions/ScriptFuncs.cs +++ b/Novetus/NovetusCore/StorageAndFunctions/ScriptFuncs.cs @@ -69,7 +69,6 @@ public class ScriptFuncs + md5s + ",'" + GlobalVars.UserConfiguration.PlayerTripcode + "');"; case ScriptType.Server: - string IP = SecurityFuncs.GetExternalIPAddress(); return "_G.CSServer(" + GlobalVars.UserConfiguration.RobloxPort + "," + GlobalVars.UserConfiguration.PlayerLimit + "," @@ -77,7 +76,7 @@ public class ScriptFuncs + GlobalVars.UserConfiguration.ShowServerNotifications.ToString().ToLower() + ",'" + GlobalVars.UserConfiguration.ServerBrowserServerName + "','" + GlobalVars.UserConfiguration.ServerBrowserServerAddress + "','" - + (!string.IsNullOrWhiteSpace(GlobalVars.UserConfiguration.AlternateServerIP) ? GlobalVars.UserConfiguration.AlternateServerIP : IP) + "','" + + (!string.IsNullOrWhiteSpace(GlobalVars.UserConfiguration.AlternateServerIP) ? GlobalVars.UserConfiguration.AlternateServerIP : GlobalVars.ExternalIP) + "','" + GlobalVars.UserConfiguration.SelectedClient + "');"; case ScriptType.Solo: case ScriptType.EasterEgg: @@ -222,7 +221,6 @@ public class ScriptFuncs + md5s + ",'" + GlobalVars.UserConfiguration.PlayerTripcode + "');"; case ScriptType.Server: - string IP = SecurityFuncs.GetExternalIPAddress(); return "dofile('" + luafile + "'); _G.CSServer(" + GlobalVars.UserConfiguration.RobloxPort + "," + GlobalVars.UserConfiguration.PlayerLimit + "," @@ -230,6 +228,7 @@ public class ScriptFuncs + GlobalVars.UserConfiguration.ShowServerNotifications.ToString().ToLower() + ",'" + GlobalVars.UserConfiguration.ServerBrowserServerName + "','" + GlobalVars.UserConfiguration.ServerBrowserServerAddress + "','" + + (!string.IsNullOrWhiteSpace(GlobalVars.UserConfiguration.AlternateServerIP) ? GlobalVars.UserConfiguration.AlternateServerIP : GlobalVars.ExternalIP) + "','" + GlobalVars.UserConfiguration.SelectedClient + "'); " + (!string.IsNullOrWhiteSpace(GlobalPaths.AddonScriptPath) ? " dofile('" + GlobalPaths.AddonScriptPath + "');" : ""); case ScriptType.Solo: diff --git a/Novetus/NovetusCore/StorageAndFunctions/SecurityFuncs.cs b/Novetus/NovetusCore/StorageAndFunctions/SecurityFuncs.cs index c0d0ed2..c384fe0 100644 --- a/Novetus/NovetusCore/StorageAndFunctions/SecurityFuncs.cs +++ b/Novetus/NovetusCore/StorageAndFunctions/SecurityFuncs.cs @@ -277,14 +277,6 @@ public class SecurityFuncs return ipAddress; } -#if !BASICLAUNCHER - public static async Task GetExternalIPAddressAsync() - { - var task = Task.Factory.StartNew(() => GetExternalIPAddress()); - return await task; - } -#endif - #if LAUNCHER //modified from https://stackoverflow.com/questions/14687658/random-name-generator-in-c-sharp public static string GenerateName(int len) diff --git a/Novetus/NovetusCore/StorageAndFunctions/VarStorage.cs b/Novetus/NovetusCore/StorageAndFunctions/VarStorage.cs index 282aa8e..58b7ace 100644 --- a/Novetus/NovetusCore/StorageAndFunctions/VarStorage.cs +++ b/Novetus/NovetusCore/StorageAndFunctions/VarStorage.cs @@ -38,6 +38,23 @@ public class VarStorage ServerClient = SecurityFuncs.Base64DecodeOld(client); } + public bool IsValid() + { + if (!string.IsNullOrWhiteSpace(ServerName) && + !string.IsNullOrWhiteSpace(ServerClient) && + !string.IsNullOrWhiteSpace(ServerIP) && + !string.IsNullOrWhiteSpace(ServerPort.ToString()) && + GlobalFuncs.IsClientValid(ServerClient) && + (!ServerIP.Equals("localhost") || !ServerIP.Equals("127.0.0.1"))) + { + return true; + } + else + { + return false; + } + } + public string ServerName { get; set; } public string ServerIP { get; set; } public int ServerPort { get; set; } diff --git a/Novetus/NovetusLauncher/Forms/LauncherForm/Compact/LauncherFormCompact.cs b/Novetus/NovetusLauncher/Forms/LauncherForm/Compact/LauncherFormCompact.cs index 39dfd82..10f7d3a 100644 --- a/Novetus/NovetusLauncher/Forms/LauncherForm/Compact/LauncherFormCompact.cs +++ b/Novetus/NovetusLauncher/Forms/LauncherForm/Compact/LauncherFormCompact.cs @@ -25,9 +25,9 @@ namespace NovetusLauncher #endregion #region Form Events - async void tabControl1_SelectedIndexChanged(object sender, EventArgs e) + void tabControl1_SelectedIndexChanged(object sender, EventArgs e) { - await launcherForm.ChangeTabs(); + launcherForm.ChangeTabs(); } void Button1Click(object sender, EventArgs e) diff --git a/Novetus/NovetusLauncher/Forms/LauncherForm/Extended/LauncherFormExtended.cs b/Novetus/NovetusLauncher/Forms/LauncherForm/Extended/LauncherFormExtended.cs index bbf9b0c..d0188b5 100644 --- a/Novetus/NovetusLauncher/Forms/LauncherForm/Extended/LauncherFormExtended.cs +++ b/Novetus/NovetusLauncher/Forms/LauncherForm/Extended/LauncherFormExtended.cs @@ -30,9 +30,9 @@ namespace NovetusLauncher #endregion #region Form Events - async void tabControl1_SelectedIndexChanged(object sender, EventArgs e) + void tabControl1_SelectedIndexChanged(object sender, EventArgs e) { - await launcherForm.ChangeTabs(); + launcherForm.ChangeTabs(); } void Button1Click(object sender, EventArgs e) diff --git a/Novetus/NovetusLauncher/Forms/LauncherForm/LauncherFormShared.cs b/Novetus/NovetusLauncher/Forms/LauncherForm/LauncherFormShared.cs index 13478be..0c1a82e 100644 --- a/Novetus/NovetusLauncher/Forms/LauncherForm/LauncherFormShared.cs +++ b/Novetus/NovetusLauncher/Forms/LauncherForm/LauncherFormShared.cs @@ -301,14 +301,10 @@ namespace NovetusLauncher Application.Exit(); } - public static async Task LoadServerInformation(TextBox box) + public static void LoadServerInformation(TextBox box) { - //since we are async, DO THESE first or we'll clear out random stuff. - box.Text = "Loading..."; - string IP = await SecurityFuncs.GetExternalIPAddressAsync(); - box.Text = ""; string[] lines1 = { - SecurityFuncs.Base64Encode(!string.IsNullOrWhiteSpace(GlobalVars.UserConfiguration.AlternateServerIP) ? GlobalVars.UserConfiguration.AlternateServerIP : IP), + SecurityFuncs.Base64Encode(!string.IsNullOrWhiteSpace(GlobalVars.UserConfiguration.AlternateServerIP) ? GlobalVars.UserConfiguration.AlternateServerIP : GlobalVars.ExternalIP), SecurityFuncs.Base64Encode(GlobalVars.UserConfiguration.RobloxPort.ToString()), SecurityFuncs.Base64Encode(GlobalVars.UserConfiguration.SelectedClient) }; @@ -321,7 +317,7 @@ namespace NovetusLauncher string URI2 = "novetus://" + SecurityFuncs.Base64Encode(string.Join("|", lines2), true); string[] text = { "Client: " + GlobalVars.UserConfiguration.SelectedClient, - "IP: " + (!string.IsNullOrWhiteSpace(GlobalVars.UserConfiguration.AlternateServerIP) ? GlobalVars.UserConfiguration.AlternateServerIP : IP), + "IP: " + (!string.IsNullOrWhiteSpace(GlobalVars.UserConfiguration.AlternateServerIP) ? GlobalVars.UserConfiguration.AlternateServerIP : GlobalVars.ExternalIP), "Port: " + GlobalVars.UserConfiguration.RobloxPort.ToString(), "Map: " + GlobalVars.UserConfiguration.Map, "Players: " + GlobalVars.UserConfiguration.PlayerLimit, @@ -344,7 +340,7 @@ namespace NovetusLauncher box.ScrollToCaret(); } - public async Task ChangeTabs() + public void ChangeTabs() { switch (Tabs.SelectedTab) { @@ -355,7 +351,7 @@ namespace NovetusLauncher ClientBox.Items.Clear(); ServerBox.Items.Clear(); PortBox.Items.Clear(); - await LoadServerInformation(ServerInfo); + LoadServerInformation(ServerInfo); break; case TabPage pg3 when pg3 == Tabs.TabPages[TabPageClients]: string clientdir = GlobalPaths.ClientDir; @@ -517,10 +513,9 @@ namespace NovetusLauncher void ServerExited(object sender, EventArgs e) { - string IP = SecurityFuncs.GetExternalIPAddress(); string pingURL = "http://" + GlobalVars.UserConfiguration.ServerBrowserServerAddress + "/query.php?name=" + GlobalVars.UserConfiguration.ServerBrowserServerName + - "&ip=" + (!string.IsNullOrWhiteSpace(GlobalVars.UserConfiguration.AlternateServerIP) ? GlobalVars.UserConfiguration.AlternateServerIP : IP) + + "&ip=" + (!string.IsNullOrWhiteSpace(GlobalVars.UserConfiguration.AlternateServerIP) ? GlobalVars.UserConfiguration.AlternateServerIP : GlobalVars.ExternalIP) + "&port=" + GlobalVars.UserConfiguration.RobloxPort + "&client=" + GlobalVars.UserConfiguration.SelectedClient + "&online=0"; diff --git a/Novetus/NovetusLauncher/Forms/LauncherForm/Stylish/LauncherFormStylishServerInfo.Designer.cs b/Novetus/NovetusLauncher/Forms/LauncherForm/Stylish/LauncherFormStylishServerInfo.Designer.cs index fab1089..65854f7 100644 --- a/Novetus/NovetusLauncher/Forms/LauncherForm/Stylish/LauncherFormStylishServerInfo.Designer.cs +++ b/Novetus/NovetusLauncher/Forms/LauncherForm/Stylish/LauncherFormStylishServerInfo.Designer.cs @@ -55,6 +55,7 @@ namespace NovetusLauncher this.ClientSize = new System.Drawing.Size(800, 450); this.Controls.Add(this.ServerInfo); this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); + this.MinimumSize = new System.Drawing.Size(540, 198); this.Name = "LauncherFormStylishServerInfo"; this.Text = "Server Information"; this.Load += new System.EventHandler(this.LauncherFormStylishServerInfo_Load); diff --git a/Novetus/NovetusLauncher/Forms/LauncherForm/Stylish/LauncherFormStylishServerInfo.cs b/Novetus/NovetusLauncher/Forms/LauncherForm/Stylish/LauncherFormStylishServerInfo.cs index 5966a07..7bcee12 100644 --- a/Novetus/NovetusLauncher/Forms/LauncherForm/Stylish/LauncherFormStylishServerInfo.cs +++ b/Novetus/NovetusLauncher/Forms/LauncherForm/Stylish/LauncherFormStylishServerInfo.cs @@ -16,9 +16,9 @@ namespace NovetusLauncher #endregion #region Form Events - private async void LauncherFormStylishServerInfo_Load(object sender, EventArgs e) + private void LauncherFormStylishServerInfo_Load(object sender, EventArgs e) { - await LauncherFormShared.LoadServerInformation(ServerInfo); + LauncherFormShared.LoadServerInformation(ServerInfo); } #endregion } diff --git a/Novetus/NovetusLauncher/Forms/ServerBrowser.cs b/Novetus/NovetusLauncher/Forms/ServerBrowser.cs index 104646f..387b7f3 100644 --- a/Novetus/NovetusLauncher/Forms/ServerBrowser.cs +++ b/Novetus/NovetusLauncher/Forms/ServerBrowser.cs @@ -2,6 +2,7 @@ using System; using System.Collections.Generic; using System.IO; +using System.Linq; using System.Net; using System.Reflection; using System.Threading.Tasks; @@ -90,6 +91,7 @@ namespace NovetusLauncher private async void ServerBrowser_Load(object sender, EventArgs e) { MasterServerBox.Text = GlobalVars.UserConfiguration.ServerBrowserServerAddress; + CenterToScreen(); await LoadServers(); } @@ -134,7 +136,10 @@ namespace NovetusLauncher string DecodedLine = SecurityFuncs.Base64DecodeOld(line); string[] serverInfo = DecodedLine.Split('|'); VarStorage.GameServer gameServer = new VarStorage.GameServer(serverInfo[0], serverInfo[1], serverInfo[2], serverInfo[3]); - serverList.Add(gameServer); + if (gameServer.IsValid() && !serverList.Any(item => item.ServerName.Equals(gameServer.ServerName))) + { + serverList.Add(gameServer); + } } } } @@ -142,13 +147,16 @@ namespace NovetusLauncher async Task LoadServers() { + string oldText = Text; + Text = Text + " (Loading Servers...)"; + if (!string.IsNullOrWhiteSpace(MasterServerBox.Text)) { try { serverList.Clear(); - - await LoadServerInfoFromFile("http://" + MasterServerBox.Text + "/serverlist.txt"); + Task info = await Task.Factory.StartNew(() => LoadServerInfoFromFile("http://" + MasterServerBox.Text + "/serverlist.txt")); + Task.WaitAll(info); ServerListView.BeginUpdate(); ServerListView.Clear(); @@ -186,8 +194,19 @@ namespace NovetusLauncher } catch (Exception ex) { + string message = "Unable to load servers (" + ex.GetBaseException().Message + ").\n\nMake sure you have a master server address other than 'localhost' in the textbox.\nIf the server still does not load properly, consult the administrator of the server for more information."; + if (ex.GetBaseException().Message.Contains("404")) + { + message = "There are no servers available on this master server."; + } + GlobalFuncs.LogExceptions(ex); - MessageBox.Show("Unable to load servers (" + ex.Message + ").\n\nMake sure you have a master server address other than 'localhost' in the textbox.\nIf the server still does not load properly, consult the administrator of the server for more information.", "Novetus - Error", MessageBoxButtons.OK, MessageBoxIcon.Error); + MessageBox.Show(message, "Novetus - Error", MessageBoxButtons.OK, MessageBoxIcon.Error); + ServerListView.Clear(); + } + finally + { + Text = oldText; } } } diff --git a/changelog.txt b/changelog.txt index ef1ac7b..1884712 100644 --- a/changelog.txt +++ b/changelog.txt @@ -38,13 +38,16 @@ Changes from Pre-Release 5: - You can now properly resize the Diogenes editor. - Clients with seperate Roblox Players and Studios are now supported with the new "Seperate Folders" option. - This option tells Novetus to load the client from 3 folders in the client: client, studio, and server. - - Items will be broken with this method. However, the client developer may edit the paths for each item loaded through the script by using Lua's string.gsub function and adding an extra "../" after rbxasset:// (string.gsub(itemURL, "rbxasset://", "rbxasset://../"). + - Items and local places will be broken with this method. However, the client developer may edit the paths for each item loaded through the script by using Lua's string.gsub function and adding an extra "../" after rbxasset:// (string.gsub(itemURL, "rbxasset://", "rbxasset://../"). - Fixed "Special splashes" not working on specific dates. - "Special splashes" how have a 1 in 5 chance to be overriden with a splash from the splash list. - Added support for the new splash formatting in the Splash Tester. - You are now able to add splash formatting through the Splash Formatting menu and see it work in real time. - "Special splashes" can now be set up through the Splash Tester. - Added context for some splashes. +- The server browser will now load the current master server address on bootup. +- Fixed a bug where joining a game with the Server Browser loads the wrong IP address in the game title. +- The user will now know when the Server Browser is loading servers. Changes from 1.2.4.1: - The OBJ2MeshV1GUI, The Asset Localizer, and the Item SDK have been merged to form the Asset SDK! - Works with the Roblox Asset Delivery API! Note: Script assets wil have to be downloaded manually in order to be used in scripts. diff --git a/query.php b/query.php index 24c3227..e68bfdc 100644 --- a/query.php +++ b/query.php @@ -18,58 +18,64 @@ along with Novetus's query.php. If not, see . */ //NOVETUS MASTER SERVER QUERY CODE +//thanks to idkwhatnametoget for the port fix -//server name +//name $name = $_GET["name"]; -//server ip -$ip = $_GET["ip"]; -//server port +//port $port = $_GET["port"]; -//client name +//client $client = $_GET["client"]; -//online status -$online = $_GET["online"]; -//strings -$deleteentry = 1; -$status = "Offline"; - -//ONLY the $name and $client arguments will show up in the master server! -$file = 'serverlist.txt'; -$text = base64_encode(base64_encode($name).'|'.base64_encode($ip).'|'.base64_encode($port).'|'.base64_encode($client))."\r\n"; - -if ($online == 1) +if (!empty($port) and $port < 65535 and is_numeric($port) and !empty($name) and !empty($client)) { - $deleteentry = 0; + //server ip + $ip = $_GET["ip"]; + //online status + $online = $_GET["online"]; + + //strings + $deleteentry = 1; + $status = "Offline"; - foreach(file($file) as $line) + $file = 'serverlist.txt'; + + //ONLY the $name and $client arguments will show up in the master server! + $text = base64_encode(base64_encode($name).'|'.base64_encode($ip).'|'.base64_encode($port).'|'.base64_encode($client))."\r\n"; + + if ($online == 1) { - if (strpos($line, $text) !== false) + $deleteentry = 0; + + foreach(file($file) as $line) { - $file_contents = file_get_contents($file); - $contents = str_replace($line, '', $file_contents); - file_put_contents($file, $contents); + if (strpos($line, $text) !== false) + { + $file_contents = file_get_contents($file); + $contents = str_replace($line, '', $file_contents); + file_put_contents($file, $contents); + } + } + + file_put_contents($file, $text, FILE_APPEND); + + $status = "Online"; + } + + if ($deleteentry == 1) + { + foreach(file($file) as $line) + { + if (strpos($line, $text) !== false) + { + $file_contents = file_get_contents($file); + $contents = str_replace($line, '', $file_contents); + file_put_contents($file, $contents); + } } } - - file_put_contents($file, $text, FILE_APPEND); - - $status = "Online"; -} -if ($deleteentry == 1) -{ - foreach(file($file) as $line) - { - if (strpos($line, $text) !== false) - { - $file_contents = file_get_contents($file); - $contents = str_replace($line, '', $file_contents); - file_put_contents($file, $contents); - } - } + // Display the server info to browsers. + echo "" . htmlspecialchars($name) . ". A " . htmlspecialchars($client) . " server. Server Status: " . htmlspecialchars($status) . ""; } - -// Display the server info to browsers. -echo "" . htmlspecialchars($name) . ". A " . htmlspecialchars($client) . " server. Server Status: " . htmlspecialchars($status) . ""; ?> \ No newline at end of file