aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Server/Handlers/Web
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Server/Handlers/Web/WebServerConnector.cs92
1 files changed, 74 insertions, 18 deletions
diff --git a/OpenSim/Server/Handlers/Web/WebServerConnector.cs b/OpenSim/Server/Handlers/Web/WebServerConnector.cs
index c4a0531..0f328d9 100644
--- a/OpenSim/Server/Handlers/Web/WebServerConnector.cs
+++ b/OpenSim/Server/Handlers/Web/WebServerConnector.cs
@@ -3,6 +3,7 @@ using System.Collections;
3using System.Collections.Generic; 3using System.Collections.Generic;
4using System.IO; 4using System.IO;
5using System.Net; 5using System.Net;
6using System.Net.Mail;
6using System.Reflection; 7using System.Reflection;
7using System.Security; 8using System.Security;
8using System.Text; 9using System.Text;
@@ -32,10 +33,10 @@ namespace OpenSim.Server.Handlers.Web
32 33
33 private IPAddress m_IP; 34 private IPAddress m_IP;
34 private IHttpServer m_server; 35 private IHttpServer m_server;
35 private IHttpServer m_SSLserver = null; 36// private IHttpServer m_SSLserver = null;
36 private string m_domain = ""; 37 private string m_domain = "";
37 private uint m_http_port; 38 private uint m_http_port;
38 private uint m_https_port = 0; 39// private uint m_https_port = 0;
39 40
40 private Dictionary<string, Hashtable> m_auth = new Dictionary<string, Hashtable>(); 41 private Dictionary<string, Hashtable> m_auth = new Dictionary<string, Hashtable>();
41 42
@@ -43,6 +44,15 @@ namespace OpenSim.Server.Handlers.Web
43 private static Dictionary<string, string> m_lastNames = new Dictionary<string, string>(); 44 private static Dictionary<string, string> m_lastNames = new Dictionary<string, string>();
44 private static Dictionary<string, string> m_fullNames = new Dictionary<string, string>(); 45 private static Dictionary<string, string> m_fullNames = new Dictionary<string, string>();
45 46
47/* TODO - shelved for now, rewrite it in Lua for lighttpd after the release.
48 private string m_SMTP_server;
49 private string m_SMTP_port;
50 private string m_SMTP_user;
51 private string m_SMTP_password;
52 private string m_email_from;
53 private SmtpClient m_smtp;
54*/
55
46 public WebServerConnector(IConfigSource config, IHttpServer server, string configName) : base(config, server, configName) 56 public WebServerConnector(IConfigSource config, IHttpServer server, string configName) : base(config, server, configName)
47 { 57 {
48 string dllName = String.Empty; 58 string dllName = String.Empty;
@@ -106,6 +116,7 @@ namespace OpenSim.Server.Handlers.Web
106 cfg = m_Config.Configs["Const"]; 116 cfg = m_Config.Configs["Const"];
107 m_domain = cfg.GetString("HostName", "localhost"); 117 m_domain = cfg.GetString("HostName", "localhost");
108 118
119/* TODO - shelved for now, rewrite it in Lua for lighttpd after the release.
109 // Copied from OpenSim/Region/OptionalModules/ViewerSupport/GodNamesModule.cs 120 // Copied from OpenSim/Region/OptionalModules/ViewerSupport/GodNamesModule.cs
110 cfg = m_Config.Configs["GodNames"]; 121 cfg = m_Config.Configs["GodNames"];
111 if (null != cfg) 122 if (null != cfg)
@@ -147,8 +158,32 @@ namespace OpenSim.Server.Handlers.Web
147 else 158 else
148 m_log.Info("[WEB SERVICE]: No god names loaded."); 159 m_log.Info("[WEB SERVICE]: No god names loaded.");
149 160
161 // Add the email client.
162 cfg = m_Config.Configs["SMTP"];
163 if (null != cfg)
164 {
165 m_log.Info("[WEB SERVICE]: Loading email configuration.");
166 m_SMTP_server = cfg.GetString("SMTP_SERVER_HOSTNAME", "127.0.0.1");
167 m_SMTP_port = cfg.GetString("SMTP_SERVER_PORT", "25");
168 m_SMTP_user = cfg.GetString("SMTP_SERVER_LOGIN", "");
169 m_SMTP_password = cfg.GetString("SMTP_SERVER_PASSWORD", "");
170 m_email_from = cfg.GetString("host_domain_header_from", "grid@localhost");
171
172 m_smtp = new SmtpClient
173 {
174 Host = m_SMTP_server,
175 Port = Convert.ToInt16(m_SMTP_port),
176 EnableSsl = false,
177 DeliveryMethod = SmtpDeliveryMethod.Network,
178 Credentials = new NetworkCredential(m_SMTP_user, m_SMTP_password),
179 Timeout = 20000
180 };
181 }
182*/
183
150 // Add the HTTP and HTTPS handlers. 184 // Add the HTTP and HTTPS handlers.
151 server.AddHTTPHandler("/web/", WebRequestHandler); 185 server.AddHTTPHandler("/web/", WebRequestHandler);
186/* TODO - shelved for now, rewrite it in Lua for lighttpd after the release.
152 IConfig networkConfig = m_Config.Configs["Network"]; 187 IConfig networkConfig = m_Config.Configs["Network"];
153 if (null != networkConfig) 188 if (null != networkConfig)
154 { 189 {
@@ -160,13 +195,16 @@ namespace OpenSim.Server.Handlers.Web
160 m_SSLserver.AddHTTPHandler("/web/", WebRequestHandlerSSL); 195 m_SSLserver.AddHTTPHandler("/web/", WebRequestHandlerSSL);
161 } 196 }
162 } 197 }
198*/
163 } 199 }
164 200
165 // AAARGGGH, in the request we don't get the HTTP/S, domain name, nor port number we were called from. So we have to fake it, sorta. 201 // AAARGGGH, in the request we don't get the HTTP/S, domain name, nor port number we were called from. So we have to fake it, sorta.
202/* TODO - shelved for now, rewrite it in Lua for lighttpd after the release.
166 private Hashtable WebRequestHandlerSSL(Hashtable request) 203 private Hashtable WebRequestHandlerSSL(Hashtable request)
167 { 204 {
168 return Handler(request, true); 205 return Handler(request, true);
169 } 206 }
207*/
170 private Hashtable WebRequestHandler(Hashtable request) 208 private Hashtable WebRequestHandler(Hashtable request)
171 { 209 {
172 return Handler(request, false); 210 return Handler(request, false);
@@ -189,8 +227,10 @@ namespace OpenSim.Server.Handlers.Web
189 string file = reqpath.Remove(0, 5); 227 string file = reqpath.Remove(0, 5);
190 string path = Path.Combine(Util.webDir(), file); 228 string path = Path.Combine(Util.webDir(), file);
191 229
230// m_log.InfoFormat("[WEB SERVICE]: {0} {1} {2} : {3} {4}, server IP {5} content type {6}, body {7}.",
231// headers["remote_addr"].ToString(), method, m_domain, (usedSSL ? m_https_port : m_http_port), reqpath, m_IP, type, body);
192 m_log.InfoFormat("[WEB SERVICE]: {0} {1} {2} : {3} {4}, server IP {5} content type {6}, body {7}.", 232 m_log.InfoFormat("[WEB SERVICE]: {0} {1} {2} : {3} {4}, server IP {5} content type {6}, body {7}.",
193 headers["remote_addr"].ToString(), method, m_domain, (usedSSL ? m_https_port : m_http_port), reqpath, m_IP, type, body); 233 headers["remote_addr"].ToString(), method, m_domain, m_http_port, reqpath, m_IP, type, body);
194 234
195 if (! Path.GetFullPath(path).StartsWith(Path.GetFullPath(Util.webDir()))) 235 if (! Path.GetFullPath(path).StartsWith(Path.GetFullPath(Util.webDir())))
196 { 236 {
@@ -244,14 +284,15 @@ namespace OpenSim.Server.Handlers.Web
244 284
245 foreach (String q in query) 285 foreach (String q in query)
246 { 286 {
247 m_log.InfoFormat("[WEB SERVICE]: {0} {1} query {2} = {3}", method, reqpath, q, (string) request[q]); 287// m_log.InfoFormat("[WEB SERVICE]: {0} {1} query {2} = {3}", method, reqpath, q, (string) request[q]);
248 fields[q] = bobbyTables(q, (string) request[q]); 288 fields[q] = bobbyTables(q, (string) request[q]);
249 } 289 }
250 foreach (DictionaryEntry h in headers) 290// foreach (DictionaryEntry h in headers)
251 m_log.DebugFormat("[WEB SERVICE]: {0} {1} header {2} = {3}", method, reqpath, (string) h.Key, (string) h.Value); 291// m_log.DebugFormat("[WEB SERVICE]: {0} {1} header {2} = {3}", method, reqpath, (string) h.Key, (string) h.Value);
252 // I dunno what these vars are or where they come from, never actually seen them. 292 // I dunno what these vars are or where they come from, never actually seen them.
253 foreach (DictionaryEntry h in vars) 293 // Ah, viewers send them, and they seem to be identical to the query that viewers also send.
254 m_log.InfoFormat("[WEB SERVICE]: {0} {1} var {2} = {3}", method, reqpath, (string) h.Key, (string) h.Value); 294// foreach (DictionaryEntry h in vars)
295// m_log.InfoFormat("[WEB SERVICE]: {0} {1} var {2} = {3}", method, reqpath, (string) h.Key, (string) h.Value);
255 296
256 reply["int_response_code"] = 200; 297 reply["int_response_code"] = 200;
257 298
@@ -305,6 +346,7 @@ namespace OpenSim.Server.Handlers.Web
305 csr.Close(); 346 csr.Close();
306 } 347 }
307 } 348 }
349/* TODO - shelved for now, rewrite it in Lua for lighttpd after the release.
308 else 350 else
309 { 351 {
310 if ("account.html" == file) 352 if ("account.html" == file)
@@ -329,15 +371,16 @@ namespace OpenSim.Server.Handlers.Web
329 "404 error, can't find the " + reqpath + " page.<p>&nbsp;</p></body></html>"; 371 "404 error, can't find the " + reqpath + " page.<p>&nbsp;</p></body></html>";
330 } 372 }
331 } 373 }
374*/
332 } 375 }
333 else if ("POST" == method) 376 else if ("POST" == method)
334 { 377 {
335 378
336 if ("account.html" == file) 379// if ("account.html" == file)
337 { 380// {
338 string doit = fields["doit"].ToString(); 381// string doit = fields["doit"].ToString();
339 string toke_n_munchie = ""; 382// string toke_n_munchie = "";
340 replyHeaders["Cache-Control"] = "no-cache"; 383// replyHeaders["Cache-Control"] = "no-cache";
341 384
342/* TODO - 385/* TODO -
343 Switch to using prepared SQL statements. 386 Switch to using prepared SQL statements.
@@ -356,7 +399,7 @@ namespace OpenSim.Server.Handlers.Web
356 Deal with editing yourself. 399 Deal with editing yourself.
357 Deal with editing others, but only as god. 400 Deal with editing others, but only as god.
358*/ 401*/
359 402/* TODO - shelved for now, rewrite it in Lua for lighttpd after the release.
360 if ((null == cookies["toke_n_munchie"]) || (null == fields["toke_n_munchie"]) 403 if ((null == cookies["toke_n_munchie"]) || (null == fields["toke_n_munchie"])
361 || ("" == cookies["toke_n_munchie"].ToString()) || ("" == fields["toke_n_munchie"].ToString())) 404 || ("" == cookies["toke_n_munchie"].ToString()) || ("" == fields["toke_n_munchie"].ToString()))
362 toke_n_munchie = newSession(doit, headers, ref fields, ref replyHeaders); 405 toke_n_munchie = newSession(doit, headers, ref fields, ref replyHeaders);
@@ -417,7 +460,19 @@ namespace OpenSim.Server.Handlers.Web
417 else if (("create" == doit)) 460 else if (("create" == doit))
418 reply["str_response_string"] = accountCreationPage(fields, body); 461 reply["str_response_string"] = accountCreationPage(fields, body);
419 else 462 else
463 {
464 var fromAddress = new MailAddress(m_email_from, (string) ssi["grid"]);
465 var toAddress = new MailAddress((string) fields["email"], (string) fields["name"]);
466 using (var message = new MailMessage(fromAddress, toAddress)
467 {
468 Subject = "validation email",
469 Body = "Should be a linky around here somewhere."
470 })
471 {
472 m_smtp.Send(message);
473 }
420 reply["str_response_string"] = loggedOnPage(fields, body); 474 reply["str_response_string"] = loggedOnPage(fields, body);
475 }
421 } 476 }
422 else 477 else
423 deleteSession(toke_n_munchie.ToString(), doit, headers, ref fields, ref replyHeaders); 478 deleteSession(toke_n_munchie.ToString(), doit, headers, ref fields, ref replyHeaders);
@@ -446,15 +501,16 @@ namespace OpenSim.Server.Handlers.Web
446 } 501 }
447 else 502 else
448 reply["str_response_string"] = loggedOnPage(fields, body); 503 reply["str_response_string"] = loggedOnPage(fields, body);
449 } 504*/
450 else // Not one of our dynamic pages. 505// }
451 { 506// else // Not one of our dynamic pages.
507// {
452 m_log.ErrorFormat("[WEB SERVICE]: No such POST target {0}.", path); 508 m_log.ErrorFormat("[WEB SERVICE]: No such POST target {0}.", path);
453 reply["int_response_code"] = 404; 509 reply["int_response_code"] = 404;
454 reply["content_type"] = "text/html"; 510 reply["content_type"] = "text/html";
455 reply["str_response_string"] = "<html><title>404 Unknown page</title><head></head><body bgcolor=\"black\" text=\"white\" alink=\"red\" link=\"blue\" vlink=\"purple\">" + 511 reply["str_response_string"] = "<html><title>404 Unknown page</title><head></head><body bgcolor=\"black\" text=\"white\" alink=\"red\" link=\"blue\" vlink=\"purple\">" +
456 "404 error, can't find the " + reqpath + " page.<p>&nbsp;</p></body></html>"; 512 "404 error, can't find the " + reqpath + " page.<p>&nbsp;</p></body></html>";
457 } 513// }
458 } 514 }
459 else // Not one of our handled methods. 515 else // Not one of our handled methods.
460 { 516 {