From c758f9b40873384bdd89fcf199c9f3d596c6c39b Mon Sep 17 00:00:00 2001 From: Katharine Berry Date: Sat, 26 Jul 2008 13:54:45 +0000 Subject: [PATCH] - Defaulted ban list to disabled - Allow ban list loading from local file - Update JS file loading --- server/BanList.cs | 49 ++++++++++++++++++----------- server/Html/Templates/AjaxLife.html | 3 +- server/Main.cs | 29 ++++++++++------- 3 files changed, 50 insertions(+), 31 deletions(-) diff --git a/server/BanList.cs b/server/BanList.cs index 3dab2ed..40d04d5 100644 --- a/server/BanList.cs +++ b/server/BanList.cs @@ -39,13 +39,23 @@ public class BanList private Timer Time; private void UpdateList() { - AjaxLife.Debug("BanList", "Fetching ban list from "+AjaxLife.BAN_LIST+"..."); + AjaxLife.Debug("BanList", "Loading ban list from "+AjaxLife.BAN_LIST+"..."); try { - HttpWebRequest request = (HttpWebRequest)WebRequest.Create(AjaxLife.BAN_LIST); - HttpWebResponse response = (HttpWebResponse)request.GetResponse(); - StreamReader reader = new System.IO.StreamReader(response.GetResponseStream()); - string sbanlist = reader.ReadToEnd(); + string sbanlist = ""; + if (AjaxLife.BAN_LIST.StartsWith("http://")) + { + HttpWebRequest request = (HttpWebRequest)WebRequest.Create(AjaxLife.BAN_LIST); + HttpWebResponse response = (HttpWebResponse)request.GetResponse(); + StreamReader reader = new System.IO.StreamReader(response.GetResponseStream()); + sbanlist = reader.ReadToEnd(); + reader.Close(); + response.Close(); + } + else + { + sbanlist = File.ReadAllText(AjaxLife.BAN_LIST); + } char[] newline = {'\n'}; this.Bans = sbanlist.Split(newline); for(int i = 0; i < this.Bans.Length; ++i) @@ -53,8 +63,6 @@ private void UpdateList() this.Bans[i] = this.Bans[i].Trim(); } AjaxLife.Debug("BanList", "Ban list up to date. "+Bans.Length+" banned names."); - reader.Close(); - response.Close(); } catch(Exception e) { @@ -64,20 +72,23 @@ private void UpdateList() public BanList() { - if(AjaxLife.BAN_UPDATE_TIME > 0) - { - Time = new Timer(); - Time.Interval = AjaxLife.BAN_UPDATE_TIME * 1000.0; - Time.AutoReset = true; - Time.Elapsed += new ElapsedEventHandler(TimerElapsed); - Time.Start(); - AjaxLife.Debug("BanList", "Set ban update timer for "+AjaxLife.BAN_UPDATE_TIME+" seconds."); - } - else + if(AjaxLife.BAN_LIST != "") { - AjaxLife.Debug("BanList", "Ban update timer disabled."); + if(AjaxLife.BAN_UPDATE_TIME > 0) + { + Time = new Timer(); + Time.Interval = AjaxLife.BAN_UPDATE_TIME * 1000.0; + Time.AutoReset = true; + Time.Elapsed += new ElapsedEventHandler(TimerElapsed); + Time.Start(); + AjaxLife.Debug("BanList", "Set ban update timer for "+AjaxLife.BAN_UPDATE_TIME+" seconds."); + } + else + { + AjaxLife.Debug("BanList", "Ban update timer disabled."); + } + UpdateList(); } - UpdateList(); } ~BanList() diff --git a/server/Html/Templates/AjaxLife.html b/server/Html/Templates/AjaxLife.html index 3c52a7c..c512fc9 100644 --- a/server/Html/Templates/AjaxLife.html +++ b/server/Html/Templates/AjaxLife.html @@ -62,7 +62,8 @@ - + + diff --git a/server/Main.cs b/server/Main.cs index b7ddf90..3d9be16 100644 --- a/server/Main.cs +++ b/server/Main.cs @@ -71,15 +71,15 @@ class AjaxLife private static string PrivateAccessKey = ""; private static string TextureCache = "texturecache/"; private static string MacAddress = "00:00:00:00:00:00"; - private static string BanList = "http://server.ajaxlife.net/banlist.txt"; + private static string BanList = ""; private static double BanUpdateTime = 300.0; public static string Id0 = ""; private static bool HandleContentEncoding = false; private static bool UseS3 = false; private static bool DebugMode = false; - public static int TextureCacheCount = 0; // Temporarily completely unused. - public static long TextureCacheSize = 0; // Temporarily completely unused. + public static int TextureCacheCount = 0; + public static long TextureCacheSize = 0; // These are used for the RSA encryption. RSAp holds the public and private keys, // RSA is the object responsible for decrypting. No encryption is done on the server. @@ -181,18 +181,25 @@ public AjaxLife(string[] arg) { BanList = args["banlist"]; } - Console.WriteLine("Using banlist at "+BanList); - if (args["banupdate"] != null) + if(BanList != "") { - BanUpdateTime = double.Parse(args["banupdate"]); - } - if(BanUpdateTime > 0.0) - { - Console.WriteLine("Updating the banlist every "+BanUpdateTime+" seconds."); + Console.WriteLine("Using banlist at "+BanList); + if (args["banupdate"] != null) + { + BanUpdateTime = double.Parse(args["banupdate"]); + } + if(BanUpdateTime > 0.0) + { + Console.WriteLine("Updating the banlist every "+BanUpdateTime+" seconds."); + } + else + { + Console.WriteLine("Banlist updating disabled."); + } } else { - Console.WriteLine("Banlist updating disabled."); + Console.WriteLine("Not using ban list."); } HandleContentEncoding = (args["doencoding"] != null); Console.WriteLine("Handling content encoding: " + (HANDLE_CONTENT_ENCODING ? "Yes" : "No"));