aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Environment/Modules/InterGrid/OpenGridProtocolModule.cs
diff options
context:
space:
mode:
authorTeravus Ovares2008-09-19 21:37:49 +0000
committerTeravus Ovares2008-09-19 21:37:49 +0000
commit293a822f7429d706a54707d3150d82edad7187cf (patch)
tree9d98f3233abfd60e222a4cf796857e3c3b734c8b /OpenSim/Region/Environment/Modules/InterGrid/OpenGridProtocolModule.cs
parentSmall formatting cleanup, before chi11ken notices. Me bad. (diff)
downloadopensim-SC_OLD-293a822f7429d706a54707d3150d82edad7187cf.zip
opensim-SC_OLD-293a822f7429d706a54707d3150d82edad7187cf.tar.gz
opensim-SC_OLD-293a822f7429d706a54707d3150d82edad7187cf.tar.bz2
opensim-SC_OLD-293a822f7429d706a54707d3150d82edad7187cf.tar.xz
* Implements an experimental method to define which region you want to go to in your 'region domain' in OGP.
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/Environment/Modules/InterGrid/OpenGridProtocolModule.cs145
1 files changed, 136 insertions, 9 deletions
diff --git a/OpenSim/Region/Environment/Modules/InterGrid/OpenGridProtocolModule.cs b/OpenSim/Region/Environment/Modules/InterGrid/OpenGridProtocolModule.cs
index 2df129b..fdb24b1 100644
--- a/OpenSim/Region/Environment/Modules/InterGrid/OpenGridProtocolModule.cs
+++ b/OpenSim/Region/Environment/Modules/InterGrid/OpenGridProtocolModule.cs
@@ -33,6 +33,7 @@ using System.Net.Security;
33using System.Security.Cryptography.X509Certificates; 33using System.Security.Cryptography.X509Certificates;
34using System.Reflection; 34using System.Reflection;
35using System.Threading; 35using System.Threading;
36using System.Web;
36 37
37using OpenMetaverse; 38using OpenMetaverse;
38using OpenMetaverse.StructuredData; 39using OpenMetaverse.StructuredData;
@@ -75,8 +76,9 @@ namespace OpenSim.Region.Environment.Modules.InterGrid
75 public int src_version; 76 public int src_version;
76 public int src_parent_estate_id; 77 public int src_parent_estate_id;
77 public bool visible_to_parent; 78 public bool visible_to_parent;
79 public string teleported_into_region;
78 } 80 }
79 81
80 public class OpenGridProtocolModule : IRegionModule 82 public class OpenGridProtocolModule : IRegionModule
81 { 83 {
82 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 84 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
@@ -84,6 +86,9 @@ namespace OpenSim.Region.Environment.Modules.InterGrid
84 86
85 private Dictionary<string, AgentCircuitData> CapsLoginID = new Dictionary<string, AgentCircuitData>(); 87 private Dictionary<string, AgentCircuitData> CapsLoginID = new Dictionary<string, AgentCircuitData>();
86 private Dictionary<UUID, OGPState> m_OGPState = new Dictionary<UUID, OGPState>(); 88 private Dictionary<UUID, OGPState> m_OGPState = new Dictionary<UUID, OGPState>();
89 private Dictionary<string, string> m_loginToRegionState = new Dictionary<string, string>();
90
91
87 private string LastNameSuffix = "_EXTERNAL"; 92 private string LastNameSuffix = "_EXTERNAL";
88 private string FirstNamePrefix = ""; 93 private string FirstNamePrefix = "";
89 private string httpsCN = ""; 94 private string httpsCN = "";
@@ -127,7 +132,7 @@ namespace OpenSim.Region.Environment.Modules.InterGrid
127 if (m_scene.Count == 0) 132 if (m_scene.Count == 0)
128 { 133 {
129 scene.AddLLSDHandler("/agent/", ProcessAgentDomainMessage); 134 scene.AddLLSDHandler("/agent/", ProcessAgentDomainMessage);
130 scene.AddLLSDHandler("/", ProcessAgentDomainMessage); 135 scene.AddLLSDHandler("/", ProcessRegionDomainSeed);
131 try 136 try
132 { 137 {
133 ServicePointManager.ServerCertificateValidationCallback += customXertificateValidation; 138 ServicePointManager.ServerCertificateValidationCallback += customXertificateValidation;
@@ -148,6 +153,12 @@ namespace OpenSim.Region.Environment.Modules.InterGrid
148 } 153 }
149 154
150 } 155 }
156 // can't pick the region 'agent' because it would conflict with our agent domain handler
157 // a zero length region name would conflict with are base region seed cap
158 if (!SceneListDuplicateCheck(scene.RegionInfo.RegionName) && scene.RegionInfo.RegionName.ToLower() != "agent" && scene.RegionInfo.RegionName.Length > 0)
159 {
160 scene.AddLLSDHandler("/" + HttpUtility.UrlPathEncode(scene.RegionInfo.RegionName.ToLower()),ProcessRegionDomainSeed);
161 }
151 162
152 if (!m_scene.Contains(scene)) 163 if (!m_scene.Contains(scene))
153 m_scene.Add(scene); 164 m_scene.Add(scene);
@@ -196,6 +207,26 @@ namespace OpenSim.Region.Environment.Modules.InterGrid
196 207
197 #endregion 208 #endregion
198 209
210 public LLSD ProcessRegionDomainSeed(string path, LLSD request, string endpoint)
211 {
212 string[] pathSegments = path.Split('/');
213
214 if (pathSegments.Length <= 1)
215 {
216 return GenerateNoHandlerMessage();
217
218 }
219
220 return GenerateRezAvatarRequestMessage(pathSegments[1]);
221
222
223
224 //m_log.InfoFormat("[OGP]: path {0}, segments {1} segment[1] {2} Last segment {3}",
225 // path, pathSegments.Length, pathSegments[1], pathSegments[pathSegments.Length - 1]);
226 //return new LLSDMap();
227
228 }
229
199 public LLSD ProcessAgentDomainMessage(string path, LLSD request, string endpoint) 230 public LLSD ProcessAgentDomainMessage(string path, LLSD request, string endpoint)
200 { 231 {
201 // /agent/* 232 // /agent/*
@@ -206,12 +237,10 @@ namespace OpenSim.Region.Environment.Modules.InterGrid
206 return GenerateNoHandlerMessage(); 237 return GenerateNoHandlerMessage();
207 238
208 } 239 }
209
210 if (pathSegments[0].Length == 0 && pathSegments[1].Length == 0) 240 if (pathSegments[0].Length == 0 && pathSegments[1].Length == 0)
211 { 241 {
212 return GenerateRezAvatarRequestMessage(""); 242 return GenerateRezAvatarRequestMessage("");
213 } 243 }
214
215 m_log.InfoFormat("[OGP]: path {0}, segments {1} segment[1] {2} Last segment {3}", 244 m_log.InfoFormat("[OGP]: path {0}, segments {1} segment[1] {2} Last segment {3}",
216 path, pathSegments.Length, pathSegments[1], pathSegments[pathSegments.Length - 1]); 245 path, pathSegments.Length, pathSegments[1], pathSegments[pathSegments.Length - 1]);
217 246
@@ -248,7 +277,33 @@ namespace OpenSim.Region.Environment.Modules.InterGrid
248 277
249 private LLSD GenerateRezAvatarRequestMessage(string regionname) 278 private LLSD GenerateRezAvatarRequestMessage(string regionname)
250 { 279 {
251 Scene region = GetRootScene(); 280 Scene region = null;
281 bool usedroot = false;
282
283 if (regionname.Length == 0)
284 {
285 region = GetRootScene();
286 usedroot = true;
287 }
288 else
289 {
290 region = GetScene(HttpUtility.UrlDecode(regionname).ToLower());
291 }
292
293 // this shouldn't happen since we don't listen for a region that is down.. but
294 // it might if the region was taken down or is in the middle of restarting
295
296 if (region == null)
297 {
298 region = GetRootScene();
299 usedroot = true;
300 }
301
302 UUID statekeeper = UUID.Random();
303
304
305
306
252 RegionInfo reg = region.RegionInfo; 307 RegionInfo reg = region.RegionInfo;
253 308
254 LLSDMap responseMap = new LLSDMap(); 309 LLSDMap responseMap = new LLSDMap();
@@ -256,7 +311,18 @@ namespace OpenSim.Region.Environment.Modules.InterGrid
256 //string regionCapsHttpProtocol = "http://"; 311 //string regionCapsHttpProtocol = "http://";
257 string httpaddr = reg.ExternalHostName; 312 string httpaddr = reg.ExternalHostName;
258 string urlport = reg.HttpPort.ToString(); 313 string urlport = reg.HttpPort.ToString();
259 string requestpath = "/agent/" + UUID.Zero + "/rez_avatar/request"; 314 string requestpath = "/agent/" + statekeeper + "/rez_avatar/request";
315
316 if (!usedroot)
317 {
318 lock (m_loginToRegionState)
319 {
320 if (!m_loginToRegionState.ContainsKey(requestpath))
321 {
322 m_loginToRegionState.Add(requestpath, region.RegionInfo.RegionName.ToLower());
323 }
324 }
325 }
260 326
261 if (httpSSL) 327 if (httpSSL)
262 { 328 {
@@ -301,8 +367,26 @@ namespace OpenSim.Region.Environment.Modules.InterGrid
301 367
302 LLSDMap requestMap = (LLSDMap)request; 368 LLSDMap requestMap = (LLSDMap)request;
303 369
304 Scene homeScene = GetRootScene();
305 370
371 Scene homeScene = null;
372
373 lock (m_loginToRegionState)
374 {
375 if (m_loginToRegionState.ContainsKey(path))
376 {
377 homeScene = GetScene(m_loginToRegionState[path]);
378 m_loginToRegionState.Remove(path);
379
380 if (homeScene == null)
381 homeScene = GetRootScene();
382 }
383 else
384 {
385 homeScene = GetRootScene();
386 }
387 }
388
389 // Homescene is still null, we must have no regions that are up
306 if (homeScene == null) 390 if (homeScene == null)
307 return GenerateNoHandlerMessage(); 391 return GenerateNoHandlerMessage();
308 392
@@ -338,6 +422,7 @@ namespace OpenSim.Region.Environment.Modules.InterGrid
338 userState.src_can_see_mainland = requestMap["src_can_see_mainland"].AsBoolean(); 422 userState.src_can_see_mainland = requestMap["src_can_see_mainland"].AsBoolean();
339 userState.src_estate_id = requestMap["src_estate_id"].AsInteger(); 423 userState.src_estate_id = requestMap["src_estate_id"].AsInteger();
340 userState.local_agent_id = LocalAgentID; 424 userState.local_agent_id = LocalAgentID;
425 userState.teleported_into_region = reg.RegionName.ToLower();
341 426
342 UpdateOGPState(LocalAgentID, userState); 427 UpdateOGPState(LocalAgentID, userState);
343 428
@@ -548,8 +633,15 @@ namespace OpenSim.Region.Environment.Modules.InterGrid
548 userData.SecureSessionID = SecureSessionID; 633 userData.SecureSessionID = SecureSessionID;
549 userData.SessionID = SessionID; 634 userData.SessionID = SessionID;
550 635
636 OGPState userState = GetOGPState(userData.AgentID);
637
551 // Locate a home scene suitable for the user. 638 // Locate a home scene suitable for the user.
552 Scene homeScene = GetRootScene(); 639 Scene homeScene = null;
640
641 homeScene = GetScene(userState.teleported_into_region);
642
643 if (homeScene == null)
644 homeScene = GetRootScene();
553 645
554 if (homeScene != null) 646 if (homeScene != null)
555 { 647 {
@@ -562,7 +654,7 @@ namespace OpenSim.Region.Environment.Modules.InterGrid
562 homeScene.ChangeCircuitCode(userData.circuitcode,(uint)circuitcode); 654 homeScene.ChangeCircuitCode(userData.circuitcode,(uint)circuitcode);
563 655
564 // Load state 656 // Load state
565 OGPState userState = GetOGPState(userData.AgentID); 657
566 658
567 // Keep state changes 659 // Keep state changes
568 userState.first_name = requestMap["first_name"].AsString(); 660 userState.first_name = requestMap["first_name"].AsString();
@@ -926,6 +1018,24 @@ namespace OpenSim.Region.Environment.Modules.InterGrid
926 return ReturnScene; 1018 return ReturnScene;
927 } 1019 }
928 1020
1021 private Scene GetScene(string scenename)
1022 {
1023 Scene ReturnScene = null;
1024 lock (m_scene)
1025 {
1026 foreach (Scene s in m_scene)
1027 {
1028 if (s.RegionInfo.RegionName.ToLower() == scenename)
1029 {
1030 ReturnScene = s;
1031 break;
1032 }
1033 }
1034 }
1035
1036 return ReturnScene;
1037 }
1038
929 private ulong GetOSCompatibleRegionHandle(RegionInfo reg) 1039 private ulong GetOSCompatibleRegionHandle(RegionInfo reg)
930 { 1040 {
931 return Util.UIntsToLong(reg.RegionLocX, reg.RegionLocY); 1041 return Util.UIntsToLong(reg.RegionLocX, reg.RegionLocY);
@@ -957,6 +1067,7 @@ namespace OpenSim.Region.Environment.Modules.InterGrid
957 returnState.src_version = 1; 1067 returnState.src_version = 1;
958 returnState.src_parent_estate_id = 1; 1068 returnState.src_parent_estate_id = 1;
959 returnState.visible_to_parent = true; 1069 returnState.visible_to_parent = true;
1070 returnState.teleported_into_region = "";
960 1071
961 return returnState; 1072 return returnState;
962 } 1073 }
@@ -999,6 +1110,22 @@ namespace OpenSim.Region.Environment.Modules.InterGrid
999 } 1110 }
1000 } 1111 }
1001 } 1112 }
1113 private bool SceneListDuplicateCheck(string str)
1114 {
1115 // no lock, called from locked space!
1116 bool found = false;
1117
1118 foreach (Scene s in m_scene)
1119 {
1120 if (s.RegionInfo.RegionName == str)
1121 {
1122 found = true;
1123 break;
1124 }
1125 }
1126
1127 return found;
1128 }
1002 1129
1003 public void ShutdownConnection(UUID avatarId, OpenGridProtocolModule mod) 1130 public void ShutdownConnection(UUID avatarId, OpenGridProtocolModule mod)
1004 { 1131 {