diff options
author | UbitUmarov | 2017-05-02 11:23:41 +0100 |
---|---|---|
committer | UbitUmarov | 2017-05-02 11:23:41 +0100 |
commit | a890ea312b56821c88bec69cfd36b799733f7a41 (patch) | |
tree | 23d15812ae3ff52a63fae55f1540e958dd025f8d /OpenSim/Region/CoreModules/Scripting | |
parent | Merge branch 'master' of opensimulator.org:/var/git/opensim (diff) | |
download | opensim-SC-a890ea312b56821c88bec69cfd36b799733f7a41.zip opensim-SC-a890ea312b56821c88bec69cfd36b799733f7a41.tar.gz opensim-SC-a890ea312b56821c88bec69cfd36b799733f7a41.tar.bz2 opensim-SC-a890ea312b56821c88bec69cfd36b799733f7a41.tar.xz |
disable LSL http listener (llRequestURL/llRequestSecureURL) if ExternalHostNameForLSL is not set in cofiguration or does not resolve
Diffstat (limited to 'OpenSim/Region/CoreModules/Scripting')
-rw-r--r-- | OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs | 69 |
1 files changed, 62 insertions, 7 deletions
diff --git a/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs b/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs index 311deab..895020c 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() + "/"; |