diff options
author | Melanie | 2019-08-07 17:58:55 +0100 |
---|---|---|
committer | Melanie | 2019-08-07 17:58:55 +0100 |
commit | ba680ceecba3dd07fc794a7a2c2a77b2dc9471df (patch) | |
tree | 0a64eefac9de3746e78c1116b2858d577133773f /OpenSim/Region/ClientStack | |
parent | Fix scope support to get friends list names across co-hosted grids (diff) | |
parent | cap EstateAccess: don't meed with keepAlive unless needed (diff) | |
download | opensim-SC-ba680ceecba3dd07fc794a7a2c2a77b2dc9471df.zip opensim-SC-ba680ceecba3dd07fc794a7a2c2a77b2dc9471df.tar.gz opensim-SC-ba680ceecba3dd07fc794a7a2c2a77b2dc9471df.tar.bz2 opensim-SC-ba680ceecba3dd07fc794a7a2c2a77b2dc9471df.tar.xz |
Merge branch 'master' of brain.opensimulator.org:/var/git/opensim
Diffstat (limited to 'OpenSim/Region/ClientStack')
-rw-r--r-- | OpenSim/Region/ClientStack/Linden/Caps/EstateAccess.cs | 224 |
1 files changed, 224 insertions, 0 deletions
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/EstateAccess.cs b/OpenSim/Region/ClientStack/Linden/Caps/EstateAccess.cs new file mode 100644 index 0000000..cd6cdef --- /dev/null +++ b/OpenSim/Region/ClientStack/Linden/Caps/EstateAccess.cs | |||
@@ -0,0 +1,224 @@ | |||
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 OpenSimulator 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 | |||
28 | using System; | ||
29 | using System.Collections; | ||
30 | using System.Collections.Generic; | ||
31 | using System.Text; | ||
32 | |||
33 | using log4net; | ||
34 | using Nini.Config; | ||
35 | using OpenMetaverse; | ||
36 | using Mono.Addins; | ||
37 | using OpenSim.Framework; | ||
38 | using OpenSim.Framework.Servers.HttpServer; | ||
39 | using OpenSim.Region.Framework.Interfaces; | ||
40 | using OpenSim.Region.Framework.Scenes; | ||
41 | using Caps=OpenSim.Framework.Capabilities.Caps; | ||
42 | |||
43 | namespace OpenSim.Region.ClientStack.Linden | ||
44 | { | ||
45 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "EstateAcessCapModule")] | ||
46 | public class EstateAccessCapModule : INonSharedRegionModule | ||
47 | { | ||
48 | // private static readonly ILog m_log = | ||
49 | // LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
50 | |||
51 | private Scene m_scene; | ||
52 | private bool m_Enabled = false; | ||
53 | private string m_capUrl; | ||
54 | //IEstateModule m_EstateModule; | ||
55 | |||
56 | #region INonSharedRegionModule Members | ||
57 | |||
58 | public void Initialise(IConfigSource pSource) | ||
59 | { | ||
60 | IConfig config = pSource.Configs["ClientStack.LindenCaps"]; | ||
61 | if (config == null) | ||
62 | return; | ||
63 | |||
64 | m_capUrl = config.GetString("Cap_EstateAccess", string.Empty); | ||
65 | if (!String.IsNullOrEmpty(m_capUrl) && m_capUrl.Equals("localhost")) | ||
66 | m_Enabled = true; | ||
67 | } | ||
68 | |||
69 | public void AddRegion(Scene scene) | ||
70 | { | ||
71 | if (!m_Enabled) | ||
72 | return; | ||
73 | |||
74 | m_scene = scene; | ||
75 | } | ||
76 | |||
77 | public void RemoveRegion(Scene scene) | ||
78 | { | ||
79 | if (!m_Enabled) | ||
80 | return; | ||
81 | |||
82 | if (m_scene == scene) | ||
83 | { | ||
84 | m_scene.EventManager.OnRegisterCaps -= RegisterCaps; | ||
85 | m_scene = null; | ||
86 | } | ||
87 | } | ||
88 | |||
89 | public void RegionLoaded(Scene scene) | ||
90 | { | ||
91 | if (!m_Enabled) | ||
92 | return; | ||
93 | |||
94 | if (scene.RegionInfo == null || scene.RegionInfo.EstateSettings == null) | ||
95 | { | ||
96 | m_Enabled = false; | ||
97 | return; | ||
98 | } | ||
99 | |||
100 | IEstateModule m_EstateModule = scene.RequestModuleInterface<IEstateModule>(); | ||
101 | if(m_EstateModule == null) | ||
102 | { | ||
103 | m_Enabled = false; | ||
104 | return; | ||
105 | } | ||
106 | |||
107 | scene.EventManager.OnRegisterCaps += RegisterCaps; | ||
108 | } | ||
109 | |||
110 | public void Close() | ||
111 | { | ||
112 | } | ||
113 | |||
114 | public string Name | ||
115 | { | ||
116 | get { return "EstateAccessCapModule"; } | ||
117 | } | ||
118 | |||
119 | public Type ReplaceableInterface | ||
120 | { | ||
121 | get { return null; } | ||
122 | } | ||
123 | |||
124 | #endregion | ||
125 | |||
126 | public void RegisterCaps(UUID agentID, Caps caps) | ||
127 | { | ||
128 | string capUrl = "/CAPS/" + UUID.Random() + "/"; | ||
129 | |||
130 | caps.RegisterHandler( | ||
131 | "EstateAccess", | ||
132 | new RestHTTPHandler( | ||
133 | "GET", | ||
134 | capUrl, | ||
135 | httpMethod => ProcessRequest(httpMethod, agentID, caps), | ||
136 | "EstateAccess", | ||
137 | agentID.ToString())); ; | ||
138 | } | ||
139 | |||
140 | public Hashtable ProcessRequest(Hashtable request, UUID AgentId, Caps cap) | ||
141 | { | ||
142 | Hashtable responsedata = new Hashtable(); | ||
143 | responsedata["int_response_code"] = 200; //501; //410; //404; | ||
144 | responsedata["content_type"] = "text/plain"; | ||
145 | |||
146 | ScenePresence avatar; | ||
147 | if (!m_scene.TryGetScenePresence(AgentId, out avatar)) | ||
148 | { | ||
149 | responsedata["str_response_string"] = "<llsd><array /></llsd>"; ; | ||
150 | responsedata["keepalive"] = false; | ||
151 | return responsedata; | ||
152 | } | ||
153 | |||
154 | if (m_scene.RegionInfo == null | ||
155 | || m_scene.RegionInfo.EstateSettings == null | ||
156 | ||!m_scene.Permissions.CanIssueEstateCommand(AgentId, false)) | ||
157 | { | ||
158 | responsedata["str_response_string"] = "<llsd><array /></llsd>"; ; | ||
159 | return responsedata; | ||
160 | } | ||
161 | |||
162 | EstateSettings regionSettings = m_scene.RegionInfo.EstateSettings; | ||
163 | UUID[] managers = regionSettings.EstateManagers; | ||
164 | UUID[] allowed = regionSettings.EstateAccess; | ||
165 | UUID[] groups = regionSettings.EstateGroups; | ||
166 | EstateBan[] EstateBans = regionSettings.EstateBans; | ||
167 | |||
168 | StringBuilder sb = LLSDxmlEncode.Start(); | ||
169 | LLSDxmlEncode.AddArray(sb); | ||
170 | |||
171 | if (allowed != null && allowed.Length > 0) | ||
172 | { | ||
173 | LLSDxmlEncode.AddMap("AllowedAgents", sb); | ||
174 | for (int i = 0; i < allowed.Length; ++i) | ||
175 | { | ||
176 | UUID id = allowed[i]; | ||
177 | if (id == UUID.Zero) | ||
178 | continue; | ||
179 | LLSDxmlEncode.AddElem("id", id, sb); | ||
180 | } | ||
181 | LLSDxmlEncode.AddEndMap(sb); | ||
182 | } | ||
183 | |||
184 | if (groups != null && groups.Length > 0) | ||
185 | { | ||
186 | LLSDxmlEncode.AddMap("AllowedGroups", sb); | ||
187 | for (int i = 0; i < groups.Length; ++i) | ||
188 | { | ||
189 | UUID id = groups[i]; | ||
190 | if (id == UUID.Zero) | ||
191 | continue; | ||
192 | LLSDxmlEncode.AddElem("id", id, sb); | ||
193 | } | ||
194 | LLSDxmlEncode.AddEndMap(sb); | ||
195 | } | ||
196 | |||
197 | if (EstateBans != null && EstateBans.Length > 0) | ||
198 | { | ||
199 | LLSDxmlEncode.AddMap("BannedAgents", sb); | ||
200 | for (int i = 0; i < EstateBans.Length; ++i) | ||
201 | { | ||
202 | UUID id = EstateBans[i].BannedUserID; | ||
203 | if (id == UUID.Zero) | ||
204 | continue; | ||
205 | LLSDxmlEncode.AddElem("id", id, sb); | ||
206 | } | ||
207 | LLSDxmlEncode.AddEndMap(sb); | ||
208 | } | ||
209 | |||
210 | if (managers != null && managers.Length > 0) | ||
211 | { | ||
212 | LLSDxmlEncode.AddMap("Managers", sb); | ||
213 | for (int i = 0; i < managers.Length; ++i) | ||
214 | LLSDxmlEncode.AddElem("id", managers[i], sb); | ||
215 | LLSDxmlEncode.AddEndMap(sb); | ||
216 | } | ||
217 | |||
218 | LLSDxmlEncode.AddEndArray(sb); | ||
219 | responsedata["str_response_string"] = LLSDxmlEncode.End(sb); | ||
220 | |||
221 | return responsedata; | ||
222 | } | ||
223 | } | ||
224 | } | ||