From e0a06f641668cd5c25a7854af2faf8a61c4053ee Mon Sep 17 00:00:00 2001 From: Dr Scofield Date: Tue, 5 May 2009 16:17:52 +0000 Subject: - moving banned check and public/private check to Scene.NewUserConnection() - adding reason reporting this enforces estate bans very early on and prevents us from circulating client objects that we'd then have to retract once we realize that the client is not allowed into the region --- OpenSim/Client/Linden/LLProxyLoginModule.cs | 13 +++++++------ OpenSim/Client/Linden/LLStandaloneLoginModule.cs | 5 +++-- OpenSim/Client/Linden/LLStandaloneLoginService.cs | 10 +++++++++- OpenSim/Client/MXP/PacketHandler/MXPPacketServer.cs | 17 ++++++++++++----- 4 files changed, 31 insertions(+), 14 deletions(-) (limited to 'OpenSim/Client') diff --git a/OpenSim/Client/Linden/LLProxyLoginModule.cs b/OpenSim/Client/Linden/LLProxyLoginModule.cs index 67d5f4c..fd8c4dd 100644 --- a/OpenSim/Client/Linden/LLProxyLoginModule.cs +++ b/OpenSim/Client/Linden/LLProxyLoginModule.cs @@ -208,21 +208,22 @@ namespace OpenSim.Client.Linden { denyMess = "User is banned from this region"; m_log.InfoFormat( - "[CLIENT]: Denying access for user {0} {1} because user is banned", - agentData.firstname, agentData.lastname); + "[CLIENT]: Denying access for user {0} {1} because user is banned", + agentData.firstname, agentData.lastname); } else { - if (scene.NewUserConnection(agentData)) + string reason; + if (scene.NewUserConnection(agentData, out reason)) { success = true; } else { - denyMess = "Login refused by region"; + denyMess = String.Format("Login refused by region: {0}", reason); m_log.InfoFormat( - "[CLIENT]: Denying access for user {0} {1} because user connection was refused by the region", - agentData.firstname, agentData.lastname); + "[CLIENT]: Denying access for user {0} {1} because user connection was refused by the region", + agentData.firstname, agentData.lastname); } } diff --git a/OpenSim/Client/Linden/LLStandaloneLoginModule.cs b/OpenSim/Client/Linden/LLStandaloneLoginModule.cs index 00a6d05..dbc401b 100644 --- a/OpenSim/Client/Linden/LLStandaloneLoginModule.cs +++ b/OpenSim/Client/Linden/LLStandaloneLoginModule.cs @@ -154,13 +154,14 @@ namespace OpenSim.Client.Linden } } - public bool NewUserConnection(ulong regionHandle, AgentCircuitData agent) + public bool NewUserConnection(ulong regionHandle, AgentCircuitData agent, out string reason) { Scene scene; if (TryGetRegion(regionHandle, out scene)) { - return scene.NewUserConnection(agent); + return scene.NewUserConnection(agent, out reason); } + reason = "Region not found."; return false; } diff --git a/OpenSim/Client/Linden/LLStandaloneLoginService.cs b/OpenSim/Client/Linden/LLStandaloneLoginService.cs index 7316587..58b004a 100644 --- a/OpenSim/Client/Linden/LLStandaloneLoginService.cs +++ b/OpenSim/Client/Linden/LLStandaloneLoginService.cs @@ -201,7 +201,15 @@ namespace OpenSim.Client.Linden if (m_regionsConnector.RegionLoginsEnabled) { - return m_regionsConnector.NewUserConnection(regionInfo.RegionHandle, agent); + string reason; + bool success = m_regionsConnector.NewUserConnection(regionInfo.RegionHandle, agent, out reason); + if (!success) + { + response.ErrorReason = "key"; + response.ErrorMessage = reason; + } + return success; + // return m_regionsConnector.NewUserConnection(regionInfo.RegionHandle, agent, out reason); } return false; diff --git a/OpenSim/Client/MXP/PacketHandler/MXPPacketServer.cs b/OpenSim/Client/MXP/PacketHandler/MXPPacketServer.cs index 5167f42..2f60810 100644 --- a/OpenSim/Client/MXP/PacketHandler/MXPPacketServer.cs +++ b/OpenSim/Client/MXP/PacketHandler/MXPPacketServer.cs @@ -312,6 +312,8 @@ namespace OpenSim.Client.MXP.PacketHandler { Scene scene = m_scenes[sceneId]; UUID mxpSessionID = UUID.Random(); + + string reason; m_log.Debug("[MXP ClientStack]: Session join request success: " + session.SessionId + " (" + (session.IsIncoming ? "from" : "to") + " " + session.RemoteEndPoint.Address + ":" + @@ -321,7 +323,13 @@ namespace OpenSim.Client.MXP.PacketHandler AttachUserAgentToUserProfile(session, mxpSessionID, sceneId, user); m_log.Debug("[MXP ClientStack]: Attached UserAgent to UserProfile."); m_log.Debug("[MXP ClientStack]: Preparing Scene to Connection..."); - PrepareSceneForConnection(mxpSessionID, sceneId, user); + if (!PrepareSceneForConnection(mxpSessionID, sceneId, user, out reason)) + { + m_log.DebugFormat("[MXP ClientStack]: Scene refused connection: {0}", reason); + DeclineConnection(session, joinRequestMessage); + tmpRemove.Add(session); + continue; + } m_log.Debug("[MXP ClientStack]: Prepared Scene to Connection."); m_log.Debug("[MXP ClientStack]: Accepting connection..."); AcceptConnection(session, joinRequestMessage, mxpSessionID, userId); @@ -579,7 +587,7 @@ namespace OpenSim.Client.MXP.PacketHandler //userService.CommitAgent(ref userProfile); } - private void PrepareSceneForConnection(UUID sessionId, UUID sceneId, UserProfileData userProfile) + private bool PrepareSceneForConnection(UUID sessionId, UUID sceneId, UserProfileData userProfile, out string reason) { Scene scene = m_scenes[sceneId]; CommunicationsManager commsManager = m_scenes[sceneId].CommsManager; @@ -603,9 +611,8 @@ namespace OpenSim.Client.MXP.PacketHandler m_log.WarnFormat("[INTER]: Appearance not found for {0} {1}. Creating default.", agent.firstname, agent.lastname); agent.Appearance = new AvatarAppearance(); } - - scene.NewUserConnection(agent); - + + return scene.NewUserConnection(agent, out reason); } public void PrintDebugInformation() -- cgit v1.1