keep a unsecure http port up for external services (datasnapshot search). Only fire poolservices on main http listener

httptests
UbitUmarov 2016-10-09 20:18:20 +01:00
parent 7aa4bd7006
commit 80d4f76d18
4 changed files with 66 additions and 36 deletions

View File

@ -111,7 +111,6 @@ namespace OpenSim.Framework.Servers.HttpServer
protected uint m_sslport; protected uint m_sslport;
protected bool m_ssl; protected bool m_ssl;
private X509Certificate2 m_cert; private X509Certificate2 m_cert;
protected bool m_firstcaps = true;
protected string m_SSLCommonName = ""; protected string m_SSLCommonName = "";
protected List<string> m_certNames = new List<string>(); protected List<string> m_certNames = new List<string>();
protected List<string> m_certIPs = new List<string>(); protected List<string> m_certIPs = new List<string>();
@ -152,11 +151,6 @@ namespace OpenSim.Framework.Servers.HttpServer
m_port = port; m_port = port;
} }
public BaseHttpServer(uint port, bool ssl) : this (port)
{
m_ssl = ssl;
}
private void load_cert(string CPath, string CPass) private void load_cert(string CPath, string CPass)
{ {
try try
@ -216,21 +210,24 @@ namespace OpenSim.Framework.Servers.HttpServer
if(m_cert.Issuer == m_cert.Subject ) if(m_cert.Issuer == m_cert.Subject )
m_log.Warn("Self signed certificate. Clients need to allow this (some viewers debug option NoVerifySSLcert must be set to true"); m_log.Warn("Self signed certificate. Clients need to allow this (some viewers debug option NoVerifySSLcert must be set to true");
} }
else else
m_ssl = false; m_ssl = false;
} }
public BaseHttpServer(uint port, bool ssl, string CPath, string CPass) : this (port, ssl) public BaseHttpServer(uint port, bool ssl, string CPath, string CPass)
{ {
if (m_ssl) m_port = port;
if (ssl)
{ {
load_cert(CPath, CPass); load_cert(CPath, CPass);
if(m_cert.Issuer == m_cert.Subject ) if(m_cert.Issuer == m_cert.Subject )
m_log.Warn("Self signed certificate. Http clients need to allow this"); m_log.Warn("Self signed certificate. Http clients need to allow this");
m_ssl = true;
m_sslport = port;
} }
else
m_ssl = false;
} }
static bool MatchDNS (string hostname, string dns) static bool MatchDNS (string hostname, string dns)
@ -2038,7 +2035,7 @@ namespace OpenSim.Framework.Servers.HttpServer
public void Start() public void Start()
{ {
Start(true); Start(true,true);
} }
/// <summary> /// <summary>
@ -2048,7 +2045,7 @@ namespace OpenSim.Framework.Servers.HttpServer
/// If true then poll responses are performed asynchronsly. /// If true then poll responses are performed asynchronsly.
/// Option exists to allow regression tests to perform processing synchronously. /// Option exists to allow regression tests to perform processing synchronously.
/// </param> /// </param>
public void Start(bool performPollResponsesAsync) public void Start(bool performPollResponsesAsync, bool runPool)
{ {
m_log.InfoFormat( m_log.InfoFormat(
"[BASE HTTP SERVER]: Starting {0} server on port {1}", UseSSL ? "HTTPS" : "HTTP", Port); "[BASE HTTP SERVER]: Starting {0} server on port {1}", UseSSL ? "HTTPS" : "HTTP", Port);
@ -2086,9 +2083,11 @@ namespace OpenSim.Framework.Servers.HttpServer
m_httpListener2.Start(64); m_httpListener2.Start(64);
// Long Poll Service Manager with 3 worker threads a 25 second timeout for no events // Long Poll Service Manager with 3 worker threads a 25 second timeout for no events
if(runPool)
PollServiceRequestManager = new PollServiceRequestManager(this, performPollResponsesAsync, 2, 25000); {
PollServiceRequestManager.Start(); PollServiceRequestManager = new PollServiceRequestManager(this, performPollResponsesAsync, 2, 25000);
PollServiceRequestManager.Start();
}
HTTPDRunning = true; HTTPDRunning = true;

View File

@ -42,6 +42,7 @@ namespace OpenSim.Framework.Servers
// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private static BaseHttpServer instance = null; private static BaseHttpServer instance = null;
private static BaseHttpServer unsecureinstance = null;
private static Dictionary<uint, BaseHttpServer> m_Servers = new Dictionary<uint, BaseHttpServer>(); private static Dictionary<uint, BaseHttpServer> m_Servers = new Dictionary<uint, BaseHttpServer>();
/// <summary> /// <summary>
@ -93,6 +94,21 @@ namespace OpenSim.Framework.Servers
} }
} }
public static BaseHttpServer ÚnSecureInstance
{
get { return unsecureinstance; }
set
{
lock (m_Servers)
if (!m_Servers.ContainsValue(value))
throw new Exception("HTTP server must already have been registered to be set as the main instance");
unsecureinstance = value;
}
}
/// <summary> /// <summary>
/// Get all the registered servers. /// Get all the registered servers.
/// </summary> /// </summary>

