public IHttpServer GetHttpServer (uint port, bool secure, string certPath, string certPass, SslProtocols sslProtocol) { if ((port == m_Port || port == 0) && HttpServer != null) return HttpServer; BaseHttpServer server; if(m_Servers.TryGetValue(port, out server) && server.Secure == secure) return server; string hostName = m_config.Configs["Network"].GetString("HostName", "http" + (secure ? "s" : "") + "://" + Utilities.GetExternalIp()); //Clean it up a bit if (hostName.StartsWith("http://") || hostName.StartsWith("https://")) hostName = hostName.Replace("https://", "").Replace("http://", ""); if (hostName.EndsWith ("/")) hostName = hostName.Remove (hostName.Length - 1, 1); server = new BaseHttpServer(port, hostName, secure); try { if(secure)//Set these params now server.SetSecureParams(certPath, certPass, sslProtocol); server.Start(); } catch(Exception) { //Remove the server from the list m_Servers.Remove (port); //Then pass the exception upwards throw; } return (m_Servers[port] = server); }
/// <summary> /// Get an HTTPServer on the given port. It will create one if one does not exist /// </summary> /// <param name="port"></param> /// <returns></returns> public IHttpServer GetHttpServer(uint port) { if ((port == m_Port || port == 0) && HttpServer != null) return HttpServer; bool useHTTPS = m_config.Configs["Network"].GetBoolean("use_https", false); IHttpServer server; if (m_Servers.TryGetValue(port, out server) && server.Secure == useHTTPS) return server; string hostName = m_config.Configs["Network"].GetString("HostName", "http" + (useHTTPS ? "s" : "") + "://" + Utilities.GetExternalIp()); uint threadCount = m_config.Configs["Network"].GetUInt("HttpThreadCount", 5); //Clean it up a bit if (hostName.StartsWith("http://") || hostName.StartsWith("https://")) hostName = hostName.Replace("https://", "").Replace("http://", ""); if (hostName.EndsWith("/")) hostName = hostName.Remove(hostName.Length - 1, 1); server = new BaseHttpServer(port, hostName, useHTTPS, threadCount); try { server.Start(); } catch (Exception) { //Remove the server from the list m_Servers.Remove(port); //Then pass the exception upwards throw; } if (m_Servers.Count == 0) MainServer.Instance = server; return (m_Servers[port] = server); }
public void RegionLoaded(IScene scene) { if (IsEnabled() && !m_httpServerStarted) { m_httpServerStarted = true; // Start http server // Attach xmlrpc handlers MainConsole.Instance.Info("[XMLRPC MODULE]: " + "Starting up XMLRPC Server on port " + m_remoteDataPort + " for llRemoteData commands."); IHttpServer httpServer = new BaseHttpServer((uint) m_remoteDataPort, MainServer.Instance.HostName, false, 1); httpServer.AddXmlRPCHandler("llRemoteData", XmlRpcRemoteData); httpServer.Start(); } m_scriptModule = scene.RequestModuleInterface<IScriptModule>(); }