Example #1
0
        // -----------------------------------------------------------------
        /// <summary>
        /// Initialise this shared module
        /// </summary>
        /// <param name="scene">this region is getting initialised</param>
        /// <param name="source">nini config, we are not using this</param>
        // -----------------------------------------------------------------
        public void Initialise(IConfigSource config)
        {
            try
            {
                if ((m_config = config.Configs["Dispatcher"]) == null)
                {
                    // There is no configuration, the module is disabled
                    m_log.InfoFormat("[Dispatcher] no configuration info");
                    return;
                }

                m_enabled = m_config.GetBoolean("Enabled", m_enabled);
                if (m_enabled)
                {
                    IPAddress[] ips = Dns.GetHostAddresses(Dns.GetHostName());
                    m_host = ips[0].ToString();

                    m_host     = m_config.GetString("HostAddress", m_host);
                    m_udpport  = m_config.GetInt("UDPPort", m_udpport);
                    m_abinding = String.Format("{0}:{1}", m_host, m_udpport);

                    m_httppath = m_config.GetString("HTTPPath", m_httppath);
                    if (!m_httppath.StartsWith("/"))
                    {
                        m_httppath = "/" + m_httppath;
                    }
                    if (!m_httppath.EndsWith("/"))
                    {
                        m_httppath = m_httppath + "/";
                    }
                    m_sbinding = String.Format("http://{0}:{1}{2}", m_host, MainServer.Instance.Port, m_httppath);

                    m_maxRequestThreads = m_config.GetInt("MaxAsyncThreads", m_maxRequestThreads);
                    m_maxInterPingTime  = m_config.GetInt("MaxInterPingTime", m_maxInterPingTime);

                    m_authorizer      = new AuthHandlers(m_config, this);
                    m_infohandler     = new InfoHandlers(m_config, this);
                    m_endpointhandler = new EndPointHandlers(m_config, this);

                    m_commands = new DispatcherCommandModule(m_config, this);
                }
            }
            catch (Exception e)
            {
                m_log.ErrorFormat("[Dispatcher] initialization error: {0}", e.Message);
                return;
            }

            m_log.WarnFormat("[Dispatcher] module {0} enabled, udp binding {1}, http binding {2}",
                             (m_enabled ? "is" : "is not"), m_abinding, m_sbinding);
        }
        // -----------------------------------------------------------------
        /// <summary>
        /// Initialise this shared module
        /// </summary>
        /// <param name="scene">this region is getting initialised</param>
        /// <param name="source">nini config, we are not using this</param>
        // -----------------------------------------------------------------
        public void Initialise(IConfigSource config)
        {
            try 
            {
                if ((m_config = config.Configs["Dispatcher"]) == null)
                {
                    // There is no configuration, the module is disabled
                    m_log.InfoFormat("[Dispatcher] no configuration info");
                    return;
                }

                m_enabled = m_config.GetBoolean("Enabled", m_enabled);
                if (m_enabled)
                {
                    IPAddress[] ips = Dns.GetHostAddresses(Dns.GetHostName());
                    m_host = ips[0].ToString();

                    m_host = m_config.GetString("HostAddress",m_host);
                    m_udpport = m_config.GetInt("UDPPort",m_udpport);
                    m_abinding = String.Format("{0}:{1}",m_host,m_udpport);

                    m_httppath = m_config.GetString("HTTPPath",m_httppath);
                    if (! m_httppath.StartsWith("/"))
                        m_httppath = "/" + m_httppath;
                    if (! m_httppath.EndsWith("/"))
                        m_httppath = m_httppath + "/";
                    m_sbinding = String.Format("http://{0}:{1}{2}",m_host,MainServer.Instance.Port,m_httppath);

                    m_maxRequestThreads = m_config.GetInt("MaxAsyncThreads",m_maxRequestThreads);
                    m_maxInterPingTime = m_config.GetInt("MaxInterPingTime",m_maxInterPingTime);

                    m_authorizer = new AuthHandlers(m_config,this);
                    m_infohandler = new InfoHandlers(m_config,this);
                    m_endpointhandler = new EndPointHandlers(m_config,this);

                    m_commands = new DispatcherCommandModule(m_config,this);
                }
            }
            catch (Exception e)
            {
                m_log.ErrorFormat("[Dispatcher] initialization error: {0}",e.Message);
                return;
            }

            m_log.WarnFormat("[Dispatcher] module {0} enabled, udp binding {1}, http binding {2}",
                             (m_enabled ? "is" : "is not"),m_abinding,m_sbinding);
        }
