fix merge

This commit is contained in:
UbitUmarov
2017-05-03 03:52:55 +01:00
31 changed files with 1083 additions and 245 deletions

View File

@@ -223,20 +223,16 @@ namespace OpenSim.Region.CoreModules.Scripting.HttpRequest
if (parms.Length - i < 2)
break;
//Have we reached the end of the list of headers?
//End is marked by a string with a single digit.
//We already know we have at least one parameter
//so it is safe to do this check at top of loop.
if (Char.IsDigit(parms[i][0]))
break;
if (htc.HttpCustomHeaders == null)
htc.HttpCustomHeaders = new List<string>();
htc.HttpCustomHeaders.Add(parms[i]);
htc.HttpCustomHeaders.Add(parms[i+1]);
int nexti = i + 2;
if (nexti >= parms.Length || Char.IsDigit(parms[nexti][0]))
break;
i += 2;
i = nexti;
}
break;

View File

@@ -26,15 +26,15 @@
*/
using System;
using System.Threading;
using System.Collections.Generic;
using System.Collections;
using System.Reflection;
using System.Net;
using System.Net.Sockets;
using log4net;
using Mono.Addins;
using Nini.Config;
using OpenMetaverse;
using OpenSim.Framework;
using OpenSim.Framework.Servers;
using OpenSim.Framework.Servers.HttpServer;
using OpenSim.Region.Framework.Interfaces;
@@ -89,6 +89,8 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
protected Dictionary<string, UrlData> m_UrlMap =
new Dictionary<string, UrlData>();
protected bool m_enabled = false;
protected string m_ErrorStr;
protected uint m_HttpsPort = 0;
protected IHttpServer m_HttpServer = null;
protected IHttpServer m_HttpsServer = null;
@@ -118,6 +120,7 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
public void Initialise(IConfigSource config)
{
IConfig networkConfig = config.Configs["Network"];
m_enabled = false;
if (networkConfig != null)
{
@@ -128,9 +131,47 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
if (ssl_enabled)
m_HttpsPort = (uint)config.Configs["Network"].GetInt("https_port", (int)m_HttpsPort);
}
else
{
m_ErrorStr = "[Network] configuration missing, HTTP listener for LSL disabled";
m_log.Warn("[URL MODULE]: " + m_ErrorStr);
return;
}
if (ExternalHostNameForLSL == null)
ExternalHostNameForLSL = System.Environment.MachineName;
if (String.IsNullOrWhiteSpace(ExternalHostNameForLSL))
{
m_ErrorStr = "ExternalHostNameForLSL not defined in configuration, HTTP listener for LSL disabled";
m_log.Warn("[URL MODULE]: " + m_ErrorStr);
return;
}
IPAddress ia = null;
try
{
foreach (IPAddress Adr in Dns.GetHostAddresses(ExternalHostNameForLSL))
{
if (Adr.AddressFamily == AddressFamily.InterNetwork ||
Adr.AddressFamily == AddressFamily.InterNetworkV6) // ipv6 will most likely smoke
{
ia = Adr;
break;
}
}
}
catch
{
ia = null;
}
if (ia == null)
{
m_ErrorStr = "Could not resolve ExternalHostNameForLSL, HTTP listener for LSL disabled";
m_log.Warn("[URL MODULE]: " + m_ErrorStr);
return;
}
m_enabled = true;
m_ErrorStr = String.Empty;
IConfig llFunctionsConfig = config.Configs["LL-Functions"];
@@ -146,7 +187,7 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
public void AddRegion(Scene scene)
{
if (m_HttpServer == null)
if (m_enabled && m_HttpServer == null)
{
// There can only be one
//
@@ -197,11 +238,18 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
{
UUID urlcode = UUID.Random();
if(!m_enabled)
{
engine.PostScriptEvent(itemID, "http_request", new Object[] { urlcode.ToString(), "URL_REQUEST_DENIED", m_ErrorStr });
return urlcode;
}
lock (m_UrlMap)
{
if (m_UrlMap.Count >= TotalUrls)
{
engine.PostScriptEvent(itemID, "http_request", new Object[] { urlcode.ToString(), "URL_REQUEST_DENIED", "" });
engine.PostScriptEvent(itemID, "http_request", new Object[] { urlcode.ToString(), "URL_REQUEST_DENIED",
"Too many URLs already open" });
return urlcode;
}
string url = "http://" + ExternalHostNameForLSL + ":" + m_HttpServer.Port.ToString() + "/lslhttp/" + urlcode.ToString() + "/";
@@ -243,6 +291,12 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
{
UUID urlcode = UUID.Random();
if(!m_enabled)
{
engine.PostScriptEvent(itemID, "http_request", new Object[] { urlcode.ToString(), "URL_REQUEST_DENIED", m_ErrorStr });
return urlcode;
}
if (m_HttpsServer == null)
{
engine.PostScriptEvent(itemID, "http_request", new Object[] { urlcode.ToString(), "URL_REQUEST_DENIED", "" });
@@ -253,7 +307,8 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
{
if (m_UrlMap.Count >= TotalUrls)
{
engine.PostScriptEvent(itemID, "http_request", new Object[] { urlcode.ToString(), "URL_REQUEST_DENIED", "" });
engine.PostScriptEvent(itemID, "http_request", new Object[] { urlcode.ToString(), "URL_REQUEST_DENIED",
"Too many URLs already open" });
return urlcode;
}
string url = "https://" + ExternalHostNameForLSL + ":" + m_HttpsServer.Port.ToString() + "/lslhttps/" + urlcode.ToString() + "/";

View File

@@ -113,7 +113,7 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm
// wrap this in a try block so that defaults will work if
// the config file doesn't specify otherwise.
int maxlisteners = 1000;
int maxhandles = 64;
int maxhandles = 65;
try
{
m_whisperdistance = config.Configs["Chat"].GetInt(
@@ -130,8 +130,15 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm
catch (Exception)
{
}
if (maxlisteners < 1) maxlisteners = int.MaxValue;
if (maxhandles < 1) maxhandles = int.MaxValue;
if (maxlisteners < 1)
maxlisteners = int.MaxValue;
if (maxhandles < 1)
maxhandles = int.MaxValue;
if (maxlisteners < maxhandles)
maxlisteners = maxhandles;
m_listenerManager = new ListenerManager(maxlisteners, maxhandles);
m_pendingQ = new Queue();
m_pending = Queue.Synchronized(m_pendingQ);
@@ -605,11 +612,9 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm
li.GetHandle().Equals(handle))
{
lis.Value.Remove(li);
m_curlisteners--;
if (lis.Value.Count == 0)
{
m_listeners.Remove(lis.Key);
m_curlisteners--;
}
m_listeners.Remove(lis.Key); // bailing of loop so this does not smoke
// there should be only one, so we bail out early
return;
}
@@ -718,6 +723,9 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm
}
}
if(handles.Count >= m_maxhandles)
return -1;
// Note: 0 is NOT a valid handle for llListen() to return
for (int i = 1; i <= m_maxhandles; i++)
{