From 14616c8438fef749c5e7cb6bdcefe9b7c9554597 Mon Sep 17 00:00:00 2001 From: onefang Date: Wed, 21 Aug 2019 21:50:16 +1000 Subject: Disable the account manager for now, and anything else HTTPS related. Bump it to the next version. --- OpenSim/Server/Handlers/Web/WebServerConnector.cs | 92 ++++++++++++++++++----- 1 file changed, 74 insertions(+), 18 deletions(-) (limited to 'OpenSim/Server/Handlers/Web/WebServerConnector.cs') 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; using System.Collections.Generic; using System.IO; using System.Net; +using System.Net.Mail; using System.Reflection; using System.Security; using System.Text; @@ -32,10 +33,10 @@ namespace OpenSim.Server.Handlers.Web private IPAddress m_IP; private IHttpServer m_server; - private IHttpServer m_SSLserver = null; +// private IHttpServer m_SSLserver = null; private string m_domain = ""; private uint m_http_port; - private uint m_https_port = 0; +// private uint m_https_port = 0; private Dictionary m_auth = new Dictionary(); @@ -43,6 +44,15 @@ namespace OpenSim.Server.Handlers.Web private static Dictionary m_lastNames = new Dictionary(); private static Dictionary m_fullNames = new Dictionary(); +/* TODO - shelved for now, rewrite it in Lua for lighttpd after the release. + private string m_SMTP_server; + private string m_SMTP_port; + private string m_SMTP_user; + private string m_SMTP_password; + private string m_email_from; + private SmtpClient m_smtp; +*/ + public WebServerConnector(IConfigSource config, IHttpServer server, string configName) : base(config, server, configName) { string dllName = String.Empty; @@ -106,6 +116,7 @@ namespace OpenSim.Server.Handlers.Web cfg = m_Config.Configs["Const"]; m_domain = cfg.GetString("HostName", "localhost"); +/* TODO - shelved for now, rewrite it in Lua for lighttpd after the release. // Copied from OpenSim/Region/OptionalModules/ViewerSupport/GodNamesModule.cs cfg = m_Config.Configs["GodNames"]; if (null != cfg) @@ -147,8 +158,32 @@ namespace OpenSim.Server.Handlers.Web else m_log.Info("[WEB SERVICE]: No god names loaded."); + // Add the email client. + cfg = m_Config.Configs["SMTP"]; + if (null != cfg) + { + m_log.Info("[WEB SERVICE]: Loading email configuration."); + m_SMTP_server = cfg.GetString("SMTP_SERVER_HOSTNAME", "127.0.0.1"); + m_SMTP_port = cfg.GetString("SMTP_SERVER_PORT", "25"); + m_SMTP_user = cfg.GetString("SMTP_SERVER_LOGIN", ""); + m_SMTP_password = cfg.GetString("SMTP_SERVER_PASSWORD", ""); + m_email_from = cfg.GetString("host_domain_header_from", "grid@localhost"); + + m_smtp = new SmtpClient + { + Host = m_SMTP_server, + Port = Convert.ToInt16(m_SMTP_port), + EnableSsl = false, + DeliveryMethod = SmtpDeliveryMethod.Network, + Credentials = new NetworkCredential(m_SMTP_user, m_SMTP_password), + Timeout = 20000 + }; + } +*/ + // Add the HTTP and HTTPS handlers. server.AddHTTPHandler("/web/", WebRequestHandler); +/* TODO - shelved for now, rewrite it in Lua for lighttpd after the release. IConfig networkConfig = m_Config.Configs["Network"]; if (null != networkConfig) { @@ -160,13 +195,16 @@ namespace OpenSim.Server.Handlers.Web m_SSLserver.AddHTTPHandler("/web/", WebRequestHandlerSSL); } } +*/ } // 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. +/* TODO - shelved for now, rewrite it in Lua for lighttpd after the release. private Hashtable WebRequestHandlerSSL(Hashtable request) { return Handler(request, true); } +*/ private Hashtable WebRequestHandler(Hashtable request) { return Handler(request, false); @@ -189,8 +227,10 @@ namespace OpenSim.Server.Handlers.Web string file = reqpath.Remove(0, 5); string path = Path.Combine(Util.webDir(), file); +// m_log.InfoFormat("[WEB SERVICE]: {0} {1} {2} : {3} {4}, server IP {5} content type {6}, body {7}.", +// headers["remote_addr"].ToString(), method, m_domain, (usedSSL ? m_https_port : m_http_port), reqpath, m_IP, type, body); m_log.InfoFormat("[WEB SERVICE]: {0} {1} {2} : {3} {4}, server IP {5} content type {6}, body {7}.", - headers["remote_addr"].ToString(), method, m_domain, (usedSSL ? m_https_port : m_http_port), reqpath, m_IP, type, body); + headers["remote_addr"].ToString(), method, m_domain, m_http_port, reqpath, m_IP, type, body); if (! Path.GetFullPath(path).StartsWith(Path.GetFullPath(Util.webDir()))) { @@ -244,14 +284,15 @@ namespace OpenSim.Server.Handlers.Web foreach (String q in query) { - m_log.InfoFormat("[WEB SERVICE]: {0} {1} query {2} = {3}", method, reqpath, q, (string) request[q]); +// m_log.InfoFormat("[WEB SERVICE]: {0} {1} query {2} = {3}", method, reqpath, q, (string) request[q]); fields[q] = bobbyTables(q, (string) request[q]); } - foreach (DictionaryEntry h in headers) - m_log.DebugFormat("[WEB SERVICE]: {0} {1} header {2} = {3}", method, reqpath, (string) h.Key, (string) h.Value); +// foreach (DictionaryEntry h in headers) +// m_log.DebugFormat("[WEB SERVICE]: {0} {1} header {2} = {3}", method, reqpath, (string) h.Key, (string) h.Value); // I dunno what these vars are or where they come from, never actually seen them. - foreach (DictionaryEntry h in vars) - m_log.InfoFormat("[WEB SERVICE]: {0} {1} var {2} = {3}", method, reqpath, (string) h.Key, (string) h.Value); + // Ah, viewers send them, and they seem to be identical to the query that viewers also send. +// foreach (DictionaryEntry h in vars) +// m_log.InfoFormat("[WEB SERVICE]: {0} {1} var {2} = {3}", method, reqpath, (string) h.Key, (string) h.Value); reply["int_response_code"] = 200; @@ -305,6 +346,7 @@ namespace OpenSim.Server.Handlers.Web csr.Close(); } } +/* TODO - shelved for now, rewrite it in Lua for lighttpd after the release. else { if ("account.html" == file) @@ -329,15 +371,16 @@ namespace OpenSim.Server.Handlers.Web "404 error, can't find the " + reqpath + " page.

 

