Example #1
0
        /// <summary>
        /// Initializes a Greylist agent for use
        /// </summary>
        /// <param name="settings">Settings object with populated settings</param>
        /// <param name="greylistDatabase">Greylist database to use for triplet management</param>
        /// <param name="hashManager">hash manager</param>
        /// <param name="server">Exchange server instance</param>
        public GreyListAgent(GreyListSettings settings, GreyListDatabase greylistDatabase, SHA256Managed hashManager, SmtpServer server, String logPath)
        {
            // Initialize instance variables.
            this.settings = settings;
            this.server = server;
            this.greylistDatabase = greylistDatabase;
            this.testOnEndOfHeaders = false;
            this.hashManager = hashManager;
            this.logPath = logPath;

            // Set up the hooks to have your functions called when certain events occur.
            this.OnRcptCommand += new RcptCommandEventHandler(this.OnRcptCommandHandler);
            this.OnEndOfHeaders += new EndOfHeadersEventHandler(this.OnEndOfHeaderHandler);
        }
        public GreyListAgentFactory()
        {
            // Initialize the hashing engine
            hashManager = new SHA256Managed();

            // Fetch the assembly, and populate paths
            Assembly currAssembly = Assembly.GetAssembly(this.GetType());
            string assemblyPath = Path.GetDirectoryName(currAssembly.Location);
            this.dataPath = Path.Combine(assemblyPath, RelativeDataPath);

            // Load GreyList settings from file
            this.greylistSettings = new GreyListSettings(Path.Combine(this.dataPath, ConfigFileName));

            // Load the database. The database will end up empty if the file doesn't exist or becomes corrupted
            this.greylistDatabase = GreyListDatabase.Load(Path.Combine(this.dataPath, DatabaseFile));
        }
        public GreyListAgentFactory()
        {
            // Initialize the hashing engine
            _hashManager = new SHA256Managed();

            // Fetch the assembly, and populate paths
            var currAssembly = Assembly.GetAssembly(GetType());
            var assemblyPath = Path.GetDirectoryName(currAssembly.Location);
            _configPath = Path.Combine(assemblyPath, Constants.RelativeConfigPath);

            // Configuring Log4Net
            XmlConfigurator.Configure(new FileInfo(Path.Combine(_configPath, Constants.LoggerConfigFileName)));

            // Load GreyList settings from file
            _greylistSettings = GreyListSettings.Load(Path.Combine(_configPath, Constants.AgentConfigFileName));

            // Load the database. The database will end up empty if the file doesn't exist or becomes corrupted
            _greylistDatabase = GreyListDatabase.Load(Path.Combine(_configPath, Constants.DatabaseFile));
        }