aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/CoreModules
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/CoreModules')
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Gods/GodsModule.cs150
1 files changed, 150 insertions, 0 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Gods/GodsModule.cs b/OpenSim/Region/CoreModules/Avatar/Gods/GodsModule.cs
new file mode 100644
index 0000000..dfd6c06
--- /dev/null
+++ b/OpenSim/Region/CoreModules/Avatar/Gods/GodsModule.cs
@@ -0,0 +1,150 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSim Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System.Collections.Generic;
29using Nini.Config;
30using OpenMetaverse;
31using OpenSim.Framework;
32using OpenSim.Region.Framework.Scenes;
33using OpenSim.Region.Framework.Interfaces;
34
35namespace OpenSim.Region.CoreModules.Avatar.Gods
36{
37 public class GodsModules : IRegionModule, IGodsModule
38 {
39 protected Scene m_scene;
40 protected IDialogModule m_dialogModule;
41
42 public void Initialise(Scene scene, IConfigSource source)
43 {
44 m_scene = scene;
45 m_dialogModule = m_scene.RequestModuleInterface<IDialogModule>();
46 m_scene.RegisterModuleInterface<IGodsModule>(this);
47 }
48
49 public void PostInitialise() {}
50 public void Close() {}
51 public string Name { get { return "Gods Module"; } }
52 public bool IsSharedModule { get { return false; } }
53
54 public void RequestGodlikePowers(
55 UUID agentID, UUID sessionID, UUID token, bool godLike, IClientAPI controllingClient)
56 {
57 ScenePresence sp = m_scene.GetScenePresence(agentID);
58
59 if (sp != null)
60 {
61 if (godLike == false)
62 {
63 sp.GrantGodlikePowers(agentID, sessionID, token, godLike);
64 return;
65 }
66
67 // First check that this is the sim owner
68 if (m_scene.Permissions.IsGod(agentID))
69 {
70 // Next we check for spoofing.....
71 UUID testSessionID = sp.ControllingClient.SessionId;
72 if (sessionID == testSessionID)
73 {
74 if (sessionID == controllingClient.SessionId)
75 {
76 //m_log.Info("godlike: " + godLike.ToString());
77 sp.GrantGodlikePowers(agentID, testSessionID, token, godLike);
78 }
79 }
80 }
81 else
82 {
83 m_dialogModule.SendAlertToUser(agentID, "Request for god powers denied");
84 }
85 }
86 }
87
88 /// <summary>
89 /// Kicks User specified from the simulator. This logs them off of the grid
90 /// If the client gets the UUID: 44e87126e7944ded05b37c42da3d5cdb it assumes
91 /// that you're kicking it even if the avatar's UUID isn't the UUID that the
92 /// agent is assigned
93 /// </summary>
94 /// <param name="godID">The person doing the kicking</param>
95 /// <param name="sessionID">The session of the person doing the kicking</param>
96 /// <param name="agentID">the person that is being kicked</param>
97 /// <param name="kickflags">This isn't used apparently</param>
98 /// <param name="reason">The message to send to the user after it's been turned into a field</param>
99 public void KickUser(UUID godID, UUID sessionID, UUID agentID, uint kickflags, byte[] reason)
100 {
101 // For some reason the client sends this seemingly hard coded UUID for kicking everyone. Dun-know.
102 UUID kickUserID = new UUID("44e87126e7944ded05b37c42da3d5cdb");
103
104 ScenePresence sp = m_scene.GetScenePresence(agentID);
105
106 if (sp != null || agentID == kickUserID)
107 {
108 if (m_scene.Permissions.IsGod(godID))
109 {
110 if (agentID == kickUserID)
111 {
112 m_scene.ClientManager.ForEachClient(
113 delegate(IClientAPI controller)
114 {
115 if (controller.AgentId != godID)
116 controller.Kick(Utils.BytesToString(reason));
117 }
118 );
119
120 // This is a bit crude. It seems the client will be null before it actually stops the thread
121 // The thread will kill itself eventually :/
122 // Is there another way to make sure *all* clients get this 'inter region' message?
123 m_scene.ForEachScenePresence(
124 delegate(ScenePresence p)
125 {
126 if (p.UUID != godID && !p.IsChildAgent)
127 {
128 // Possibly this should really be p.Close() though that method doesn't send a close
129 // to the client
130 p.ControllingClient.Close(true);
131 }
132 }
133 );
134 }
135 else
136 {
137 m_scene.SceneGraph.removeUserCount(!sp.IsChildAgent);
138
139 sp.ControllingClient.Kick(Utils.BytesToString(reason));
140 sp.ControllingClient.Close(true);
141 }
142 }
143 else
144 {
145 m_dialogModule.SendAlertToUser(godID, "Kick request denied");
146 }
147 }
148 }
149 }
150} \ No newline at end of file