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 --- .../Communications/Clients/RegionClient.cs | 29 ++++++++++++++++------ .../Communications/Services/LoginResponse.cs | 2 +- .../Communications/Services/LoginService.cs | 6 +++-- .../Communications/Tests/LoginServiceTests.cs | 4 ++- 4 files changed, 29 insertions(+), 12 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Clients/RegionClient.cs b/OpenSim/Framework/Communications/Clients/RegionClient.cs index da3f620..6fdacb1 100644 --- a/OpenSim/Framework/Communications/Clients/RegionClient.cs +++ b/OpenSim/Framework/Communications/Clients/RegionClient.cs @@ -43,7 +43,7 @@ namespace OpenSim.Framework.Communications.Clients { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - public bool DoCreateChildAgentCall(RegionInfo region, AgentCircuitData aCircuit, string authKey) + public bool DoCreateChildAgentCall(RegionInfo region, AgentCircuitData aCircuit, string authKey, out string reason) { // Eventually, we want to use a caps url instead of the agentID string uri = "http://" + region.ExternalEndPoint.Address + ":" + region.HttpPort + "/agent/" + aCircuit.AgentID + "/"; @@ -56,6 +56,8 @@ namespace OpenSim.Framework.Communications.Clients //AgentCreateRequest.KeepAlive = false; AgentCreateRequest.Headers.Add("Authorization", authKey); + reason = String.Empty; + // Fill it in OSDMap args = null; try @@ -98,7 +100,7 @@ namespace OpenSim.Framework.Communications.Clients catch { //m_log.InfoFormat("[REST COMMS]: Bad send on ChildAgentUpdate {0}", ex.Message); - + reason = "cannot contact remote region"; return false; } @@ -112,13 +114,24 @@ namespace OpenSim.Framework.Communications.Clients { m_log.Info("[REST COMMS]: Null reply on DoCreateChildAgentCall post"); } + else + { - StreamReader sr = new StreamReader(webResponse.GetResponseStream()); - //reply = sr.ReadToEnd().Trim(); - sr.ReadToEnd().Trim(); - sr.Close(); - //m_log.InfoFormat("[REST COMMS]: DoCreateChildAgentCall reply was {0} ", reply); - + StreamReader sr = new StreamReader(webResponse.GetResponseStream()); + string response = sr.ReadToEnd().Trim(); + sr.Close(); + m_log.InfoFormat("[REST COMMS]: DoCreateChildAgentCall reply was {0} ", response); + + if (!String.IsNullOrEmpty(response)) + { + // we assume we got an OSDMap back + OSDMap r = GetOSDMap(response); + bool success = r["success"].AsBoolean(); + reason = r["reason"].AsString(); + + return success; + } + } } catch (WebException ex) { diff --git a/OpenSim/Framework/Communications/Services/LoginResponse.cs b/OpenSim/Framework/Communications/Services/LoginResponse.cs index d91bf84..4b5c99d 100644 --- a/OpenSim/Framework/Communications/Services/LoginResponse.cs +++ b/OpenSim/Framework/Communications/Services/LoginResponse.cs @@ -320,7 +320,7 @@ namespace OpenSim.Framework.Communications.Services { return GenerateFailureResponseLLSD( "key", - "Error connecting to grid. Could not percieve credentials from login XML.", + "Error connecting to grid. Could not perceive credentials from login XML.", "false"); } diff --git a/OpenSim/Framework/Communications/Services/LoginService.cs b/OpenSim/Framework/Communications/Services/LoginService.cs index 168f7a6..f55c030 100644 --- a/OpenSim/Framework/Communications/Services/LoginService.cs +++ b/OpenSim/Framework/Communications/Services/LoginService.cs @@ -946,13 +946,15 @@ namespace OpenSim.Framework.Communications.Services { regionInfo = homeInfo; theUser.CurrentAgent.Position = theUser.HomeLocation; - response.LookAt = "[r" + theUser.HomeLookAt.X.ToString() + ",r" + theUser.HomeLookAt.Y.ToString() + ",r" + theUser.HomeLookAt.Z.ToString() + "]"; + response.LookAt = String.Format("[r{0},r{1},r{2}]", theUser.HomeLookAt.X.ToString(), + theUser.HomeLookAt.Y.ToString(), theUser.HomeLookAt.Z.ToString()); } else if (startLocationRequest == "last") { UUID lastRegion = theUser.CurrentAgent.Region; regionInfo = GetRegionInfo(lastRegion); - response.LookAt = "[r" + theUser.CurrentAgent.LookAt.X.ToString() + ",r" + theUser.CurrentAgent.LookAt.Y.ToString() + ",r" + theUser.CurrentAgent.LookAt.Z.ToString() + "]"; + response.LookAt = String.Format("[r{0},r{1},r{2}]", theUser.CurrentAgent.LookAt.X.ToString(), + theUser.CurrentAgent.LookAt.Y.ToString(), theUser.CurrentAgent.LookAt.Z.ToString()); } else { diff --git a/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs b/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs index d0c1b3b..965e6b4 100644 --- a/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs +++ b/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs @@ -345,8 +345,9 @@ namespace OpenSim.Framework.Communications.Tests { } - public bool NewUserConnection(ulong regionHandle, AgentCircuitData agent) + public bool NewUserConnection(ulong regionHandle, AgentCircuitData agent, out string reason) { + reason = String.Empty; lock (m_regionsList) { foreach (RegionInfo regInfo in m_regionsList) @@ -355,6 +356,7 @@ namespace OpenSim.Framework.Communications.Tests return true; } } + reason = "Region not found"; return false; } -- cgit v1.1