Example #3
0
        // -----------------------------------------------------------------
        /// <summary>
        /// Initialise this shared module
        /// </summary>
        /// <param name="scene">this region is getting initialised</param>
        /// <param name="source">nini config, we are not using this</param>
        // -----------------------------------------------------------------
        public void Initialise(IConfigSource config)
        {
            try
            {
                string configFileName = "Dispatcher.ini";
                string configFilePath;
                bool   created;

                if (!Util.MergeConfigurationFile(config, configFileName, "", out configFilePath, out created))
                {
                    string exampleConfigFile = Path.Combine(AssemblyDirectory, "Dispatcher.ini.example");
                    m_log.WarnFormat("[Dispatcher] please edit configuration at {0} before running this module, an example can be found at {1}",
                                     configFilePath, exampleConfigFile);
                }

                if ((m_config = config.Configs["Dispatcher"]) == null)
                {
                    // There is no configuration, the module is disabled
                    m_log.InfoFormat("[Dispatcher] no configuration info, module disabled");
                    return;
                }

                m_enabled = m_config.GetBoolean("Enabled", m_enabled);
                if (m_enabled)
                {
                    IPAddress[] ips = Dns.GetHostAddresses(Dns.GetHostName());
                    m_host = ips[0].ToString();

                    m_host     = m_config.GetString("HostAddress", m_host);
                    m_udpport  = m_config.GetInt("UDPPort", m_udpport);
                    m_abinding = String.Format("{0}:{1}", m_host, m_udpport);

                    m_httppath = m_config.GetString("HTTPPath", m_httppath);
                    if (!m_httppath.StartsWith("/"))
                    {
                        m_httppath = "/" + m_httppath;
                    }
                    if (!m_httppath.EndsWith("/"))
                    {
                        m_httppath = m_httppath + "/";
                    }
                    m_sbinding = String.Format("http://{0}:{1}{2}", m_host, MainServer.Instance.Port, m_httppath);

                    m_maxRequestThreads = m_config.GetInt("MaxAsyncThreads", m_maxRequestThreads);
                    m_maxInterPingTime  = m_config.GetInt("MaxInterPingTime", m_maxInterPingTime);

                    m_filterIPs     = m_config.GetBoolean("UseIPAddressFiltering", m_filterIPs);
                    m_filterPattern = m_config.GetString("AcceptableIPAddressPattern", m_filterPattern);
                    if (!String.IsNullOrEmpty(m_filterPattern))
                    {
                        try
                        {
                            m_filterRegex = new Regex(m_filterPattern);
                            //m_log.DebugFormat("[Dispatcher] filtering ip addresses with pattern <{0}>",m_filterPattern);
                        }
                        catch (Exception e)
                        {
                            m_log.WarnFormat("[Dispatcher] failed to parse regular expression in AcceptableIPAddressPattern");
                            m_filterRegex = null;
                        }
                    }

                    m_authorizer      = new AuthHandlers(m_config, this);
                    m_infohandler     = new InfoHandlers(m_config, this);
                    m_endpointhandler = new EndPointHandlers(m_config, this);

                    m_commands = new DispatcherCommandModule(m_config, this);
                }
            }
            catch (Exception e)
            {
                m_log.ErrorFormat("[Dispatcher] initialization error: {0}", e.Message);
                return;
            }

            m_log.WarnFormat("[Dispatcher] module {0} enabled, udp binding {1}, http binding {2}",
                             (m_enabled ? "is" : "is not"), m_abinding, m_sbinding);
        }
        // -----------------------------------------------------------------
        /// <summary>
        /// Initialise this shared module
        /// </summary>
        /// <param name="scene">this region is getting initialised</param>
        /// <param name="source">nini config, we are not using this</param>
        // -----------------------------------------------------------------
        public void Initialise(IConfigSource config)
        {
            try 
            {
                string configFileName = "Dispatcher.ini";
                string configFilePath;
                bool created;

                if (! Util.MergeConfigurationFile(config, configFileName, "", out configFilePath, out created))
                {
                    string exampleConfigFile = Path.Combine(AssemblyDirectory, "Dispatcher.ini.example");
                    m_log.WarnFormat("[Dispatcher] please edit configuration at {0} before running this module, an example can be found at {1}",
                                     configFilePath, exampleConfigFile);
                }

                if ((m_config = config.Configs["Dispatcher"]) == null)
                {
                    // There is no configuration, the module is disabled
                    m_log.InfoFormat("[Dispatcher] no configuration info, module disabled");
                    return;
                }

                m_enabled = m_config.GetBoolean("Enabled", m_enabled);
                if (m_enabled)
                {
                    IPAddress[] ips = Dns.GetHostAddresses(Dns.GetHostName());
                    m_host = ips[0].ToString();

                    m_host = m_config.GetString("HostAddress",m_host);
                    m_udpport = m_config.GetInt("UDPPort",m_udpport);
                    m_abinding = String.Format("{0}:{1}",m_host,m_udpport);

                    m_httppath = m_config.GetString("HTTPPath",m_httppath);
                    if (! m_httppath.StartsWith("/"))
                        m_httppath = "/" + m_httppath;
                    if (! m_httppath.EndsWith("/"))
                        m_httppath = m_httppath + "/";
                    m_sbinding = String.Format("http://{0}:{1}{2}",m_host,MainServer.Instance.Port,m_httppath);

                    m_maxRequestThreads = m_config.GetInt("MaxAsyncThreads",m_maxRequestThreads);
                    m_maxInterPingTime = m_config.GetInt("MaxInterPingTime",m_maxInterPingTime);

                    m_filterIPs = m_config.GetBoolean("UseIPAddressFiltering",m_filterIPs);
                    m_filterPattern = m_config.GetString("AcceptableIPAddressPattern",m_filterPattern);
                    if (! String.IsNullOrEmpty(m_filterPattern))
                    {
                        try
                        {
                            m_filterRegex = new Regex(m_filterPattern);
                            //m_log.DebugFormat("[Dispatcher] filtering ip addresses with pattern <{0}>",m_filterPattern);
                        }
                        catch (Exception e)
                        {
                            m_log.WarnFormat("[Dispatcher] failed to parse regular expression in AcceptableIPAddressPattern");
                            m_filterRegex = null;
                        }
                    }

                    m_authorizer = new AuthHandlers(m_config,this);
                    m_infohandler = new InfoHandlers(m_config,this);
                    m_endpointhandler = new EndPointHandlers(m_config,this);

                    m_commands = new DispatcherCommandModule(m_config,this);
                }
            }
            catch (Exception e)
            {
                m_log.ErrorFormat("[Dispatcher] initialization error: {0}",e.Message);
                return;
            }

            m_log.WarnFormat("[Dispatcher] module {0} enabled, udp binding {1}, http binding {2}",
                             (m_enabled ? "is" : "is not"),m_abinding,m_sbinding);
        }