aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/CoreModules/Scripting
diff options
context:
space:
mode:
authorMelanie2011-05-08 20:23:06 +0100
committerMelanie2011-05-08 20:23:06 +0100
commitb451cc1ebb9e950bb93e790ab9e83aff30a47c61 (patch)
treec9fbe41be36cf791976f9e5afabd44f69b64e747 /OpenSim/Region/CoreModules/Scripting
parentEnable compressed (gzip) fatpack transfers. (diff)
parentMerge branch 'master' of melanie@opensimulator.org:/var/git/opensim (diff)
downloadopensim-SC-b451cc1ebb9e950bb93e790ab9e83aff30a47c61.zip
opensim-SC-b451cc1ebb9e950bb93e790ab9e83aff30a47c61.tar.gz
opensim-SC-b451cc1ebb9e950bb93e790ab9e83aff30a47c61.tar.bz2
opensim-SC-b451cc1ebb9e950bb93e790ab9e83aff30a47c61.tar.xz
Merge branch 'master' into careminster-presence-refactor
Diffstat (limited to 'OpenSim/Region/CoreModules/Scripting')
-rw-r--r--OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs61
1 files changed, 56 insertions, 5 deletions
diff --git a/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs b/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs
index bdbd0c2..fa17fb6 100644
--- a/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs
+++ b/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs
@@ -79,7 +79,9 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
79 79
80 private int m_TotalUrls = 5000; 80 private int m_TotalUrls = 5000;
81 81
82 private uint https_port = 0;
82 private IHttpServer m_HttpServer = null; 83 private IHttpServer m_HttpServer = null;
84 private IHttpServer m_HttpsServer = null;
83 85
84 private string m_ExternalHostNameForLSL = ""; 86 private string m_ExternalHostNameForLSL = "";
85 87
@@ -101,6 +103,11 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
101 public void Initialise(IConfigSource config) 103 public void Initialise(IConfigSource config)
102 { 104 {
103 m_ExternalHostNameForLSL = config.Configs["Network"].GetString("ExternalHostNameForLSL", System.Environment.MachineName); 105 m_ExternalHostNameForLSL = config.Configs["Network"].GetString("ExternalHostNameForLSL", System.Environment.MachineName);
106 bool ssl_enabled = config.Configs["Network"].GetBoolean("https_listener",false);
107 if (ssl_enabled)
108 {
109 https_port = (uint) config.Configs["Network"].GetInt("https_port",0);
110 }
104 } 111 }
105 112
106 public void PostInitialise() 113 public void PostInitialise()
@@ -114,6 +121,12 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
114 // There can only be one 121 // There can only be one
115 // 122 //
116 m_HttpServer = MainServer.Instance; 123 m_HttpServer = MainServer.Instance;
124 //
125 // We can use the https if it is enabled
126 if (https_port > 0)
127 {
128 m_HttpsServer = MainServer.GetHttpServer(https_port);
129 }
117 } 130 }
118 131
119 scene.RegisterModuleInterface<IUrlModule>(this); 132 scene.RegisterModuleInterface<IUrlModule>(this);
@@ -171,7 +184,40 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
171 { 184 {
172 UUID urlcode = UUID.Random(); 185 UUID urlcode = UUID.Random();
173 186
174 engine.PostScriptEvent(itemID, "http_request", new Object[] { urlcode.ToString(), "URL_REQUEST_DENIED", "" }); 187 if (m_HttpsServer == null)
188 {
189 engine.PostScriptEvent(itemID, "http_request", new Object[] { urlcode.ToString(), "URL_REQUEST_DENIED", "" });
190 return urlcode;
191 }
192
193 lock (m_UrlMap)
194 {
195 if (m_UrlMap.Count >= m_TotalUrls)
196 {
197 engine.PostScriptEvent(itemID, "http_request", new Object[] { urlcode.ToString(), "URL_REQUEST_DENIED", "" });
198 return urlcode;
199 }
200 string url = "https://" + m_ExternalHostNameForLSL + ":" + m_HttpsServer.Port.ToString() + "/lslhttps/" + urlcode.ToString() + "/";
201
202 UrlData urlData = new UrlData();
203 urlData.hostID = host.UUID;
204 urlData.itemID = itemID;
205 urlData.engine = engine;
206 urlData.url = url;
207 urlData.urlcode = urlcode;
208 urlData.requests = new Dictionary<UUID, RequestData>();
209
210
211 m_UrlMap[url] = urlData;
212
213 string uri = "/lslhttps/" + urlcode.ToString() + "/";
214
215 m_HttpsServer.AddPollServiceHTTPHandler(uri,HandleHttpPoll,
216 new PollServiceEventArgs(HttpRequestHandler,HasEvents, GetEvents, NoEvents,
217 urlcode));
218
219 engine.PostScriptEvent(itemID, "http_request", new Object[] { urlcode.ToString(), "URL_REQUEST_GRANTED", url });
220 }
175 221
176 return urlcode; 222 return urlcode;
177 } 223 }
@@ -349,7 +395,7 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
349 } 395 }
350 private Hashtable GetEvents(UUID requestID, UUID sessionID, string request) 396 private Hashtable GetEvents(UUID requestID, UUID sessionID, string request)
351 { 397 {
352 UrlData url = null; 398 UrlData url = null;
353 RequestData requestData = null; 399 RequestData requestData = null;
354 400
355 lock (m_RequestMap) 401 lock (m_RequestMap)
@@ -396,11 +442,12 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
396 lock (request) 442 lock (request)
397 { 443 {
398 string uri = request["uri"].ToString(); 444 string uri = request["uri"].ToString();
399 445 bool is_ssl = uri.Contains("lslhttps");
446
400 try 447 try
401 { 448 {
402 Hashtable headers = (Hashtable)request["headers"]; 449 Hashtable headers = (Hashtable)request["headers"];
403 450
404// string uri_full = "http://" + m_ExternalHostNameForLSL + ":" + m_HttpServer.Port.ToString() + uri;// "/lslhttp/" + urlcode.ToString() + "/"; 451// string uri_full = "http://" + m_ExternalHostNameForLSL + ":" + m_HttpServer.Port.ToString() + uri;// "/lslhttp/" + urlcode.ToString() + "/";
405 452
406 int pos1 = uri.IndexOf("/");// /lslhttp 453 int pos1 = uri.IndexOf("/");// /lslhttp
@@ -414,7 +461,11 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
414 461
415 pathInfo = uri.Substring(pos3); 462 pathInfo = uri.Substring(pos3);
416 463
417 UrlData url = m_UrlMap["http://" + m_ExternalHostNameForLSL + ":" + m_HttpServer.Port.ToString() + uri_tmp]; 464 UrlData url = null;
465 if (!is_ssl)
466 url = m_UrlMap["http://" + m_ExternalHostNameForLSL + ":" + m_HttpServer.Port.ToString() + uri_tmp];
467 else
468 url = m_UrlMap["https://" + m_ExternalHostNameForLSL + ":" + m_HttpsServer.Port.ToString() + uri_tmp];
418 469
419 //for llGetHttpHeader support we need to store original URI here 470 //for llGetHttpHeader support we need to store original URI here
420 //to make x-path-info / x-query-string / x-script-url / x-remote-ip headers 471 //to make x-path-info / x-query-string / x-script-url / x-remote-ip headers