mirror of
https://github.com/opensim/opensim.git
synced 2026-08-12 04:05:42 +08:00
another..
This commit is contained in:
@@ -27,7 +27,7 @@
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Net;
|
||||
using OpenSim.Framework.Client;
|
||||
using OpenSim.Framework;
|
||||
using OpenSim.Region.Framework.Scenes;
|
||||
|
||||
namespace OpenSim.Region.CoreModules.Agent.IPBan
|
||||
@@ -41,42 +41,36 @@ namespace OpenSim.Region.CoreModules.Agent.IPBan
|
||||
// private SceneBase m_scene;
|
||||
public SceneBanner(SceneBase scene, List<string> banList)
|
||||
{
|
||||
scene.EventManager.OnClientConnect += EventManager_OnClientConnect;
|
||||
scene.EventManager.OnNewClient += EventManager_OnClientConnect;
|
||||
|
||||
bans = banList;
|
||||
// m_scene = scene;
|
||||
}
|
||||
|
||||
void EventManager_OnClientConnect(IClientCore client)
|
||||
void EventManager_OnClientConnect(IClientAPI client)
|
||||
{
|
||||
// Only need to run through all this if there are entries in the ban list
|
||||
if (bans.Count > 0)
|
||||
{
|
||||
IClientIPEndpoint ipEndpoint;
|
||||
if (client.TryGet(out ipEndpoint) && ipEndpoint.RemoteEndPoint != null)
|
||||
IPAddress end = client.RemoteEndPoint.Address;
|
||||
try
|
||||
{
|
||||
IPAddress end = ipEndpoint.RemoteEndPoint.Address;
|
||||
|
||||
try
|
||||
IPHostEntry rDNS = Dns.GetHostEntry(end);
|
||||
foreach (string ban in bans)
|
||||
{
|
||||
IPHostEntry rDNS = Dns.GetHostEntry(end);
|
||||
foreach (string ban in bans)
|
||||
if (rDNS.HostName.Contains(ban) || end.ToString().StartsWith(ban))
|
||||
{
|
||||
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;
|
||||
}
|
||||
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)
|
||||
{
|
||||
m_log.WarnFormat("[IPBAN] IP address \"{0}\" cannot be resolved via DNS", end);
|
||||
}
|
||||
// m_log.DebugFormat("[IPBAN] User \"{0}\" not in any ban lists. Allowing connection.", end);
|
||||
}
|
||||
catch (System.Net.Sockets.SocketException)
|
||||
{
|
||||
m_log.WarnFormat("[IPBAN] IP address \"{0}\" cannot be resolved via DNS", end);
|
||||
}
|
||||
// m_log.DebugFormat("[IPBAN] User \"{0}\" not in any ban lists. Allowing connection.", end);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user