Skip to content

Commit

Permalink
- Defaulted ban list to disabled
Browse files Browse the repository at this point in the history
- Allow ban list loading from local file
- Update JS file loading
  • Loading branch information
Katharine committed Jul 26, 2008
1 parent 82f20e7 commit c758f9b
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 31 deletions.
49 changes: 30 additions & 19 deletions server/BanList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,22 +39,30 @@ 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)
{
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)
{
Expand All @@ -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()
Expand Down
3 changes: 2 additions & 1 deletion server/Html/Templates/AjaxLife.html
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@
<script src="{STATIC_ROOT}AjaxLife.SpatialChat.js" type="text/javascript"></script>
<script src="{STATIC_ROOT}AjaxLife.Toolbar.js" type="text/javascript"></script>
<script src="{STATIC_ROOT}AjaxLife.Friends.js" type="text/javascript"></script>
<script src="{STATIC_ROOT}AjaxLife.FriendList.js" type="text/javascript"></script>
<script src="{STATIC_ROOT}AjaxLife.Groups.js" type="text/javascript"></script>
<script src="{STATIC_ROOT}AjaxLife.Contacts.js" type="text/javascript"></script>
<script src="{STATIC_ROOT}AjaxLife.Search.js" type="text/javascript"></script>
<script src="{STATIC_ROOT}AjaxLife.StatusBar.js" type="text/javascript"></script>
<script src="{STATIC_ROOT}AjaxLife.Profile.js" type="text/javascript"></script>
Expand Down
29 changes: 18 additions & 11 deletions server/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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"));
Expand Down

0 comments on commit c758f9b

Please sign in to comment.