diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/CoreModules/Avatar/Gods/GodsModule.cs | 213 |
1 files changed, 125 insertions, 88 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Gods/GodsModule.cs b/OpenSim/Region/CoreModules/Avatar/Gods/GodsModule.cs index 3b6d970..6e6974a 100644 --- a/OpenSim/Region/CoreModules/Avatar/Gods/GodsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Gods/GodsModule.cs | |||
@@ -59,19 +59,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Gods | |||
59 | 59 | ||
60 | /// <summary>Special UUID for actions that apply to all agents</summary> | 60 | /// <summary>Special UUID for actions that apply to all agents</summary> |
61 | private static readonly UUID ALL_AGENTS = new UUID("44e87126-e794-4ded-05b3-7c42da3d5cdb"); | 61 | private static readonly UUID ALL_AGENTS = new UUID("44e87126-e794-4ded-05b3-7c42da3d5cdb"); |
62 | private static readonly UUID UUID_GRID_GOD = new UUID("6571e388-6218-4574-87db-f9379718315e"); | ||
62 | 63 | ||
63 | protected Scene m_scene; | 64 | protected Scene m_scene; |
64 | protected IDialogModule m_dialogModule; | 65 | protected IDialogModule m_dialogModule; |
65 | protected IDialogModule DialogModule | ||
66 | { | ||
67 | get | ||
68 | { | ||
69 | if (m_dialogModule == null) | ||
70 | m_dialogModule = m_scene.RequestModuleInterface<IDialogModule>(); | ||
71 | |||
72 | return m_dialogModule; | ||
73 | } | ||
74 | } | ||
75 | 66 | ||
76 | public void Initialise(IConfigSource source) | 67 | public void Initialise(IConfigSource source) |
77 | { | 68 | { |
@@ -96,6 +87,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Gods | |||
96 | 87 | ||
97 | public void RegionLoaded(Scene scene) | 88 | public void RegionLoaded(Scene scene) |
98 | { | 89 | { |
90 | m_dialogModule = m_scene.RequestModuleInterface<IDialogModule>(); | ||
99 | } | 91 | } |
100 | 92 | ||
101 | public void Close() {} | 93 | public void Close() {} |
@@ -111,19 +103,19 @@ namespace OpenSim.Region.CoreModules.Avatar.Gods | |||
111 | client.OnGodKickUser += KickUser; | 103 | client.OnGodKickUser += KickUser; |
112 | client.OnRequestGodlikePowers += RequestGodlikePowers; | 104 | client.OnRequestGodlikePowers += RequestGodlikePowers; |
113 | } | 105 | } |
114 | 106 | ||
115 | public void UnsubscribeFromClientEvents(IClientAPI client) | 107 | public void UnsubscribeFromClientEvents(IClientAPI client) |
116 | { | 108 | { |
117 | client.OnGodKickUser -= KickUser; | 109 | client.OnGodKickUser -= KickUser; |
118 | client.OnRequestGodlikePowers -= RequestGodlikePowers; | 110 | client.OnRequestGodlikePowers -= RequestGodlikePowers; |
119 | } | 111 | } |
120 | 112 | ||
121 | private void OnRegisterCaps(UUID agentID, Caps caps) | 113 | private void OnRegisterCaps(UUID agentID, Caps caps) |
122 | { | 114 | { |
123 | string uri = "/CAPS/" + UUID.Random(); | 115 | string uri = "/CAPS/" + UUID.Random(); |
124 | 116 | ||
125 | caps.RegisterHandler( | 117 | caps.RegisterHandler( |
126 | "UntrustedSimulatorMessage", | 118 | "UntrustedSimulatorMessage", |
127 | new RestStreamHandler("POST", uri, HandleUntrustedSimulatorMessage, "UntrustedSimulatorMessage", null)); | 119 | new RestStreamHandler("POST", uri, HandleUntrustedSimulatorMessage, "UntrustedSimulatorMessage", null)); |
128 | } | 120 | } |
129 | 121 | ||
@@ -146,11 +138,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Gods | |||
146 | UUID godSessionID = userData["GodSessionID"].AsUUID(); | 138 | UUID godSessionID = userData["GodSessionID"].AsUUID(); |
147 | uint kickFlags = userData["KickFlags"].AsUInteger(); | 139 | uint kickFlags = userData["KickFlags"].AsUInteger(); |
148 | string reason = userData["Reason"].AsString(); | 140 | string reason = userData["Reason"].AsString(); |
141 | |||
149 | ScenePresence god = m_scene.GetScenePresence(godID); | 142 | ScenePresence god = m_scene.GetScenePresence(godID); |
150 | if (god == null || god.ControllingClient.SessionId != godSessionID) | 143 | if (god == null || god.ControllingClient.SessionId != godSessionID) |
151 | return String.Empty; | 144 | return String.Empty; |
152 | 145 | ||
153 | KickUser(godID, godSessionID, agentID, kickFlags, Util.StringToBytes1024(reason)); | 146 | KickUser(godID, agentID, kickFlags, reason); |
154 | } | 147 | } |
155 | else | 148 | else |
156 | { | 149 | { |
@@ -160,59 +153,63 @@ namespace OpenSim.Region.CoreModules.Avatar.Gods | |||
160 | } | 153 | } |
161 | 154 | ||
162 | public void RequestGodlikePowers( | 155 | public void RequestGodlikePowers( |
163 | UUID agentID, UUID sessionID, UUID token, bool godLike, IClientAPI controllingClient) | 156 | UUID agentID, UUID sessionID, UUID token, bool godLike) |
164 | { | 157 | { |
165 | ScenePresence sp = m_scene.GetScenePresence(agentID); | 158 | ScenePresence sp = m_scene.GetScenePresence(agentID); |
159 | if(sp == null || sp.IsDeleted || sp.IsNPC) | ||
160 | return; | ||
166 | 161 | ||
167 | if (sp != null) | 162 | if (sessionID != sp.ControllingClient.SessionId) |
168 | { | 163 | return; |
169 | if (godLike == false) | ||
170 | { | ||
171 | sp.GrantGodlikePowers(agentID, sessionID, token, godLike); | ||
172 | return; | ||
173 | } | ||
174 | 164 | ||
175 | // First check that this is the sim owner | 165 | sp.GrantGodlikePowers(token, godLike); |
176 | if (m_scene.Permissions.IsGod(agentID)) | 166 | |
177 | { | 167 | if (godLike && !sp.IsViewerUIGod && m_dialogModule != null) |
178 | // Next we check for spoofing..... | 168 | m_dialogModule.SendAlertToUser(agentID, "Request for god powers denied"); |
179 | UUID testSessionID = sp.ControllingClient.SessionId; | ||
180 | if (sessionID == testSessionID) | ||
181 | { | ||
182 | if (sessionID == controllingClient.SessionId) | ||
183 | { | ||
184 | //m_log.Info("godlike: " + godLike.ToString()); | ||
185 | sp.GrantGodlikePowers(agentID, testSessionID, token, godLike); | ||
186 | } | ||
187 | } | ||
188 | } | ||
189 | else | ||
190 | { | ||
191 | if (DialogModule != null) | ||
192 | DialogModule.SendAlertToUser(agentID, "Request for god powers denied"); | ||
193 | } | ||
194 | } | ||
195 | } | 169 | } |
196 | 170 | ||
171 | public void KickUser(UUID godID, UUID agentID, uint kickflags, byte[] reason) | ||
172 | { | ||
173 | KickUser(godID, agentID, kickflags, Utils.BytesToString(reason)); | ||
174 | } | ||
175 | |||
197 | /// <summary> | 176 | /// <summary> |
198 | /// Kicks User specified from the simulator. This logs them off of the grid | 177 | /// Kicks or freezes User specified from the simulator. This logs them off of the grid |
199 | /// If the client gets the UUID: 44e87126e7944ded05b37c42da3d5cdb it assumes | ||
200 | /// that you're kicking it even if the avatar's UUID isn't the UUID that the | ||
201 | /// agent is assigned | ||
202 | /// </summary> | 178 | /// </summary> |
203 | /// <param name="godID">The person doing the kicking</param> | 179 | /// <param name="godID">The person doing the kicking</param> |
204 | /// <param name="sessionID">The session of the person doing the kicking</param> | ||
205 | /// <param name="agentID">the person that is being kicked</param> | 180 | /// <param name="agentID">the person that is being kicked</param> |
206 | /// <param name="kickflags">Tells what to do to the user</param> | 181 | /// <param name="kickflags">Tells what to do to the user</param> |
207 | /// <param name="reason">The message to send to the user after it's been turned into a field</param> | 182 | /// <param name="reason">The message to send to the user after it's been turned into a field</param> |
208 | public void KickUser(UUID godID, UUID sessionID, UUID agentID, uint kickflags, byte[] reason) | 183 | public void KickUser(UUID godID, UUID agentID, uint kickflags, string reason) |
209 | { | 184 | { |
210 | if (!m_scene.Permissions.IsGod(godID)) | 185 | // assuming automatic god rights on this for fast griefing reaction |
186 | // this is also needed for kick via message | ||
187 | if(!m_scene.Permissions.IsGod(godID)) | ||
211 | return; | 188 | return; |
212 | 189 | ||
213 | ScenePresence sp = m_scene.GetScenePresence(agentID); | 190 | int godlevel = 200; |
191 | // update level so higher gods can kick lower ones | ||
192 | ScenePresence god = m_scene.GetScenePresence(godID); | ||
193 | if(god != null && god.GodController.GodLevel > godlevel) | ||
194 | godlevel = god.GodController.GodLevel; | ||
195 | |||
196 | if(agentID == ALL_AGENTS) | ||
197 | { | ||
198 | m_scene.ForEachRootScenePresence(delegate(ScenePresence p) | ||
199 | { | ||
200 | if (p.UUID != godID) | ||
201 | { | ||
202 | if(godlevel > p.GodController.GodLevel) | ||
203 | doKickmodes(godID, p, kickflags, reason); | ||
204 | else if(m_dialogModule != null) | ||
205 | m_dialogModule.SendAlertToUser(p.UUID, "Kick from " + godID.ToString() + " ignored, kick reason: " + reason); | ||
206 | } | ||
207 | }); | ||
208 | return; | ||
209 | } | ||
214 | 210 | ||
215 | if (sp == null && agentID != ALL_AGENTS) | 211 | ScenePresence sp = m_scene.GetScenePresence(agentID); |
212 | if (sp == null || sp.IsChildAgent) | ||
216 | { | 213 | { |
217 | IMessageTransferModule transferModule = | 214 | IMessageTransferModule transferModule = |
218 | m_scene.RequestModuleInterface<IMessageTransferModule>(); | 215 | m_scene.RequestModuleInterface<IMessageTransferModule>(); |
@@ -221,58 +218,95 @@ namespace OpenSim.Region.CoreModules.Avatar.Gods | |||
221 | m_log.DebugFormat("[GODS]: Sending nonlocal kill for agent {0}", agentID); | 218 | m_log.DebugFormat("[GODS]: Sending nonlocal kill for agent {0}", agentID); |
222 | transferModule.SendInstantMessage(new GridInstantMessage( | 219 | transferModule.SendInstantMessage(new GridInstantMessage( |
223 | m_scene, godID, "God", agentID, (byte)250, false, | 220 | m_scene, godID, "God", agentID, (byte)250, false, |
224 | Utils.BytesToString(reason), UUID.Zero, true, | 221 | reason, UUID.Zero, true, |
225 | new Vector3(), new byte[] {(byte)kickflags}, true), | 222 | new Vector3(), new byte[] {(byte)kickflags}, true), |
226 | delegate(bool success) {} ); | 223 | delegate(bool success) {} ); |
227 | } | 224 | } |
228 | return; | 225 | return; |
229 | } | 226 | } |
230 | 227 | ||
228 | if (godlevel <= sp.GodController.GodLevel) // no god wars | ||
229 | { | ||
230 | if(m_dialogModule != null) | ||
231 | m_dialogModule.SendAlertToUser(sp.UUID, "Kick from " + godID.ToString() + " ignored, kick reason: " + reason); | ||
232 | return; | ||
233 | } | ||
234 | |||
235 | if(sp.UUID == godID) | ||
236 | return; | ||
237 | |||
238 | doKickmodes(godID, sp, kickflags, reason); | ||
239 | } | ||
240 | |||
241 | private void doKickmodes(UUID godID, ScenePresence sp, uint kickflags, string reason) | ||
242 | { | ||
231 | switch (kickflags) | 243 | switch (kickflags) |
232 | { | 244 | { |
233 | case 0: | 245 | case 0: |
234 | if (sp != null) | 246 | KickPresence(sp, reason); |
235 | { | 247 | break; |
236 | KickPresence(sp, Utils.BytesToString(reason)); | 248 | case 1: |
237 | } | ||
238 | else if (agentID == ALL_AGENTS) | ||
239 | { | ||
240 | m_scene.ForEachRootScenePresence( | ||
241 | delegate(ScenePresence p) | ||
242 | { | ||
243 | if (p.UUID != godID && (!m_scene.Permissions.IsGod(p.UUID))) | ||
244 | KickPresence(p, Utils.BytesToString(reason)); | ||
245 | } | ||
246 | ); | ||
247 | } | ||
248 | break; | ||
249 | case 1: | ||
250 | if (sp != null) | ||
251 | { | ||
252 | sp.AllowMovement = false; | 249 | sp.AllowMovement = false; |
253 | m_dialogModule.SendAlertToUser(agentID, Utils.BytesToString(reason)); | 250 | if(m_dialogModule != null) |
254 | m_dialogModule.SendAlertToUser(godID, "User Frozen"); | 251 | { |
255 | } | 252 | m_dialogModule.SendAlertToUser(sp.UUID, reason); |
256 | break; | 253 | m_dialogModule.SendAlertToUser(godID, "User Frozen"); |
257 | case 2: | 254 | } |
258 | if (sp != null) | 255 | break; |
259 | { | 256 | case 2: |
260 | sp.AllowMovement = true; | 257 | sp.AllowMovement = true; |
261 | m_dialogModule.SendAlertToUser(agentID, Utils.BytesToString(reason)); | 258 | if(m_dialogModule != null) |
262 | m_dialogModule.SendAlertToUser(godID, "User Unfrozen"); | 259 | { |
263 | } | 260 | m_dialogModule.SendAlertToUser(sp.UUID, reason); |
264 | break; | 261 | m_dialogModule.SendAlertToUser(godID, "User Unfrozen"); |
265 | default: | 262 | } |
266 | break; | 263 | break; |
264 | default: | ||
265 | break; | ||
267 | } | 266 | } |
268 | } | 267 | } |
269 | 268 | ||
270 | private void KickPresence(ScenePresence sp, string reason) | 269 | private void KickPresence(ScenePresence sp, string reason) |
271 | { | 270 | { |
272 | if (sp.IsChildAgent) | 271 | if(sp.IsDeleted || sp.IsChildAgent) |
272 | return; | ||
273 | sp.ControllingClient.Kick(reason); | ||
274 | sp.Scene.CloseAgent(sp.UUID, true); | ||
275 | } | ||
276 | |||
277 | public void GridKickUser(UUID agentID, string reason) | ||
278 | { | ||
279 | int godlevel = 240; // grid god default | ||
280 | |||
281 | ScenePresence sp = m_scene.GetScenePresence(agentID); | ||
282 | if (sp == null || sp.IsChildAgent) | ||
283 | { | ||
284 | IMessageTransferModule transferModule = | ||
285 | m_scene.RequestModuleInterface<IMessageTransferModule>(); | ||
286 | if (transferModule != null) | ||
287 | { | ||
288 | m_log.DebugFormat("[GODS]: Sending nonlocal kill for agent {0}", agentID); | ||
289 | transferModule.SendInstantMessage(new GridInstantMessage( | ||
290 | m_scene, UUID_GRID_GOD, "GRID", agentID, (byte)250, false, | ||
291 | reason, UUID.Zero, true, | ||
292 | new Vector3(), new byte[] {0}, true), | ||
293 | delegate(bool success) {} ); | ||
294 | } | ||
295 | return; | ||
296 | } | ||
297 | |||
298 | if(sp.IsDeleted) | ||
299 | return; | ||
300 | |||
301 | if (godlevel <= sp.GodController.GodLevel) // no god wars | ||
302 | { | ||
303 | if(m_dialogModule != null) | ||
304 | m_dialogModule.SendAlertToUser(sp.UUID, "GRID kick detected and ignored, kick reason: " + reason); | ||
273 | return; | 305 | return; |
306 | } | ||
307 | |||
274 | sp.ControllingClient.Kick(reason); | 308 | sp.ControllingClient.Kick(reason); |
275 | sp.Scene.CloseAgent(sp.UUID, true); | 309 | sp.Scene.CloseAgent(sp.UUID, true); |
276 | } | 310 | } |
277 | 311 | ||
278 | private void OnIncomingInstantMessage(GridInstantMessage msg) | 312 | private void OnIncomingInstantMessage(GridInstantMessage msg) |
@@ -284,7 +318,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Gods | |||
284 | UUID godID = new UUID(msg.fromAgentID); | 318 | UUID godID = new UUID(msg.fromAgentID); |
285 | uint kickMode = (uint)msg.binaryBucket[0]; | 319 | uint kickMode = (uint)msg.binaryBucket[0]; |
286 | 320 | ||
287 | KickUser(godID, UUID.Zero, agentID, kickMode, Util.StringToBytes1024(reason)); | 321 | if(godID == UUID_GRID_GOD) |
322 | GridKickUser(agentID, reason); | ||
323 | else | ||
324 | KickUser(godID, agentID, kickMode, reason); | ||
288 | } | 325 | } |
289 | } | 326 | } |
290 | } | 327 | } |