aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
authorDr Scofield2009-05-05 16:17:52 +0000
committerDr Scofield2009-05-05 16:17:52 +0000
commite0a06f641668cd5c25a7854af2faf8a61c4053ee (patch)
treec2a4620c4bdc0e479ca16528cd9e0524529a7998 /OpenSim
parent* Fix http://opensimulator.org/mantis/view.php?id=3585 (diff)
downloadopensim-SC-e0a06f641668cd5c25a7854af2faf8a61c4053ee.zip
opensim-SC-e0a06f641668cd5c25a7854af2faf8a61c4053ee.tar.gz
opensim-SC-e0a06f641668cd5c25a7854af2faf8a61c4053ee.tar.bz2
opensim-SC-e0a06f641668cd5c25a7854af2faf8a61c4053ee.tar.xz
- 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
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Client/Linden/LLProxyLoginModule.cs13
-rw-r--r--OpenSim/Client/Linden/LLStandaloneLoginModule.cs5
-rw-r--r--OpenSim/Client/Linden/LLStandaloneLoginService.cs10
-rw-r--r--OpenSim/Client/MXP/PacketHandler/MXPPacketServer.cs17
-rw-r--r--OpenSim/Framework/Communications/Clients/RegionClient.cs29
-rw-r--r--OpenSim/Framework/Communications/Services/LoginResponse.cs2
-rw-r--r--OpenSim/Framework/Communications/Services/LoginService.cs6
-rw-r--r--OpenSim/Framework/Communications/Tests/LoginServiceTests.cs4
-rw-r--r--OpenSim/Framework/ILoginServiceToRegionsConnector.cs2
-rw-r--r--OpenSim/Region/CoreModules/Hypergrid/HGStandaloneLoginModule.cs3
-rw-r--r--OpenSim/Region/CoreModules/InterGrid/OpenGridProtocolModule.cs10
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectors/Interregion/LocalInterregionComms.cs7
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectors/Interregion/RESTInterregionComms.cs17
-rw-r--r--OpenSim/Region/Framework/Interfaces/IInterregionComms.cs2
-rw-r--r--OpenSim/Region/Framework/Scenes/Hypergrid/HGSceneCommunicationService.cs7
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.cs159
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs11
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTests.cs9
-rw-r--r--OpenSim/Tests/Common/Setup/SceneSetupHelpers.cs4
19 files changed, 186 insertions, 131 deletions
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
208 { 208 {
209 denyMess = "User is banned from this region"; 209 denyMess = "User is banned from this region";
210 m_log.InfoFormat( 210 m_log.InfoFormat(
211 "[CLIENT]: Denying access for user {0} {1} because user is banned", 211 "[CLIENT]: Denying access for user {0} {1} because user is banned",
212 agentData.firstname, agentData.lastname); 212 agentData.firstname, agentData.lastname);
213 } 213 }
214 else 214 else
215 { 215 {
216 if (scene.NewUserConnection(agentData)) 216 string reason;
217 if (scene.NewUserConnection(agentData, out reason))
217 { 218 {
218 success = true; 219 success = true;
219 } 220 }
220 else 221 else
221 { 222 {
222 denyMess = "Login refused by region"; 223 denyMess = String.Format("Login refused by region: {0}", reason);
223 m_log.InfoFormat( 224 m_log.InfoFormat(
224 "[CLIENT]: Denying access for user {0} {1} because user connection was refused by the region", 225 "[CLIENT]: Denying access for user {0} {1} because user connection was refused by the region",
225 agentData.firstname, agentData.lastname); 226 agentData.firstname, agentData.lastname);
226 } 227 }
227 } 228 }
228 229
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
154 } 154 }
155 } 155 }
156 156
157 public bool NewUserConnection(ulong regionHandle, AgentCircuitData agent) 157 public bool NewUserConnection(ulong regionHandle, AgentCircuitData agent, out string reason)
158 { 158 {
159 Scene scene; 159 Scene scene;
160 if (TryGetRegion(regionHandle, out scene)) 160 if (TryGetRegion(regionHandle, out scene))
161 { 161 {
162 return scene.NewUserConnection(agent); 162 return scene.NewUserConnection(agent, out reason);
163 } 163 }
164 reason = "Region not found.";
164 return false; 165 return false;
165 } 166 }
166 167
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
201 201
202 if (m_regionsConnector.RegionLoginsEnabled) 202 if (m_regionsConnector.RegionLoginsEnabled)
203 { 203 {
204 return m_regionsConnector.NewUserConnection(regionInfo.RegionHandle, agent); 204 string reason;
205 bool success = m_regionsConnector.NewUserConnection(regionInfo.RegionHandle, agent, out reason);
206 if (!success)
207 {
208 response.ErrorReason = "key";
209 response.ErrorMessage = reason;
210 }
211 return success;
212 // return m_regionsConnector.NewUserConnection(regionInfo.RegionHandle, agent, out reason);
205 } 213 }
206 214
207 return false; 215 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
312 { 312 {
313 Scene scene = m_scenes[sceneId]; 313 Scene scene = m_scenes[sceneId];
314 UUID mxpSessionID = UUID.Random(); 314 UUID mxpSessionID = UUID.Random();
315
316 string reason;
315 317
316 m_log.Debug("[MXP ClientStack]: Session join request success: " + session.SessionId + " (" + 318 m_log.Debug("[MXP ClientStack]: Session join request success: " + session.SessionId + " (" +
317 (session.IsIncoming ? "from" : "to") + " " + session.RemoteEndPoint.Address + ":" + 319 (session.IsIncoming ? "from" : "to") + " " + session.RemoteEndPoint.Address + ":" +
@@ -321,7 +323,13 @@ namespace OpenSim.Client.MXP.PacketHandler
321 AttachUserAgentToUserProfile(session, mxpSessionID, sceneId, user); 323 AttachUserAgentToUserProfile(session, mxpSessionID, sceneId, user);
322 m_log.Debug("[MXP ClientStack]: Attached UserAgent to UserProfile."); 324 m_log.Debug("[MXP ClientStack]: Attached UserAgent to UserProfile.");
323 m_log.Debug("[MXP ClientStack]: Preparing Scene to Connection..."); 325 m_log.Debug("[MXP ClientStack]: Preparing Scene to Connection...");
324 PrepareSceneForConnection(mxpSessionID, sceneId, user); 326 if (!PrepareSceneForConnection(mxpSessionID, sceneId, user, out reason))
327 {
328 m_log.DebugFormat("[MXP ClientStack]: Scene refused connection: {0}", reason);
329 DeclineConnection(session, joinRequestMessage);
330 tmpRemove.Add(session);
331 continue;
332 }
325 m_log.Debug("[MXP ClientStack]: Prepared Scene to Connection."); 333 m_log.Debug("[MXP ClientStack]: Prepared Scene to Connection.");
326 m_log.Debug("[MXP ClientStack]: Accepting connection..."); 334 m_log.Debug("[MXP ClientStack]: Accepting connection...");
327 AcceptConnection(session, joinRequestMessage, mxpSessionID, userId); 335 AcceptConnection(session, joinRequestMessage, mxpSessionID, userId);
@@ -579,7 +587,7 @@ namespace OpenSim.Client.MXP.PacketHandler
579 //userService.CommitAgent(ref userProfile); 587 //userService.CommitAgent(ref userProfile);
580 } 588 }
581 589
582 private void PrepareSceneForConnection(UUID sessionId, UUID sceneId, UserProfileData userProfile) 590 private bool PrepareSceneForConnection(UUID sessionId, UUID sceneId, UserProfileData userProfile, out string reason)
583 { 591 {
584 Scene scene = m_scenes[sceneId]; 592 Scene scene = m_scenes[sceneId];
585 CommunicationsManager commsManager = m_scenes[sceneId].CommsManager; 593 CommunicationsManager commsManager = m_scenes[sceneId].CommsManager;
@@ -603,9 +611,8 @@ namespace OpenSim.Client.MXP.PacketHandler
603 m_log.WarnFormat("[INTER]: Appearance not found for {0} {1}. Creating default.", agent.firstname, agent.lastname); 611 m_log.WarnFormat("[INTER]: Appearance not found for {0} {1}. Creating default.", agent.firstname, agent.lastname);
604 agent.Appearance = new AvatarAppearance(); 612 agent.Appearance = new AvatarAppearance();
605 } 613 }
606 614
607 scene.NewUserConnection(agent); 615 return scene.NewUserConnection(agent, out reason);
608
609 } 616 }
610 617
611 public void PrintDebugInformation() 618 public void PrintDebugInformation()
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
43 { 43 {
44 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 44 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
45 45
46 public bool DoCreateChildAgentCall(RegionInfo region, AgentCircuitData aCircuit, string authKey) 46 public bool DoCreateChildAgentCall(RegionInfo region, AgentCircuitData aCircuit, string authKey, out string reason)
47 { 47 {
48 // Eventually, we want to use a caps url instead of the agentID 48 // Eventually, we want to use a caps url instead of the agentID
49 string uri = "http://" + region.ExternalEndPoint.Address + ":" + region.HttpPort + "/agent/" + aCircuit.AgentID + "/"; 49 string uri = "http://" + region.ExternalEndPoint.Address + ":" + region.HttpPort + "/agent/" + aCircuit.AgentID + "/";
@@ -56,6 +56,8 @@ namespace OpenSim.Framework.Communications.Clients
56 //AgentCreateRequest.KeepAlive = false; 56 //AgentCreateRequest.KeepAlive = false;
57 AgentCreateRequest.Headers.Add("Authorization", authKey); 57 AgentCreateRequest.Headers.Add("Authorization", authKey);
58 58
59 reason = String.Empty;
60
59 // Fill it in 61 // Fill it in
60 OSDMap args = null; 62 OSDMap args = null;
61 try 63 try
@@ -98,7 +100,7 @@ namespace OpenSim.Framework.Communications.Clients
98 catch 100 catch
99 { 101 {
100 //m_log.InfoFormat("[REST COMMS]: Bad send on ChildAgentUpdate {0}", ex.Message); 102 //m_log.InfoFormat("[REST COMMS]: Bad send on ChildAgentUpdate {0}", ex.Message);
101 103 reason = "cannot contact remote region";
102 return false; 104 return false;
103 } 105 }
104 106
@@ -112,13 +114,24 @@ namespace OpenSim.Framework.Communications.Clients
112 { 114 {
113 m_log.Info("[REST COMMS]: Null reply on DoCreateChildAgentCall post"); 115 m_log.Info("[REST COMMS]: Null reply on DoCreateChildAgentCall post");
114 } 116 }
117 else
118 {
115 119
116 StreamReader sr = new StreamReader(webResponse.GetResponseStream()); 120 StreamReader sr = new StreamReader(webResponse.GetResponseStream());
117 //reply = sr.ReadToEnd().Trim(); 121 string response = sr.ReadToEnd().Trim();
118 sr.ReadToEnd().Trim(); 122 sr.Close();
119 sr.Close(); 123 m_log.InfoFormat("[REST COMMS]: DoCreateChildAgentCall reply was {0} ", response);
120 //m_log.InfoFormat("[REST COMMS]: DoCreateChildAgentCall reply was {0} ", reply); 124
121 125 if (!String.IsNullOrEmpty(response))
126 {
127 // we assume we got an OSDMap back
128 OSDMap r = GetOSDMap(response);
129 bool success = r["success"].AsBoolean();
130 reason = r["reason"].AsString();
131
132 return success;
133 }
134 }
122 } 135 }
123 catch (WebException ex) 136 catch (WebException ex)
124 { 137 {
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
320 { 320 {
321 return GenerateFailureResponseLLSD( 321 return GenerateFailureResponseLLSD(
322 "key", 322 "key",
323 "Error connecting to grid. Could not percieve credentials from login XML.", 323 "Error connecting to grid. Could not perceive credentials from login XML.",
324 "false"); 324 "false");
325 } 325 }
326 326
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
946 { 946 {
947 regionInfo = homeInfo; 947 regionInfo = homeInfo;
948 theUser.CurrentAgent.Position = theUser.HomeLocation; 948 theUser.CurrentAgent.Position = theUser.HomeLocation;
949 response.LookAt = "[r" + theUser.HomeLookAt.X.ToString() + ",r" + theUser.HomeLookAt.Y.ToString() + ",r" + theUser.HomeLookAt.Z.ToString() + "]"; 949 response.LookAt = String.Format("[r{0},r{1},r{2}]", theUser.HomeLookAt.X.ToString(),
950 theUser.HomeLookAt.Y.ToString(), theUser.HomeLookAt.Z.ToString());
950 } 951 }
951 else if (startLocationRequest == "last") 952 else if (startLocationRequest == "last")
952 { 953 {
953 UUID lastRegion = theUser.CurrentAgent.Region; 954 UUID lastRegion = theUser.CurrentAgent.Region;
954 regionInfo = GetRegionInfo(lastRegion); 955 regionInfo = GetRegionInfo(lastRegion);
955 response.LookAt = "[r" + theUser.CurrentAgent.LookAt.X.ToString() + ",r" + theUser.CurrentAgent.LookAt.Y.ToString() + ",r" + theUser.CurrentAgent.LookAt.Z.ToString() + "]"; 956 response.LookAt = String.Format("[r{0},r{1},r{2}]", theUser.CurrentAgent.LookAt.X.ToString(),
957 theUser.CurrentAgent.LookAt.Y.ToString(), theUser.CurrentAgent.LookAt.Z.ToString());
956 } 958 }
957 else 959 else
958 { 960 {
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
345 { 345 {
346 } 346 }
347 347
348 public bool NewUserConnection(ulong regionHandle, AgentCircuitData agent) 348 public bool NewUserConnection(ulong regionHandle, AgentCircuitData agent, out string reason)
349 { 349 {
350 reason = String.Empty;
350 lock (m_regionsList) 351 lock (m_regionsList)
351 { 352 {
352 foreach (RegionInfo regInfo in m_regionsList) 353 foreach (RegionInfo regInfo in m_regionsList)
@@ -355,6 +356,7 @@ namespace OpenSim.Framework.Communications.Tests
355 return true; 356 return true;
356 } 357 }
357 } 358 }
359 reason = "Region not found";
358 return false; 360 return false;
359 } 361 }
360 362
diff --git a/OpenSim/Framework/ILoginServiceToRegionsConnector.cs b/OpenSim/Framework/ILoginServiceToRegionsConnector.cs
index 0ce9924..2aee88e 100644
--- a/OpenSim/Framework/ILoginServiceToRegionsConnector.cs
+++ b/OpenSim/Framework/ILoginServiceToRegionsConnector.cs
@@ -34,7 +34,7 @@ namespace OpenSim.Framework
34 { 34 {
35 bool RegionLoginsEnabled { get; } 35 bool RegionLoginsEnabled { get; }
36 void LogOffUserFromGrid(ulong regionHandle, UUID AvatarID, UUID RegionSecret, string message); 36 void LogOffUserFromGrid(ulong regionHandle, UUID AvatarID, UUID RegionSecret, string message);
37 bool NewUserConnection(ulong regionHandle, AgentCircuitData agent); 37 bool NewUserConnection(ulong regionHandle, AgentCircuitData agent, out string reason);
38 RegionInfo RequestClosestRegion(string region); 38 RegionInfo RequestClosestRegion(string region);
39 RegionInfo RequestNeighbourInfo(UUID regionID); 39 RegionInfo RequestNeighbourInfo(UUID regionID);
40 RegionInfo RequestNeighbourInfo(ulong regionhandle); 40 RegionInfo RequestNeighbourInfo(ulong regionhandle);
diff --git a/OpenSim/Region/CoreModules/Hypergrid/HGStandaloneLoginModule.cs b/OpenSim/Region/CoreModules/Hypergrid/HGStandaloneLoginModule.cs
index f21ce0f..a5101d0 100644
--- a/OpenSim/Region/CoreModules/Hypergrid/HGStandaloneLoginModule.cs
+++ b/OpenSim/Region/CoreModules/Hypergrid/HGStandaloneLoginModule.cs
@@ -160,8 +160,9 @@ namespace OpenSim.Region.CoreModules.Hypergrid
160 } 160 }
161 } 161 }
162 162
163 public bool NewUserConnection(ulong regionHandle, AgentCircuitData agent) 163 public bool NewUserConnection(ulong regionHandle, AgentCircuitData agent, out string reason)
164 { 164 {
165 reason = String.Empty;
165 return true; 166 return true;
166 } 167 }
167 168
diff --git a/OpenSim/Region/CoreModules/InterGrid/OpenGridProtocolModule.cs b/OpenSim/Region/CoreModules/InterGrid/OpenGridProtocolModule.cs
index ad91d63..5278b74 100644
--- a/OpenSim/Region/CoreModules/InterGrid/OpenGridProtocolModule.cs
+++ b/OpenSim/Region/CoreModules/InterGrid/OpenGridProtocolModule.cs
@@ -545,7 +545,15 @@ namespace OpenSim.Region.CoreModules.InterGrid
545 homeScene.CommsManager.UserProfileCacheService.PreloadUserCache(userProfile); 545 homeScene.CommsManager.UserProfileCacheService.PreloadUserCache(userProfile);
546 546
547 // Call 'new user' event handler 547 // Call 'new user' event handler
548 homeScene.NewUserConnection(agentData); 548 string reason;
549 if (!homeScene.NewUserConnection(agentData, out reason))
550 {
551 responseMap["connect"] = OSD.FromBoolean(false);
552 responseMap["message"] = OSD.FromString(String.Format("Connection refused: {0}", reason));
553 m_log.ErrorFormat("[OGP]: rez_avatar/request failed: {0}", reason);
554 return responseMap;
555 }
556
549 557
550 //string raCap = string.Empty; 558 //string raCap = string.Empty;
551 559
diff --git a/OpenSim/Region/CoreModules/ServiceConnectors/Interregion/LocalInterregionComms.cs b/OpenSim/Region/CoreModules/ServiceConnectors/Interregion/LocalInterregionComms.cs
index b94efa7..bdf2280 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectors/Interregion/LocalInterregionComms.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectors/Interregion/LocalInterregionComms.cs
@@ -24,6 +24,7 @@
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */ 26 */
27using System;
27using System.Collections.Generic; 28using System.Collections.Generic;
28using System.Reflection; 29using System.Reflection;
29using log4net; 30using log4net;
@@ -112,19 +113,19 @@ namespace OpenSim.Region.CoreModules.ServiceConnectors.Interregion
112 * Agent-related communications 113 * Agent-related communications
113 */ 114 */
114 115
115 public bool SendCreateChildAgent(ulong regionHandle, AgentCircuitData aCircuit) 116 public bool SendCreateChildAgent(ulong regionHandle, AgentCircuitData aCircuit, out string reason)
116 { 117 {
117 foreach (Scene s in m_sceneList) 118 foreach (Scene s in m_sceneList)
118 { 119 {
119 if (s.RegionInfo.RegionHandle == regionHandle) 120 if (s.RegionInfo.RegionHandle == regionHandle)
120 { 121 {
121// m_log.DebugFormat("[LOCAL COMMS]: Found region {0} to send SendCreateChildAgent", regionHandle); 122// m_log.DebugFormat("[LOCAL COMMS]: Found region {0} to send SendCreateChildAgent", regionHandle);
122 s.NewUserConnection(aCircuit); 123 return s.NewUserConnection(aCircuit, out reason);
123 return true;
124 } 124 }
125 } 125 }
126 126
127// m_log.DebugFormat("[LOCAL COMMS]: Did not find region {0} for SendCreateChildAgent", regionHandle); 127// m_log.DebugFormat("[LOCAL COMMS]: Did not find region {0} for SendCreateChildAgent", regionHandle);
128 reason = "Did not find region.";
128 return false; 129 return false;
129 } 130 }
130 131
diff --git a/OpenSim/Region/CoreModules/ServiceConnectors/Interregion/RESTInterregionComms.cs b/OpenSim/Region/CoreModules/ServiceConnectors/Interregion/RESTInterregionComms.cs
index 7fafb6e..80dced7 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectors/Interregion/RESTInterregionComms.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectors/Interregion/RESTInterregionComms.cs
@@ -140,10 +140,10 @@ namespace OpenSim.Region.CoreModules.ServiceConnectors.Interregion
140 * Agent-related communications 140 * Agent-related communications
141 */ 141 */
142 142
143 public bool SendCreateChildAgent(ulong regionHandle, AgentCircuitData aCircuit) 143 public bool SendCreateChildAgent(ulong regionHandle, AgentCircuitData aCircuit, out string reason)
144 { 144 {
145 // Try local first 145 // Try local first
146 if (m_localBackend.SendCreateChildAgent(regionHandle, aCircuit)) 146 if (m_localBackend.SendCreateChildAgent(regionHandle, aCircuit, out reason))
147 return true; 147 return true;
148 148
149 // else do the remote thing 149 // else do the remote thing
@@ -154,7 +154,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectors.Interregion
154 { 154 {
155 m_regionClient.SendUserInformation(regInfo, aCircuit); 155 m_regionClient.SendUserInformation(regInfo, aCircuit);
156 156
157 return m_regionClient.DoCreateChildAgentCall(regInfo, aCircuit, "None"); 157 return m_regionClient.DoCreateChildAgentCall(regInfo, aCircuit, "None", out reason);
158 } 158 }
159 //else 159 //else
160 // m_log.Warn("[REST COMMS]: Region not found " + regionHandle); 160 // m_log.Warn("[REST COMMS]: Region not found " + regionHandle);
@@ -431,12 +431,19 @@ namespace OpenSim.Region.CoreModules.ServiceConnectors.Interregion
431 return; 431 return;
432 } 432 }
433 433
434 OSDMap resp = new OSDMap(2);
435 string reason = String.Empty;
436
434 // This is the meaning of POST agent 437 // This is the meaning of POST agent
435 m_regionClient.AdjustUserInformation(aCircuit); 438 m_regionClient.AdjustUserInformation(aCircuit);
436 bool result = m_localBackend.SendCreateChildAgent(regionhandle, aCircuit); 439 bool result = m_localBackend.SendCreateChildAgent(regionhandle, aCircuit, out reason);
440
441 resp["reason"] = OSD.FromString(reason);
442 resp["success"] = OSD.FromBoolean(result);
437 443
444 // TODO: add reason if not String.Empty?
438 responsedata["int_response_code"] = 200; 445 responsedata["int_response_code"] = 200;
439 responsedata["str_response_string"] = result.ToString(); 446 responsedata["str_response_string"] = OSDParser.SerializeJsonString(resp);
440 } 447 }
441 448
442 protected virtual void DoAgentPut(Hashtable request, Hashtable responsedata) 449 protected virtual void DoAgentPut(Hashtable request, Hashtable responsedata)
diff --git a/OpenSim/Region/Framework/Interfaces/IInterregionComms.cs b/OpenSim/Region/Framework/Interfaces/IInterregionComms.cs
index b5a9395..95b1079 100644
--- a/OpenSim/Region/Framework/Interfaces/IInterregionComms.cs
+++ b/OpenSim/Region/Framework/Interfaces/IInterregionComms.cs
@@ -38,7 +38,7 @@ namespace OpenSim.Region.Framework.Interfaces
38 38
39 #region Agents 39 #region Agents
40 40
41 bool SendCreateChildAgent(ulong regionHandle, AgentCircuitData aCircuit); 41 bool SendCreateChildAgent(ulong regionHandle, AgentCircuitData aCircuit, out string reason);
42 42
43 /// <summary> 43 /// <summary>
44 /// Full child agent update. 44 /// Full child agent update.
diff --git a/OpenSim/Region/Framework/Scenes/Hypergrid/HGSceneCommunicationService.cs b/OpenSim/Region/Framework/Scenes/Hypergrid/HGSceneCommunicationService.cs
index dcebce5..542e7d0 100644
--- a/OpenSim/Region/Framework/Scenes/Hypergrid/HGSceneCommunicationService.cs
+++ b/OpenSim/Region/Framework/Scenes/Hypergrid/HGSceneCommunicationService.cs
@@ -180,10 +180,13 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid
180 agentCircuit.CapsPath = CapsUtil.GetRandomCapsObjectPath(); 180 agentCircuit.CapsPath = CapsUtil.GetRandomCapsObjectPath();
181 } 181 }
182 182
183 string reason = String.Empty;
184
183 //if (!m_commsProvider.InterRegion.InformRegionOfChildAgent(reg.RegionHandle, agentCircuit)) 185 //if (!m_commsProvider.InterRegion.InformRegionOfChildAgent(reg.RegionHandle, agentCircuit))
184 if (!m_interregionCommsOut.SendCreateChildAgent(reg.RegionHandle, agentCircuit)) 186 if (!m_interregionCommsOut.SendCreateChildAgent(reg.RegionHandle, agentCircuit, out reason))
185 { 187 {
186 avatar.ControllingClient.SendTeleportFailed("Destination is not accepting teleports."); 188 avatar.ControllingClient.SendTeleportFailed(String.Format("Destination is not accepting teleports: {0}",
189 reason));
187 return; 190 return;
188 } 191 }
189 192
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index a516a5a..77ca3bc 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -1859,87 +1859,46 @@ namespace OpenSim.Region.Framework.Scenes
1859 1859
1860 public override void AddNewClient(IClientAPI client) 1860 public override void AddNewClient(IClientAPI client)
1861 { 1861 {
1862 bool welcome = true; 1862 SubscribeToClientEvents(client);
1863 1863 ScenePresence presence;
1864 if (m_regInfo.EstateSettings.IsBanned(client.AgentId) && (!Permissions.IsGod(client.AgentId)))
1865 {
1866 m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user is on the banlist",
1867 client.AgentId, client.FirstName, client.LastName, RegionInfo.RegionName);
1868 client.SendAlertMessage("Denied access to region " + RegionInfo.RegionName + ". You have been banned from that region.");
1869 welcome = false;
1870 }
1871 else if (!m_regInfo.EstateSettings.PublicAccess && !m_regInfo.EstateSettings.HasAccess(client.AgentId) && !Permissions.IsGod(client.AgentId))
1872 {
1873 m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user does not have access",
1874 client.AgentId, client.FirstName, client.LastName, RegionInfo.RegionName);
1875 client.SendAlertMessage("Denied access to private region " + RegionInfo.RegionName + ". You do not have access to this region.");
1876 welcome = false;
1877 }
1878 1864
1879 if (!welcome) 1865 if (m_restorePresences.ContainsKey(client.AgentId))
1880 { 1866 {
1881 try 1867 m_log.DebugFormat("[SCENE]: Restoring agent {0} {1} in {2}", client.Name, client.AgentId, RegionInfo.RegionName);
1882 { 1868
1883 IEventQueue eq = RequestModuleInterface<IEventQueue>(); 1869 presence = m_restorePresences[client.AgentId];
1884 if (eq != null) 1870 m_restorePresences.Remove(client.AgentId);
1885 { 1871
1886 eq.DisableSimulator(RegionInfo.RegionHandle, client.AgentId); 1872 // This is one of two paths to create avatars that are
1887 } 1873 // used. This tends to get called more in standalone
1888 else 1874 // than grid, not really sure why, but as such needs
1889 client.SendShutdownConnectionNotice(); 1875 // an explicity appearance lookup here.
1890 1876 AvatarAppearance appearance = null;
1891 client.Close(false); 1877 GetAvatarAppearance(client, out appearance);
1892 CapsModule.RemoveCapsHandler(client.AgentId); 1878 presence.Appearance = appearance;
1893 m_authenticateHandler.RemoveCircuit(client.CircuitCode); 1879
1894 } 1880 presence.initializeScenePresence(client, RegionInfo, this);
1895 catch (Exception e) 1881
1882 m_sceneGraph.AddScenePresence(presence);
1883
1884 lock (m_restorePresences)
1896 { 1885 {
1897 m_log.DebugFormat("[SCENE]: Exception while closing unwelcome client {0} {1}: {2}", client.FirstName, client.LastName, e.Message); 1886 Monitor.PulseAll(m_restorePresences);
1898 } 1887 }
1899 } 1888 }
1900 else 1889 else
1901 { 1890 {
1902 SubscribeToClientEvents(client); 1891 m_log.DebugFormat(
1903 ScenePresence presence; 1892 "[SCENE]: Adding new child agent for {0} in {1}",
1904 1893 client.Name, RegionInfo.RegionName);
1905 if (m_restorePresences.ContainsKey(client.AgentId)) 1894
1906 { 1895 CommsManager.UserProfileCacheService.AddNewUser(client.AgentId);
1907 m_log.DebugFormat("[SCENE]: Restoring agent {0} {1} in {2}", client.Name, client.AgentId, RegionInfo.RegionName); 1896
1908 1897 CreateAndAddScenePresence(client);
1909 presence = m_restorePresences[client.AgentId];
1910 m_restorePresences.Remove(client.AgentId);
1911
1912 // This is one of two paths to create avatars that are
1913 // used. This tends to get called more in standalone
1914 // than grid, not really sure why, but as such needs
1915 // an explicity appearance lookup here.
1916 AvatarAppearance appearance = null;
1917 GetAvatarAppearance(client, out appearance);
1918 presence.Appearance = appearance;
1919
1920 presence.initializeScenePresence(client, RegionInfo, this);
1921
1922 m_sceneGraph.AddScenePresence(presence);
1923
1924 lock (m_restorePresences)
1925 {
1926 Monitor.PulseAll(m_restorePresences);
1927 }
1928 }
1929 else
1930 {
1931 m_log.DebugFormat(
1932 "[SCENE]: Adding new child agent for {0} in {1}",
1933 client.Name, RegionInfo.RegionName);
1934
1935 CommsManager.UserProfileCacheService.AddNewUser(client.AgentId);
1936
1937 CreateAndAddScenePresence(client);
1938 }
1939
1940 m_LastLogin = Environment.TickCount;
1941 EventManager.TriggerOnNewClient(client);
1942 } 1898 }
1899
1900 m_LastLogin = Environment.TickCount;
1901 EventManager.TriggerOnNewClient(client);
1943 } 1902 }
1944 1903
1945 protected virtual void SubscribeToClientEvents(IClientAPI client) 1904 protected virtual void SubscribeToClientEvents(IClientAPI client)
@@ -2404,7 +2363,8 @@ namespace OpenSim.Region.Framework.Scenes
2404 /// <param name="agent"></param> 2363 /// <param name="agent"></param>
2405 public void HandleNewUserConnection(AgentCircuitData agent) 2364 public void HandleNewUserConnection(AgentCircuitData agent)
2406 { 2365 {
2407 NewUserConnection(agent); 2366 string reason;
2367 NewUserConnection(agent, out reason);
2408 } 2368 }
2409 2369
2410 /// <summary> 2370 /// <summary>
@@ -2415,10 +2375,36 @@ namespace OpenSim.Region.Framework.Scenes
2415 /// </summary> 2375 /// </summary>
2416 /// <param name="regionHandle"></param> 2376 /// <param name="regionHandle"></param>
2417 /// <param name="agent"></param> 2377 /// <param name="agent"></param>
2418 public bool NewUserConnection(AgentCircuitData agent) 2378 /// <param name="reason"></param>
2379 public bool NewUserConnection(AgentCircuitData agent, out string reason)
2419 { 2380 {
2420 bool goodUserConnection = AuthenticateUser(agent); 2381 bool goodUserConnection = AuthenticateUser(agent);
2421 2382
2383 reason = String.Empty;
2384
2385 if (goodUserConnection &&
2386 m_regInfo.EstateSettings.IsBanned(agent.AgentID) &&
2387 (!Permissions.IsGod(agent.AgentID)))
2388 {
2389 m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user is on the banlist",
2390 agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName);
2391 reason = String.Format("Denied access to region {0}: You have been banned from that region.",
2392 RegionInfo.RegionName);
2393 goodUserConnection = false;
2394 }
2395 else if (goodUserConnection &&
2396 !m_regInfo.EstateSettings.PublicAccess &&
2397 !m_regInfo.EstateSettings.HasAccess(agent.AgentID) &&
2398 !Permissions.IsGod(agent.AgentID))
2399 {
2400 m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user does not have access",
2401 agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName);
2402 reason = String.Format("Denied access to private region {0}: You are not on the access list for that region.",
2403 RegionInfo.RegionName);
2404 goodUserConnection = false;
2405 }
2406
2407
2422 if (goodUserConnection) 2408 if (goodUserConnection)
2423 { 2409 {
2424 CapsModule.NewUserConnection(agent); 2410 CapsModule.NewUserConnection(agent);
@@ -2431,7 +2417,7 @@ namespace OpenSim.Region.Framework.Scenes
2431 agent.AgentID, RegionInfo.RegionName); 2417 agent.AgentID, RegionInfo.RegionName);
2432 2418
2433 sp.AdjustKnownSeeds(); 2419 sp.AdjustKnownSeeds();
2434 2420
2435 return true; 2421 return true;
2436 } 2422 }
2437 2423
@@ -2440,13 +2426,13 @@ namespace OpenSim.Region.Framework.Scenes
2440 "[CONNECTION BEGIN]: Region {0} told of incoming client {1} {2} {3} (circuit code {4})", 2426 "[CONNECTION BEGIN]: Region {0} told of incoming client {1} {2} {3} (circuit code {4})",
2441 RegionInfo.RegionName, agent.firstname, agent.lastname, agent.AgentID, agent.circuitcode); 2427 RegionInfo.RegionName, agent.firstname, agent.lastname, agent.AgentID, agent.circuitcode);
2442 2428
2443 if (m_regInfo.EstateSettings.IsBanned(agent.AgentID)) 2429 // if (m_regInfo.EstateSettings.IsBanned(agent.AgentID))
2444 { 2430 // {
2445 m_log.WarnFormat( 2431 // m_log.WarnFormat(
2446 "[CONNECTION BEGIN]: Incoming user {0} at {1} is on the region banlist", 2432 // "[CONNECTION BEGIN]: Incoming user {0} at {1} is on the region banlist",
2447 agent.AgentID, RegionInfo.RegionName); 2433 // agent.AgentID, RegionInfo.RegionName);
2448 //return false; 2434 // //return false;
2449 } 2435 // }
2450 2436
2451 CapsModule.AddCapsHandler(agent.AgentID); 2437 CapsModule.AddCapsHandler(agent.AgentID);
2452 2438
@@ -2481,7 +2467,12 @@ namespace OpenSim.Region.Framework.Scenes
2481 } 2467 }
2482 else 2468 else
2483 { 2469 {
2484 m_log.WarnFormat("[CONNECTION BEGIN]: failed to authenticate user {0} {1}. Denying connection.", agent.firstname, agent.lastname); 2470 m_log.WarnFormat("[CONNECTION BEGIN]: failed to authenticate user {0} {1}: {2}. Denying connection.",
2471 agent.firstname, agent.lastname, reason);
2472 if (String.IsNullOrEmpty(reason))
2473 {
2474 reason = String.Format("Failed to authenticate user {0} {1}, access denied.", agent.firstname, agent.lastname);
2475 }
2485 return false; 2476 return false;
2486 } 2477 }
2487 } 2478 }
diff --git a/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs b/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs
index 2fe005d..0699552 100644
--- a/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs
@@ -296,8 +296,10 @@ namespace OpenSim.Region.Framework.Scenes
296 string capsPath = "http://" + reg.ExternalHostName + ":" + reg.HttpPort 296 string capsPath = "http://" + reg.ExternalHostName + ":" + reg.HttpPort
297 + "/CAPS/" + a.CapsPath + "0000/"; 297 + "/CAPS/" + a.CapsPath + "0000/";
298 298
299 string reason = String.Empty;
300
299 //bool regionAccepted = m_commsProvider.InterRegion.InformRegionOfChildAgent(reg.RegionHandle, a); 301 //bool regionAccepted = m_commsProvider.InterRegion.InformRegionOfChildAgent(reg.RegionHandle, a);
300 bool regionAccepted = m_interregionCommsOut.SendCreateChildAgent(reg.RegionHandle, a); 302 bool regionAccepted = m_interregionCommsOut.SendCreateChildAgent(reg.RegionHandle, a, out reason);
301 303
302 if (regionAccepted && newAgent) 304 if (regionAccepted && newAgent)
303 { 305 {
@@ -785,11 +787,14 @@ namespace OpenSim.Region.Framework.Scenes
785 agentCircuit.CapsPath = CapsUtil.GetRandomCapsObjectPath(); 787 agentCircuit.CapsPath = CapsUtil.GetRandomCapsObjectPath();
786 } 788 }
787 789
790 string reason = String.Empty;
791
788 // Let's create an agent there if one doesn't exist yet. 792 // Let's create an agent there if one doesn't exist yet.
789 //if (!m_commsProvider.InterRegion.InformRegionOfChildAgent(reg.RegionHandle, agentCircuit)) 793 //if (!m_commsProvider.InterRegion.InformRegionOfChildAgent(reg.RegionHandle, agentCircuit))
790 if (!m_interregionCommsOut.SendCreateChildAgent(reg.RegionHandle, agentCircuit)) 794 if (!m_interregionCommsOut.SendCreateChildAgent(reg.RegionHandle, agentCircuit, out reason))
791 { 795 {
792 avatar.ControllingClient.SendTeleportFailed("Destination is not accepting teleports."); 796 avatar.ControllingClient.SendTeleportFailed(String.Format("Destination is not accepting teleports: {0}",
797 reason));
793 return; 798 return;
794 } 799 }
795 800
diff --git a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTests.cs b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTests.cs
index a26cb94..2903766 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTests.cs
@@ -115,7 +115,8 @@ namespace OpenSim.Region.Framework.Scenes.Tests
115 agent.startpos = Vector3.Zero; 115 agent.startpos = Vector3.Zero;
116 agent.CapsPath = GetRandomCapsObjectPath(); 116 agent.CapsPath = GetRandomCapsObjectPath();
117 117
118 scene.NewUserConnection(agent); 118 string reason;
119 scene.NewUserConnection(agent, out reason);
119 testclient = new TestClient(agent, scene); 120 testclient = new TestClient(agent, scene);
120 scene.AddNewClient(testclient); 121 scene.AddNewClient(testclient);
121 122
@@ -146,7 +147,8 @@ namespace OpenSim.Region.Framework.Scenes.Tests
146 { 147 {
147 Console.WriteLine("Beginning test {0}", MethodBase.GetCurrentMethod()); 148 Console.WriteLine("Beginning test {0}", MethodBase.GetCurrentMethod());
148 149
149 scene.NewUserConnection(acd1); 150 string reason;
151 scene.NewUserConnection(acd1, out reason);
150 scene.AddNewClient(testclient); 152 scene.AddNewClient(testclient);
151 153
152 ScenePresence presence = scene.GetScenePresence(agent1); 154 ScenePresence presence = scene.GetScenePresence(agent1);
@@ -203,7 +205,8 @@ namespace OpenSim.Region.Framework.Scenes.Tests
203 Console.WriteLine("Beginning test {0}", MethodBase.GetCurrentMethod()); 205 Console.WriteLine("Beginning test {0}", MethodBase.GetCurrentMethod());
204 206
205 // Adding child agent to region 1001 207 // Adding child agent to region 1001
206 scene2.NewUserConnection(acd1); 208 string reason;
209 scene2.NewUserConnection(acd1, out reason);
207 scene2.AddNewClient(testclient); 210 scene2.AddNewClient(testclient);
208 211
209 ScenePresence presence = scene.GetScenePresence(agent1); 212 ScenePresence presence = scene.GetScenePresence(agent1);
diff --git a/OpenSim/Tests/Common/Setup/SceneSetupHelpers.cs b/OpenSim/Tests/Common/Setup/SceneSetupHelpers.cs
index ea4f0af..8527886 100644
--- a/OpenSim/Tests/Common/Setup/SceneSetupHelpers.cs
+++ b/OpenSim/Tests/Common/Setup/SceneSetupHelpers.cs
@@ -245,9 +245,11 @@ namespace OpenSim.Tests.Common.Setup
245 /// <returns></returns> 245 /// <returns></returns>
246 public static TestClient AddRootAgent(Scene scene, AgentCircuitData agentData) 246 public static TestClient AddRootAgent(Scene scene, AgentCircuitData agentData)
247 { 247 {
248 string reason;
249
248 // We emulate the proper login sequence here by doing things in three stages 250 // We emulate the proper login sequence here by doing things in three stages
249 // Stage 1: simulate login by telling the scene to expect a new user connection 251 // Stage 1: simulate login by telling the scene to expect a new user connection
250 scene.NewUserConnection(agentData); 252 scene.NewUserConnection(agentData, out reason);
251 253
252 // Stage 2: add the new client as a child agent to the scene 254 // Stage 2: add the new client as a child agent to the scene
253 TestClient client = new TestClient(agentData, scene); 255 TestClient client = new TestClient(agentData, scene);