aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Server
diff options
context:
space:
mode:
authorMelanie2018-09-12 13:22:17 +0100
committerMelanie2018-09-12 13:22:17 +0100
commite874e3a2ad47af6a045dbe3f4dd91364cd92750a (patch)
treea92dc21f85d01e421842cb2fbfa4ecdf3430334a /OpenSim/Server
parentSquelch "connection reset by peer" exceptions (diff)
parentoooops (diff)
downloadopensim-SC-e874e3a2ad47af6a045dbe3f4dd91364cd92750a.zip
opensim-SC-e874e3a2ad47af6a045dbe3f4dd91364cd92750a.tar.gz
opensim-SC-e874e3a2ad47af6a045dbe3f4dd91364cd92750a.tar.bz2
opensim-SC-e874e3a2ad47af6a045dbe3f4dd91364cd92750a.tar.xz
Merge branch 'master' of opensimulator.org:/var/git/opensim
Diffstat (limited to 'OpenSim/Server')
-rw-r--r--OpenSim/Server/Base/ServerUtils.cs145
-rw-r--r--OpenSim/Server/Base/ServicesServerBase.cs11
-rw-r--r--OpenSim/Server/Handlers/Authentication/AuthenticationServerPostHandler.cs8
-rw-r--r--OpenSim/Server/Handlers/Authentication/OpenIdServerHandler.cs5
-rw-r--r--OpenSim/Server/Handlers/Avatar/AvatarServerPostHandler.cs6
-rw-r--r--OpenSim/Server/Handlers/BakedTextures/XBakesPostHandler.cs6
-rw-r--r--OpenSim/Server/Handlers/Estate/EstateDataRobustConnector.cs7
-rw-r--r--OpenSim/Server/Handlers/Friends/FriendsServerPostHandler.cs6
-rw-r--r--OpenSim/Server/Handlers/Grid/GridServerPostHandler.cs6
-rw-r--r--OpenSim/Server/Handlers/GridUser/GridUserServerConnector.cs2
-rw-r--r--OpenSim/Server/Handlers/GridUser/GridUserServerPostHandler.cs6
-rw-r--r--OpenSim/Server/Handlers/Hypergrid/HGFriendsServerPostHandler.cs6
-rw-r--r--OpenSim/Server/Handlers/Inventory/XInventoryInConnector.cs6
-rw-r--r--OpenSim/Server/Handlers/Land/LandHandlers.cs1
-rw-r--r--OpenSim/Server/Handlers/Login/LLLoginHandlers.cs2
-rw-r--r--OpenSim/Server/Handlers/Map/MapAddServerConnector.cs12
-rw-r--r--OpenSim/Server/Handlers/Map/MapRemoveServerConnector.cs27
-rw-r--r--OpenSim/Server/Handlers/MuteList/MuteListServerConnector.cs63
-rw-r--r--OpenSim/Server/Handlers/MuteList/MuteListServerPostHandler.cs240
-rw-r--r--OpenSim/Server/Handlers/Simulation/AgentHandlers.cs40
-rw-r--r--OpenSim/Server/Handlers/UserAccounts/UserAccountServerPostHandler.cs6
-rw-r--r--OpenSim/Server/ServerMain.cs39
22 files changed, 521 insertions, 129 deletions
diff --git a/OpenSim/Server/Base/ServerUtils.cs b/OpenSim/Server/Base/ServerUtils.cs
index b17d7ba..d0043ba 100644
--- a/OpenSim/Server/Base/ServerUtils.cs
+++ b/OpenSim/Server/Base/ServerUtils.cs
@@ -39,7 +39,7 @@ using OpenMetaverse;
39using Mono.Addins; 39using Mono.Addins;
40using OpenSim.Framework.Servers.HttpServer; 40using OpenSim.Framework.Servers.HttpServer;
41using OpenSim.Framework.Servers; 41using OpenSim.Framework.Servers;
42 42using OpenMetaverse.StructuredData; // LitJson is hidden on this
43 43
44[assembly:AddinRoot("Robust", OpenSim.VersionInfo.VersionNumber)] 44[assembly:AddinRoot("Robust", OpenSim.VersionInfo.VersionNumber)]
45namespace OpenSim.Server.Base 45namespace OpenSim.Server.Base
@@ -327,49 +327,62 @@ namespace OpenSim.Server.Base
327 327
328 public static Dictionary<string, object> ParseQueryString(string query) 328 public static Dictionary<string, object> ParseQueryString(string query)
329 { 329 {
330 Dictionary<string, object> result = new Dictionary<string, object>();
331 string[] terms = query.Split(new char[] {'&'}); 330 string[] terms = query.Split(new char[] {'&'});
332 331
333 if (terms.Length == 0) 332 int nterms = terms.Length;
334 return result; 333 if (nterms == 0)
334 return new Dictionary<string, object>();
335
336 Dictionary<string, object> result = new Dictionary<string, object>(nterms);
337 string name;
335 338
336 foreach (string t in terms) 339 for(int i = 0; i < nterms; ++i)
337 { 340 {
338 string[] elems = t.Split(new char[] {'='}); 341 string[] elems = terms[i].Split(new char[] {'='});
342
339 if (elems.Length == 0) 343 if (elems.Length == 0)
340 continue; 344 continue;
341 345
342 string name = System.Web.HttpUtility.UrlDecode(elems[0]); 346 if(String.IsNullOrWhiteSpace(elems[0]))
343 string value = String.Empty; 347 continue;
344 348
345 if (elems.Length > 1) 349 name = System.Web.HttpUtility.UrlDecode(elems[0]);
346 value = System.Web.HttpUtility.UrlDecode(elems[1]);
347 350
348 if (name.EndsWith("[]")) 351 if (name.EndsWith("[]"))
349 { 352 {
350 string cleanName = name.Substring(0, name.Length - 2); 353 name = name.Substring(0, name.Length - 2);
351 if (result.ContainsKey(cleanName)) 354 if(String.IsNullOrWhiteSpace(name))
355 continue;
356 if (result.ContainsKey(name))
352 { 357 {
353 if (!(result[cleanName] is List<string>)) 358 if (!(result[name] is List<string>))
354 continue; 359 continue;
355 360
356 List<string> l = (List<string>)result[cleanName]; 361 List<string> l = (List<string>)result[name];
357 362 if (elems.Length > 1 && !String.IsNullOrWhiteSpace(elems[1]))
358 l.Add(value); 363 l.Add(System.Web.HttpUtility.UrlDecode(elems[1]));
364 else
365 l.Add(String.Empty);
359 } 366 }
360 else 367 else
361 { 368 {
362 List<string> newList = new List<string>(); 369 List<string> newList = new List<string>();
363 370 if (elems.Length > 1 && !String.IsNullOrWhiteSpace(elems[1]))
364 newList.Add(value); 371 newList.Add(System.Web.HttpUtility.UrlDecode(elems[1]));
365 372 else
366 result[cleanName] = newList; 373 newList.Add(String.Empty);
374 result[name] = newList;
367 } 375 }
368 } 376 }
369 else 377 else
370 { 378 {
371 if (!result.ContainsKey(name)) 379 if (!result.ContainsKey(name))
372 result[name] = value; 380 {
381 if (elems.Length > 1 && !String.IsNullOrWhiteSpace(elems[1]))
382 result[name] = System.Web.HttpUtility.UrlDecode(elems[1]);
383 else
384 result[name] = String.Empty;
385 }
373 } 386 }
374 } 387 }
375 388
@@ -378,47 +391,70 @@ namespace OpenSim.Server.Base
378 391
379 public static string BuildQueryString(Dictionary<string, object> data) 392 public static string BuildQueryString(Dictionary<string, object> data)
380 { 393 {
381 string qstring = String.Empty; 394 // this is not conform to html url encoding
395 // can only be used on Body of POST or PUT
396 StringBuilder sb = new StringBuilder(4096);
382 397
383 string part; 398 string pvalue;
384 399
385 foreach (KeyValuePair<string, object> kvp in data) 400 foreach (KeyValuePair<string, object> kvp in data)
386 { 401 {
387 if (kvp.Value is List<string>) 402 if (kvp.Value is List<string>)
388 { 403 {
389 List<string> l = (List<String>)kvp.Value; 404 List<string> l = (List<String>)kvp.Value;
390 405 int llen = l.Count;
391 foreach (string s in l) 406 string nkey = System.Web.HttpUtility.UrlEncode(kvp.Key);
407 for(int i = 0; i < llen; ++i)
392 { 408 {
393 part = System.Web.HttpUtility.UrlEncode(kvp.Key) + 409 if (sb.Length != 0)
394 "[]=" + System.Web.HttpUtility.UrlEncode(s); 410 sb.Append("&");
395 411 sb.Append(nkey);
396 if (qstring != String.Empty) 412 sb.Append("[]=");
397 qstring += "&"; 413 sb.Append(System.Web.HttpUtility.UrlEncode(l[i]));
398
399 qstring += part;
400 } 414 }
401 } 415 }
402 else 416 else if(kvp.Value is Dictionary<string, object>)
403 { 417 {
404 if (kvp.Value.ToString() != String.Empty) 418 // encode complex structures as JSON
419 // needed for estate bans with the encoding used on xml
420 // encode can be here because object does contain the structure information
421 // but decode needs to be on estateSettings (or other user)
422 string js;
423 try
405 { 424 {
406 part = System.Web.HttpUtility.UrlEncode(kvp.Key) + 425 // bypass libovm, we dont need even more useless high level maps
407 "=" + System.Web.HttpUtility.UrlEncode(kvp.Value.ToString()); 426 // this should only be called once.. but no problem, i hope
427 // (other uses may need more..)
428 LitJson.JsonMapper.RegisterExporter<UUID>((uuid, writer) => writer.Write(uuid.ToString()) );
429 js = LitJson.JsonMapper.ToJson(kvp.Value);
408 } 430 }
409 else 431 // catch(Exception e)
432 catch
410 { 433 {
411 part = System.Web.HttpUtility.UrlEncode(kvp.Key); 434 continue;
435 }
436 if (sb.Length != 0)
437 sb.Append("&");
438 sb.Append(System.Web.HttpUtility.UrlEncode(kvp.Key));
439 sb.Append("=");
440 sb.Append(System.Web.HttpUtility.UrlEncode(js));
441 }
442 else
443 {
444 if (sb.Length != 0)
445 sb.Append("&");
446 sb.Append(System.Web.HttpUtility.UrlEncode(kvp.Key));
447
448 pvalue = kvp.Value.ToString();
449 if (!String.IsNullOrEmpty(pvalue))
450 {
451 sb.Append("=");
452 sb.Append(System.Web.HttpUtility.UrlEncode(pvalue));
412 } 453 }
413
414 if (qstring != String.Empty)
415 qstring += "&";
416
417 qstring += part;
418 } 454 }
419 } 455 }
420 456
421 return qstring; 457 return sb.ToString();
422 } 458 }
423 459
424 public static string BuildXmlResponse(Dictionary<string, object> data) 460 public static string BuildXmlResponse(Dictionary<string, object> data)
@@ -478,17 +514,22 @@ namespace OpenSim.Server.Base
478 514
479 XmlDocument doc = new XmlDocument(); 515 XmlDocument doc = new XmlDocument();
480 516
481 doc.LoadXml(data); 517 try
482 518 {
483 XmlNodeList rootL = doc.GetElementsByTagName("ServerResponse"); 519 doc.LoadXml(data);
484 520 XmlNodeList rootL = doc.GetElementsByTagName("ServerResponse");
485 if (rootL.Count != 1)
486 return ret;
487 521
488 XmlNode rootNode = rootL[0]; 522 if (rootL.Count != 1)
523 return ret;
489 524
490 ret = ParseElement(rootNode); 525 XmlNode rootNode = rootL[0];
491 526
527 ret = ParseElement(rootNode);
528 }
529 catch (Exception e)
530 {
531 m_log.DebugFormat("[serverUtils.ParseXmlResponse]: failed error: {0} \n --- string: {1} - ",e.Message, data);
532 }
492 return ret; 533 return ret;
493 } 534 }
494 535
diff --git a/OpenSim/Server/Base/ServicesServerBase.cs b/OpenSim/Server/Base/ServicesServerBase.cs
index d151de6..900327a 100644
--- a/OpenSim/Server/Base/ServicesServerBase.cs
+++ b/OpenSim/Server/Base/ServicesServerBase.cs
@@ -61,8 +61,9 @@ namespace OpenSim.Server.Base
61 // 61 //
62 private bool m_Running = true; 62 private bool m_Running = true;
63 63
64#if (_MONO)
64 private static Mono.Unix.UnixSignal[] signals; 65 private static Mono.Unix.UnixSignal[] signals;
65 66#endif
66 67
67 // Handle all the automagical stuff 68 // Handle all the automagical stuff
68 // 69 //
@@ -186,6 +187,7 @@ namespace OpenSim.Server.Base
186 RegisterCommonCommands(); 187 RegisterCommonCommands();
187 RegisterCommonComponents(Config); 188 RegisterCommonComponents(Config);
188 189
190#if (_MONO)
189 Thread signal_thread = new Thread (delegate () 191 Thread signal_thread = new Thread (delegate ()
190 { 192 {
191 while (true) 193 while (true)
@@ -209,6 +211,7 @@ namespace OpenSim.Server.Base
209 { 211 {
210 new Mono.Unix.UnixSignal(Mono.Unix.Native.Signum.SIGTERM) 212 new Mono.Unix.UnixSignal(Mono.Unix.Native.Signum.SIGTERM)
211 }; 213 };
214 ignal_thread.IsBackground = true;
212 signal_thread.Start(); 215 signal_thread.Start();
213 } 216 }
214 catch (Exception e) 217 catch (Exception e)
@@ -218,6 +221,7 @@ namespace OpenSim.Server.Base
218 m_log.Debug("Exception was: ", e); 221 m_log.Debug("Exception was: ", e);
219 } 222 }
220 } 223 }
224#endif
221 225
222 // Allow derived classes to perform initialization that 226 // Allow derived classes to perform initialization that
223 // needs to be done after the console has opened 227 // needs to be done after the console has opened
@@ -246,6 +250,9 @@ namespace OpenSim.Server.Base
246 } 250 }
247 } 251 }
248 252
253 MemoryWatchdog.Enabled = false;
254 Watchdog.Enabled = false;
255 WorkManager.Stop();
249 RemovePIDFile(); 256 RemovePIDFile();
250 257
251 return 0; 258 return 0;
@@ -253,6 +260,8 @@ namespace OpenSim.Server.Base
253 260
254 protected override void ShutdownSpecific() 261 protected override void ShutdownSpecific()
255 { 262 {
263 if(!m_Running)
264 return;
256 m_Running = false; 265 m_Running = false;
257 m_log.Info("[CONSOLE] Quitting"); 266 m_log.Info("[CONSOLE] Quitting");
258 267
diff --git a/OpenSim/Server/Handlers/Authentication/AuthenticationServerPostHandler.cs b/OpenSim/Server/Handlers/Authentication/AuthenticationServerPostHandler.cs
index d3ea7e2..4f03cf4 100644
--- a/OpenSim/Server/Handlers/Authentication/AuthenticationServerPostHandler.cs
+++ b/OpenSim/Server/Handlers/Authentication/AuthenticationServerPostHandler.cs
@@ -82,11 +82,11 @@ namespace OpenSim.Server.Handlers.Authentication
82 switch (p[0]) 82 switch (p[0])
83 { 83 {
84 case "plain": 84 case "plain":
85 StreamReader sr = new StreamReader(request); 85 string body;
86 string body = sr.ReadToEnd(); 86 using(StreamReader sr = new StreamReader(request))
87 sr.Close(); 87 body = sr.ReadToEnd();
88
89 return DoPlainMethods(body); 88 return DoPlainMethods(body);
89
90 case "crypt": 90 case "crypt":
91 byte[] buffer = new byte[request.Length]; 91 byte[] buffer = new byte[request.Length];
92 long length = request.Length; 92 long length = request.Length;
diff --git a/OpenSim/Server/Handlers/Authentication/OpenIdServerHandler.cs b/OpenSim/Server/Handlers/Authentication/OpenIdServerHandler.cs
index a6605a1..254b82f 100644
--- a/OpenSim/Server/Handlers/Authentication/OpenIdServerHandler.cs
+++ b/OpenSim/Server/Handlers/Authentication/OpenIdServerHandler.cs
@@ -222,7 +222,10 @@ For more information, see <a href='http://openid.net/'>http://openid.net/</a>.
222 222
223 try 223 try
224 { 224 {
225 NameValueCollection postQuery = HttpUtility.ParseQueryString(new StreamReader(httpRequest.InputStream).ReadToEnd()); 225 string forPost;
226 using(StreamReader sr = new StreamReader(httpRequest.InputStream))
227 forPost = sr.ReadToEnd();
228 NameValueCollection postQuery = HttpUtility.ParseQueryString(forPost);
226 NameValueCollection getQuery = HttpUtility.ParseQueryString(httpRequest.Url.Query); 229 NameValueCollection getQuery = HttpUtility.ParseQueryString(httpRequest.Url.Query);
227 NameValueCollection openIdQuery = (postQuery.GetValues("openid.mode") != null ? postQuery : getQuery); 230 NameValueCollection openIdQuery = (postQuery.GetValues("openid.mode") != null ? postQuery : getQuery);
228 231
diff --git a/OpenSim/Server/Handlers/Avatar/AvatarServerPostHandler.cs b/OpenSim/Server/Handlers/Avatar/AvatarServerPostHandler.cs
index 69c1a89..b8fdacf 100644
--- a/OpenSim/Server/Handlers/Avatar/AvatarServerPostHandler.cs
+++ b/OpenSim/Server/Handlers/Avatar/AvatarServerPostHandler.cs
@@ -60,9 +60,9 @@ namespace OpenSim.Server.Handlers.Avatar
60 protected override byte[] ProcessRequest(string path, Stream requestData, 60 protected override byte[] ProcessRequest(string path, Stream requestData,
61 IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) 61 IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
62 { 62 {
63 StreamReader sr = new StreamReader(requestData); 63 string body;
64 string body = sr.ReadToEnd(); 64 using(StreamReader sr = new StreamReader(requestData))
65 sr.Close(); 65 body = sr.ReadToEnd();
66 body = body.Trim(); 66 body = body.Trim();
67 67
68 //m_log.DebugFormat("[XXX]: query String: {0}", body); 68 //m_log.DebugFormat("[XXX]: query String: {0}", body);
diff --git a/OpenSim/Server/Handlers/BakedTextures/XBakesPostHandler.cs b/OpenSim/Server/Handlers/BakedTextures/XBakesPostHandler.cs
index 24f63d9..d16000d 100644
--- a/OpenSim/Server/Handlers/BakedTextures/XBakesPostHandler.cs
+++ b/OpenSim/Server/Handlers/BakedTextures/XBakesPostHandler.cs
@@ -65,10 +65,8 @@ namespace OpenSim.Server.Handlers.BakedTextures
65 return new byte[0]; 65 return new byte[0];
66 } 66 }
67 67
68 StreamReader sr = new StreamReader(request); 68 using(StreamReader sr = new StreamReader(request))
69 69 m_BakesService.Store(p[0],sr.ReadToEnd());
70 m_BakesService.Store(p[0], sr.ReadToEnd());
71 sr.Close();
72 70
73 return new byte[0]; 71 return new byte[0];
74 } 72 }
diff --git a/OpenSim/Server/Handlers/Estate/EstateDataRobustConnector.cs b/OpenSim/Server/Handlers/Estate/EstateDataRobustConnector.cs
index e0c2810..b7558ec 100644
--- a/OpenSim/Server/Handlers/Estate/EstateDataRobustConnector.cs
+++ b/OpenSim/Server/Handlers/Estate/EstateDataRobustConnector.cs
@@ -282,9 +282,10 @@ namespace OpenSim.Server.Handlers
282 // /estates/estate/?eid=int&region=uuid 282 // /estates/estate/?eid=int&region=uuid
283 if ("estate".Equals(resource)) 283 if ("estate".Equals(resource))
284 { 284 {
285 StreamReader sr = new StreamReader(request); 285 string body;
286 string body = sr.ReadToEnd(); 286 using(StreamReader sr = new StreamReader(request))
287 sr.Close(); 287 body = sr.ReadToEnd();
288
288 body = body.Trim(); 289 body = body.Trim();
289 290
290 Dictionary<string, object> requestData = ServerUtils.ParseQueryString(body); 291 Dictionary<string, object> requestData = ServerUtils.ParseQueryString(body);
diff --git a/OpenSim/Server/Handlers/Friends/FriendsServerPostHandler.cs b/OpenSim/Server/Handlers/Friends/FriendsServerPostHandler.cs
index 3aab30b..d6668ab 100644
--- a/OpenSim/Server/Handlers/Friends/FriendsServerPostHandler.cs
+++ b/OpenSim/Server/Handlers/Friends/FriendsServerPostHandler.cs
@@ -61,9 +61,9 @@ namespace OpenSim.Server.Handlers.Friends
61 protected override byte[] ProcessRequest(string path, Stream requestData, 61 protected override byte[] ProcessRequest(string path, Stream requestData,
62 IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) 62 IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
63 { 63 {
64 StreamReader sr = new StreamReader(requestData); 64 string body;
65 string body = sr.ReadToEnd(); 65 using(StreamReader sr = new StreamReader(requestData))
66 sr.Close(); 66 body = sr.ReadToEnd();
67 body = body.Trim(); 67 body = body.Trim();
68 68
69 //m_log.DebugFormat("[XXX]: query String: {0}", body); 69 //m_log.DebugFormat("[XXX]: query String: {0}", body);
diff --git a/OpenSim/Server/Handlers/Grid/GridServerPostHandler.cs b/OpenSim/Server/Handlers/Grid/GridServerPostHandler.cs
index f51c4ee..44d4654 100644
--- a/OpenSim/Server/Handlers/Grid/GridServerPostHandler.cs
+++ b/OpenSim/Server/Handlers/Grid/GridServerPostHandler.cs
@@ -65,9 +65,9 @@ namespace OpenSim.Server.Handlers.Grid
65 protected override byte[] ProcessRequest(string path, Stream requestData, 65 protected override byte[] ProcessRequest(string path, Stream requestData,
66 IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) 66 IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
67 { 67 {
68 StreamReader sr = new StreamReader(requestData); 68 string body;
69 string body = sr.ReadToEnd(); 69 using(StreamReader sr = new StreamReader(requestData))
70 sr.Close(); 70 body = sr.ReadToEnd();
71 body = body.Trim(); 71 body = body.Trim();
72 72
73 //m_log.DebugFormat("[XXX]: query String: {0}", body); 73 //m_log.DebugFormat("[XXX]: query String: {0}", body);
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/GridUser/GridUserServerPostHandler.cs b/OpenSim/Server/Handlers/GridUser/GridUserServerPostHandler.cs
index 8806c2c..1f691d6 100644
--- a/OpenSim/Server/Handlers/GridUser/GridUserServerPostHandler.cs
+++ b/OpenSim/Server/Handlers/GridUser/GridUserServerPostHandler.cs
@@ -60,9 +60,9 @@ namespace OpenSim.Server.Handlers.GridUser
60 protected override byte[] ProcessRequest(string path, Stream requestData, 60 protected override byte[] ProcessRequest(string path, Stream requestData,
61 IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) 61 IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
62 { 62 {
63 StreamReader sr = new StreamReader(requestData); 63 string body;
64 string body = sr.ReadToEnd(); 64 using(StreamReader sr = new StreamReader(requestData))
65 sr.Close(); 65 body = sr.ReadToEnd();
66 body = body.Trim(); 66 body = body.Trim();
67 67
68 //m_log.DebugFormat("[XXX]: query String: {0}", body); 68 //m_log.DebugFormat("[XXX]: query String: {0}", body);
diff --git a/OpenSim/Server/Handlers/Hypergrid/HGFriendsServerPostHandler.cs b/OpenSim/Server/Handlers/Hypergrid/HGFriendsServerPostHandler.cs
index 8116050..fc1a77d 100644
--- a/OpenSim/Server/Handlers/Hypergrid/HGFriendsServerPostHandler.cs
+++ b/OpenSim/Server/Handlers/Hypergrid/HGFriendsServerPostHandler.cs
@@ -71,9 +71,9 @@ namespace OpenSim.Server.Handlers.Hypergrid
71 protected override byte[] ProcessRequest(string path, Stream requestData, 71 protected override byte[] ProcessRequest(string path, Stream requestData,
72 IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) 72 IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
73 { 73 {
74 StreamReader sr = new StreamReader(requestData); 74 string body;
75 string body = sr.ReadToEnd(); 75 using(StreamReader sr = new StreamReader(requestData))
76 sr.Close(); 76 body = sr.ReadToEnd();
77 body = body.Trim(); 77 body = body.Trim();
78 78
79 //m_log.DebugFormat("[XXX]: query String: {0}", body); 79 //m_log.DebugFormat("[XXX]: query String: {0}", body);
diff --git a/OpenSim/Server/Handlers/Inventory/XInventoryInConnector.cs b/OpenSim/Server/Handlers/Inventory/XInventoryInConnector.cs
index 4400395..742d1a0 100644
--- a/OpenSim/Server/Handlers/Inventory/XInventoryInConnector.cs
+++ b/OpenSim/Server/Handlers/Inventory/XInventoryInConnector.cs
@@ -95,9 +95,9 @@ namespace OpenSim.Server.Handlers.Inventory
95 protected override byte[] ProcessRequest(string path, Stream requestData, 95 protected override byte[] ProcessRequest(string path, Stream requestData,
96 IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) 96 IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
97 { 97 {
98 StreamReader sr = new StreamReader(requestData); 98 string body;
99 string body = sr.ReadToEnd(); 99 using(StreamReader sr = new StreamReader(requestData))
100 sr.Close(); 100 body = sr.ReadToEnd();
101 body = body.Trim(); 101 body = body.Trim();
102 102
103 //m_log.DebugFormat("[XXX]: query String: {0}", body); 103 //m_log.DebugFormat("[XXX]: query String: {0}", body);
diff --git a/OpenSim/Server/Handlers/Land/LandHandlers.cs b/OpenSim/Server/Handlers/Land/LandHandlers.cs
index 150eaae..d74077a 100644
--- a/OpenSim/Server/Handlers/Land/LandHandlers.cs
+++ b/OpenSim/Server/Handlers/Land/LandHandlers.cs
@@ -85,6 +85,7 @@ namespace OpenSim.Server.Handlers.Land
85 hash["SnapshotID"] = landData.SnapshotID.ToString(); 85 hash["SnapshotID"] = landData.SnapshotID.ToString();
86 hash["UserLocation"] = landData.UserLocation.ToString(); 86 hash["UserLocation"] = landData.UserLocation.ToString();
87 hash["RegionAccess"] = regionAccess.ToString(); 87 hash["RegionAccess"] = regionAccess.ToString();
88 hash["Dwell"] = landData.Dwell.ToString();
88 } 89 }
89 90
90 XmlRpcResponse response = new XmlRpcResponse(); 91 XmlRpcResponse response = new XmlRpcResponse();
diff --git a/OpenSim/Server/Handlers/Login/LLLoginHandlers.cs b/OpenSim/Server/Handlers/Login/LLLoginHandlers.cs
index 072429a..4e7ab00 100644
--- a/OpenSim/Server/Handlers/Login/LLLoginHandlers.cs
+++ b/OpenSim/Server/Handlers/Login/LLLoginHandlers.cs
@@ -64,7 +64,7 @@ namespace OpenSim.Server.Handlers.Login
64 public XmlRpcResponse HandleXMLRPCLogin(XmlRpcRequest request, IPEndPoint remoteClient) 64 public XmlRpcResponse HandleXMLRPCLogin(XmlRpcRequest request, IPEndPoint remoteClient)
65 { 65 {
66 Hashtable requestData = (Hashtable)request.Params[0]; 66 Hashtable requestData = (Hashtable)request.Params[0];
67 if (m_Proxy && request.Params[3] != null) 67 if (request.Params[3] != null)
68 { 68 {
69 IPEndPoint ep = Util.GetClientIPFromXFF((string)request.Params[3]); 69 IPEndPoint ep = Util.GetClientIPFromXFF((string)request.Params[3]);
70 if (ep != null) 70 if (ep != null)
diff --git a/OpenSim/Server/Handlers/Map/MapAddServerConnector.cs b/OpenSim/Server/Handlers/Map/MapAddServerConnector.cs
index 7611f53..331dabf 100644
--- a/OpenSim/Server/Handlers/Map/MapAddServerConnector.cs
+++ b/OpenSim/Server/Handlers/Map/MapAddServerConnector.cs
@@ -104,9 +104,9 @@ namespace OpenSim.Server.Handlers.MapImage
104 protected override byte[] ProcessRequest(string path, Stream requestData, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) 104 protected override byte[] ProcessRequest(string path, Stream requestData, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
105 { 105 {
106// m_log.DebugFormat("[MAP SERVICE IMAGE HANDLER]: Received {0}", path); 106// m_log.DebugFormat("[MAP SERVICE IMAGE HANDLER]: Received {0}", path);
107 StreamReader sr = new StreamReader(requestData); 107 string body;
108 string body = sr.ReadToEnd(); 108 using(StreamReader sr = new StreamReader(requestData))
109 sr.Close(); 109 body = sr.ReadToEnd();
110 body = body.Trim(); 110 body = body.Trim();
111 111
112 try 112 try
@@ -225,8 +225,8 @@ namespace OpenSim.Server.Handlers.MapImage
225 225
226 private System.Net.IPAddress GetCallerIP(IOSHttpRequest request) 226 private System.Net.IPAddress GetCallerIP(IOSHttpRequest request)
227 { 227 {
228 if (!m_Proxy) 228// if (!m_Proxy)
229 return request.RemoteIPEndPoint.Address; 229// return request.RemoteIPEndPoint.Address;
230 230
231 // We're behind a proxy 231 // We're behind a proxy
232 string xff = "X-Forwarded-For"; 232 string xff = "X-Forwarded-For";
@@ -236,7 +236,7 @@ namespace OpenSim.Server.Handlers.MapImage
236 236
237 if (xffValue == null || (xffValue != null && xffValue == string.Empty)) 237 if (xffValue == null || (xffValue != null && xffValue == string.Empty))
238 { 238 {
239 m_log.WarnFormat("[MAP IMAGE HANDLER]: No XFF header"); 239// m_log.WarnFormat("[MAP IMAGE HANDLER]: No XFF header");
240 return request.RemoteIPEndPoint.Address; 240 return request.RemoteIPEndPoint.Address;
241 } 241 }
242 242
diff --git a/OpenSim/Server/Handlers/Map/MapRemoveServerConnector.cs b/OpenSim/Server/Handlers/Map/MapRemoveServerConnector.cs
index f292b95..9daeb73 100644
--- a/OpenSim/Server/Handlers/Map/MapRemoveServerConnector.cs
+++ b/OpenSim/Server/Handlers/Map/MapRemoveServerConnector.cs
@@ -102,9 +102,9 @@ namespace OpenSim.Server.Handlers.MapImage
102 public override byte[] Handle(string path, Stream requestData, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) 102 public override byte[] Handle(string path, Stream requestData, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
103 { 103 {
104// m_log.DebugFormat("[MAP SERVICE IMAGE HANDLER]: Received {0}", path); 104// m_log.DebugFormat("[MAP SERVICE IMAGE HANDLER]: Received {0}", path);
105 StreamReader sr = new StreamReader(requestData); 105 string body;
106 string body = sr.ReadToEnd(); 106 using(StreamReader sr = new StreamReader(requestData))
107 sr.Close(); 107 body = sr.ReadToEnd();
108 body = body.Trim(); 108 body = body.Trim();
109 109
110 try 110 try
@@ -215,19 +215,22 @@ namespace OpenSim.Server.Handlers.MapImage
215 215
216 private byte[] DocToBytes(XmlDocument doc) 216 private byte[] DocToBytes(XmlDocument doc)
217 { 217 {
218 MemoryStream ms = new MemoryStream(); 218 using(MemoryStream ms = new MemoryStream())
219 XmlTextWriter xw = new XmlTextWriter(ms, null); 219 {
220 xw.Formatting = Formatting.Indented; 220 using(XmlTextWriter xw = new XmlTextWriter(ms,null))
221 doc.WriteTo(xw); 221 {
222 xw.Flush(); 222 xw.Formatting = Formatting.Indented;
223 223 doc.WriteTo(xw);
224 xw.Flush();
225 }
224 return ms.ToArray(); 226 return ms.ToArray();
227 }
225 } 228 }
226 229
227 private System.Net.IPAddress GetCallerIP(IOSHttpRequest request) 230 private System.Net.IPAddress GetCallerIP(IOSHttpRequest request)
228 { 231 {
229 if (!m_Proxy) 232// if (!m_Proxy)
230 return request.RemoteIPEndPoint.Address; 233// return request.RemoteIPEndPoint.Address;
231 234
232 // We're behind a proxy 235 // We're behind a proxy
233 string xff = "X-Forwarded-For"; 236 string xff = "X-Forwarded-For";
@@ -237,7 +240,7 @@ namespace OpenSim.Server.Handlers.MapImage
237 240
238 if (xffValue == null || (xffValue != null && xffValue == string.Empty)) 241 if (xffValue == null || (xffValue != null && xffValue == string.Empty))
239 { 242 {
240 m_log.WarnFormat("[MAP IMAGE HANDLER]: No XFF header"); 243// m_log.WarnFormat("[MAP IMAGE HANDLER]: No XFF header");
241 return request.RemoteIPEndPoint.Address; 244 return request.RemoteIPEndPoint.Address;
242 } 245 }
243 246
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}
diff --git a/OpenSim/Server/Handlers/Simulation/AgentHandlers.cs b/OpenSim/Server/Handlers/Simulation/AgentHandlers.cs
index 4e1f72e..c52a1ab 100644
--- a/OpenSim/Server/Handlers/Simulation/AgentHandlers.cs
+++ b/OpenSim/Server/Handlers/Simulation/AgentHandlers.cs
@@ -517,32 +517,30 @@ namespace OpenSim.Server.Handlers.Simulation
517 517
518 protected string GetCallerIP(Hashtable request) 518 protected string GetCallerIP(Hashtable request)
519 { 519 {
520 if (!m_Proxy) 520 if (request.ContainsKey("headers"))
521 return Util.GetCallerIP(request); 521 {
522 522 Hashtable headers = (Hashtable)request["headers"];
523 // We're behind a proxy
524 Hashtable headers = (Hashtable)request["headers"];
525
526 //// DEBUG
527 //foreach (object o in headers.Keys)
528 // m_log.DebugFormat("XXX {0} = {1}", o.ToString(), (headers[o] == null? "null" : headers[o].ToString()));
529 523
530 string xff = "X-Forwarded-For"; 524 //// DEBUG
531 if (headers.ContainsKey(xff.ToLower())) 525 //foreach (object o in headers.Keys)
532 xff = xff.ToLower(); 526 // m_log.DebugFormat("XXX {0} = {1}", o.ToString(), (headers[o] == null? "null" : headers[o].ToString()));
533 527
534 if (!headers.ContainsKey(xff) || headers[xff] == null) 528 string xff = "X-Forwarded-For";
535 { 529 if (!headers.ContainsKey(xff))
536 m_log.WarnFormat("[AGENT HANDLER]: No XFF header"); 530 xff = xff.ToLower();
537 return Util.GetCallerIP(request);
538 }
539 531
540 m_log.DebugFormat("[AGENT HANDLER]: XFF is {0}", headers[xff]); 532 if (!headers.ContainsKey(xff) || headers[xff] == null)
533 {
534// m_log.WarnFormat("[AGENT HANDLER]: No XFF header");
535 return Util.GetCallerIP(request);
536 }
541 537
542 IPEndPoint ep = Util.GetClientIPFromXFF((string)headers[xff]); 538// m_log.DebugFormat("[AGENT HANDLER]: XFF is {0}", headers[xff]);
543 if (ep != null)
544 return ep.Address.ToString();
545 539
540 IPEndPoint ep = Util.GetClientIPFromXFF((string)headers[xff]);
541 if (ep != null)
542 return ep.Address.ToString();
543 }
546 // Oops 544 // Oops
547 return Util.GetCallerIP(request); 545 return Util.GetCallerIP(request);
548 } 546 }
diff --git a/OpenSim/Server/Handlers/UserAccounts/UserAccountServerPostHandler.cs b/OpenSim/Server/Handlers/UserAccounts/UserAccountServerPostHandler.cs
index a02255f..bc12ef9 100644
--- a/OpenSim/Server/Handlers/UserAccounts/UserAccountServerPostHandler.cs
+++ b/OpenSim/Server/Handlers/UserAccounts/UserAccountServerPostHandler.cs
@@ -72,9 +72,9 @@ namespace OpenSim.Server.Handlers.UserAccounts
72 protected override byte[] ProcessRequest(string path, Stream requestData, 72 protected override byte[] ProcessRequest(string path, Stream requestData,
73 IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) 73 IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
74 { 74 {
75 StreamReader sr = new StreamReader(requestData); 75 string body;
76 string body = sr.ReadToEnd(); 76 using(StreamReader sr = new StreamReader(requestData))
77 sr.Close(); 77 body = sr.ReadToEnd();
78 body = body.Trim(); 78 body = body.Trim();
79 79
80 // We need to check the authorization header 80 // We need to check the authorization header
diff --git a/OpenSim/Server/ServerMain.cs b/OpenSim/Server/ServerMain.cs
index c343044..4b7fd8a 100644
--- a/OpenSim/Server/ServerMain.cs
+++ b/OpenSim/Server/ServerMain.cs
@@ -30,7 +30,10 @@ using log4net;
30using System.Reflection; 30using System.Reflection;
31using System; 31using System;
32using System.Net; 32using System.Net;
33using System.Net.Security;
34using System.Security.Cryptography.X509Certificates;
33using System.Collections.Generic; 35using System.Collections.Generic;
36using OpenSim.Framework;
34using OpenSim.Framework.Servers; 37using OpenSim.Framework.Servers;
35using OpenSim.Framework.Servers.HttpServer; 38using OpenSim.Framework.Servers.HttpServer;
36using OpenSim.Server.Base; 39using OpenSim.Server.Base;
@@ -51,12 +54,35 @@ namespace OpenSim.Server
51 new List<IServiceConnector>(); 54 new List<IServiceConnector>();
52 55
53 protected static PluginLoader loader; 56 protected static PluginLoader loader;
57 private static bool m_NoVerifyCertChain = false;
58 private static bool m_NoVerifyCertHostname = false;
59
60 public static bool ValidateServerCertificate(
61 object sender,
62 X509Certificate certificate,
63 X509Chain chain,
64 SslPolicyErrors sslPolicyErrors)
65 {
66 if (m_NoVerifyCertChain)
67 sslPolicyErrors &= ~SslPolicyErrors.RemoteCertificateChainErrors;
68
69 if (m_NoVerifyCertHostname)
70 sslPolicyErrors &= ~SslPolicyErrors.RemoteCertificateNameMismatch;
71
72 if (sslPolicyErrors == SslPolicyErrors.None)
73 return true;
74
75 return false;
76 }
54 77
55 public static int Main(string[] args) 78 public static int Main(string[] args)
56 { 79 {
57 // Make sure we don't get outbound connections queueing 80 ServicePointManager.DefaultConnectionLimit = 64;
58 ServicePointManager.DefaultConnectionLimit = 50; 81 ServicePointManager.Expect100Continue = false;
59 ServicePointManager.UseNagleAlgorithm = false; 82 ServicePointManager.UseNagleAlgorithm = false;
83 ServicePointManager.ServerCertificateValidationCallback = ValidateServerCertificate;
84
85 try { ServicePointManager.DnsRefreshTimeout = 300000; } catch { }
60 86
61 m_Server = new HttpServerBase("R.O.B.U.S.T.", args); 87 m_Server = new HttpServerBase("R.O.B.U.S.T.", args);
62 88
@@ -69,6 +95,10 @@ namespace OpenSim.Server
69 throw new Exception("Configuration error"); 95 throw new Exception("Configuration error");
70 } 96 }
71 97
98 m_NoVerifyCertChain = serverConfig.GetBoolean("NoVerifyCertChain", m_NoVerifyCertChain);
99 m_NoVerifyCertHostname = serverConfig.GetBoolean("NoVerifyCertHostname", m_NoVerifyCertHostname);
100
101
72 string connList = serverConfig.GetString("ServiceConnectors", String.Empty); 102 string connList = serverConfig.GetString("ServiceConnectors", String.Empty);
73 103
74 registryLocation = serverConfig.GetString("RegistryLocation","."); 104 registryLocation = serverConfig.GetString("RegistryLocation",".");
@@ -158,6 +188,11 @@ namespace OpenSim.Server
158 188
159 int res = m_Server.Run(); 189 int res = m_Server.Run();
160 190
191 if(m_Server != null)
192 m_Server.Shutdown();
193
194 Util.StopThreadPool();
195
161 Environment.Exit(res); 196 Environment.Exit(res);
162 197
163 return 0; 198 return 0;