View File

@ -69,23 +69,38 @@ namespace OpenSim
Initialize(); Initialize();
m_httpServer uint mainport = m_networkServersInfo.HttpListenerPort;
= new BaseHttpServer( uint mainSSLport =m_networkServersInfo.httpSSLPort;
m_httpServerPort, m_networkServersInfo.HttpUsesSSL,
m_networkServersInfo.httpSSLPort, m_networkServersInfo.HttpSSLCN,
m_networkServersInfo.HttpSSLCertPath, m_networkServersInfo.HttpSSLCNCertPass);
/* why this? we only run one if (m_networkServersInfo.HttpUsesSSL && (mainport == mainSSLport))
if (m_networkServersInfo.HttpUsesSSL && (m_networkServersInfo.HttpListenerPort == m_networkServersInfo.httpSSLPort))
{ {
m_log.Error("[REGION SERVER]: HTTP Server config failed. HTTP Server and HTTPS server must be on different ports"); m_log.Error("[REGION SERVER]: HTTP Server config failed. HTTP Server and HTTPS server must be on different ports");
} }
*/
m_log.InfoFormat("[REGION SERVER]: Starting HTTP{0} server on port {1}",
m_networkServersInfo.HttpUsesSSL ? "S" : "", m_httpServerPort);
m_httpServer.Start();
MainServer.AddHttpServer(m_httpServer); if(m_networkServersInfo.HttpUsesSSL)
{
m_httpServer = new BaseHttpServer(
mainSSLport, m_networkServersInfo.HttpUsesSSL,
mainSSLport, m_networkServersInfo.HttpSSLCN,
m_networkServersInfo.HttpSSLCertPath, m_networkServersInfo.HttpSSLCNCertPass);
m_httpServer.Start(true,true);
MainServer.AddHttpServer(m_httpServer);
}
// unsecure main server
BaseHttpServer server = new BaseHttpServer(mainport);
if(!m_networkServersInfo.HttpUsesSSL)
{
m_httpServer = server;
server.Start(true, true);
}
else
server.Start(false, false);
MainServer.AddHttpServer(server);
MainServer.ÚnSecureInstance = server;
MainServer.Instance = m_httpServer; MainServer.Instance = m_httpServer;
// "OOB" Server // "OOB" Server
@ -93,22 +108,22 @@ namespace OpenSim
{ {
if (!m_networkServersInfo.ssl_external) if (!m_networkServersInfo.ssl_external)
{ {
BaseHttpServer server = new BaseHttpServer( server = new BaseHttpServer(
m_networkServersInfo.https_port, m_networkServersInfo.ssl_listener, m_networkServersInfo.cert_path, m_networkServersInfo.https_port, m_networkServersInfo.ssl_listener,
m_networkServersInfo.cert_path,
m_networkServersInfo.cert_pass); m_networkServersInfo.cert_pass);
m_log.InfoFormat("[REGION SERVER]: Starting HTTPS server on port {0}", server.Port); m_log.InfoFormat("[REGION SERVER]: Starting OOB HTTPS server on port {0}", server.SSLPort);
server.Start(false, false);
MainServer.AddHttpServer(server); MainServer.AddHttpServer(server);
server.Start();
} }
else else
{ {
BaseHttpServer server = new BaseHttpServer( server = new BaseHttpServer(m_networkServersInfo.https_port);
m_networkServersInfo.https_port);
m_log.InfoFormat("[REGION SERVER]: Starting HTTP server on port {0} for external HTTPS", server.Port); m_log.InfoFormat("[REGION SERVER]: Starting HTTP server on port {0} for external HTTPS", server.Port);
server.Start(false, false);
MainServer.AddHttpServer(server); MainServer.AddHttpServer(server);
server.Start();
} }
} }

View File

@ -52,12 +52,12 @@ namespace OpenSim.Region.DataSnapshot
m_externalData = externalData; m_externalData = externalData;
//Register HTTP handler //Register HTTP handler
if (MainServer.Instance.AddHTTPHandler("collector", OnGetSnapshot)) if (MainServer.ÚnSecureInstance.AddHTTPHandler("collector", OnGetSnapshot))
{ {
m_log.Info("[DATASNAPSHOT]: Set up snapshot service"); m_log.Info("[DATASNAPSHOT]: Set up snapshot service");
} }
// Register validation callback handler // Register validation callback handler
MainServer.Instance.AddHTTPHandler("validate", OnValidate); MainServer.ÚnSecureInstance.AddHTTPHandler("validate", OnValidate);
} }