diff options
Diffstat (limited to 'OpenSim/Region/CoreModules/Scripting')
3 files changed, 81 insertions, 22 deletions
diff --git a/OpenSim/Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs b/OpenSim/Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs index 09891f7..035097f 100644 --- a/OpenSim/Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs +++ b/OpenSim/Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs | |||
@@ -223,20 +223,16 @@ namespace OpenSim.Region.CoreModules.Scripting.HttpRequest | |||
223 | if (parms.Length - i < 2) | 223 | if (parms.Length - i < 2) |
224 | break; | 224 | break; |
225 | 225 | ||
226 | //Have we reached the end of the list of headers? | ||
227 | //End is marked by a string with a single digit. | ||
228 | //We already know we have at least one parameter | ||
229 | //so it is safe to do this check at top of loop. | ||
230 | if (Char.IsDigit(parms[i][0])) | ||
231 | break; | ||
232 | |||
233 | if (htc.HttpCustomHeaders == null) | 226 | if (htc.HttpCustomHeaders == null) |
234 | htc.HttpCustomHeaders = new List<string>(); | 227 | htc.HttpCustomHeaders = new List<string>(); |
235 | 228 | ||
236 | htc.HttpCustomHeaders.Add(parms[i]); | 229 | htc.HttpCustomHeaders.Add(parms[i]); |
237 | htc.HttpCustomHeaders.Add(parms[i+1]); | 230 | htc.HttpCustomHeaders.Add(parms[i+1]); |
231 | int nexti = i + 2; | ||
232 | if (nexti >= parms.Length || Char.IsDigit(parms[nexti][0])) | ||
233 | break; | ||
238 | 234 | ||
239 | i += 2; | 235 | i = nexti; |
240 | } | 236 | } |
241 | break; | 237 | break; |
242 | 238 | ||
diff --git a/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs b/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs index 290daa9..66ebdbe 100644 --- a/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs +++ b/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs | |||
@@ -26,15 +26,15 @@ | |||
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.Threading; | ||
30 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
31 | using System.Collections; | 30 | using System.Collections; |
32 | using System.Reflection; | 31 | using System.Reflection; |
32 | using System.Net; | ||
33 | using System.Net.Sockets; | ||
33 | using log4net; | 34 | using log4net; |
34 | using Mono.Addins; | 35 | using Mono.Addins; |
35 | using Nini.Config; | 36 | using Nini.Config; |
36 | using OpenMetaverse; | 37 | using OpenMetaverse; |
37 | using OpenSim.Framework; | ||
38 | using OpenSim.Framework.Servers; | 38 | using OpenSim.Framework.Servers; |
39 | using OpenSim.Framework.Servers.HttpServer; | 39 | using OpenSim.Framework.Servers.HttpServer; |
40 | using OpenSim.Region.Framework.Interfaces; | 40 | using OpenSim.Region.Framework.Interfaces; |
@@ -89,6 +89,8 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp | |||
89 | protected Dictionary<string, UrlData> m_UrlMap = | 89 | protected Dictionary<string, UrlData> m_UrlMap = |
90 | new Dictionary<string, UrlData>(); | 90 | new Dictionary<string, UrlData>(); |
91 | 91 | ||
92 | protected bool m_enabled = false; | ||
93 | protected string m_ErrorStr; | ||
92 | protected uint m_HttpsPort = 0; | 94 | protected uint m_HttpsPort = 0; |
93 | protected IHttpServer m_HttpServer = null; | 95 | protected IHttpServer m_HttpServer = null; |
94 | protected IHttpServer m_HttpsServer = null; | 96 | protected IHttpServer m_HttpsServer = null; |
@@ -118,6 +120,7 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp | |||
118 | public void Initialise(IConfigSource config) | 120 | public void Initialise(IConfigSource config) |
119 | { | 121 | { |
120 | IConfig networkConfig = config.Configs["Network"]; | 122 | IConfig networkConfig = config.Configs["Network"]; |
123 | m_enabled = false; | ||
121 | 124 | ||
122 | if (networkConfig != null) | 125 | if (networkConfig != null) |
123 | { | 126 | { |
@@ -128,9 +131,47 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp | |||
128 | if (ssl_enabled) | 131 | if (ssl_enabled) |
129 | m_HttpsPort = (uint)config.Configs["Network"].GetInt("https_port", (int)m_HttpsPort); | 132 | m_HttpsPort = (uint)config.Configs["Network"].GetInt("https_port", (int)m_HttpsPort); |
130 | } | 133 | } |
134 | else | ||
135 | { | ||
136 | m_ErrorStr = "[Network] configuration missing, HTTP listener for LSL disabled"; | ||
137 | m_log.Warn("[URL MODULE]: " + m_ErrorStr); | ||
138 | return; | ||
139 | } | ||
140 | |||
141 | if (String.IsNullOrWhiteSpace(ExternalHostNameForLSL)) | ||
142 | { | ||
143 | m_ErrorStr = "ExternalHostNameForLSL not defined in configuration, HTTP listener for LSL disabled"; | ||
144 | m_log.Warn("[URL MODULE]: " + m_ErrorStr); | ||
145 | return; | ||
146 | } | ||
147 | |||
148 | IPAddress ia = null; | ||
149 | try | ||
150 | { | ||
151 | foreach (IPAddress Adr in Dns.GetHostAddresses(ExternalHostNameForLSL)) | ||
152 | { | ||
153 | if (Adr.AddressFamily == AddressFamily.InterNetwork || | ||
154 | Adr.AddressFamily == AddressFamily.InterNetworkV6) // ipv6 will most likely smoke | ||
155 | { | ||
156 | ia = Adr; | ||
157 | break; | ||
158 | } | ||
159 | } | ||
160 | } | ||
161 | catch | ||
162 | { | ||
163 | ia = null; | ||
164 | } | ||
131 | 165 | ||
132 | if (ExternalHostNameForLSL == null) | 166 | if (ia == null) |
133 | ExternalHostNameForLSL = System.Environment.MachineName; | 167 | { |
168 | m_ErrorStr = "Could not resolve ExternalHostNameForLSL, HTTP listener for LSL disabled"; | ||
169 | m_log.Warn("[URL MODULE]: " + m_ErrorStr); | ||
170 | return; | ||
171 | } | ||
172 | |||
173 | m_enabled = true; | ||
174 | m_ErrorStr = String.Empty; | ||
134 | 175 | ||
135 | IConfig llFunctionsConfig = config.Configs["LL-Functions"]; | 176 | IConfig llFunctionsConfig = config.Configs["LL-Functions"]; |
136 | 177 | ||
@@ -146,7 +187,7 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp | |||
146 | 187 | ||
147 | public void AddRegion(Scene scene) | 188 | public void AddRegion(Scene scene) |
148 | { | 189 | { |
149 | if (m_HttpServer == null) | 190 | if (m_enabled && m_HttpServer == null) |
150 | { | 191 | { |
151 | // There can only be one | 192 | // There can only be one |
152 | // | 193 | // |
@@ -197,11 +238,18 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp | |||
197 | { | 238 | { |
198 | UUID urlcode = UUID.Random(); | 239 | UUID urlcode = UUID.Random(); |
199 | 240 | ||
241 | if(!m_enabled) | ||
242 | { | ||
243 | engine.PostScriptEvent(itemID, "http_request", new Object[] { urlcode.ToString(), "URL_REQUEST_DENIED", m_ErrorStr }); | ||
244 | return urlcode; | ||
245 | } | ||
246 | |||
200 | lock (m_UrlMap) | 247 | lock (m_UrlMap) |
201 | { | 248 | { |
202 | if (m_UrlMap.Count >= TotalUrls) | 249 | if (m_UrlMap.Count >= TotalUrls) |
203 | { | 250 | { |
204 | engine.PostScriptEvent(itemID, "http_request", new Object[] { urlcode.ToString(), "URL_REQUEST_DENIED", "" }); | 251 | engine.PostScriptEvent(itemID, "http_request", new Object[] { urlcode.ToString(), "URL_REQUEST_DENIED", |
252 | "Too many URLs already open" }); | ||
205 | return urlcode; | 253 | return urlcode; |
206 | } | 254 | } |
207 | string url = "http://" + ExternalHostNameForLSL + ":" + m_HttpServer.Port.ToString() + "/lslhttp/" + urlcode.ToString() + "/"; | 255 | string url = "http://" + ExternalHostNameForLSL + ":" + m_HttpServer.Port.ToString() + "/lslhttp/" + urlcode.ToString() + "/"; |
@@ -243,6 +291,12 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp | |||
243 | { | 291 | { |
244 | UUID urlcode = UUID.Random(); | 292 | UUID urlcode = UUID.Random(); |
245 | 293 | ||
294 | if(!m_enabled) | ||
295 | { | ||
296 | engine.PostScriptEvent(itemID, "http_request", new Object[] { urlcode.ToString(), "URL_REQUEST_DENIED", m_ErrorStr }); | ||
297 | return urlcode; | ||
298 | } | ||
299 | |||
246 | if (m_HttpsServer == null) | 300 | if (m_HttpsServer == null) |
247 | { | 301 | { |
248 | engine.PostScriptEvent(itemID, "http_request", new Object[] { urlcode.ToString(), "URL_REQUEST_DENIED", "" }); | 302 | engine.PostScriptEvent(itemID, "http_request", new Object[] { urlcode.ToString(), "URL_REQUEST_DENIED", "" }); |
@@ -253,7 +307,8 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp | |||
253 | { | 307 | { |
254 | if (m_UrlMap.Count >= TotalUrls) | 308 | if (m_UrlMap.Count >= TotalUrls) |
255 | { | 309 | { |
256 | engine.PostScriptEvent(itemID, "http_request", new Object[] { urlcode.ToString(), "URL_REQUEST_DENIED", "" }); | 310 | engine.PostScriptEvent(itemID, "http_request", new Object[] { urlcode.ToString(), "URL_REQUEST_DENIED", |
311 | "Too many URLs already open" }); | ||
257 | return urlcode; | 312 | return urlcode; |
258 | } | 313 | } |
259 | string url = "https://" + ExternalHostNameForLSL + ":" + m_HttpsServer.Port.ToString() + "/lslhttps/" + urlcode.ToString() + "/"; | 314 | string url = "https://" + ExternalHostNameForLSL + ":" + m_HttpsServer.Port.ToString() + "/lslhttps/" + urlcode.ToString() + "/"; |
diff --git a/OpenSim/Region/CoreModules/Scripting/WorldComm/WorldCommModule.cs b/OpenSim/Region/CoreModules/Scripting/WorldComm/WorldCommModule.cs index 660e03f..a5203ea 100644 --- a/OpenSim/Region/CoreModules/Scripting/WorldComm/WorldCommModule.cs +++ b/OpenSim/Region/CoreModules/Scripting/WorldComm/WorldCommModule.cs | |||
@@ -113,7 +113,7 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm | |||
113 | // wrap this in a try block so that defaults will work if | 113 | // wrap this in a try block so that defaults will work if |
114 | // the config file doesn't specify otherwise. | 114 | // the config file doesn't specify otherwise. |
115 | int maxlisteners = 1000; | 115 | int maxlisteners = 1000; |
116 | int maxhandles = 64; | 116 | int maxhandles = 65; |
117 | try | 117 | try |
118 | { | 118 | { |
119 | m_whisperdistance = config.Configs["Chat"].GetInt( | 119 | m_whisperdistance = config.Configs["Chat"].GetInt( |
@@ -130,8 +130,15 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm | |||
130 | catch (Exception) | 130 | catch (Exception) |
131 | { | 131 | { |
132 | } | 132 | } |
133 | if (maxlisteners < 1) maxlisteners = int.MaxValue; | 133 | |
134 | if (maxhandles < 1) maxhandles = int.MaxValue; | 134 | if (maxlisteners < 1) |
135 | maxlisteners = int.MaxValue; | ||
136 | if (maxhandles < 1) | ||
137 | maxhandles = int.MaxValue; | ||
138 | |||
139 | if (maxlisteners < maxhandles) | ||
140 | maxlisteners = maxhandles; | ||
141 | |||
135 | m_listenerManager = new ListenerManager(maxlisteners, maxhandles); | 142 | m_listenerManager = new ListenerManager(maxlisteners, maxhandles); |
136 | m_pendingQ = new Queue(); | 143 | m_pendingQ = new Queue(); |
137 | m_pending = Queue.Synchronized(m_pendingQ); | 144 | m_pending = Queue.Synchronized(m_pendingQ); |
@@ -605,11 +612,9 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm | |||
605 | li.GetHandle().Equals(handle)) | 612 | li.GetHandle().Equals(handle)) |
606 | { | 613 | { |
607 | lis.Value.Remove(li); | 614 | lis.Value.Remove(li); |
615 | m_curlisteners--; | ||
608 | if (lis.Value.Count == 0) | 616 | if (lis.Value.Count == 0) |
609 | { | 617 | m_listeners.Remove(lis.Key); // bailing of loop so this does not smoke |
610 | m_listeners.Remove(lis.Key); | ||
611 | m_curlisteners--; | ||
612 | } | ||
613 | // there should be only one, so we bail out early | 618 | // there should be only one, so we bail out early |
614 | return; | 619 | return; |
615 | } | 620 | } |
@@ -718,6 +723,9 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm | |||
718 | } | 723 | } |
719 | } | 724 | } |
720 | 725 | ||
726 | if(handles.Count >= m_maxhandles) | ||
727 | return -1; | ||
728 | |||
721 | // Note: 0 is NOT a valid handle for llListen() to return | 729 | // Note: 0 is NOT a valid handle for llListen() to return |
722 | for (int i = 1; i <= m_maxhandles; i++) | 730 | for (int i = 1; i <= m_maxhandles; i++) |
723 | { | 731 | { |