Exemple #1
0
        /// <summary>
        /// Get the pop3 server information from
        /// the configuration file, the host and
        /// port of the pop3 server is located in
        /// the default section, this data is used
        /// to connect to the pop3 server.
        /// </summary>
        private void GetPop3ServerHost()
        {
            try
            {
                // Create a new connection adapter.
                _connection = new Pop3ConnectionAdapter();

                // If no host name set then
                // use the defualt values.
                if (String.IsNullOrEmpty(_pop3ServerName))
                {
                    // Create a new default host type
                    // an load the values from the configuration
                    // file into the default host type.
                    ProxyPop3ServerDefaultHost defaultHost =
                        (ProxyPop3ServerDefaultHost)System.Configuration.ConfigurationManager.GetSection(
                            "ProxyPop3ServerGroup/ProxyPop3ServerDefaultHost");

                    // If the port is greater than zero then
                    // assign the port number.
                    if (defaultHost.HostSection.PortAttribute > 0)
                    {
                        _connection.Port = defaultHost.HostSection.PortAttribute;
                    }

                    // Get the pop3 server.
                    _connection.Server = defaultHost.HostSection.HostAttribute;
                }
                else
                {
                    // Create a new host type
                    // an load the values from the configuration
                    // file into the host type.
                    ProxyPop3ServerHosts hosts =
                        (ProxyPop3ServerHosts)System.Configuration.ConfigurationManager.GetSection(
                            "ProxyPop3ServerGroup/ProxyPop3ServerHosts");

                    // If the port is greater than zero then
                    // assign the port number.
                    if (hosts.HostSection[_pop3ServerName].PortAttribute > 0)
                    {
                        _connection.Port = hosts.HostSection[_pop3ServerName].PortAttribute;
                    }

                    // Get the pop3 server.
                    _connection.Server = hosts.HostSection[_pop3ServerName].HostAttribute;
                }
            }
            catch (Exception e)
            {
                // Detect a thread abort exception.
                if (e is ThreadAbortException)
                {
                    Thread.ResetAbort();
                }

                base.Write("Pop3SslProxyServer", "GetListeningPort", e.Message,
                           246, WriteTo.EventLog, LogType.Error);
            }
        }
Exemple #2
0
        /// <summary>
        /// Get the maximum number of clients from the configuration
        /// file, if no value is specified then default or
        /// the current value will be used.
        /// </summary>
        private void GetMaxNumClients()
        {
            try
            {
                // If no host name set then
                // use the defualt values.
                if (String.IsNullOrEmpty(_hostName))
                {
                    // Create a new default host type
                    // an load the values from the configuration
                    // file into the default host type.
                    ProxyPop3ServerDefaultHost defaultHost =
                        (ProxyPop3ServerDefaultHost)System.Configuration.ConfigurationManager.GetSection(
                            "ProxyPop3ServerGroup/ProxyPop3ServerDefaultHost");

                    // If the value is greater than zero then
                    // assign the port number.
                    if (defaultHost.HostSection.MaxNumClientsAttribute > 0)
                    {
                        _maxNumClients = defaultHost.HostSection.MaxNumClientsAttribute;
                    }
                }
                else
                {
                    // Create a new host type
                    // an load the values from the configuration
                    // file into the host type.
                    ProxyPop3ServerHosts hosts =
                        (ProxyPop3ServerHosts)System.Configuration.ConfigurationManager.GetSection(
                            "ProxyPop3ServerGroup/ProxyPop3ServerHosts");

                    // If the value is greater than zero then
                    // assign the port number.
                    if (hosts.HostSection[_hostName].MaxNumClientsAttribute > 0)
                    {
                        _maxNumClients = hosts.HostSection[_hostName].MaxNumClientsAttribute;
                    }
                }

                // Create a new client array.
                _client = new Pop3SslProxyConnection[_maxNumClients];
            }
            catch (Exception e)
            {
                // Detect a thread abort exception.
                if (e is ThreadAbortException)
                {
                    Thread.ResetAbort();
                }

                base.Write("Pop3SslProxyServer", "GetMaxNumClients", e.Message,
                           246, WriteTo.EventLog, LogType.Error);
            }
        }