Update svn properties.

This commit is contained in:
Jeff Ames
2009-05-17 10:26:00 +00:00
parent 0379dbe2fd
commit 5cfd84c924
11 changed files with 569 additions and 569 deletions

View File

@@ -1,81 +1,81 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using Nini.Config;
using OpenSim.Framework;
using OpenSim.Region.Framework.Interfaces;
using OpenSim.Region.Framework.Scenes;
namespace OpenSim.Region.CoreModules.Agent.IPBan
{
public class IPBanModule : IRegionModule
{
#region Implementation of IRegionModule
private List<string> m_bans = new List<string>();
public void Initialise(Scene scene, IConfigSource source)
{
new SceneBanner(scene, m_bans);
lock(m_bans)
{
foreach (EstateBan ban in scene.RegionInfo.EstateSettings.EstateBans)
{
if(!String.IsNullOrEmpty(ban.BannedHostIPMask))
m_bans.Add(ban.BannedHostIPMask);
if (!String.IsNullOrEmpty(ban.BannedHostNameMask))
m_bans.Add(ban.BannedHostNameMask);
}
}
}
public void PostInitialise()
{
if(File.Exists("bans.txt"))
{
string[] bans = File.ReadAllLines("bans.txt");
foreach (string ban in bans)
{
m_bans.Add(ban);
}
}
}
public void Close()
{
}
public string Name
{
get { return "IPBanModule"; }
}
public bool IsSharedModule
{
get { return true; }
}
#endregion
/// <summary>
/// Bans all users from the specified network from connecting.
/// DNS bans are in the form "somewhere.com" will block ANY
/// matching domain (including "betasomewhere.com", "beta.somewhere.com",
/// "somewhere.com.beta") - make sure to be reasonably specific in DNS
/// bans.
///
/// IP address bans match on first characters, so,
/// "127.0.0.1" will ban only that address,
/// "127.0.1" will ban "127.0.10.0"
/// but "127.0.1." will ban only the "127.0.1.*" network
/// </summary>
/// <param name="host">See summary for explanation of parameter</param>
public void Ban(string host)
{
m_bans.Add(host);
}
}
}
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using Nini.Config;
using OpenSim.Framework;
using OpenSim.Region.Framework.Interfaces;
using OpenSim.Region.Framework.Scenes;
namespace OpenSim.Region.CoreModules.Agent.IPBan
{
public class IPBanModule : IRegionModule
{
#region Implementation of IRegionModule
private List<string> m_bans = new List<string>();
public void Initialise(Scene scene, IConfigSource source)
{
new SceneBanner(scene, m_bans);
lock(m_bans)
{
foreach (EstateBan ban in scene.RegionInfo.EstateSettings.EstateBans)
{
if(!String.IsNullOrEmpty(ban.BannedHostIPMask))
m_bans.Add(ban.BannedHostIPMask);
if (!String.IsNullOrEmpty(ban.BannedHostNameMask))
m_bans.Add(ban.BannedHostNameMask);
}
}
}
public void PostInitialise()
{
if(File.Exists("bans.txt"))
{
string[] bans = File.ReadAllLines("bans.txt");
foreach (string ban in bans)
{
m_bans.Add(ban);
}
}
}
public void Close()
{
}
public string Name
{
get { return "IPBanModule"; }
}
public bool IsSharedModule
{
get { return true; }
}
#endregion
/// <summary>
/// Bans all users from the specified network from connecting.
/// DNS bans are in the form "somewhere.com" will block ANY
/// matching domain (including "betasomewhere.com", "beta.somewhere.com",
/// "somewhere.com.beta") - make sure to be reasonably specific in DNS
/// bans.
///
/// IP address bans match on first characters, so,
/// "127.0.0.1" will ban only that address,
/// "127.0.1" will ban "127.0.10.0"
/// but "127.0.1." will ban only the "127.0.1.*" network
/// </summary>
/// <param name="host">See summary for explanation of parameter</param>
public void Ban(string host)
{
m_bans.Add(host);
}
}
}

View File

@@ -1,52 +1,52 @@
using System.Collections.Generic;
using System.Net;
using OpenSim.Framework.Client;
using OpenSim.Region.Framework.Scenes;
namespace OpenSim.Region.CoreModules.Agent.IPBan
{
internal class SceneBanner
{
private static readonly log4net.ILog m_log
= log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
private List<string> bans;
private SceneBase m_scene;
public SceneBanner(SceneBase scene, List<string> banList)
{
scene.EventManager.OnClientConnect += EventManager_OnClientConnect;
bans = banList;
m_scene = scene;
}
void EventManager_OnClientConnect(IClientCore client)
{
IClientIPEndpoint ipEndpoint;
if(client.TryGet(out ipEndpoint))
{
IPAddress end = ipEndpoint.EndPoint;
try
{
IPHostEntry rDNS = Dns.GetHostEntry(end);
foreach (string ban in bans)
{
if (rDNS.HostName.Contains(ban) ||
end.ToString().StartsWith(ban))
{
client.Disconnect("Banned - network \"" + ban + "\" is not allowed to connect to this server.");
m_log.Warn("[IPBAN] Disconnected '" + end + "' due to '" + ban + "' ban.");
return;
}
}
}
catch (System.Net.Sockets.SocketException sex)
{
m_log.WarnFormat("[IPBAN] IP address \"{0}\" cannot be resolved via DNS", end);
}
m_log.WarnFormat("[IPBAN] User \"{0}\" not in any ban lists. Allowing connection.", end);
}
}
}
}
using System.Collections.Generic;
using System.Net;
using OpenSim.Framework.Client;
using OpenSim.Region.Framework.Scenes;
namespace OpenSim.Region.CoreModules.Agent.IPBan
{
internal class SceneBanner
{
private static readonly log4net.ILog m_log
= log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
private List<string> bans;
private SceneBase m_scene;
public SceneBanner(SceneBase scene, List<string> banList)
{
scene.EventManager.OnClientConnect += EventManager_OnClientConnect;
bans = banList;
m_scene = scene;
}
void EventManager_OnClientConnect(IClientCore client)
{
IClientIPEndpoint ipEndpoint;
if(client.TryGet(out ipEndpoint))
{
IPAddress end = ipEndpoint.EndPoint;
try
{
IPHostEntry rDNS = Dns.GetHostEntry(end);
foreach (string ban in bans)
{
if (rDNS.HostName.Contains(ban) ||
end.ToString().StartsWith(ban))
{
client.Disconnect("Banned - network \"" + ban + "\" is not allowed to connect to this server.");
m_log.Warn("[IPBAN] Disconnected '" + end + "' due to '" + ban + "' ban.");
return;
}
}
}
catch (System.Net.Sockets.SocketException sex)
{
m_log.WarnFormat("[IPBAN] IP address \"{0}\" cannot be resolved via DNS", end);
}
m_log.WarnFormat("[IPBAN] User \"{0}\" not in any ban lists. Allowing connection.", end);
}
}
}
}