Added whitelist

This commit is contained in:
Shank 2011-05-30 02:08:32 -06:00
parent c61a4b6aca
commit 089c5b027b

View file

@ -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);