diff --git a/OpenSim/Framework/IClientAPI.cs b/OpenSim/Framework/IClientAPI.cs index 01aa954ead..cb6b78b6a4 100755 --- a/OpenSim/Framework/IClientAPI.cs +++ b/OpenSim/Framework/IClientAPI.cs @@ -1065,6 +1065,7 @@ namespace OpenSim.Framework /// Close this client /// void Close(); + void Disconnect(string reason); /// /// Close this client diff --git a/OpenSim/Region/CoreModules/Agent/IPBan/SceneBanner.cs b/OpenSim/Region/CoreModules/Agent/IPBan/SceneBanner.cs index b4c68e2a65..eac0a89a15 100644 --- a/OpenSim/Region/CoreModules/Agent/IPBan/SceneBanner.cs +++ b/OpenSim/Region/CoreModules/Agent/IPBan/SceneBanner.cs @@ -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 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); } } } diff --git a/OpenSim/Region/CoreModules/Avatar/InstantMessage/InstantMessageModule.cs b/OpenSim/Region/CoreModules/Avatar/InstantMessage/InstantMessageModule.cs index 0383b0557f..6fdba0c26b 100644 --- a/OpenSim/Region/CoreModules/Avatar/InstantMessage/InstantMessageModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/InstantMessage/InstantMessageModule.cs @@ -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() diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs index b8a78dc6af..19c4b1dc2e 100644 --- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs +++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs @@ -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}>) " + diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 7db65fd304..20893bb168 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -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; } diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs index 11e815cb36..1c1fcfe80b 100755 --- a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs +++ b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs @@ -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.