"; } } +*/ } else if ("POST" == method) { - if ("account.html" == file) - { - string doit = fields["doit"].ToString(); - string toke_n_munchie = ""; - replyHeaders["Cache-Control"] = "no-cache"; +// if ("account.html" == file) +// { +// string doit = fields["doit"].ToString(); +// string toke_n_munchie = ""; +// replyHeaders["Cache-Control"] = "no-cache"; /* TODO - Switch to using prepared SQL statements. @@ -356,7 +399,7 @@ namespace OpenSim.Server.Handlers.Web Deal with editing yourself. Deal with editing others, but only as god. */ - +/* TODO - shelved for now, rewrite it in Lua for lighttpd after the release. if ((null == cookies["toke_n_munchie"]) || (null == fields["toke_n_munchie"]) || ("" == cookies["toke_n_munchie"].ToString()) || ("" == fields["toke_n_munchie"].ToString())) toke_n_munchie = newSession(doit, headers, ref fields, ref replyHeaders); @@ -417,7 +460,19 @@ namespace OpenSim.Server.Handlers.Web else if (("create" == doit)) reply["str_response_string"] = accountCreationPage(fields, body); else + { + var fromAddress = new MailAddress(m_email_from, (string) ssi["grid"]); + var toAddress = new MailAddress((string) fields["email"], (string) fields["name"]); + using (var message = new MailMessage(fromAddress, toAddress) + { + Subject = "validation email", + Body = "Should be a linky around here somewhere." + }) + { + m_smtp.Send(message); + } reply["str_response_string"] = loggedOnPage(fields, body); + } } else deleteSession(toke_n_munchie.ToString(), doit, headers, ref fields, ref replyHeaders); @@ -446,15 +501,16 @@ namespace OpenSim.Server.Handlers.Web } else reply["str_response_string"] = loggedOnPage(fields, body); - } - else // Not one of our dynamic pages. - { +*/ +// } +// else // Not one of our dynamic pages. +// { m_log.ErrorFormat("[WEB SERVICE]: No such POST target {0}.", path); reply["int_response_code"] = 404; reply["content_type"] = "text/html"; reply["str_response_string"] = "404 Unknown page" + "404 error, can't find the " + reqpath + " page.

 

"; - } +// } } else // Not one of our handled methods. { -- cgit v1.1