From 089c5b027bbece27b5882c715666135ddcc74d2e Mon Sep 17 00:00:00 2001 From: Shank Date: Mon, 30 May 2011 02:08:32 -0600 Subject: [PATCH] Added whitelist --- TShockAPI/TShock.cs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/TShockAPI/TShock.cs b/TShockAPI/TShock.cs index 608000fc..f5d08318 100644 --- a/TShockAPI/TShock.cs +++ b/TShockAPI/TShock.cs @@ -111,6 +111,10 @@ namespace TShockAPI { Kick(ply, "Your account has been disabled."); } + if (!OnWhitelist(ip)) + { + Kick(ply, "Not on whitelist."); + } } void OnLoadContent(Microsoft.Xna.Framework.Content.ContentManager obj) @@ -137,6 +141,16 @@ namespace TShockAPI * Useful stuff: * */ + public static bool OnWhitelist(string ip) + { + if (!enableWhitelist) { return true; } + if (!System.IO.File.Exists(saveDir + "whitelist.txt")) { CreateFile(saveDir + "whitelist.txt"); TextWriter tw = new StreamWriter(saveDir + "whitelist.txt"); tw.WriteLine("127.0.0.1"); tw.Close(); } + TextReader tr = new StreamReader(saveDir + "whitelist.txt"); + string whitelist = tr.ReadToEnd(); + ip = GetRealIP(ip); + if (whitelist.Contains(ip)) { return true; } else { return false; } + } + public static bool CheckGreif(String ip) { ip = GetRealIP(ip);