* Implements an experimental method to define which region you want to go to in your 'region domain' in OGP.

0.6.0-stable
Teravus Ovares 2008-09-19 21:37:49 +00:00
parent 025441d722
commit 293a822f74
3 changed files with 143 additions and 11 deletions

View File

@ -752,10 +752,13 @@ namespace OpenSim.Framework.Servers
foreach (string pattern in m_llsdHandlers.Keys) 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) if (String.IsNullOrEmpty(bestMatch) || searchquery.Length > bestMatch.Length)
{ {
// You have to specifically register for '/' and to get it, you must specificaly request it
//
if (pattern == "/" && searchquery == "/" || pattern != "/")
bestMatch = pattern; bestMatch = pattern;
} }
} }

View File

@ -33,6 +33,7 @@ using System.Net.Security;
using System.Security.Cryptography.X509Certificates; using System.Security.Cryptography.X509Certificates;
using System.Reflection; using System.Reflection;
using System.Threading; using System.Threading;
using System.Web;
using OpenMetaverse; using OpenMetaverse;
using OpenMetaverse.StructuredData; using OpenMetaverse.StructuredData;
@ -75,6 +76,7 @@ namespace OpenSim.Region.Environment.Modules.InterGrid
public int src_version; public int src_version;
public int src_parent_estate_id; public int src_parent_estate_id;
public bool visible_to_parent; public bool visible_to_parent;
public string teleported_into_region;
} }
public class OpenGridProtocolModule : IRegionModule public class OpenGridProtocolModule : IRegionModule
@ -84,6 +86,9 @@ namespace OpenSim.Region.Environment.Modules.InterGrid
private Dictionary<string, AgentCircuitData> CapsLoginID = new Dictionary<string, AgentCircuitData>(); private Dictionary<string, AgentCircuitData> CapsLoginID = new Dictionary<string, AgentCircuitData>();
private Dictionary<UUID, OGPState> m_OGPState = new Dictionary<UUID, OGPState>(); private Dictionary<UUID, OGPState> m_OGPState = new Dictionary<UUID, OGPState>();
private Dictionary<string, string> m_loginToRegionState = new Dictionary<string, string>();
private string LastNameSuffix = "_EXTERNAL"; private string LastNameSuffix = "_EXTERNAL";
private string FirstNamePrefix = ""; private string FirstNamePrefix = "";
private string httpsCN = ""; private string httpsCN = "";
@ -127,7 +132,7 @@ namespace OpenSim.Region.Environment.Modules.InterGrid
if (m_scene.Count == 0) if (m_scene.Count == 0)
{ {
scene.AddLLSDHandler("/agent/", ProcessAgentDomainMessage); scene.AddLLSDHandler("/agent/", ProcessAgentDomainMessage);
scene.AddLLSDHandler("/", ProcessAgentDomainMessage); scene.AddLLSDHandler("/", ProcessRegionDomainSeed);
try try
{ {
ServicePointManager.ServerCertificateValidationCallback += customXertificateValidation; 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)) if (!m_scene.Contains(scene))
m_scene.Add(scene); m_scene.Add(scene);
@ -196,6 +207,26 @@ namespace OpenSim.Region.Environment.Modules.InterGrid
#endregion #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) public LLSD ProcessAgentDomainMessage(string path, LLSD request, string endpoint)
{ {
// /agent/* // /agent/*
@ -206,12 +237,10 @@ namespace OpenSim.Region.Environment.Modules.InterGrid
return GenerateNoHandlerMessage(); return GenerateNoHandlerMessage();
} }
if (pathSegments[0].Length == 0 && pathSegments[1].Length == 0) if (pathSegments[0].Length == 0 && pathSegments[1].Length == 0)
{ {
return GenerateRezAvatarRequestMessage(""); return GenerateRezAvatarRequestMessage("");
} }
m_log.InfoFormat("[OGP]: path {0}, segments {1} segment[1] {2} Last segment {3}", m_log.InfoFormat("[OGP]: path {0}, segments {1} segment[1] {2} Last segment {3}",
path, pathSegments.Length, pathSegments[1], pathSegments[pathSegments.Length - 1]); path, pathSegments.Length, pathSegments[1], pathSegments[pathSegments.Length - 1]);
@ -248,7 +277,33 @@ namespace OpenSim.Region.Environment.Modules.InterGrid
private LLSD GenerateRezAvatarRequestMessage(string regionname) 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; RegionInfo reg = region.RegionInfo;
LLSDMap responseMap = new LLSDMap(); LLSDMap responseMap = new LLSDMap();
@ -256,7 +311,18 @@ namespace OpenSim.Region.Environment.Modules.InterGrid
//string regionCapsHttpProtocol = "http://"; //string regionCapsHttpProtocol = "http://";
string httpaddr = reg.ExternalHostName; string httpaddr = reg.ExternalHostName;
string urlport = reg.HttpPort.ToString(); 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) if (httpSSL)
{ {
@ -301,8 +367,26 @@ namespace OpenSim.Region.Environment.Modules.InterGrid
LLSDMap requestMap = (LLSDMap)request; 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) if (homeScene == null)
return GenerateNoHandlerMessage(); 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_can_see_mainland = requestMap["src_can_see_mainland"].AsBoolean();
userState.src_estate_id = requestMap["src_estate_id"].AsInteger(); userState.src_estate_id = requestMap["src_estate_id"].AsInteger();
userState.local_agent_id = LocalAgentID; userState.local_agent_id = LocalAgentID;
userState.teleported_into_region = reg.RegionName.ToLower();
UpdateOGPState(LocalAgentID, userState); UpdateOGPState(LocalAgentID, userState);
@ -548,8 +633,15 @@ namespace OpenSim.Region.Environment.Modules.InterGrid
userData.SecureSessionID = SecureSessionID; userData.SecureSessionID = SecureSessionID;
userData.SessionID = SessionID; userData.SessionID = SessionID;
OGPState userState = GetOGPState(userData.AgentID);
// Locate a home scene suitable for the user. // 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) if (homeScene != null)
{ {
@ -562,7 +654,7 @@ namespace OpenSim.Region.Environment.Modules.InterGrid
homeScene.ChangeCircuitCode(userData.circuitcode,(uint)circuitcode); homeScene.ChangeCircuitCode(userData.circuitcode,(uint)circuitcode);
// Load state // Load state
OGPState userState = GetOGPState(userData.AgentID);
// Keep state changes // Keep state changes
userState.first_name = requestMap["first_name"].AsString(); userState.first_name = requestMap["first_name"].AsString();
@ -926,6 +1018,24 @@ namespace OpenSim.Region.Environment.Modules.InterGrid
return ReturnScene; 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) private ulong GetOSCompatibleRegionHandle(RegionInfo reg)
{ {
return Util.UIntsToLong(reg.RegionLocX, reg.RegionLocY); return Util.UIntsToLong(reg.RegionLocX, reg.RegionLocY);
@ -957,6 +1067,7 @@ namespace OpenSim.Region.Environment.Modules.InterGrid
returnState.src_version = 1; returnState.src_version = 1;
returnState.src_parent_estate_id = 1; returnState.src_parent_estate_id = 1;
returnState.visible_to_parent = true; returnState.visible_to_parent = true;
returnState.teleported_into_region = "";
return returnState; 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) public void ShutdownConnection(UUID avatarId, OpenGridProtocolModule mod)
{ {

View File

@ -791,6 +791,7 @@
<Reference name="System.Xml"/> <Reference name="System.Xml"/>
<Reference name="System.Drawing"/> <Reference name="System.Drawing"/>
<Reference name="System.Runtime.Remoting"/> <Reference name="System.Runtime.Remoting"/>
<Reference name="System.Web"/>
<Reference name="OpenMetaverseTypes.dll"/> <Reference name="OpenMetaverseTypes.dll"/>
<Reference name="OpenMetaverse.dll"/> <Reference name="OpenMetaverse.dll"/>
<Reference name="OpenSim.Framework"/> <Reference name="OpenSim.Framework"/>
@ -810,6 +811,7 @@
<Reference name="log4net.dll"/> <Reference name="log4net.dll"/>
<Reference name="DotNetOpenMail.dll"/> <Reference name="DotNetOpenMail.dll"/>
<Files> <Files>
<Match pattern="*.cs" recurse="true"> <Match pattern="*.cs" recurse="true">
<Exclude name="Tests" pattern="Tests" /> <Exclude name="Tests" pattern="Tests" />