change GodsModule

master
UbitUmarov 2020-04-25 19:44:25 +01:00
parent 0348c01ce7
commit 2d1900165b
1 changed files with 46 additions and 40 deletions

View File

@ -26,22 +26,14 @@
*/ */
using System; using System;
using System.Collections; using System.Net;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.IO;
using System.Reflection; using System.Reflection;
using System.Web;
using System.Xml;
using log4net; using log4net;
using Mono.Addins; using Mono.Addins;
using Nini.Config; using Nini.Config;
using OpenMetaverse; using OpenMetaverse;
using OpenMetaverse.Messages.Linden;
using OpenMetaverse.StructuredData; using OpenMetaverse.StructuredData;
using OpenSim.Framework; using OpenSim.Framework;
using OpenSim.Framework.Capabilities;
using OpenSim.Framework.Servers;
using OpenSim.Framework.Servers.HttpServer; using OpenSim.Framework.Servers.HttpServer;
using OpenSim.Region.Framework.Scenes; using OpenSim.Region.Framework.Scenes;
using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Interfaces;
@ -112,21 +104,23 @@ namespace OpenSim.Region.CoreModules.Avatar.Gods
private void OnRegisterCaps(UUID agentID, Caps caps) private void OnRegisterCaps(UUID agentID, Caps caps)
{ {
string uri = "/CAPS/" + UUID.Random(); caps.RegisterSimpleHandler("UntrustedSimulatorMessage", new SimpleStreamHandler("/C" + UUID.Random(), HandleUntrustedSimulatorMessage));
caps.RegisterHandler(
"UntrustedSimulatorMessage",
new RestStreamHandler("POST", uri, HandleUntrustedSimulatorMessage, "UntrustedSimulatorMessage", null));
} }
private string HandleUntrustedSimulatorMessage(string request, private void HandleUntrustedSimulatorMessage(IOSHttpRequest request, IOSHttpResponse response)
string path, string param, IOSHttpRequest httpRequest,
IOSHttpResponse httpResponse)
{ {
OSDMap osd = (OSDMap)OSDParser.DeserializeLLSDXml(request); if (request.HttpMethod != "POST")
{
response.StatusCode = (int)HttpStatusCode.NotFound;
return;
}
OSDMap osd;
try
{
osd = (OSDMap)OSDParser.DeserializeLLSDXml(request.InputStream);
string message = osd["message"].AsString(); string message = osd["message"].AsString();
if (message == "GodKickUser") if (message == "GodKickUser")
{ {
OSDMap body = (OSDMap)osd["body"]; OSDMap body = (OSDMap)osd["body"];
@ -141,15 +135,27 @@ namespace OpenSim.Region.CoreModules.Avatar.Gods
ScenePresence god = m_scene.GetScenePresence(godID); ScenePresence god = m_scene.GetScenePresence(godID);
if (god == null || god.ControllingClient.SessionId != godSessionID) if (god == null || god.ControllingClient.SessionId != godSessionID)
return String.Empty; {
response.StatusCode = (int)HttpStatusCode.Unauthorized;
return;
}
KickUser(godID, agentID, kickFlags, reason); KickUser(godID, agentID, kickFlags, reason);
} }
else else
{ {
m_log.ErrorFormat("[GOD]: Unhandled UntrustedSimulatorMessage: {0}", message); m_log.ErrorFormat("[GOD]: Unhandled UntrustedSimulatorMessage: {0}", message);
response.StatusCode = (int)HttpStatusCode.BadRequest;
return;
} }
return String.Empty; }
catch
{
response.StatusCode = (int)HttpStatusCode.BadRequest;
return;
}
response.StatusCode = (int)HttpStatusCode.OK;
} }
public void RequestGodlikePowers( public void RequestGodlikePowers(