From 0085241d2366f266b5416488dbead174184420b0 Mon Sep 17 00:00:00 2001 From: MichaelTheShifter Date: Sun, 1 May 2016 20:23:48 -0400 Subject: Beta 2.2 Patch 1 Commit for Beta 2.2 Patch 1 - Removed unused "Linux Mint 7" and "NetSockets" files from Resources.resx - Added a better server startup pool, no longer hardcoded. - Added a server blacklist for disabling servers that break the rules of the playshiftos.ml/forum server showcase --- source/WindowsFormsApplication1/Package_Grabber.cs | 55 +++++++++++++++++----- 1 file changed, 42 insertions(+), 13 deletions(-) (limited to 'source/WindowsFormsApplication1/Package_Grabber.cs') diff --git a/source/WindowsFormsApplication1/Package_Grabber.cs b/source/WindowsFormsApplication1/Package_Grabber.cs index c9948b0..a041910 100644 --- a/source/WindowsFormsApplication1/Package_Grabber.cs +++ b/source/WindowsFormsApplication1/Package_Grabber.cs @@ -54,29 +54,58 @@ namespace ShiftOS { clients = new Dictionary(); } - var client = new NetObjectClient(); - client.OnReceived += (object s, NetReceivedEventArgs a) => { - try { - var obj = (ObjectModel)a.Data.Object; - if (obj.Command == "set_ident") + bool blacklisted = false; + string blacklist = new WebClient().DownloadString("http://playshiftos.ml/server/blacklist"); + string[] splitter = blacklist.Split(';'); + foreach (string addr in splitter) + { + try + { + string[] addSplitter = addr.Split(':'); + string host = addSplitter[0]; + int prt = Convert.ToInt32(addSplitter[1]); + if(address == host && port == prt) { - this_id = obj.SysId; + blacklisted = true; } } catch { } - }; - - try + } + if (!blacklisted) { - client.Connect(address, port); - clients.Add(client.RemoteHost, client); + var client = new NetObjectClient(); + client.OnReceived += (object s, NetReceivedEventArgs a) => + { + try + { + var obj = (ObjectModel)a.Data.Object; + if (obj.Command == "set_ident") + { + this_id = obj.SysId; + } + } + catch + { + + } + }; + + try + { + client.Connect(address, port); + clients.Add(client.RemoteHost, client); + } + catch (Exception ex) + { + API.CreateInfoboxSession("Server Connection Error", $"{ex.Message}", infobox.InfoboxMode.Info); + } } - catch(Exception ex) + else { - MessageBox.Show($"Error: {ex.Message}"); + API.CreateInfoboxSession("Server Connection Error", "The server you are trying to connect to has been blacklisted for breaking the rules of the Server Showcase, therefore you may not connect to it.", infobox.InfoboxMode.Info); } } -- cgit v1.2.3