/// <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;

            uint threadCount = m_config.Configs["Network"].GetUInt("HttpThreadCount", 5);

            // find out where we live
            string hostName;

            // been here before?
            if (Utilities.HostName == "")
            {
                hostName = m_config.Configs ["Network"].GetString ("HostName", "0.0.0.0");

                if ((hostName == "") || (hostName == "0.0.0.0"))
                {
                    MainConsole.Instance.Info ("[Network]: Retrieving the external IP address");
                    hostName = "http" + (useHTTPS ? "s" : "") + "://" + Utilities.GetExternalIp ();
                }
            
                //Clean it up a bit
                if (hostName.StartsWith ("http://", StringComparison.OrdinalIgnoreCase) || hostName.StartsWith ("https://", StringComparison.OrdinalIgnoreCase))
                    hostName = hostName.Replace ("https://", "").Replace ("http://", "");
                if (hostName.EndsWith ("/", StringComparison.Ordinal))
                    hostName = hostName.Remove (hostName.Length - 1, 1);
                
                // save this for posterity in case it is needed
                MainConsole.Instance.Info ("[Network]: Network IP address has been set to " + hostName);
                Utilities.HostName = hostName;
            } else
                hostName = Utilities.HostName;

            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);
        }
Esempio n. 2
0
 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>();
 }
Esempio n. 3
0
        /// <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;
            }

            return (m_Servers[port] = server);
        }
 public void FinishedStartup()
 {
     if (IsEnabled () && ! ServerStarted())
     {
         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 ();
     }
 }