mirror of
https://github.com/opensim/opensim.git
synced 2026-08-04 16:22:50 +08:00
another..
This commit is contained in:
@@ -1065,6 +1065,7 @@ namespace OpenSim.Framework
|
||||
/// Close this client
|
||||
/// </summary>
|
||||
void Close();
|
||||
void Disconnect(string reason);
|
||||
|
||||
/// <summary>
|
||||
/// Close this client
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,7 +33,6 @@ using Mono.Addins;
|
||||
using Nini.Config;
|
||||
using OpenMetaverse;
|
||||
using OpenSim.Framework;
|
||||
using OpenSim.Framework.Client;
|
||||
using OpenSim.Region.Framework.Interfaces;
|
||||
using OpenSim.Region.Framework.Scenes;
|
||||
|
||||
@@ -90,14 +89,14 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
|
||||
if (m_TransferModule == null)
|
||||
{
|
||||
m_log.Error("[INSTANT MESSAGE]: No message transfer module, IM will not work!");
|
||||
scene.EventManager.OnClientConnect -= OnClientConnect;
|
||||
scene.EventManager.OnNewClient -= OnClientConnect;
|
||||
scene.EventManager.OnIncomingInstantMessage -= OnGridInstantMessage;
|
||||
|
||||
m_scenes.Clear();
|
||||
m_enabled = false;
|
||||
}
|
||||
}
|
||||
scene.EventManager.OnClientConnect += OnClientConnect;
|
||||
scene.EventManager.OnNewClient += OnClientConnect;
|
||||
scene.EventManager.OnIncomingInstantMessage += OnGridInstantMessage;
|
||||
}
|
||||
|
||||
@@ -112,13 +111,9 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual void OnClientConnect(IClientCore client)
|
||||
protected virtual void OnClientConnect(IClientAPI client)
|
||||
{
|
||||
IClientIM clientIM;
|
||||
if (client.TryGet(out clientIM))
|
||||
{
|
||||
clientIM.OnInstantMessage += OnInstantMessage;
|
||||
}
|
||||
client.OnInstantMessage += OnInstantMessage;
|
||||
}
|
||||
|
||||
public virtual void PostInitialise()
|
||||
|
||||
@@ -2656,7 +2656,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
|
||||
if (newAgent)
|
||||
{
|
||||
// we may already had lost this sp
|
||||
if(sp == null || sp.IsDeleted || sp.ClientView == null) // something bad already happened
|
||||
if(sp == null || sp.IsDeleted || sp.ControllingClient == null) // something bad already happened
|
||||
return;
|
||||
|
||||
Scene scene = sp.Scene;
|
||||
@@ -2679,7 +2679,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
|
||||
|
||||
if (m_eqModule != null)
|
||||
{
|
||||
if(sp == null || sp.IsDeleted || sp.ClientView == null) // something bad already happened
|
||||
if(sp == null || sp.IsDeleted || sp.ControllingClient == null) // something bad already happened
|
||||
return;
|
||||
|
||||
m_log.DebugFormat("{0} {1} is sending {2} EnableSimulator for neighbour region {3}(loc=<{4},{5}>,siz=<{6},{7}>) " +
|
||||
|
||||
@@ -701,6 +701,7 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
|
||||
public IClientAPI ControllingClient { get; set; }
|
||||
|
||||
// dead end do not use
|
||||
public IClientCore ClientView
|
||||
{
|
||||
get { return (IClientCore)ControllingClient; }
|
||||
|
||||
@@ -1029,6 +1029,11 @@ namespace OpenSim.Region.OptionalModules.World.NPC
|
||||
m_scene.RemoveClient(AgentId, false);
|
||||
}
|
||||
|
||||
public void Disconnect(string reason)
|
||||
{
|
||||
Close(true, false);
|
||||
}
|
||||
|
||||
public void Start()
|
||||
{
|
||||
// We never start the client, so always fail.
|
||||
|
||||
Reference in New Issue
Block a user