diff options
author | UbitUmarov | 2018-01-04 20:56:48 +0000 |
---|---|---|
committer | UbitUmarov | 2018-01-04 20:56:48 +0000 |
commit | 48dbba34416e31fa9d525007807b070d0eb25cf9 (patch) | |
tree | 7bf4c4e9c7804e8b232eaadab0ea66a7658c9c3d /OpenSim/Server/Handlers | |
parent | fix estates URI (diff) | |
download | opensim-SC_OLD-48dbba34416e31fa9d525007807b070d0eb25cf9.zip opensim-SC_OLD-48dbba34416e31fa9d525007807b070d0eb25cf9.tar.gz opensim-SC_OLD-48dbba34416e31fa9d525007807b070d0eb25cf9.tar.bz2 opensim-SC_OLD-48dbba34416e31fa9d525007807b070d0eb25cf9.tar.xz |
add more files for robust mutes suport. (module is still named MuteListModuleTst for testing, others in core will be removed later
Diffstat (limited to 'OpenSim/Server/Handlers')
3 files changed, 304 insertions, 1 deletions
diff --git a/OpenSim/Server/Handlers/GridUser/GridUserServerConnector.cs b/OpenSim/Server/Handlers/GridUser/GridUserServerConnector.cs index 1e29378..755272b 100644 --- a/OpenSim/Server/Handlers/GridUser/GridUserServerConnector.cs +++ b/OpenSim/Server/Handlers/GridUser/GridUserServerConnector.cs | |||
@@ -56,7 +56,7 @@ namespace OpenSim.Server.Handlers.GridUser | |||
56 | Object[] args = new Object[] { config }; | 56 | Object[] args = new Object[] { config }; |
57 | m_GridUserService = ServerUtils.LoadPlugin<IGridUserService>(service, args); | 57 | m_GridUserService = ServerUtils.LoadPlugin<IGridUserService>(service, args); |
58 | 58 | ||
59 | IServiceAuth auth = ServiceAuth.Create(config, m_ConfigName); ; | 59 | IServiceAuth auth = ServiceAuth.Create(config, m_ConfigName); |
60 | 60 | ||
61 | server.AddStreamHandler(new GridUserServerPostHandler(m_GridUserService, auth)); | 61 | server.AddStreamHandler(new GridUserServerPostHandler(m_GridUserService, auth)); |
62 | } | 62 | } |
diff --git a/OpenSim/Server/Handlers/MuteList/MuteListServerConnector.cs b/OpenSim/Server/Handlers/MuteList/MuteListServerConnector.cs new file mode 100644 index 0000000..8d27f07 --- /dev/null +++ b/OpenSim/Server/Handlers/MuteList/MuteListServerConnector.cs | |||
@@ -0,0 +1,63 @@ | |||
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 Nini.Config; | ||
30 | using OpenSim.Server.Base; | ||
31 | using OpenSim.Services.Interfaces; | ||
32 | using OpenSim.Framework.ServiceAuth; | ||
33 | using OpenSim.Framework.Servers.HttpServer; | ||
34 | using OpenSim.Server.Handlers.Base; | ||
35 | |||
36 | namespace OpenSim.Server.Handlers.GridUser | ||
37 | { | ||
38 | public class MuteListServiceConnector : ServiceConnector | ||
39 | { | ||
40 | private IMuteListService m_MuteListService; | ||
41 | private string m_ConfigName = "MuteListService"; | ||
42 | |||
43 | public MuteListServiceConnector(IConfigSource config, IHttpServer server, string configName) : | ||
44 | base(config, server, configName) | ||
45 | { | ||
46 | IConfig serverConfig = config.Configs[m_ConfigName]; | ||
47 | if (serverConfig == null) | ||
48 | throw new Exception(String.Format("No section {0} in config file", m_ConfigName)); | ||
49 | |||
50 | string service = serverConfig.GetString("LocalServiceModule", String.Empty); | ||
51 | |||
52 | if (service == String.Empty) | ||
53 | throw new Exception("LocalServiceModule not present in MuteListService config file MuteListService section"); | ||
54 | |||
55 | Object[] args = new Object[] { config }; | ||
56 | m_MuteListService = ServerUtils.LoadPlugin<IMuteListService>(service, args); | ||
57 | |||
58 | IServiceAuth auth = ServiceAuth.Create(config, m_ConfigName); | ||
59 | |||
60 | server.AddStreamHandler(new MuteListServerPostHandler(m_MuteListService, auth)); | ||
61 | } | ||
62 | } | ||
63 | } | ||
diff --git a/OpenSim/Server/Handlers/MuteList/MuteListServerPostHandler.cs b/OpenSim/Server/Handlers/MuteList/MuteListServerPostHandler.cs new file mode 100644 index 0000000..26c4093 --- /dev/null +++ b/OpenSim/Server/Handlers/MuteList/MuteListServerPostHandler.cs | |||
@@ -0,0 +1,240 @@ | |||
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 Nini.Config; | ||
29 | using log4net; | ||
30 | using System; | ||
31 | using System.Reflection; | ||
32 | using System.IO; | ||
33 | using System.Net; | ||
34 | using System.Text; | ||
35 | using System.Text.RegularExpressions; | ||
36 | using System.Xml; | ||
37 | using System.Xml.Serialization; | ||
38 | using System.Collections.Generic; | ||
39 | using OpenSim.Server.Base; | ||
40 | using OpenSim.Services.Interfaces; | ||
41 | using OpenSim.Framework; | ||
42 | using OpenSim.Framework.ServiceAuth; | ||
43 | using OpenSim.Framework.Servers.HttpServer; | ||
44 | using OpenMetaverse; | ||
45 | |||
46 | namespace OpenSim.Server.Handlers.GridUser | ||
47 | { | ||
48 | public class MuteListServerPostHandler : BaseStreamHandler | ||
49 | { | ||
50 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
51 | |||
52 | private IMuteListService m_service; | ||
53 | |||
54 | public MuteListServerPostHandler(IMuteListService service, IServiceAuth auth) : | ||
55 | base("POST", "/mutelist", auth) | ||
56 | { | ||
57 | m_service = service; | ||
58 | } | ||
59 | |||
60 | protected override byte[] ProcessRequest(string path, Stream requestData, | ||
61 | IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) | ||
62 | { | ||
63 | string body; | ||
64 | using(StreamReader sr = new StreamReader(requestData)) | ||
65 | body = sr.ReadToEnd(); | ||
66 | body = body.Trim(); | ||
67 | |||
68 | //m_log.DebugFormat("[XXX]: query String: {0}", body); | ||
69 | string method = string.Empty; | ||
70 | |||
71 | try | ||
72 | { | ||
73 | Dictionary<string, object> request = | ||
74 | ServerUtils.ParseQueryString(body); | ||
75 | |||
76 | if (!request.ContainsKey("METHOD")) | ||
77 | return FailureResult(); | ||
78 | |||
79 | method = request["METHOD"].ToString(); | ||
80 | |||
81 | switch (method) | ||
82 | { | ||
83 | case "get": | ||
84 | return getmutes(request); | ||
85 | case "update": | ||
86 | return updatemute(request); | ||
87 | case "delete": | ||
88 | return deletemute(request); | ||
89 | } | ||
90 | m_log.DebugFormat("[MUTELIST HANDLER]: unknown method request: {0}", method); | ||
91 | } | ||
92 | catch (Exception e) | ||
93 | { | ||
94 | m_log.DebugFormat("[MUTELIST HANDLER]: Exception in method {0}: {1}", method, e); | ||
95 | } | ||
96 | |||
97 | return FailureResult(); | ||
98 | } | ||
99 | |||
100 | byte[] getmutes(Dictionary<string, object> request) | ||
101 | { | ||
102 | if(!request.ContainsKey("agentid") || !request.ContainsKey("mutecrc")) | ||
103 | return FailureResult(); | ||
104 | |||
105 | UUID agentID; | ||
106 | if(!UUID.TryParse(request["agentid"].ToString(), out agentID)) | ||
107 | return FailureResult(); | ||
108 | |||
109 | uint mutecrc; | ||
110 | if(!UInt32.TryParse(request["mutecrc"].ToString(), out mutecrc)) | ||
111 | return FailureResult(); | ||
112 | |||
113 | byte[] data = m_service.MuteListRequest(agentID, mutecrc); | ||
114 | |||
115 | Dictionary<string, object> result = new Dictionary<string, object>(); | ||
116 | result["result"] = Convert.ToBase64String(data); | ||
117 | |||
118 | string xmlString = ServerUtils.BuildXmlResponse(result); | ||
119 | |||
120 | //m_log.DebugFormat("[GRID USER HANDLER]: resp string: {0}", xmlString); | ||
121 | return Util.UTF8NoBomEncoding.GetBytes(xmlString); | ||
122 | } | ||
123 | |||
124 | byte[] updatemute(Dictionary<string, object> request) | ||
125 | { | ||
126 | if(!request.ContainsKey("agentid") || !request.ContainsKey("muteid")) | ||
127 | return FailureResult(); | ||
128 | |||
129 | MuteData mute = new MuteData(); | ||
130 | |||
131 | if( !UUID.TryParse(request["agentid"].ToString(), out mute.AgentID)) | ||
132 | return FailureResult(); | ||
133 | |||
134 | if(!UUID.TryParse(request["muteid"].ToString(), out mute.MuteID)) | ||
135 | return FailureResult(); | ||
136 | |||
137 | if(request.ContainsKey("mutename")) | ||
138 | { | ||
139 | mute.MuteName = request["mutename"].ToString(); | ||
140 | } | ||
141 | else | ||
142 | mute.MuteName = String.Empty; | ||
143 | |||
144 | if(request.ContainsKey("mutetype")) | ||
145 | { | ||
146 | if(!Int32.TryParse(request["mutetype"].ToString(), out mute.MuteType)) | ||
147 | return FailureResult(); | ||
148 | } | ||
149 | else | ||
150 | mute.MuteType = 0; | ||
151 | |||
152 | if(request.ContainsKey("muteflags")) | ||
153 | { | ||
154 | if(!Int32.TryParse(request["muteflags"].ToString(), out mute.MuteFlags)) | ||
155 | return FailureResult(); | ||
156 | } | ||
157 | else | ||
158 | mute.MuteFlags = 0; | ||
159 | |||
160 | if(request.ContainsKey("mutestamp")) | ||
161 | { | ||
162 | if(!Int32.TryParse(request["mutestamp"].ToString(), out mute.Stamp)) | ||
163 | return FailureResult(); | ||
164 | } | ||
165 | else | ||
166 | mute.Stamp = Util.UnixTimeSinceEpoch(); | ||
167 | |||
168 | return m_service.UpdateMute(mute) ? SuccessResult() : FailureResult(); | ||
169 | } | ||
170 | |||
171 | byte[] deletemute(Dictionary<string, object> request) | ||
172 | { | ||
173 | if(!request.ContainsKey("agentid") || !request.ContainsKey("muteid")) | ||
174 | return FailureResult(); | ||
175 | |||
176 | UUID agentID; | ||
177 | if( !UUID.TryParse(request["agentid"].ToString(), out agentID)) | ||
178 | return FailureResult(); | ||
179 | |||
180 | UUID muteID; | ||
181 | if(!UUID.TryParse(request["muteid"].ToString(), out muteID)) | ||
182 | return FailureResult(); | ||
183 | |||
184 | string muteName; | ||
185 | if(request.ContainsKey("mutename")) | ||
186 | { | ||
187 | muteName = request["mutename"].ToString(); | ||
188 | |||
189 | } | ||
190 | else | ||
191 | muteName = String.Empty; | ||
192 | |||
193 | return m_service.RemoveMute(agentID, muteID, muteName) ? SuccessResult() : FailureResult(); | ||
194 | } | ||
195 | |||
196 | private byte[] SuccessResult() | ||
197 | { | ||
198 | XmlDocument doc = new XmlDocument(); | ||
199 | |||
200 | XmlNode xmlnode = doc.CreateNode(XmlNodeType.XmlDeclaration, | ||
201 | "", ""); | ||
202 | |||
203 | doc.AppendChild(xmlnode); | ||
204 | |||
205 | XmlElement rootElement = doc.CreateElement("", "ServerResponse", | ||
206 | ""); | ||
207 | |||
208 | doc.AppendChild(rootElement); | ||
209 | |||
210 | XmlElement result = doc.CreateElement("", "result", ""); | ||
211 | result.AppendChild(doc.CreateTextNode("Success")); | ||
212 | |||
213 | rootElement.AppendChild(result); | ||
214 | |||
215 | return Util.DocToBytes(doc); | ||
216 | } | ||
217 | |||
218 | private byte[] FailureResult() | ||
219 | { | ||
220 | XmlDocument doc = new XmlDocument(); | ||
221 | |||
222 | XmlNode xmlnode = doc.CreateNode(XmlNodeType.XmlDeclaration, | ||
223 | "", ""); | ||
224 | |||
225 | doc.AppendChild(xmlnode); | ||
226 | |||
227 | XmlElement rootElement = doc.CreateElement("", "ServerResponse", | ||
228 | ""); | ||
229 | |||
230 | doc.AppendChild(rootElement); | ||
231 | |||
232 | XmlElement result = doc.CreateElement("", "result", ""); | ||
233 | result.AppendChild(doc.CreateTextNode("Failure")); | ||
234 | |||
235 | rootElement.AppendChild(result); | ||
236 | |||
237 | return Util.DocToBytes(doc); | ||
238 | } | ||
239 | } | ||
240 | } | ||