mirror of
https://github.com/opensim/opensim.git
synced 2026-08-07 01:35:46 +08:00
Merge branch 'master' into diva-textures
This commit is contained in:
@@ -26,6 +26,7 @@
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using System.Reflection;
|
||||
using OpenSim.Framework;
|
||||
@@ -40,17 +41,40 @@ namespace OpenSim.Server.Base
|
||||
{
|
||||
// Logger
|
||||
//
|
||||
// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||
private static readonly ILog m_Log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
// The http server instance
|
||||
//
|
||||
protected BaseHttpServer m_HttpServer = null;
|
||||
protected uint m_Port = 0;
|
||||
protected Dictionary<uint, BaseHttpServer> m_Servers =
|
||||
new Dictionary<uint, BaseHttpServer>();
|
||||
|
||||
public IHttpServer HttpServer
|
||||
{
|
||||
get { return m_HttpServer; }
|
||||
}
|
||||
|
||||
public uint DefaultPort
|
||||
{
|
||||
get { return m_Port; }
|
||||
}
|
||||
|
||||
public IHttpServer GetHttpServer(uint port)
|
||||
{
|
||||
m_Log.InfoFormat("[SERVER]: Requested port {0}", port);
|
||||
if (port == m_Port)
|
||||
return HttpServer;
|
||||
|
||||
if (m_Servers.ContainsKey(port))
|
||||
return m_Servers[port];
|
||||
|
||||
m_Servers[port] = new BaseHttpServer(port);
|
||||
m_Servers[port].Start();
|
||||
|
||||
return m_Servers[port];
|
||||
}
|
||||
|
||||
// Handle all the automagical stuff
|
||||
//
|
||||
public HttpServerBase(string prompt, string[] args) : base(prompt, args)
|
||||
@@ -74,6 +98,8 @@ namespace OpenSim.Server.Base
|
||||
Thread.CurrentThread.Abort();
|
||||
}
|
||||
|
||||
m_Port = port;
|
||||
|
||||
m_HttpServer = new BaseHttpServer(port);
|
||||
|
||||
MainServer.Instance = m_HttpServer;
|
||||
|
||||
56
OpenSim/Server/Base/ProtocolVersions.cs
Normal file
56
OpenSim/Server/Base/ProtocolVersions.cs
Normal file
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* Copyright (c) Contributors, http://opensimulator.org/
|
||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of the OpenSimulator Project nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
namespace OpenSim.Server.Base
|
||||
{
|
||||
public class ProtocolVersions
|
||||
{
|
||||
/// <value>
|
||||
/// This is the external protocol versions. It is separate from the OpenSimulator project version.
|
||||
///
|
||||
/// These version numbers should be increased by 1 every time a code
|
||||
/// change in the Service.Connectors and Server.Handlers, espectively,
|
||||
/// makes the previous OpenSimulator revision incompatible
|
||||
/// with the new revision.
|
||||
///
|
||||
/// Changes which are compatible with an older revision (e.g. older revisions experience degraded functionality
|
||||
/// but not outright failure) do not need a version number increment.
|
||||
///
|
||||
/// Having this version number allows the grid service to reject connections from regions running a version
|
||||
/// of the code that is too old.
|
||||
///
|
||||
/// </value>
|
||||
|
||||
// The range of acceptable servers for client-side connectors
|
||||
public readonly static int ClientProtocolVersionMin = 0;
|
||||
public readonly static int ClientProtocolVersionMax = 0;
|
||||
|
||||
// The range of acceptable clients in server-side handlers
|
||||
public readonly static int ServerProtocolVersionMin = 0;
|
||||
public readonly static int ServerProtocolVersionMax = 0;
|
||||
}
|
||||
}
|
||||
@@ -141,7 +141,9 @@ namespace OpenSim.Server.Base
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
m_log.ErrorFormat("Error loading plugin from {0}, exception {1}", dllName, e.InnerException);
|
||||
if (!(e is System.MissingMethodException))
|
||||
m_log.ErrorFormat("Error loading plugin from {0}, exception {1}", dllName, e.InnerException);
|
||||
return null;
|
||||
}
|
||||
|
||||
return plug;
|
||||
@@ -183,5 +185,121 @@ namespace OpenSim.Server.Base
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public static string BuildQueryString(Dictionary<string, string> data)
|
||||
{
|
||||
string qstring = String.Empty;
|
||||
|
||||
foreach (KeyValuePair<string, string> kvp in data)
|
||||
{
|
||||
string part;
|
||||
if (kvp.Value != String.Empty)
|
||||
{
|
||||
part = System.Web.HttpUtility.UrlEncode(kvp.Key) +
|
||||
"=" + System.Web.HttpUtility.UrlEncode(kvp.Value);
|
||||
}
|
||||
else
|
||||
{
|
||||
part = System.Web.HttpUtility.UrlEncode(kvp.Key);
|
||||
}
|
||||
|
||||
if (qstring != String.Empty)
|
||||
qstring += "&";
|
||||
|
||||
qstring += part;
|
||||
}
|
||||
|
||||
return qstring;
|
||||
}
|
||||
|
||||
public static string BuildXmlResponse(Dictionary<string, object> data)
|
||||
{
|
||||
XmlDocument doc = new XmlDocument();
|
||||
|
||||
XmlNode xmlnode = doc.CreateNode(XmlNodeType.XmlDeclaration,
|
||||
"", "");
|
||||
|
||||
doc.AppendChild(xmlnode);
|
||||
|
||||
XmlElement rootElement = doc.CreateElement("", "ServerResponse",
|
||||
"");
|
||||
|
||||
doc.AppendChild(rootElement);
|
||||
|
||||
BuildXmlData(rootElement, data);
|
||||
|
||||
return doc.InnerXml;
|
||||
}
|
||||
|
||||
private static void BuildXmlData(XmlElement parent, Dictionary<string, object> data)
|
||||
{
|
||||
foreach (KeyValuePair<string, object> kvp in data)
|
||||
{
|
||||
XmlElement elem = parent.OwnerDocument.CreateElement("",
|
||||
kvp.Key, "");
|
||||
|
||||
if (kvp.Value is Dictionary<string, object>)
|
||||
{
|
||||
XmlAttribute type = parent.OwnerDocument.CreateAttribute("",
|
||||
"type", "");
|
||||
type.Value = "List";
|
||||
|
||||
elem.Attributes.Append(type);
|
||||
|
||||
BuildXmlData(elem, (Dictionary<string, object>)kvp.Value);
|
||||
}
|
||||
else
|
||||
{
|
||||
elem.AppendChild(parent.OwnerDocument.CreateTextNode(
|
||||
kvp.Value.ToString()));
|
||||
}
|
||||
|
||||
parent.AppendChild(elem);
|
||||
}
|
||||
}
|
||||
|
||||
public static Dictionary<string, object> ParseXmlResponse(string data)
|
||||
{
|
||||
//m_log.DebugFormat("[XXX]: received xml string: {0}", data);
|
||||
|
||||
Dictionary<string, object> ret = new Dictionary<string, object>();
|
||||
|
||||
XmlDocument doc = new XmlDocument();
|
||||
|
||||
doc.LoadXml(data);
|
||||
|
||||
XmlNodeList rootL = doc.GetElementsByTagName("ServerResponse");
|
||||
|
||||
if (rootL.Count != 1)
|
||||
return ret;
|
||||
|
||||
XmlNode rootNode = rootL[0];
|
||||
|
||||
ret = ParseElement(rootNode);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
private static Dictionary<string, object> ParseElement(XmlNode element)
|
||||
{
|
||||
Dictionary<string, object> ret = new Dictionary<string, object>();
|
||||
|
||||
XmlNodeList partL = element.ChildNodes;
|
||||
|
||||
foreach (XmlNode part in partL)
|
||||
{
|
||||
XmlNode type = part.Attributes.GetNamedItem("type");
|
||||
if (type == null || type.Value != "List")
|
||||
{
|
||||
ret[part.Name] = part.InnerText;
|
||||
}
|
||||
else
|
||||
{
|
||||
ret[part.Name] = ParseElement(part);
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,13 +37,17 @@ namespace OpenSim.Server.Handlers.Asset
|
||||
public class AssetServiceConnector : ServiceConnector
|
||||
{
|
||||
private IAssetService m_AssetService;
|
||||
private string m_ConfigName = "AssetService";
|
||||
|
||||
public AssetServiceConnector(IConfigSource config, IHttpServer server) :
|
||||
base(config, server)
|
||||
public AssetServiceConnector(IConfigSource config, IHttpServer server, string configName) :
|
||||
base(config, server, configName)
|
||||
{
|
||||
IConfig serverConfig = config.Configs["AssetService"];
|
||||
if (configName != String.Empty)
|
||||
m_ConfigName = configName;
|
||||
|
||||
IConfig serverConfig = config.Configs[m_ConfigName];
|
||||
if (serverConfig == null)
|
||||
throw new Exception("No section 'Server' in config file");
|
||||
throw new Exception(String.Format("No section '{0}' in config file", m_ConfigName));
|
||||
|
||||
string assetService = serverConfig.GetString("LocalServiceModule",
|
||||
String.Empty);
|
||||
@@ -55,7 +59,6 @@ namespace OpenSim.Server.Handlers.Asset
|
||||
m_AssetService =
|
||||
ServerUtils.LoadPlugin<IAssetService>(assetService, args);
|
||||
|
||||
//System.Console.WriteLine("XXXXXXXXXXXXXXXXXXX m_AssetSetvice == null? " + ((m_AssetService == null) ? "yes" : "no"));
|
||||
server.AddStreamHandler(new AssetServerGetHandler(m_AssetService));
|
||||
server.AddStreamHandler(new AssetServerPostHandler(m_AssetService));
|
||||
server.AddStreamHandler(new AssetServerDeleteHandler(m_AssetService));
|
||||
|
||||
@@ -37,13 +37,17 @@ namespace OpenSim.Server.Handlers.Authentication
|
||||
public class AuthenticationServiceConnector : ServiceConnector
|
||||
{
|
||||
private IAuthenticationService m_AuthenticationService;
|
||||
private string m_ConfigName = "AuthenticationService";
|
||||
|
||||
public AuthenticationServiceConnector(IConfigSource config, IHttpServer server) :
|
||||
base(config, server)
|
||||
public AuthenticationServiceConnector(IConfigSource config, IHttpServer server, string configName) :
|
||||
base(config, server, configName)
|
||||
{
|
||||
IConfig serverConfig = config.Configs["AuthenticationService"];
|
||||
if (configName != String.Empty)
|
||||
m_ConfigName = configName;
|
||||
|
||||
IConfig serverConfig = config.Configs[m_ConfigName];
|
||||
if (serverConfig == null)
|
||||
throw new Exception("No section 'Server' in config file");
|
||||
throw new Exception(String.Format("No section '{0}' in config file", m_ConfigName));
|
||||
|
||||
string authenticationService = serverConfig.GetString("AuthenticationServiceModule",
|
||||
String.Empty);
|
||||
|
||||
@@ -157,7 +157,7 @@ namespace OpenSim.Server.Handlers.Authentication
|
||||
|
||||
doc.AppendChild(xmlnode);
|
||||
|
||||
XmlElement rootElement = doc.CreateElement("", "Authentication",
|
||||
XmlElement rootElement = doc.CreateElement("", "ServerResponse",
|
||||
"");
|
||||
|
||||
doc.AppendChild(rootElement);
|
||||
@@ -179,7 +179,7 @@ namespace OpenSim.Server.Handlers.Authentication
|
||||
|
||||
doc.AppendChild(xmlnode);
|
||||
|
||||
XmlElement rootElement = doc.CreateElement("", "Authentication",
|
||||
XmlElement rootElement = doc.CreateElement("", "ServerResponse",
|
||||
"");
|
||||
|
||||
doc.AppendChild(rootElement);
|
||||
@@ -201,7 +201,7 @@ namespace OpenSim.Server.Handlers.Authentication
|
||||
|
||||
doc.AppendChild(xmlnode);
|
||||
|
||||
XmlElement rootElement = doc.CreateElement("", "Authentication",
|
||||
XmlElement rootElement = doc.CreateElement("", "ServerResponse",
|
||||
"");
|
||||
|
||||
doc.AppendChild(rootElement);
|
||||
|
||||
@@ -37,13 +37,16 @@ namespace OpenSim.Server.Handlers.Authorization
|
||||
public class AuthorizationServerConnector : ServiceConnector
|
||||
{
|
||||
private IAuthorizationService m_AuthorizationService;
|
||||
private string m_ConfigName = "AuthorizationService";
|
||||
|
||||
public AuthorizationServerConnector(IConfigSource config, IHttpServer server) :
|
||||
base(config, server)
|
||||
public AuthorizationServerConnector(IConfigSource config, IHttpServer server, string configName) :
|
||||
base(config, server, configName)
|
||||
{
|
||||
IConfig serverConfig = config.Configs["AuthorizationService"];
|
||||
if (configName != String.Empty)
|
||||
m_ConfigName = configName;
|
||||
IConfig serverConfig = config.Configs[m_ConfigName];
|
||||
if (serverConfig == null)
|
||||
throw new Exception("No section 'Server' in config file");
|
||||
throw new Exception(String.Format("No section '{0}' in config file", m_ConfigName));
|
||||
|
||||
string authorizationService = serverConfig.GetString("LocalServiceModule",
|
||||
String.Empty);
|
||||
|
||||
@@ -44,7 +44,7 @@ namespace OpenSim.Server.Handlers.Authorization
|
||||
{
|
||||
public class AuthorizationServerPostHandler : BaseStreamHandler
|
||||
{
|
||||
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||
// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
private IAuthorizationService m_AuthorizationService;
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ namespace OpenSim.Server.Handlers.Base
|
||||
|
||||
public class ServiceConnector : IServiceConnector
|
||||
{
|
||||
public ServiceConnector(IConfigSource config, IHttpServer server)
|
||||
public ServiceConnector(IConfigSource config, IHttpServer server, string configName)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,19 +37,23 @@ namespace OpenSim.Server.Handlers.Freeswitch
|
||||
public class FreeswitchServerConnector : ServiceConnector
|
||||
{
|
||||
private IFreeswitchService m_FreeswitchService;
|
||||
private string m_ConfigName = "FreeswitchService";
|
||||
|
||||
public FreeswitchServerConnector(IConfigSource config, IHttpServer server) :
|
||||
base(config, server)
|
||||
public FreeswitchServerConnector(IConfigSource config, IHttpServer server, string configName) :
|
||||
base(config, server, configName)
|
||||
{
|
||||
IConfig serverConfig = config.Configs["FreeswitchService"];
|
||||
if (configName != String.Empty)
|
||||
m_ConfigName = configName;
|
||||
|
||||
IConfig serverConfig = config.Configs[m_ConfigName];
|
||||
if (serverConfig == null)
|
||||
throw new Exception("No section 'Server' in config file");
|
||||
throw new Exception(String.Format("No section '{0}' in config file", m_ConfigName));
|
||||
|
||||
string freeswitchService = serverConfig.GetString("LocalServiceModule",
|
||||
String.Empty);
|
||||
|
||||
if (freeswitchService == String.Empty)
|
||||
throw new Exception("No FreeswitchService in config file");
|
||||
throw new Exception("No LocalServiceModule in config file");
|
||||
|
||||
Object[] args = new Object[] { config };
|
||||
m_FreeswitchService =
|
||||
|
||||
61
OpenSim/Server/Handlers/Grid/GridServerConnector.cs
Normal file
61
OpenSim/Server/Handlers/Grid/GridServerConnector.cs
Normal file
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
* Copyright (c) Contributors, http://opensimulator.org/
|
||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of the OpenSimulator Project nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using Nini.Config;
|
||||
using OpenSim.Server.Base;
|
||||
using OpenSim.Services.Interfaces;
|
||||
using OpenSim.Framework.Servers.HttpServer;
|
||||
using OpenSim.Server.Handlers.Base;
|
||||
|
||||
namespace OpenSim.Server.Handlers.Grid
|
||||
{
|
||||
public class GridServiceConnector : ServiceConnector
|
||||
{
|
||||
private IGridService m_GridService;
|
||||
private string m_ConfigName = "GridService";
|
||||
|
||||
public GridServiceConnector(IConfigSource config, IHttpServer server, string configName) :
|
||||
base(config, server, configName)
|
||||
{
|
||||
IConfig serverConfig = config.Configs[m_ConfigName];
|
||||
if (serverConfig == null)
|
||||
throw new Exception(String.Format("No section {0} in config file", m_ConfigName));
|
||||
|
||||
string gridService = serverConfig.GetString("LocalServiceModule",
|
||||
String.Empty);
|
||||
|
||||
if (gridService == String.Empty)
|
||||
throw new Exception("No LocalServiceModule in config file");
|
||||
|
||||
Object[] args = new Object[] { config };
|
||||
m_GridService = ServerUtils.LoadPlugin<IGridService>(gridService, args);
|
||||
|
||||
server.AddStreamHandler(new GridServerPostHandler(m_GridService));
|
||||
}
|
||||
}
|
||||
}
|
||||
451
OpenSim/Server/Handlers/Grid/GridServerPostHandler.cs
Normal file
451
OpenSim/Server/Handlers/Grid/GridServerPostHandler.cs
Normal file
@@ -0,0 +1,451 @@
|
||||
/*
|
||||
* Copyright (c) Contributors, http://opensimulator.org/
|
||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of the OpenSimulator Project nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
using Nini.Config;
|
||||
using log4net;
|
||||
using System;
|
||||
using System.Reflection;
|
||||
using System.IO;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Xml;
|
||||
using System.Xml.Serialization;
|
||||
using System.Collections.Generic;
|
||||
using OpenSim.Server.Base;
|
||||
using OpenSim.Services.Interfaces;
|
||||
using GridRegion = OpenSim.Services.Interfaces.GridRegion;
|
||||
using OpenSim.Framework;
|
||||
using OpenSim.Framework.Servers.HttpServer;
|
||||
using OpenMetaverse;
|
||||
|
||||
namespace OpenSim.Server.Handlers.Grid
|
||||
{
|
||||
public class GridServerPostHandler : BaseStreamHandler
|
||||
{
|
||||
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
private IGridService m_GridService;
|
||||
|
||||
public GridServerPostHandler(IGridService service) :
|
||||
base("POST", "/grid")
|
||||
{
|
||||
m_GridService = service;
|
||||
}
|
||||
|
||||
public override byte[] Handle(string path, Stream requestData,
|
||||
OSHttpRequest httpRequest, OSHttpResponse httpResponse)
|
||||
{
|
||||
StreamReader sr = new StreamReader(requestData);
|
||||
string body = sr.ReadToEnd();
|
||||
sr.Close();
|
||||
body = body.Trim();
|
||||
|
||||
//m_log.DebugFormat("[XXX]: query String: {0}", body);
|
||||
|
||||
Dictionary<string, string> request =
|
||||
ServerUtils.ParseQueryString(body);
|
||||
|
||||
if (!request.ContainsKey("METHOD"))
|
||||
return FailureResult();
|
||||
|
||||
string method = request["METHOD"];
|
||||
|
||||
switch (method)
|
||||
{
|
||||
case "register":
|
||||
return Register(request);
|
||||
|
||||
case "deregister":
|
||||
return Deregister(request);
|
||||
|
||||
case "get_neighbours":
|
||||
return GetNeighbours(request);
|
||||
|
||||
case "get_region_by_uuid":
|
||||
return GetRegionByUUID(request);
|
||||
|
||||
case "get_region_by_position":
|
||||
return GetRegionByPosition(request);
|
||||
|
||||
case "get_region_by_name":
|
||||
return GetRegionByName(request);
|
||||
|
||||
case "get_regions_by_name":
|
||||
return GetRegionsByName(request);
|
||||
|
||||
case "get_region_range":
|
||||
return GetRegionRange(request);
|
||||
|
||||
}
|
||||
|
||||
m_log.DebugFormat("[GRID HANDLER]: unknown method {0} request {1}", method.Length, method);
|
||||
return FailureResult();
|
||||
|
||||
}
|
||||
|
||||
#region Method-specific handlers
|
||||
|
||||
byte[] Register(Dictionary<string, string> request)
|
||||
{
|
||||
UUID scopeID = UUID.Zero;
|
||||
if (request["SCOPEID"] != null)
|
||||
UUID.TryParse(request["SCOPEID"], out scopeID);
|
||||
else
|
||||
m_log.WarnFormat("[GRID HANDLER]: no scopeID in request to register region");
|
||||
|
||||
int versionNumberMin = 0, versionNumberMax = 0;
|
||||
if (request.ContainsKey("VERSIONMIN"))
|
||||
Int32.TryParse(request["VERSIONMIN"], out versionNumberMin);
|
||||
else
|
||||
m_log.WarnFormat("[GRID HANDLER]: no minimum protocol version in request to register region");
|
||||
|
||||
if (request.ContainsKey("VERSIONMAX"))
|
||||
Int32.TryParse(request["VERSIONMAX"], out versionNumberMax);
|
||||
else
|
||||
m_log.WarnFormat("[GRID HANDLER]: no maximum protocol version in request to register region");
|
||||
|
||||
// Check the protocol version
|
||||
if ((versionNumberMin > ProtocolVersions.ServerProtocolVersionMax && versionNumberMax < ProtocolVersions.ServerProtocolVersionMax))
|
||||
{
|
||||
// Can't do, there is no overlap in the acceptable ranges
|
||||
return FailureResult();
|
||||
}
|
||||
|
||||
Dictionary<string, object> rinfoData = new Dictionary<string, object>();
|
||||
foreach (KeyValuePair<string, string> kvp in request)
|
||||
rinfoData[kvp.Key] = kvp.Value;
|
||||
GridRegion rinfo = new GridRegion(rinfoData);
|
||||
|
||||
bool result = m_GridService.RegisterRegion(scopeID, rinfo);
|
||||
|
||||
if (result)
|
||||
return SuccessResult();
|
||||
else
|
||||
return FailureResult();
|
||||
}
|
||||
|
||||
byte[] Deregister(Dictionary<string, string> request)
|
||||
{
|
||||
UUID regionID = UUID.Zero;
|
||||
if (request["REGIONID"] != null)
|
||||
UUID.TryParse(request["REGIONID"], out regionID);
|
||||
else
|
||||
m_log.WarnFormat("[GRID HANDLER]: no regionID in request to deregister region");
|
||||
|
||||
bool result = m_GridService.DeregisterRegion(regionID);
|
||||
|
||||
if (result)
|
||||
return SuccessResult();
|
||||
else
|
||||
return FailureResult();
|
||||
|
||||
}
|
||||
|
||||
byte[] GetNeighbours(Dictionary<string, string> request)
|
||||
{
|
||||
UUID scopeID = UUID.Zero;
|
||||
if (request["SCOPEID"] != null)
|
||||
UUID.TryParse(request["SCOPEID"], out scopeID);
|
||||
else
|
||||
m_log.WarnFormat("[GRID HANDLER]: no scopeID in request to get neighbours");
|
||||
|
||||
UUID regionID = UUID.Zero;
|
||||
if (request["REGIONID"] != null)
|
||||
UUID.TryParse(request["REGIONID"], out regionID);
|
||||
else
|
||||
m_log.WarnFormat("[GRID HANDLER]: no regionID in request to get neighbours");
|
||||
|
||||
List<GridRegion> rinfos = m_GridService.GetNeighbours(scopeID, regionID);
|
||||
//m_log.DebugFormat("[GRID HANDLER]: neighbours for region {0}: {1}", regionID, rinfos.Count);
|
||||
|
||||
Dictionary<string, object> result = new Dictionary<string, object>();
|
||||
if ((rinfos == null) || ((rinfos != null) && (rinfos.Count == 0)))
|
||||
result["result"] = "null";
|
||||
else
|
||||
{
|
||||
int i = 0;
|
||||
foreach (GridRegion rinfo in rinfos)
|
||||
{
|
||||
Dictionary<string, object> rinfoDict = rinfo.ToKeyValuePairs();
|
||||
result["region" + i] = rinfoDict;
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
string xmlString = ServerUtils.BuildXmlResponse(result);
|
||||
//m_log.DebugFormat("[GRID HANDLER]: resp string: {0}", xmlString);
|
||||
UTF8Encoding encoding = new UTF8Encoding();
|
||||
return encoding.GetBytes(xmlString);
|
||||
|
||||
}
|
||||
|
||||
byte[] GetRegionByUUID(Dictionary<string, string> request)
|
||||
{
|
||||
UUID scopeID = UUID.Zero;
|
||||
if (request["SCOPEID"] != null)
|
||||
UUID.TryParse(request["SCOPEID"], out scopeID);
|
||||
else
|
||||
m_log.WarnFormat("[GRID HANDLER]: no scopeID in request to get neighbours");
|
||||
|
||||
UUID regionID = UUID.Zero;
|
||||
if (request["REGIONID"] != null)
|
||||
UUID.TryParse(request["REGIONID"], out regionID);
|
||||
else
|
||||
m_log.WarnFormat("[GRID HANDLER]: no regionID in request to get neighbours");
|
||||
|
||||
GridRegion rinfo = m_GridService.GetRegionByUUID(scopeID, regionID);
|
||||
//m_log.DebugFormat("[GRID HANDLER]: neighbours for region {0}: {1}", regionID, rinfos.Count);
|
||||
|
||||
Dictionary<string, object> result = new Dictionary<string, object>();
|
||||
if (rinfo == null)
|
||||
result["result"] = "null";
|
||||
else
|
||||
result["result"] = rinfo.ToKeyValuePairs();
|
||||
|
||||
string xmlString = ServerUtils.BuildXmlResponse(result);
|
||||
//m_log.DebugFormat("[GRID HANDLER]: resp string: {0}", xmlString);
|
||||
UTF8Encoding encoding = new UTF8Encoding();
|
||||
return encoding.GetBytes(xmlString);
|
||||
}
|
||||
|
||||
byte[] GetRegionByPosition(Dictionary<string, string> request)
|
||||
{
|
||||
UUID scopeID = UUID.Zero;
|
||||
if (request["SCOPEID"] != null)
|
||||
UUID.TryParse(request["SCOPEID"], out scopeID);
|
||||
else
|
||||
m_log.WarnFormat("[GRID HANDLER]: no scopeID in request to get region by position");
|
||||
|
||||
int x = 0, y = 0;
|
||||
if (request["X"] != null)
|
||||
Int32.TryParse(request["X"], out x);
|
||||
else
|
||||
m_log.WarnFormat("[GRID HANDLER]: no X in request to get region by position");
|
||||
if (request["Y"] != null)
|
||||
Int32.TryParse(request["Y"], out y);
|
||||
else
|
||||
m_log.WarnFormat("[GRID HANDLER]: no Y in request to get region by position");
|
||||
|
||||
GridRegion rinfo = m_GridService.GetRegionByPosition(scopeID, x, y);
|
||||
//m_log.DebugFormat("[GRID HANDLER]: neighbours for region {0}: {1}", regionID, rinfos.Count);
|
||||
|
||||
Dictionary<string, object> result = new Dictionary<string, object>();
|
||||
if (rinfo == null)
|
||||
result["result"] = "null";
|
||||
else
|
||||
result["result"] = rinfo.ToKeyValuePairs();
|
||||
|
||||
string xmlString = ServerUtils.BuildXmlResponse(result);
|
||||
//m_log.DebugFormat("[GRID HANDLER]: resp string: {0}", xmlString);
|
||||
UTF8Encoding encoding = new UTF8Encoding();
|
||||
return encoding.GetBytes(xmlString);
|
||||
}
|
||||
|
||||
byte[] GetRegionByName(Dictionary<string, string> request)
|
||||
{
|
||||
UUID scopeID = UUID.Zero;
|
||||
if (request["SCOPEID"] != null)
|
||||
UUID.TryParse(request["SCOPEID"], out scopeID);
|
||||
else
|
||||
m_log.WarnFormat("[GRID HANDLER]: no scopeID in request to get region by name");
|
||||
|
||||
string regionName = string.Empty;
|
||||
if (request["NAME"] != null)
|
||||
regionName = request["NAME"];
|
||||
else
|
||||
m_log.WarnFormat("[GRID HANDLER]: no name in request to get region by name");
|
||||
|
||||
GridRegion rinfo = m_GridService.GetRegionByName(scopeID, regionName);
|
||||
//m_log.DebugFormat("[GRID HANDLER]: neighbours for region {0}: {1}", regionID, rinfos.Count);
|
||||
|
||||
Dictionary<string, object> result = new Dictionary<string, object>();
|
||||
if (rinfo == null)
|
||||
result["result"] = "null";
|
||||
else
|
||||
result["result"] = rinfo.ToKeyValuePairs();
|
||||
|
||||
string xmlString = ServerUtils.BuildXmlResponse(result);
|
||||
//m_log.DebugFormat("[GRID HANDLER]: resp string: {0}", xmlString);
|
||||
UTF8Encoding encoding = new UTF8Encoding();
|
||||
return encoding.GetBytes(xmlString);
|
||||
}
|
||||
|
||||
byte[] GetRegionsByName(Dictionary<string, string> request)
|
||||
{
|
||||
UUID scopeID = UUID.Zero;
|
||||
if (request["SCOPEID"] != null)
|
||||
UUID.TryParse(request["SCOPEID"], out scopeID);
|
||||
else
|
||||
m_log.WarnFormat("[GRID HANDLER]: no scopeID in request to get regions by name");
|
||||
|
||||
string regionName = string.Empty;
|
||||
if (request["NAME"] != null)
|
||||
regionName = request["NAME"];
|
||||
else
|
||||
m_log.WarnFormat("[GRID HANDLER]: no NAME in request to get regions by name");
|
||||
|
||||
int max = 0;
|
||||
if (request["MAX"] != null)
|
||||
Int32.TryParse(request["MAX"], out max);
|
||||
else
|
||||
m_log.WarnFormat("[GRID HANDLER]: no MAX in request to get regions by name");
|
||||
|
||||
List<GridRegion> rinfos = m_GridService.GetRegionsByName(scopeID, regionName, max);
|
||||
//m_log.DebugFormat("[GRID HANDLER]: neighbours for region {0}: {1}", regionID, rinfos.Count);
|
||||
|
||||
Dictionary<string, object> result = new Dictionary<string, object>();
|
||||
if ((rinfos == null) || ((rinfos != null) && (rinfos.Count == 0)))
|
||||
result["result"] = "null";
|
||||
else
|
||||
{
|
||||
int i = 0;
|
||||
foreach (GridRegion rinfo in rinfos)
|
||||
{
|
||||
Dictionary<string, object> rinfoDict = rinfo.ToKeyValuePairs();
|
||||
result["region" + i] = rinfoDict;
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
string xmlString = ServerUtils.BuildXmlResponse(result);
|
||||
//m_log.DebugFormat("[GRID HANDLER]: resp string: {0}", xmlString);
|
||||
UTF8Encoding encoding = new UTF8Encoding();
|
||||
return encoding.GetBytes(xmlString);
|
||||
}
|
||||
|
||||
byte[] GetRegionRange(Dictionary<string, string> request)
|
||||
{
|
||||
//m_log.DebugFormat("[GRID HANDLER]: GetRegionRange");
|
||||
UUID scopeID = UUID.Zero;
|
||||
if (request.ContainsKey("SCOPEID"))
|
||||
UUID.TryParse(request["SCOPEID"], out scopeID);
|
||||
else
|
||||
m_log.WarnFormat("[GRID HANDLER]: no scopeID in request to get region range");
|
||||
|
||||
int xmin = 0, xmax = 0, ymin = 0, ymax = 0;
|
||||
if (request.ContainsKey("XMIN"))
|
||||
Int32.TryParse(request["XMIN"], out xmin);
|
||||
else
|
||||
m_log.WarnFormat("[GRID HANDLER]: no XMIN in request to get region range");
|
||||
if (request.ContainsKey("XMAX"))
|
||||
Int32.TryParse(request["XMAX"], out xmax);
|
||||
else
|
||||
m_log.WarnFormat("[GRID HANDLER]: no XMAX in request to get region range");
|
||||
if (request.ContainsKey("YMIN"))
|
||||
Int32.TryParse(request["YMIN"], out ymin);
|
||||
else
|
||||
m_log.WarnFormat("[GRID HANDLER]: no YMIN in request to get region range");
|
||||
if (request.ContainsKey("YMAX"))
|
||||
Int32.TryParse(request["YMAX"], out ymax);
|
||||
else
|
||||
m_log.WarnFormat("[GRID HANDLER]: no YMAX in request to get region range");
|
||||
|
||||
|
||||
List<GridRegion> rinfos = m_GridService.GetRegionRange(scopeID, xmin, xmax, ymin, ymax);
|
||||
|
||||
Dictionary<string, object> result = new Dictionary<string, object>();
|
||||
if ((rinfos == null) || ((rinfos != null) && (rinfos.Count == 0)))
|
||||
result["result"] = "null";
|
||||
else
|
||||
{
|
||||
int i = 0;
|
||||
foreach (GridRegion rinfo in rinfos)
|
||||
{
|
||||
Dictionary<string, object> rinfoDict = rinfo.ToKeyValuePairs();
|
||||
result["region" + i] = rinfoDict;
|
||||
i++;
|
||||
}
|
||||
}
|
||||
string xmlString = ServerUtils.BuildXmlResponse(result);
|
||||
//m_log.DebugFormat("[GRID HANDLER]: resp string: {0}", xmlString);
|
||||
UTF8Encoding encoding = new UTF8Encoding();
|
||||
return encoding.GetBytes(xmlString);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Misc
|
||||
|
||||
private byte[] SuccessResult()
|
||||
{
|
||||
XmlDocument doc = new XmlDocument();
|
||||
|
||||
XmlNode xmlnode = doc.CreateNode(XmlNodeType.XmlDeclaration,
|
||||
"", "");
|
||||
|
||||
doc.AppendChild(xmlnode);
|
||||
|
||||
XmlElement rootElement = doc.CreateElement("", "ServerResponse",
|
||||
"");
|
||||
|
||||
doc.AppendChild(rootElement);
|
||||
|
||||
XmlElement result = doc.CreateElement("", "Result", "");
|
||||
result.AppendChild(doc.CreateTextNode("Success"));
|
||||
|
||||
rootElement.AppendChild(result);
|
||||
|
||||
return DocToBytes(doc);
|
||||
}
|
||||
|
||||
private byte[] FailureResult()
|
||||
{
|
||||
XmlDocument doc = new XmlDocument();
|
||||
|
||||
XmlNode xmlnode = doc.CreateNode(XmlNodeType.XmlDeclaration,
|
||||
"", "");
|
||||
|
||||
doc.AppendChild(xmlnode);
|
||||
|
||||
XmlElement rootElement = doc.CreateElement("", "ServerResponse",
|
||||
"");
|
||||
|
||||
doc.AppendChild(rootElement);
|
||||
|
||||
XmlElement result = doc.CreateElement("", "Result", "");
|
||||
result.AppendChild(doc.CreateTextNode("Failure"));
|
||||
|
||||
rootElement.AppendChild(result);
|
||||
|
||||
return DocToBytes(doc);
|
||||
}
|
||||
|
||||
private byte[] DocToBytes(XmlDocument doc)
|
||||
{
|
||||
MemoryStream ms = new MemoryStream();
|
||||
XmlTextWriter xw = new XmlTextWriter(ms, null);
|
||||
xw.Formatting = Formatting.Indented;
|
||||
doc.WriteTo(xw);
|
||||
xw.Flush();
|
||||
|
||||
return ms.ToArray();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
208
OpenSim/Server/Handlers/Grid/HypergridServerConnector.cs
Normal file
208
OpenSim/Server/Handlers/Grid/HypergridServerConnector.cs
Normal file
@@ -0,0 +1,208 @@
|
||||
/*
|
||||
* Copyright (c) Contributors, http://opensimulator.org/
|
||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of the OpenSimulator Project nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using System.Net;
|
||||
using Nini.Config;
|
||||
using OpenSim.Framework;
|
||||
using OpenSim.Server.Base;
|
||||
using OpenSim.Services.Interfaces;
|
||||
using OpenSim.Framework.Servers.HttpServer;
|
||||
using OpenSim.Server.Handlers.Base;
|
||||
using GridRegion = OpenSim.Services.Interfaces.GridRegion;
|
||||
|
||||
using OpenMetaverse;
|
||||
using log4net;
|
||||
using Nwc.XmlRpc;
|
||||
|
||||
namespace OpenSim.Server.Handlers.Grid
|
||||
{
|
||||
public class HypergridServiceInConnector : ServiceConnector
|
||||
{
|
||||
private static readonly ILog m_log =
|
||||
LogManager.GetLogger(
|
||||
MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
private List<GridRegion> m_RegionsOnSim = new List<GridRegion>();
|
||||
private IHyperlinkService m_HyperlinkService;
|
||||
|
||||
public HypergridServiceInConnector(IConfigSource config, IHttpServer server, IHyperlinkService hyperService) :
|
||||
base(config, server, String.Empty)
|
||||
{
|
||||
m_HyperlinkService = hyperService;
|
||||
server.AddXmlRPCHandler("link_region", LinkRegionRequest, false);
|
||||
server.AddXmlRPCHandler("expect_hg_user", ExpectHGUser, false);
|
||||
}
|
||||
|
||||
public void AddRegion(GridRegion rinfo)
|
||||
{
|
||||
m_RegionsOnSim.Add(rinfo);
|
||||
}
|
||||
|
||||
public void RemoveRegion(GridRegion rinfo)
|
||||
{
|
||||
if (m_RegionsOnSim.Contains(rinfo))
|
||||
m_RegionsOnSim.Remove(rinfo);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Someone wants to link to us
|
||||
/// </summary>
|
||||
/// <param name="request"></param>
|
||||
/// <returns></returns>
|
||||
public XmlRpcResponse LinkRegionRequest(XmlRpcRequest request, IPEndPoint remoteClient)
|
||||
{
|
||||
Hashtable requestData = (Hashtable)request.Params[0];
|
||||
//string host = (string)requestData["host"];
|
||||
//string portstr = (string)requestData["port"];
|
||||
string name = (string)requestData["region_name"];
|
||||
|
||||
m_log.DebugFormat("[HGrid]: Hyperlink request");
|
||||
|
||||
GridRegion regInfo = null;
|
||||
foreach (GridRegion r in m_RegionsOnSim)
|
||||
{
|
||||
if ((r.RegionName != null) && (name != null) && (r.RegionName.ToLower() == name.ToLower()))
|
||||
{
|
||||
regInfo = r;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (regInfo == null)
|
||||
regInfo = m_RegionsOnSim[0]; // Send out the first region
|
||||
|
||||
Hashtable hash = new Hashtable();
|
||||
hash["uuid"] = regInfo.RegionID.ToString();
|
||||
m_log.Debug(">> Here " + regInfo.RegionID);
|
||||
hash["handle"] = regInfo.RegionHandle.ToString();
|
||||
hash["region_image"] = regInfo.TerrainImage.ToString();
|
||||
hash["region_name"] = regInfo.RegionName;
|
||||
hash["internal_port"] = regInfo.InternalEndPoint.Port.ToString();
|
||||
//m_log.Debug(">> Here: " + regInfo.InternalEndPoint.Port);
|
||||
|
||||
|
||||
XmlRpcResponse response = new XmlRpcResponse();
|
||||
response.Value = hash;
|
||||
return response;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Received from other HGrid nodes when a user wants to teleport here. This call allows
|
||||
/// the region to prepare for direct communication from the client. Sends back an empty
|
||||
/// xmlrpc response on completion.
|
||||
/// This is somewhat similar to OGS1's ExpectUser, but with the additional task of
|
||||
/// registering the user in the local user cache.
|
||||
/// </summary>
|
||||
/// <param name="request"></param>
|
||||
/// <returns></returns>
|
||||
public XmlRpcResponse ExpectHGUser(XmlRpcRequest request, IPEndPoint remoteClient)
|
||||
{
|
||||
Hashtable requestData = (Hashtable)request.Params[0];
|
||||
ForeignUserProfileData userData = new ForeignUserProfileData();
|
||||
|
||||
userData.FirstName = (string)requestData["firstname"];
|
||||
userData.SurName = (string)requestData["lastname"];
|
||||
userData.ID = new UUID((string)requestData["agent_id"]);
|
||||
UUID sessionID = new UUID((string)requestData["session_id"]);
|
||||
userData.HomeLocation = new Vector3((float)Convert.ToDecimal((string)requestData["startpos_x"]),
|
||||
(float)Convert.ToDecimal((string)requestData["startpos_y"]),
|
||||
(float)Convert.ToDecimal((string)requestData["startpos_z"]));
|
||||
|
||||
userData.UserServerURI = (string)requestData["userserver_id"];
|
||||
userData.UserAssetURI = (string)requestData["assetserver_id"];
|
||||
userData.UserInventoryURI = (string)requestData["inventoryserver_id"];
|
||||
|
||||
m_log.DebugFormat("[HGrid]: Prepare for connection from {0} {1} (@{2}) UUID={3}",
|
||||
userData.FirstName, userData.SurName, userData.UserServerURI, userData.ID);
|
||||
|
||||
ulong userRegionHandle = 0;
|
||||
int userhomeinternalport = 0;
|
||||
if (requestData.ContainsKey("region_uuid"))
|
||||
{
|
||||
UUID uuid = UUID.Zero;
|
||||
UUID.TryParse((string)requestData["region_uuid"], out uuid);
|
||||
userData.HomeRegionID = uuid;
|
||||
userRegionHandle = Convert.ToUInt64((string)requestData["regionhandle"]);
|
||||
userData.UserHomeAddress = (string)requestData["home_address"];
|
||||
userData.UserHomePort = (string)requestData["home_port"];
|
||||
userhomeinternalport = Convert.ToInt32((string)requestData["internal_port"]);
|
||||
|
||||
m_log.Debug("[HGrid]: home_address: " + userData.UserHomeAddress +
|
||||
"; home_port: " + userData.UserHomePort);
|
||||
}
|
||||
else
|
||||
m_log.WarnFormat("[HGrid]: User has no home region information");
|
||||
|
||||
XmlRpcResponse resp = new XmlRpcResponse();
|
||||
|
||||
// Let's check if someone is trying to get in with a stolen local identity.
|
||||
// The need for this test is a consequence of not having truly global names :-/
|
||||
bool comingHome = false;
|
||||
if (m_HyperlinkService.CheckUserAtEntry(userData.ID, sessionID, out comingHome) == false)
|
||||
{
|
||||
m_log.WarnFormat("[HGrid]: Access denied to foreign user.");
|
||||
Hashtable respdata = new Hashtable();
|
||||
respdata["success"] = "FALSE";
|
||||
respdata["reason"] = "Foreign user has the same ID as a local user, or logins disabled.";
|
||||
resp.Value = respdata;
|
||||
return resp;
|
||||
}
|
||||
|
||||
// Finally, everything looks ok
|
||||
//m_log.Debug("XXX---- EVERYTHING OK ---XXX");
|
||||
|
||||
if (!comingHome)
|
||||
{
|
||||
// We don't do this if the user is coming to the home grid
|
||||
GridRegion home = new GridRegion();
|
||||
home.RegionID = userData.HomeRegionID;
|
||||
home.ExternalHostName = userData.UserHomeAddress;
|
||||
home.HttpPort = Convert.ToUInt32(userData.UserHomePort);
|
||||
uint x = 0, y = 0;
|
||||
Utils.LongToUInts(userRegionHandle, out x, out y);
|
||||
home.RegionLocX = (int)x;
|
||||
home.RegionLocY = (int)y;
|
||||
home.InternalEndPoint = new IPEndPoint(IPAddress.Parse("0.0.0.0"), (int)userhomeinternalport);
|
||||
|
||||
m_HyperlinkService.AcceptUser(userData, home);
|
||||
}
|
||||
// else the user is coming to a non-home region of the home grid
|
||||
// We simply drop this user information altogether
|
||||
|
||||
Hashtable respdata2 = new Hashtable();
|
||||
respdata2["success"] = "TRUE";
|
||||
resp.Value = respdata2;
|
||||
|
||||
return resp;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -54,19 +54,20 @@ namespace OpenSim.Server.Handlers.Inventory
|
||||
//private AuthedSessionCache m_session_cache = new AuthedSessionCache(INVENTORY_DEFAULT_SESSION_TIME);
|
||||
|
||||
private string m_userserver_url;
|
||||
private string m_ConfigName = "InventoryService";
|
||||
|
||||
public InventoryServiceInConnector(IConfigSource config, IHttpServer server) :
|
||||
base(config, server)
|
||||
public InventoryServiceInConnector(IConfigSource config, IHttpServer server, string configName) :
|
||||
base(config, server, configName)
|
||||
{
|
||||
IConfig serverConfig = config.Configs["InventoryService"];
|
||||
IConfig serverConfig = config.Configs[m_ConfigName];
|
||||
if (serverConfig == null)
|
||||
throw new Exception("No section 'InventoryService' in config file");
|
||||
throw new Exception(String.Format("No section '{0}' in config file", m_ConfigName));
|
||||
|
||||
string inventoryService = serverConfig.GetString("LocalServiceModule",
|
||||
String.Empty);
|
||||
|
||||
if (inventoryService == String.Empty)
|
||||
throw new Exception("No InventoryService in config file");
|
||||
throw new Exception("No LocalServiceModule in config file");
|
||||
|
||||
Object[] args = new Object[] { config };
|
||||
m_InventoryService =
|
||||
|
||||
@@ -46,7 +46,7 @@ namespace OpenSim.Server.Handlers.Land
|
||||
// TODO : private IAuthenticationService m_AuthenticationService;
|
||||
|
||||
public LandServiceInConnector(IConfigSource source, IHttpServer server, ILandService service, IScene scene) :
|
||||
base(source, server)
|
||||
base(source, server, String.Empty)
|
||||
{
|
||||
m_LandService = service;
|
||||
if (m_LandService == null)
|
||||
|
||||
@@ -36,6 +36,7 @@ using OpenSim.Server.Handlers.Base;
|
||||
using OpenSim.Services.Interfaces;
|
||||
using OpenSim.Framework;
|
||||
using OpenSim.Framework.Servers.HttpServer;
|
||||
using GridRegion = OpenSim.Services.Interfaces.GridRegion;
|
||||
|
||||
using OpenMetaverse;
|
||||
using OpenMetaverse.StructuredData;
|
||||
@@ -148,11 +149,14 @@ namespace OpenSim.Server.Handlers.Neighbour
|
||||
}
|
||||
|
||||
// Finally!
|
||||
bool success = m_NeighbourService.HelloNeighbour(regionhandle, aRegion);
|
||||
|
||||
GridRegion thisRegion = m_NeighbourService.HelloNeighbour(regionhandle, aRegion);
|
||||
|
||||
OSDMap resp = new OSDMap(1);
|
||||
|
||||
resp["success"] = OSD.FromBoolean(success);
|
||||
if (thisRegion != null)
|
||||
resp["success"] = OSD.FromBoolean(true);
|
||||
else
|
||||
resp["success"] = OSD.FromBoolean(false);
|
||||
|
||||
httpResponse.StatusCode = (int)HttpStatusCode.OK;
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@ namespace OpenSim.Server.Handlers.Neighbour
|
||||
private IAuthenticationService m_AuthenticationService = null;
|
||||
|
||||
public NeighbourServiceInConnector(IConfigSource source, IHttpServer server, INeighbourService nService, IScene scene) :
|
||||
base(source, server)
|
||||
base(source, server, String.Empty)
|
||||
{
|
||||
|
||||
m_NeighbourService = nService;
|
||||
|
||||
@@ -41,7 +41,7 @@ namespace OpenSim.Server.Handlers.Simulation
|
||||
private IAuthenticationService m_AuthenticationService;
|
||||
|
||||
public SimulationServiceInConnector(IConfigSource config, IHttpServer server, IScene scene) :
|
||||
base(config, server)
|
||||
base(config, server, String.Empty)
|
||||
{
|
||||
IConfig serverConfig = config.Configs["SimulationService"];
|
||||
if (serverConfig == null)
|
||||
|
||||
@@ -30,6 +30,7 @@ using log4net;
|
||||
using System.Reflection;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using OpenSim.Framework.Servers.HttpServer;
|
||||
using OpenSim.Server.Base;
|
||||
using OpenSim.Server.Handlers.Base;
|
||||
|
||||
@@ -60,22 +61,59 @@ namespace OpenSim.Server
|
||||
string connList = serverConfig.GetString("ServiceConnectors", String.Empty);
|
||||
string[] conns = connList.Split(new char[] {',', ' '});
|
||||
|
||||
foreach (string conn in conns)
|
||||
int i = 0;
|
||||
foreach (string c in conns)
|
||||
{
|
||||
if (conn == String.Empty)
|
||||
if (c == String.Empty)
|
||||
continue;
|
||||
|
||||
string configName = String.Empty;
|
||||
string conn = c;
|
||||
uint port = 0;
|
||||
|
||||
string[] split1 = conn.Split(new char[] {'/'});
|
||||
if (split1.Length > 1)
|
||||
{
|
||||
conn = split1[1];
|
||||
|
||||
string[] split2 = split1[0].Split(new char[] {'@'});
|
||||
if (split2.Length > 1)
|
||||
{
|
||||
configName = split2[0];
|
||||
port = Convert.ToUInt32(split2[1]);
|
||||
}
|
||||
else
|
||||
{
|
||||
port = Convert.ToUInt32(split1[0]);
|
||||
}
|
||||
}
|
||||
string[] parts = conn.Split(new char[] {':'});
|
||||
string friendlyName = parts[0];
|
||||
if (parts.Length > 1)
|
||||
friendlyName = parts[1];
|
||||
|
||||
m_log.InfoFormat("[SERVER]: Loading {0}", friendlyName);
|
||||
IHttpServer server = m_Server.HttpServer;
|
||||
if (port != 0)
|
||||
server = m_Server.GetHttpServer(port);
|
||||
|
||||
Object[] modargs = new Object[] { m_Server.Config, m_Server.HttpServer };
|
||||
IServiceConnector connector =
|
||||
ServerUtils.LoadPlugin<IServiceConnector>(conn,
|
||||
if (port != m_Server.DefaultPort)
|
||||
m_log.InfoFormat("[SERVER]: Loading {0} on port {1}", friendlyName, port);
|
||||
else
|
||||
m_log.InfoFormat("[SERVER]: Loading {0}", friendlyName);
|
||||
|
||||
IServiceConnector connector = null;
|
||||
|
||||
Object[] modargs = new Object[] { m_Server.Config, server,
|
||||
configName };
|
||||
connector = ServerUtils.LoadPlugin<IServiceConnector>(conn,
|
||||
modargs);
|
||||
if (connector == null)
|
||||
{
|
||||
modargs = new Object[] { m_Server.Config, server };
|
||||
connector =
|
||||
ServerUtils.LoadPlugin<IServiceConnector>(conn,
|
||||
modargs);
|
||||
}
|
||||
|
||||
if (connector != null)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user