29 using System.Collections;
30 using System.Collections.Generic;
31 using System.Collections.Specialized;
33 using System.Reflection;
40 using OpenMetaverse.Messages.Linden;
41 using OpenMetaverse.StructuredData;
42 using OpenSim.Framework;
43 using OpenSim.Framework.Capabilities;
44 using OpenSim.Framework.Servers;
45 using OpenSim.Framework.Servers.HttpServer;
46 using OpenSim.Region.Framework.Scenes;
47 using OpenSim.Region.Framework.Interfaces;
54 [Extension(Path =
"/OpenSim/RegionModules", NodeName =
"RegionModule", Id =
"GodsModule")]
57 private static readonly ILog m_log =
58 LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
61 private static readonly
UUID ALL_AGENTS =
new UUID(
"44e87126-e794-4ded-05b3-7c42da3d5cdb");
70 if (m_dialogModule == null)
71 m_dialogModule = m_scene.RequestModuleInterface<
IDialogModule>();
73 return m_dialogModule;
85 m_scene.EventManager.OnNewClient += SubscribeToClientEvents;
86 m_scene.EventManager.OnRegisterCaps += OnRegisterCaps;
87 scene.EventManager.OnIncomingInstantMessage +=
88 OnIncomingInstantMessage;
93 m_scene.UnregisterModuleInterface<
IGodsModule>(
this);
94 m_scene.EventManager.OnNewClient -= SubscribeToClientEvents;
103 public string Name {
get {
return "Gods Module"; } }
105 public Type ReplaceableInterface
112 client.OnGodKickUser += KickUser;
118 client.OnGodKickUser -= KickUser;
122 private void OnRegisterCaps(UUID agentID,
Caps caps)
124 string uri =
"/CAPS/" + UUID.Random();
126 caps.RegisterHandler(
127 "UntrustedSimulatorMessage",
128 new RestStreamHandler(
"POST", uri, HandleUntrustedSimulatorMessage,
"UntrustedSimulatorMessage", null));
131 private string HandleUntrustedSimulatorMessage(
string request,
135 OSDMap osd = (
OSDMap)OSDParser.DeserializeLLSDXml(request);
137 string message = osd[
"message"].AsString();
139 if (message ==
"GodKickUser")
145 UUID agentID = userData[
"AgentID"].AsUUID();
146 UUID godID = userData[
"GodID"].AsUUID();
147 UUID godSessionID = userData[
"GodSessionID"].AsUUID();
148 uint kickFlags = userData[
"KickFlags"].AsUInteger();
149 string reason = userData[
"Reason"].AsString();
152 if (god == null || god.ControllingClient.SessionId != godSessionID)
155 KickUser(godID, godSessionID, agentID, kickFlags, Util.StringToBytes1024(reason));
159 m_log.ErrorFormat(
"[GOD]: Unhandled UntrustedSimulatorMessage: {0}", message);
165 UUID agentID, UUID sessionID, UUID token,
bool godLike,
IClientAPI controllingClient)
171 if (godLike ==
false)
173 sp.GrantGodlikePowers(agentID, sessionID, token, godLike);
178 if (m_scene.Permissions.IsGod(agentID))
181 UUID testSessionID = sp.ControllingClient.SessionId;
182 if (sessionID == testSessionID)
184 if (sessionID == controllingClient.
SessionId)
187 sp.GrantGodlikePowers(agentID, testSessionID, token, godLike);
193 if (DialogModule != null)
194 DialogModule.SendAlertToUser(agentID,
"Request for god powers denied");
210 public void KickUser(UUID godID, UUID sessionID, UUID agentID, uint kickflags, byte[] reason)
212 if (!m_scene.Permissions.IsGod(godID))
217 if (sp == null && agentID != ALL_AGENTS)
221 if (transferModule != null)
223 m_log.DebugFormat(
"[GODS]: Sending nonlocal kill for agent {0}", agentID);
225 m_scene, godID,
"God", agentID, (byte)250,
false,
226 Utils.BytesToString(reason), UUID.Zero,
true,
227 new Vector3(),
new byte[] {(byte)kickflags},
true),
228 delegate(
bool success) {} );
238 KickPresence(sp,
Utils.BytesToString(reason));
240 else if (agentID == ALL_AGENTS)
242 m_scene.ForEachRootScenePresence(
245 if (p.
UUID != godID && (!m_scene.Permissions.IsGod(p.
UUID)))
246 KickPresence(p,
Utils.BytesToString(reason));
254 sp.AllowMovement =
false;
255 m_dialogModule.SendAlertToUser(agentID, Utils.BytesToString(reason));
256 m_dialogModule.SendAlertToUser(godID,
"User Frozen");
262 sp.AllowMovement =
true;
263 m_dialogModule.SendAlertToUser(agentID, Utils.BytesToString(reason));
264 m_dialogModule.SendAlertToUser(godID,
"User Unfrozen");
276 sp.ControllingClient.Kick(reason);
277 sp.Scene.CloseAgent(sp.UUID,
true);
282 if (msg.
dialog == (uint)250)
285 string reason = msg.message;
289 KickUser(godID,
UUID.Zero, agentID, kickMode, Util.StringToBytes1024(reason));
void UnsubscribeFromClientEvents(IClientAPI client)
void KickUser(UUID godID, UUID sessionID, UUID agentID, uint kickflags, byte[] reason)
Kicks User specified from the simulator. This logs them off of the grid If the client gets the UUID: ...
void Initialise(IConfigSource source)
This is called to initialize the region module. For shared modules, this is called exactly once...
OpenSim.Server.Handlers.Simulation.Utils Utils
void SubscribeToClientEvents(IClientAPI client)
OpenMetaverse.StructuredData.OSDMap OSDMap
delegate void RequestGodlikePowers(UUID AgentID, UUID SessionID, UUID token, bool GodLike, IClientAPI remote_client)
void RequestGodlikePowers(UUID agentID, UUID sessionID, UUID token, bool godLike, IClientAPI controllingClient)
Handle a request for admin rights
void RegionLoaded(Scene scene)
This will be called once for every scene loaded. In a shared module this will be multiple times in on...
void RemoveRegion(Scene scene)
This is called whenever a Scene is removed. For shared modules, this can happen several times...
void Close()
This is the inverse to Initialise. After a Close(), this instance won't be usable anymore...
This interface provides god related methods
IDialogModule m_dialogModule
Interactive OpenSim region server
OpenMetaverse.StructuredData.OSDArray OSDArray
OpenSim.Framework.Capabilities.Caps Caps
void AddRegion(Scene scene)
This is called whenever a Scene is added. For shared modules, this can happen several times...