From 293a822f7429d706a54707d3150d82edad7187cf Mon Sep 17 00:00:00 2001 From: Teravus Ovares Date: Fri, 19 Sep 2008 21:37:49 +0000 Subject: [PATCH] * Implements an experimental method to define which region you want to go to in your 'region domain' in OGP. --- OpenSim/Framework/Servers/BaseHttpServer.cs | 7 +- .../InterGrid/OpenGridProtocolModule.cs | 145 ++++++++++++++++-- prebuild.xml | 2 + 3 files changed, 143 insertions(+), 11 deletions(-) diff --git a/OpenSim/Framework/Servers/BaseHttpServer.cs b/OpenSim/Framework/Servers/BaseHttpServer.cs index 69fc4ad3dd..86ce4c3ad7 100644 --- a/OpenSim/Framework/Servers/BaseHttpServer.cs +++ b/OpenSim/Framework/Servers/BaseHttpServer.cs @@ -752,11 +752,14 @@ namespace OpenSim.Framework.Servers foreach (string pattern in m_llsdHandlers.Keys) { - if (searchquery.StartsWith(searchquery)) + if (searchquery.ToLower().StartsWith(pattern.ToLower())) { if (String.IsNullOrEmpty(bestMatch) || searchquery.Length > bestMatch.Length) { - bestMatch = pattern; + // You have to specifically register for '/' and to get it, you must specificaly request it + // + if (pattern == "/" && searchquery == "/" || pattern != "/") + bestMatch = pattern; } } } diff --git a/OpenSim/Region/Environment/Modules/InterGrid/OpenGridProtocolModule.cs b/OpenSim/Region/Environment/Modules/InterGrid/OpenGridProtocolModule.cs index 2df129bbef..fdb24b14c6 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; using System.Security.Cryptography.X509Certificates; using System.Reflection; using System.Threading; +using System.Web; using OpenMetaverse; using OpenMetaverse.StructuredData; @@ -75,8 +76,9 @@ namespace OpenSim.Region.Environment.Modules.InterGrid public int src_version; public int src_parent_estate_id; public bool visible_to_parent; + public string teleported_into_region; } - + public class OpenGridProtocolModule : IRegionModule { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); @@ -84,6 +86,9 @@ namespace OpenSim.Region.Environment.Modules.InterGrid private Dictionary CapsLoginID = new Dictionary(); private Dictionary m_OGPState = new Dictionary(); + private Dictionary m_loginToRegionState = new Dictionary(); + + private string LastNameSuffix = "_EXTERNAL"; private string FirstNamePrefix = ""; private string httpsCN = ""; @@ -127,7 +132,7 @@ namespace OpenSim.Region.Environment.Modules.InterGrid if (m_scene.Count == 0) { scene.AddLLSDHandler("/agent/", ProcessAgentDomainMessage); - scene.AddLLSDHandler("/", ProcessAgentDomainMessage); + scene.AddLLSDHandler("/", ProcessRegionDomainSeed); try { ServicePointManager.ServerCertificateValidationCallback += customXertificateValidation; @@ -148,6 +153,12 @@ namespace OpenSim.Region.Environment.Modules.InterGrid } } + // can't pick the region 'agent' because it would conflict with our agent domain handler + // a zero length region name would conflict with are base region seed cap + if (!SceneListDuplicateCheck(scene.RegionInfo.RegionName) && scene.RegionInfo.RegionName.ToLower() != "agent" && scene.RegionInfo.RegionName.Length > 0) + { + scene.AddLLSDHandler("/" + HttpUtility.UrlPathEncode(scene.RegionInfo.RegionName.ToLower()),ProcessRegionDomainSeed); + } if (!m_scene.Contains(scene)) m_scene.Add(scene); @@ -196,6 +207,26 @@ namespace OpenSim.Region.Environment.Modules.InterGrid #endregion + public LLSD ProcessRegionDomainSeed(string path, LLSD request, string endpoint) + { + string[] pathSegments = path.Split('/'); + + if (pathSegments.Length <= 1) + { + return GenerateNoHandlerMessage(); + + } + + return GenerateRezAvatarRequestMessage(pathSegments[1]); + + + + //m_log.InfoFormat("[OGP]: path {0}, segments {1} segment[1] {2} Last segment {3}", + // path, pathSegments.Length, pathSegments[1], pathSegments[pathSegments.Length - 1]); + //return new LLSDMap(); + + } + public LLSD ProcessAgentDomainMessage(string path, LLSD request, string endpoint) { // /agent/* @@ -206,12 +237,10 @@ namespace OpenSim.Region.Environment.Modules.InterGrid return GenerateNoHandlerMessage(); } - if (pathSegments[0].Length == 0 && pathSegments[1].Length == 0) { return GenerateRezAvatarRequestMessage(""); } - m_log.InfoFormat("[OGP]: path {0}, segments {1} segment[1] {2} Last segment {3}", path, pathSegments.Length, pathSegments[1], pathSegments[pathSegments.Length - 1]); @@ -248,7 +277,33 @@ namespace OpenSim.Region.Environment.Modules.InterGrid private LLSD GenerateRezAvatarRequestMessage(string regionname) { - Scene region = GetRootScene(); + Scene region = null; + bool usedroot = false; + + if (regionname.Length == 0) + { + region = GetRootScene(); + usedroot = true; + } + else + { + region = GetScene(HttpUtility.UrlDecode(regionname).ToLower()); + } + + // this shouldn't happen since we don't listen for a region that is down.. but + // it might if the region was taken down or is in the middle of restarting + + if (region == null) + { + region = GetRootScene(); + usedroot = true; + } + + UUID statekeeper = UUID.Random(); + + + + RegionInfo reg = region.RegionInfo; LLSDMap responseMap = new LLSDMap(); @@ -256,7 +311,18 @@ namespace OpenSim.Region.Environment.Modules.InterGrid //string regionCapsHttpProtocol = "http://"; string httpaddr = reg.ExternalHostName; string urlport = reg.HttpPort.ToString(); - string requestpath = "/agent/" + UUID.Zero + "/rez_avatar/request"; + string requestpath = "/agent/" + statekeeper + "/rez_avatar/request"; + + if (!usedroot) + { + lock (m_loginToRegionState) + { + if (!m_loginToRegionState.ContainsKey(requestpath)) + { + m_loginToRegionState.Add(requestpath, region.RegionInfo.RegionName.ToLower()); + } + } + } if (httpSSL) { @@ -301,8 +367,26 @@ namespace OpenSim.Region.Environment.Modules.InterGrid LLSDMap requestMap = (LLSDMap)request; - Scene homeScene = GetRootScene(); + Scene homeScene = null; + + lock (m_loginToRegionState) + { + if (m_loginToRegionState.ContainsKey(path)) + { + homeScene = GetScene(m_loginToRegionState[path]); + m_loginToRegionState.Remove(path); + + if (homeScene == null) + homeScene = GetRootScene(); + } + else + { + homeScene = GetRootScene(); + } + } + + // Homescene is still null, we must have no regions that are up if (homeScene == null) return GenerateNoHandlerMessage(); @@ -338,6 +422,7 @@ namespace OpenSim.Region.Environment.Modules.InterGrid userState.src_can_see_mainland = requestMap["src_can_see_mainland"].AsBoolean(); userState.src_estate_id = requestMap["src_estate_id"].AsInteger(); userState.local_agent_id = LocalAgentID; + userState.teleported_into_region = reg.RegionName.ToLower(); UpdateOGPState(LocalAgentID, userState); @@ -548,8 +633,15 @@ namespace OpenSim.Region.Environment.Modules.InterGrid userData.SecureSessionID = SecureSessionID; userData.SessionID = SessionID; + OGPState userState = GetOGPState(userData.AgentID); + // Locate a home scene suitable for the user. - Scene homeScene = GetRootScene(); + Scene homeScene = null; + + homeScene = GetScene(userState.teleported_into_region); + + if (homeScene == null) + homeScene = GetRootScene(); if (homeScene != null) { @@ -562,7 +654,7 @@ namespace OpenSim.Region.Environment.Modules.InterGrid homeScene.ChangeCircuitCode(userData.circuitcode,(uint)circuitcode); // Load state - OGPState userState = GetOGPState(userData.AgentID); + // Keep state changes userState.first_name = requestMap["first_name"].AsString(); @@ -926,6 +1018,24 @@ namespace OpenSim.Region.Environment.Modules.InterGrid return ReturnScene; } + private Scene GetScene(string scenename) + { + Scene ReturnScene = null; + lock (m_scene) + { + foreach (Scene s in m_scene) + { + if (s.RegionInfo.RegionName.ToLower() == scenename) + { + ReturnScene = s; + break; + } + } + } + + return ReturnScene; + } + private ulong GetOSCompatibleRegionHandle(RegionInfo reg) { return Util.UIntsToLong(reg.RegionLocX, reg.RegionLocY); @@ -957,6 +1067,7 @@ namespace OpenSim.Region.Environment.Modules.InterGrid returnState.src_version = 1; returnState.src_parent_estate_id = 1; returnState.visible_to_parent = true; + returnState.teleported_into_region = ""; return returnState; } @@ -999,6 +1110,22 @@ namespace OpenSim.Region.Environment.Modules.InterGrid } } } + private bool SceneListDuplicateCheck(string str) + { + // no lock, called from locked space! + bool found = false; + + foreach (Scene s in m_scene) + { + if (s.RegionInfo.RegionName == str) + { + found = true; + break; + } + } + + return found; + } public void ShutdownConnection(UUID avatarId, OpenGridProtocolModule mod) { diff --git a/prebuild.xml b/prebuild.xml index 0da4bb24f1..c9f1bbcfe6 100644 --- a/prebuild.xml +++ b/prebuild.xml @@ -791,6 +791,7 @@ + @@ -809,6 +810,7 @@ +