aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Server/Handlers
diff options
context:
space:
mode:
authorUbitUmarov2018-01-04 20:56:48 +0000
committerUbitUmarov2018-01-04 20:56:48 +0000
commit48dbba34416e31fa9d525007807b070d0eb25cf9 (patch)
tree7bf4c4e9c7804e8b232eaadab0ea66a7658c9c3d /OpenSim/Server/Handlers
parentfix estates URI (diff)
downloadopensim-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')
-rw-r--r--OpenSim/Server/Handlers/GridUser/GridUserServerConnector.cs2
-rw-r--r--OpenSim/Server/Handlers/MuteList/MuteListServerConnector.cs63
-rw-r--r--OpenSim/Server/Handlers/MuteList/MuteListServerPostHandler.cs240
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
28using System;
29using Nini.Config;
30using OpenSim.Server.Base;
31using OpenSim.Services.Interfaces;
32using OpenSim.Framework.ServiceAuth;
33using OpenSim.Framework.Servers.HttpServer;
34using OpenSim.Server.Handlers.Base;
35
36namespace 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
28using Nini.Config;
29using log4net;
30using System;
31using System.Reflection;
32using System.IO;
33using System.Net;
34using System.Text;
35using System.Text.RegularExpressions;
36using System.Xml;
37using System.Xml.Serialization;
38using System.Collections.Generic;
39using OpenSim.Server.Base;
40using OpenSim.Services.Interfaces;
41using OpenSim.Framework;
42using OpenSim.Framework.ServiceAuth;
43using OpenSim.Framework.Servers.HttpServer;
44using OpenMetaverse;
45
46namespace 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}