change NeighbourHandlers whatever they are...
parent
05f098be56
commit
c07f4f3c41
|
@ -26,13 +26,12 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections;
|
using System.IO;
|
||||||
using System.Net;
|
using System.IO.Compression;
|
||||||
|
|
||||||
using OpenSim.Framework;
|
|
||||||
using OpenSim.Framework.Servers.HttpServer;
|
using OpenSim.Framework.Servers.HttpServer;
|
||||||
using OpenSim.Services.Interfaces;
|
|
||||||
using OpenMetaverse;
|
using OpenMetaverse;
|
||||||
|
using OpenMetaverse.StructuredData;
|
||||||
|
|
||||||
namespace OpenSim.Server.Handlers.Base
|
namespace OpenSim.Server.Handlers.Base
|
||||||
{
|
{
|
||||||
|
@ -93,5 +92,28 @@ namespace OpenSim.Server.Handlers.Base
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static OSDMap DeserializeOSMap(IOSHttpRequest httpRequest)
|
||||||
|
{
|
||||||
|
Stream inputStream = httpRequest.InputStream;
|
||||||
|
Stream innerStream = null;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if ((httpRequest.ContentType == "application/x-gzip" || httpRequest.Headers["Content-Encoding"] == "gzip") || (httpRequest.Headers["X-Content-Encoding"] == "gzip"))
|
||||||
|
{
|
||||||
|
innerStream = inputStream;
|
||||||
|
inputStream = new GZipStream(innerStream, CompressionMode.Decompress);
|
||||||
|
}
|
||||||
|
return (OSDMap)OSDParser.DeserializeJson(inputStream);
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
if (innerStream != null)
|
||||||
|
innerStream.Dispose();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,66 +40,74 @@ using GridRegion = OpenSim.Services.Interfaces.GridRegion;
|
||||||
|
|
||||||
using OpenMetaverse;
|
using OpenMetaverse;
|
||||||
using OpenMetaverse.StructuredData;
|
using OpenMetaverse.StructuredData;
|
||||||
using Nini.Config;
|
|
||||||
using log4net;
|
using log4net;
|
||||||
|
|
||||||
|
|
||||||
namespace OpenSim.Server.Handlers.Neighbour
|
namespace OpenSim.Server.Handlers.Neighbour
|
||||||
{
|
{
|
||||||
public class NeighbourGetHandler : BaseStreamHandler
|
public class NeighbourSimpleHandler : SimpleStreamHandler
|
||||||
{
|
|
||||||
// TODO: unused: private ISimulationService m_SimulationService;
|
|
||||||
// TODO: unused: private IAuthenticationService m_AuthenticationService;
|
|
||||||
|
|
||||||
public NeighbourGetHandler(INeighbourService service, IAuthenticationService authentication) :
|
|
||||||
base("GET", "/region")
|
|
||||||
{
|
|
||||||
// TODO: unused: m_SimulationService = service;
|
|
||||||
// TODO: unused: m_AuthenticationService = authentication;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override byte[] ProcessRequest(string path, Stream request,
|
|
||||||
IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
|
|
||||||
{
|
|
||||||
// Not implemented yet
|
|
||||||
Console.WriteLine("--- Get region --- " + path);
|
|
||||||
httpResponse.StatusCode = (int)HttpStatusCode.NotImplemented;
|
|
||||||
return new byte[] { };
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public class NeighbourPostHandler : BaseStreamHandler
|
|
||||||
{
|
{
|
||||||
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||||
private INeighbourService m_NeighbourService;
|
private INeighbourService m_NeighbourService;
|
||||||
private IAuthenticationService m_AuthenticationService;
|
private IAuthenticationService m_AuthenticationService;
|
||||||
// TODO: unused: private bool m_AllowForeignGuests;
|
|
||||||
|
|
||||||
public NeighbourPostHandler(INeighbourService service, IAuthenticationService authentication) :
|
public NeighbourSimpleHandler(INeighbourService service, IAuthenticationService authentication) :
|
||||||
base("POST", "/region")
|
base("/region")
|
||||||
{
|
{
|
||||||
m_NeighbourService = service;
|
m_NeighbourService = service;
|
||||||
m_AuthenticationService = authentication;
|
m_AuthenticationService = authentication;
|
||||||
// TODO: unused: m_AllowForeignGuests = foreignGuests;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override byte[] ProcessRequest(string path, Stream request,
|
protected override void ProcessRequest(IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
|
||||||
IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
|
{
|
||||||
|
httpResponse.KeepAlive = false;
|
||||||
|
|
||||||
|
if (m_NeighbourService == null)
|
||||||
|
{
|
||||||
|
httpResponse.StatusCode = (int)HttpStatusCode.InternalServerError;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (httpRequest.HttpMethod)
|
||||||
|
{
|
||||||
|
case "POST":
|
||||||
|
{
|
||||||
|
OSDMap args = RestHandlerUtils.DeserializeOSMap(httpRequest);
|
||||||
|
if (args == null)
|
||||||
|
{
|
||||||
|
httpResponse.StatusCode = (int)HttpStatusCode.BadRequest;
|
||||||
|
httpResponse.RawBuffer = Util.UTF8.GetBytes("false");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (RestHandlerUtils.GetParams(httpRequest.UriPath, out UUID regionID, out ulong regionHandle, out string action)
|
||||||
|
|| regionID == UUID.Zero)
|
||||||
|
{
|
||||||
|
m_log.InfoFormat("[RegionPostHandler]: Invalid parameters for neighbour message {0}", httpRequest.UriPath);
|
||||||
|
httpResponse.StatusCode = (int)HttpStatusCode.BadRequest;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
ProcessPostRequest(args, httpRequest, httpResponse, regionID);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case "GET":
|
||||||
|
case "PUT":
|
||||||
|
case "DELETE":
|
||||||
|
httpResponse.StatusCode = (int)HttpStatusCode.NotImplemented;
|
||||||
|
return;
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
httpResponse.StatusCode = (int)HttpStatusCode.MethodNotAllowed;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: unused: private bool m_AllowForeignGuests;
|
||||||
|
protected void ProcessPostRequest(OSDMap args, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse, UUID regionID)
|
||||||
{
|
{
|
||||||
byte[] result = new byte[0];
|
byte[] result = new byte[0];
|
||||||
|
|
||||||
UUID regionID;
|
|
||||||
string action;
|
|
||||||
ulong regionHandle;
|
|
||||||
if (RestHandlerUtils.GetParams(path, out regionID, out regionHandle, out action))
|
|
||||||
{
|
|
||||||
m_log.InfoFormat("[RegionPostHandler]: Invalid parameters for neighbour message {0}", path);
|
|
||||||
httpResponse.StatusCode = (int)HttpStatusCode.BadRequest;
|
|
||||||
httpResponse.StatusDescription = "Invalid parameters for neighbour message " + path;
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (m_AuthenticationService != null)
|
if (m_AuthenticationService != null)
|
||||||
{
|
{
|
||||||
// Authentication
|
// Authentication
|
||||||
|
@ -107,9 +115,9 @@ namespace OpenSim.Server.Handlers.Neighbour
|
||||||
string authToken = string.Empty;
|
string authToken = string.Empty;
|
||||||
if (!RestHandlerUtils.GetAuthentication(httpRequest, out authority, out authToken))
|
if (!RestHandlerUtils.GetAuthentication(httpRequest, out authority, out authToken))
|
||||||
{
|
{
|
||||||
m_log.InfoFormat("[RegionPostHandler]: Authentication failed for neighbour message {0}", path);
|
m_log.InfoFormat("[RegionPostHandler]: Authentication failed for neighbour message");
|
||||||
httpResponse.StatusCode = (int)HttpStatusCode.Unauthorized;
|
httpResponse.StatusCode = (int)HttpStatusCode.Unauthorized;
|
||||||
return result;
|
return;
|
||||||
}
|
}
|
||||||
// TODO: Rethink this
|
// TODO: Rethink this
|
||||||
//if (!m_AuthenticationService.VerifyKey(regionID, authToken))
|
//if (!m_AuthenticationService.VerifyKey(regionID, authToken))
|
||||||
|
@ -121,15 +129,6 @@ namespace OpenSim.Server.Handlers.Neighbour
|
||||||
m_log.DebugFormat("[RegionPostHandler]: Authentication succeeded for {0}", regionID);
|
m_log.DebugFormat("[RegionPostHandler]: Authentication succeeded for {0}", regionID);
|
||||||
}
|
}
|
||||||
|
|
||||||
OSDMap args = Util.GetOSDMap(request, (int)httpRequest.ContentLength);
|
|
||||||
if (args == null)
|
|
||||||
{
|
|
||||||
httpResponse.StatusCode = (int)HttpStatusCode.BadRequest;
|
|
||||||
httpResponse.StatusDescription = "Unable to retrieve data";
|
|
||||||
m_log.DebugFormat("[RegionPostHandler]: Unable to retrieve data for post {0}", path);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
// retrieve the regionhandle
|
// retrieve the regionhandle
|
||||||
ulong regionhandle = 0;
|
ulong regionhandle = 0;
|
||||||
if (args["destination_handle"] != null)
|
if (args["destination_handle"] != null)
|
||||||
|
@ -144,8 +143,7 @@ namespace OpenSim.Server.Handlers.Neighbour
|
||||||
{
|
{
|
||||||
m_log.InfoFormat("[RegionPostHandler]: exception on unpacking region info {0}", ex.Message);
|
m_log.InfoFormat("[RegionPostHandler]: exception on unpacking region info {0}", ex.Message);
|
||||||
httpResponse.StatusCode = (int)HttpStatusCode.BadRequest;
|
httpResponse.StatusCode = (int)HttpStatusCode.BadRequest;
|
||||||
httpResponse.StatusDescription = "Problems with data deserialization";
|
return;
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Finally!
|
// Finally!
|
||||||
|
@ -158,51 +156,9 @@ namespace OpenSim.Server.Handlers.Neighbour
|
||||||
else
|
else
|
||||||
resp["success"] = OSD.FromBoolean(false);
|
resp["success"] = OSD.FromBoolean(false);
|
||||||
|
|
||||||
|
httpResponse.RawBuffer = Util.UTF8.GetBytes(OSDParser.SerializeJsonString(resp));
|
||||||
httpResponse.StatusCode = (int)HttpStatusCode.OK;
|
httpResponse.StatusCode = (int)HttpStatusCode.OK;
|
||||||
|
|
||||||
return Util.UTF8.GetBytes(OSDParser.SerializeJsonString(resp));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public class NeighbourPutHandler : BaseStreamHandler
|
|
||||||
{
|
|
||||||
// TODO: unused: private ISimulationService m_SimulationService;
|
|
||||||
// TODO: unused: private IAuthenticationService m_AuthenticationService;
|
|
||||||
|
|
||||||
public NeighbourPutHandler(INeighbourService service, IAuthenticationService authentication) :
|
|
||||||
base("PUT", "/region")
|
|
||||||
{
|
|
||||||
// TODO: unused: m_SimulationService = service;
|
|
||||||
// TODO: unused: m_AuthenticationService = authentication;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override byte[] ProcessRequest(string path, Stream request,
|
|
||||||
IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
|
|
||||||
{
|
|
||||||
// Not implemented yet
|
|
||||||
httpResponse.StatusCode = (int)HttpStatusCode.NotImplemented;
|
|
||||||
return new byte[] { };
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public class NeighbourDeleteHandler : BaseStreamHandler
|
|
||||||
{
|
|
||||||
// TODO: unused: private ISimulationService m_SimulationService;
|
|
||||||
// TODO: unused: private IAuthenticationService m_AuthenticationService;
|
|
||||||
|
|
||||||
public NeighbourDeleteHandler(INeighbourService service, IAuthenticationService authentication) :
|
|
||||||
base("DELETE", "/region")
|
|
||||||
{
|
|
||||||
// TODO: unused: m_SimulationService = service;
|
|
||||||
// TODO: unused: m_AuthenticationService = authentication;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override byte[] ProcessRequest(string path, Stream request,
|
|
||||||
IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
|
|
||||||
{
|
|
||||||
// Not implemented yet
|
|
||||||
httpResponse.StatusCode = (int)HttpStatusCode.NotImplemented;
|
|
||||||
return new byte[] { };
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -60,9 +60,7 @@ namespace OpenSim.Server.Handlers.Neighbour
|
||||||
//if (authentication)
|
//if (authentication)
|
||||||
// m_AuthenticationService = scene.RequestModuleInterface<IAuthenticationService>();
|
// m_AuthenticationService = scene.RequestModuleInterface<IAuthenticationService>();
|
||||||
|
|
||||||
|
server.AddSimpleStreamHandler(new NeighbourSimpleHandler(m_NeighbourService, m_AuthenticationService));
|
||||||
server.AddStreamHandler(new NeighbourPostHandler(m_NeighbourService, m_AuthenticationService));
|
|
||||||
server.AddStreamHandler(new NeighbourGetHandler(m_NeighbourService, m_AuthenticationService));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,15 +26,8 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections;
|
|
||||||
using System.IO;
|
|
||||||
using System.IO.Compression;
|
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using System.Text;
|
|
||||||
|
|
||||||
using OpenSim.Server.Base;
|
|
||||||
using OpenSim.Server.Handlers.Base;
|
|
||||||
using OpenSim.Services.Interfaces;
|
using OpenSim.Services.Interfaces;
|
||||||
using GridRegion = OpenSim.Services.Interfaces.GridRegion;
|
using GridRegion = OpenSim.Services.Interfaces.GridRegion;
|
||||||
using OpenSim.Framework;
|
using OpenSim.Framework;
|
||||||
|
@ -42,7 +35,6 @@ using OpenSim.Framework.Servers.HttpServer;
|
||||||
|
|
||||||
using OpenMetaverse;
|
using OpenMetaverse;
|
||||||
using OpenMetaverse.StructuredData;
|
using OpenMetaverse.StructuredData;
|
||||||
using Nini.Config;
|
|
||||||
using log4net;
|
using log4net;
|
||||||
|
|
||||||
|
|
||||||
|
@ -71,7 +63,7 @@ namespace OpenSim.Server.Handlers.Simulation
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* this things are ignored
|
/*this things are ignored
|
||||||
if (!Utils.GetParams(httpRequest.UriPath, out UUID objectID, out UUID regionID, out string action))
|
if (!Utils.GetParams(httpRequest.UriPath, out UUID objectID, out UUID regionID, out string action))
|
||||||
{
|
{
|
||||||
m_log.InfoFormat("[OBJECT HANDLER]: Invalid parameters for object message {0}", httpRequest.UriPath);
|
m_log.InfoFormat("[OBJECT HANDLER]: Invalid parameters for object message {0}", httpRequest.UriPath);
|
||||||
|
@ -84,7 +76,7 @@ namespace OpenSim.Server.Handlers.Simulation
|
||||||
{
|
{
|
||||||
case "POST":
|
case "POST":
|
||||||
{
|
{
|
||||||
OSDMap args = Deserialize(httpRequest);
|
OSDMap args = Utils.DeserializeOSMap(httpRequest);
|
||||||
if (args == null)
|
if (args == null)
|
||||||
{
|
{
|
||||||
httpResponse.StatusCode = (int)HttpStatusCode.BadRequest;
|
httpResponse.StatusCode = (int)HttpStatusCode.BadRequest;
|
||||||
|
@ -101,32 +93,8 @@ namespace OpenSim.Server.Handlers.Simulation
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private OSDMap Deserialize(IOSHttpRequest httpRequest)
|
|
||||||
{
|
|
||||||
Stream inputStream = httpRequest.InputStream;
|
|
||||||
Stream innerStream = null;
|
|
||||||
try
|
|
||||||
{
|
|
||||||
if ((httpRequest.ContentType == "application/x-gzip" || httpRequest.Headers["Content-Encoding"] == "gzip") || (httpRequest.Headers["X-Content-Encoding"] == "gzip"))
|
|
||||||
{
|
|
||||||
innerStream = inputStream;
|
|
||||||
inputStream = new GZipStream(innerStream, CompressionMode.Decompress);
|
|
||||||
}
|
|
||||||
return (OSDMap)OSDParser.DeserializeJson(inputStream);
|
|
||||||
}
|
|
||||||
catch
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
if (innerStream != null)
|
|
||||||
innerStream.Dispose();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
protected void DoObjectPost(OSDMap args, IOSHttpResponse httpResponse)
|
protected void DoObjectPost(OSDMap args, IOSHttpResponse httpResponse)
|
||||||
{
|
{
|
||||||
// retrieve the input arguments
|
// retrieve the input arguments
|
||||||
|
|
|
@ -26,11 +26,13 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.IO;
|
||||||
|
using System.IO.Compression;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
|
|
||||||
using OpenMetaverse;
|
using OpenMetaverse;
|
||||||
using OpenMetaverse.StructuredData;
|
using OpenMetaverse.StructuredData;
|
||||||
|
using OpenSim.Framework.Servers.HttpServer;
|
||||||
|
|
||||||
using log4net;
|
using log4net;
|
||||||
|
|
||||||
|
@ -99,5 +101,28 @@ namespace OpenSim.Server.Handlers.Simulation
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static OSDMap DeserializeOSMap(IOSHttpRequest httpRequest)
|
||||||
|
{
|
||||||
|
Stream inputStream = httpRequest.InputStream;
|
||||||
|
Stream innerStream = null;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if ((httpRequest.ContentType == "application/x-gzip" || httpRequest.Headers["Content-Encoding"] == "gzip") || (httpRequest.Headers["X-Content-Encoding"] == "gzip"))
|
||||||
|
{
|
||||||
|
innerStream = inputStream;
|
||||||
|
inputStream = new GZipStream(innerStream, CompressionMode.Decompress);
|
||||||
|
}
|
||||||
|
return (OSDMap)OSDParser.DeserializeJson(inputStream);
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
if (innerStream != null)
|
||||||
|
innerStream.Dispose();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue