diff options
author | Melanie | 2010-11-02 21:29:02 +0000 |
---|---|---|
committer | Melanie | 2010-11-02 21:29:02 +0000 |
commit | 5eeabb8b4b8137499cf91e4b61133d5f12b9ecdf (patch) | |
tree | 90488d2377d35c3de7a62647ec9a41a536a125bd /OpenSim/Framework/Console | |
parent | Fix sitting and standing up (diff) | |
parent | Add support for cross-domain AJAX requests to REST console. (diff) | |
download | opensim-SC-5eeabb8b4b8137499cf91e4b61133d5f12b9ecdf.zip opensim-SC-5eeabb8b4b8137499cf91e4b61133d5f12b9ecdf.tar.gz opensim-SC-5eeabb8b4b8137499cf91e4b61133d5f12b9ecdf.tar.bz2 opensim-SC-5eeabb8b4b8137499cf91e4b61133d5f12b9ecdf.tar.xz |
Merge branch 'master' of melanie@opensimulator.org:/var/git/opensim
Diffstat (limited to 'OpenSim/Framework/Console')
-rw-r--r-- | OpenSim/Framework/Console/RemoteConsole.cs | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/OpenSim/Framework/Console/RemoteConsole.cs b/OpenSim/Framework/Console/RemoteConsole.cs index 7eb289b..07de27a 100644 --- a/OpenSim/Framework/Console/RemoteConsole.cs +++ b/OpenSim/Framework/Console/RemoteConsole.cs | |||
@@ -32,6 +32,7 @@ using System.Collections.Generic; | |||
32 | using System.Diagnostics; | 32 | using System.Diagnostics; |
33 | using System.Reflection; | 33 | using System.Reflection; |
34 | using System.Text; | 34 | using System.Text; |
35 | using System.Text.RegularExpressions; | ||
35 | using System.Threading; | 36 | using System.Threading; |
36 | using OpenMetaverse; | 37 | using OpenMetaverse; |
37 | using Nini.Config; | 38 | using Nini.Config; |
@@ -62,6 +63,7 @@ namespace OpenSim.Framework.Console | |||
62 | new Dictionary<UUID, ConsoleConnection>(); | 63 | new Dictionary<UUID, ConsoleConnection>(); |
63 | private string m_UserName = String.Empty; | 64 | private string m_UserName = String.Empty; |
64 | private string m_Password = String.Empty; | 65 | private string m_Password = String.Empty; |
66 | private string m_AllowedOrigin = String.Empty; | ||
65 | 67 | ||
66 | public RemoteConsole(string defaultPrompt) : base(defaultPrompt) | 68 | public RemoteConsole(string defaultPrompt) : base(defaultPrompt) |
67 | { | 69 | { |
@@ -77,6 +79,7 @@ namespace OpenSim.Framework.Console | |||
77 | 79 | ||
78 | m_UserName = netConfig.GetString("ConsoleUser", String.Empty); | 80 | m_UserName = netConfig.GetString("ConsoleUser", String.Empty); |
79 | m_Password = netConfig.GetString("ConsolePass", String.Empty); | 81 | m_Password = netConfig.GetString("ConsolePass", String.Empty); |
82 | m_AllowedOrigin = netConfig.GetString("ConsoleAllowedOrigin", String.Empty); | ||
80 | } | 83 | } |
81 | 84 | ||
82 | public void SetServer(IHttpServer server) | 85 | public void SetServer(IHttpServer server) |
@@ -150,6 +153,29 @@ namespace OpenSim.Framework.Console | |||
150 | return cmdinput; | 153 | return cmdinput; |
151 | } | 154 | } |
152 | 155 | ||
156 | private Hashtable CheckOrigin(Hashtable result) | ||
157 | { | ||
158 | if (!string.IsNullOrEmpty(m_AllowedOrigin)) | ||
159 | result["access_control_allow_origin"] = m_AllowedOrigin; | ||
160 | return result; | ||
161 | } | ||
162 | /* TODO: Figure out how PollServiceHTTPHandler can access the request headers | ||
163 | * in order to use m_AllowedOrigin as a regular expression | ||
164 | private Hashtable CheckOrigin(Hashtable headers, Hashtable result) | ||
165 | { | ||
166 | if (!string.IsNullOrEmpty(m_AllowedOrigin)) | ||
167 | { | ||
168 | if (headers.ContainsKey("origin")) | ||
169 | { | ||
170 | string origin = headers["origin"].ToString(); | ||
171 | if (Regex.IsMatch(origin, m_AllowedOrigin)) | ||
172 | result["access_control_allow_origin"] = origin; | ||
173 | } | ||
174 | } | ||
175 | return result; | ||
176 | } | ||
177 | */ | ||
178 | |||
153 | private void DoExpire() | 179 | private void DoExpire() |
154 | { | 180 | { |
155 | List<UUID> expired = new List<UUID>(); | 181 | List<UUID> expired = new List<UUID>(); |
@@ -235,6 +261,7 @@ namespace OpenSim.Framework.Console | |||
235 | reply["str_response_string"] = xmldoc.InnerXml; | 261 | reply["str_response_string"] = xmldoc.InnerXml; |
236 | reply["int_response_code"] = 200; | 262 | reply["int_response_code"] = 200; |
237 | reply["content_type"] = "text/xml"; | 263 | reply["content_type"] = "text/xml"; |
264 | reply = CheckOrigin(reply); | ||
238 | 265 | ||
239 | return reply; | 266 | return reply; |
240 | } | 267 | } |
@@ -289,6 +316,7 @@ namespace OpenSim.Framework.Console | |||
289 | reply["str_response_string"] = xmldoc.InnerXml; | 316 | reply["str_response_string"] = xmldoc.InnerXml; |
290 | reply["int_response_code"] = 200; | 317 | reply["int_response_code"] = 200; |
291 | reply["content_type"] = "text/xml"; | 318 | reply["content_type"] = "text/xml"; |
319 | reply = CheckOrigin(reply); | ||
292 | 320 | ||
293 | return reply; | 321 | return reply; |
294 | } | 322 | } |
@@ -344,6 +372,7 @@ namespace OpenSim.Framework.Console | |||
344 | reply["str_response_string"] = xmldoc.InnerXml; | 372 | reply["str_response_string"] = xmldoc.InnerXml; |
345 | reply["int_response_code"] = 200; | 373 | reply["int_response_code"] = 200; |
346 | reply["content_type"] = "text/xml"; | 374 | reply["content_type"] = "text/xml"; |
375 | reply = CheckOrigin(reply); | ||
347 | 376 | ||
348 | return reply; | 377 | return reply; |
349 | } | 378 | } |
@@ -457,6 +486,7 @@ namespace OpenSim.Framework.Console | |||
457 | result["content_type"] = "application/xml"; | 486 | result["content_type"] = "application/xml"; |
458 | result["keepalive"] = false; | 487 | result["keepalive"] = false; |
459 | result["reusecontext"] = false; | 488 | result["reusecontext"] = false; |
489 | result = CheckOrigin(result); | ||
460 | 490 | ||
461 | return result; | 491 | return result; |
462 | } | 492 | } |
@@ -480,6 +510,7 @@ namespace OpenSim.Framework.Console | |||
480 | result["content_type"] = "text/xml"; | 510 | result["content_type"] = "text/xml"; |
481 | result["keepalive"] = false; | 511 | result["keepalive"] = false; |
482 | result["reusecontext"] = false; | 512 | result["reusecontext"] = false; |
513 | result = CheckOrigin(result); | ||
483 | 514 | ||
484 | return result; | 515 | return result; |
485 | } | 516 | } |