Beispiel #1
0
        private void EditSelectedBlockedAttachment()
        {
            if (listBlockedAttachments.SelectedItems.Count < 0)
            {
                return;
            }

            int id = Convert.ToInt32(listBlockedAttachments.SelectedItems[0].Tag);

            hMailServer.Settings           settings          = APICreator.Settings;
            hMailServer.AntiVirus          antiVirusSettings = settings.AntiVirus;
            hMailServer.BlockedAttachments attachments       = antiVirusSettings.BlockedAttachments;
            hMailServer.BlockedAttachment  ba = attachments.get_ItemByDBID(id);

            formBlockedAttachment blockedDlg = new formBlockedAttachment();

            blockedDlg.LoadProperties(ba);

            if (blockedDlg.ShowDialog() == DialogResult.OK)
            {
                blockedDlg.SaveProperties(ba);
                ba.Save();
            }

            Marshal.ReleaseComObject(settings);
            Marshal.ReleaseComObject(antiVirusSettings);
            Marshal.ReleaseComObject(attachments);
            Marshal.ReleaseComObject(ba);

            ListBlockedAttachments();
        }
Beispiel #2
0
        public void LoadData()
        {
            hMailServer.Settings  settings          = APICreator.Application.Settings;
            hMailServer.AntiVirus antiVirusSettings = settings.AntiVirus;

            radioDeleteEmail.Checked       = antiVirusSettings.Action == eAntivirusAction.hDeleteEmail;
            radioDeleteAttachments.Checked = antiVirusSettings.Action == eAntivirusAction.hDeleteAttachments;
            checkNotifySender.Checked      = antiVirusSettings.NotifySender;
            checkNotifyReceiver.Checked    = antiVirusSettings.NotifyReceiver;
            textVirusScanMaxSize.Number    = antiVirusSettings.MaximumMessageSize;

            checkUseClamWin.Checked     = antiVirusSettings.ClamWinEnabled;
            textClamScanExecutable.Text = antiVirusSettings.ClamWinExecutable;
            textClamScanDatabase.Text   = antiVirusSettings.ClamWinDBFolder;

            checkUseCustomScanner.Checked       = antiVirusSettings.CustomScannerEnabled;
            textCustomScannerExecutable.Text    = antiVirusSettings.CustomScannerExecutable;
            textCustomScannerReturnValue.Number = antiVirusSettings.CustomScannerReturnValue;

            checkBlockAttachmentsEnabled.Checked = antiVirusSettings.EnableAttachmentBlocking;

            textClamAVHostName.Text    = antiVirusSettings.ClamAVHost;
            textClamAVPort.Number      = antiVirusSettings.ClamAVPort;
            checkClamAVEnabled.Checked = antiVirusSettings.ClamAVEnabled;

            ListBlockedAttachments();

            EnableDisable();

            Marshal.ReleaseComObject(settings);
            Marshal.ReleaseComObject(antiVirusSettings);
        }
Beispiel #3
0
        private void buttonDeleteBlockedAttachment_Click(object sender, EventArgs e)
        {
            if (!Utility.AskDeleteItems())
            {
                return;
            }

            hMailServer.Settings           settings          = APICreator.Settings;
            hMailServer.AntiVirus          antiVirusSettings = settings.AntiVirus;
            hMailServer.BlockedAttachments attachments       = antiVirusSettings.BlockedAttachments;

            List <ListViewItem> itemsToRemove = new List <ListViewItem>();

            foreach (ListViewItem item in listBlockedAttachments.SelectedItems)
            {
                int id = Convert.ToInt32(item.Tag);
                attachments.DeleteByDBID(id);
                itemsToRemove.Add(item);
            }

            foreach (ListViewItem item in itemsToRemove)
            {
                listBlockedAttachments.Items.Remove(item);
            }

            Marshal.ReleaseComObject(settings);
            Marshal.ReleaseComObject(antiVirusSettings);
            Marshal.ReleaseComObject(attachments);
        }
Beispiel #4
0
        public bool SaveData()
        {
            hMailServer.Settings  settings          = APICreator.Application.Settings;
            hMailServer.AntiVirus antiVirusSettings = settings.AntiVirus;

            antiVirusSettings.Action = radioDeleteEmail.Checked ? eAntivirusAction.hDeleteEmail : eAntivirusAction.hDeleteAttachments;

            antiVirusSettings.NotifySender       = checkNotifySender.Checked;
            antiVirusSettings.NotifyReceiver     = checkNotifyReceiver.Checked;
            antiVirusSettings.MaximumMessageSize = textVirusScanMaxSize.Number;

            antiVirusSettings.ClamWinEnabled    = checkUseClamWin.Checked;
            antiVirusSettings.ClamWinExecutable = textClamScanExecutable.Text;
            antiVirusSettings.ClamWinDBFolder   = textClamScanDatabase.Text;

            antiVirusSettings.CustomScannerEnabled     = checkUseCustomScanner.Checked;
            antiVirusSettings.CustomScannerExecutable  = textCustomScannerExecutable.Text;
            antiVirusSettings.CustomScannerReturnValue = textCustomScannerReturnValue.Number;

            antiVirusSettings.EnableAttachmentBlocking = checkBlockAttachmentsEnabled.Checked;

            antiVirusSettings.ClamAVHost    = textClamAVHostName.Text;
            antiVirusSettings.ClamAVPort    = textClamAVPort.Number;
            antiVirusSettings.ClamAVEnabled = checkClamAVEnabled.Checked;

            DirtyChecker.SetClean(this);

            Marshal.ReleaseComObject(settings);
            Marshal.ReleaseComObject(antiVirusSettings);

            return(true);
        }
Beispiel #5
0
        private void buttonCustomScannerTest_Click(object sender, EventArgs e)
        {
            using (new WaitCursor())
            {
                hMailServer.Settings  settings          = APICreator.Application.Settings;
                hMailServer.AntiVirus antiVirusSettings = settings.AntiVirus;

                string messageText = "";
                bool   testPass    = antiVirusSettings.TestCustomerScanner(textCustomScannerExecutable.Text, textCustomScannerReturnValue.Number, out messageText);

                Marshal.ReleaseComObject(antiVirusSettings);
                Marshal.ReleaseComObject(settings);

                ProcessVirusTestResult(testPass, messageText);
            }
        }
Beispiel #6
0
        private void buttonAddBlockedAttachment_Click(object sender, EventArgs e)
        {
            formBlockedAttachment blockedDlg = new formBlockedAttachment();

            if (blockedDlg.ShowDialog() == DialogResult.OK)
            {
                hMailServer.Settings           settings          = APICreator.Application.Settings;
                hMailServer.AntiVirus          antiVirusSettings = settings.AntiVirus;
                hMailServer.BlockedAttachments attachments       = antiVirusSettings.BlockedAttachments;

                hMailServer.BlockedAttachment ba = attachments.Add();
                blockedDlg.SaveProperties(ba);
                ba.Save();

                Marshal.ReleaseComObject(ba);
                Marshal.ReleaseComObject(settings);
                Marshal.ReleaseComObject(antiVirusSettings);
                Marshal.ReleaseComObject(attachments);
            }

            ListBlockedAttachments();
        }
Beispiel #7
0
        private void ListBlockedAttachments()
        {
            listBlockedAttachments.Items.Clear();

            hMailServer.Settings settings = APICreator.Application.Settings;

            hMailServer.AntiVirus          antiVirusSettings = settings.AntiVirus;
            hMailServer.BlockedAttachments attachments       = antiVirusSettings.BlockedAttachments;

            for (int i = 0; i < attachments.Count; i++)
            {
                hMailServer.BlockedAttachment attachment = attachments[i];

                ListViewItem item = listBlockedAttachments.Items.Add(attachment.Wildcard);
                item.SubItems.Add(attachment.Description);
                item.Tag = attachment.ID;

                Marshal.ReleaseComObject(attachment);
            }

            Marshal.ReleaseComObject(settings);
            Marshal.ReleaseComObject(antiVirusSettings);
            Marshal.ReleaseComObject(attachments);
        }
Beispiel #8
0
        public hMailServer.Domain DoBasicSetup()
        {
            if (application.ServerState == hMailServer.eServerState.hStateStopped)
            {
                application.Start();
            }

            hMailServer.Domain domain = SingletonProvider <Utilities> .Instance.AddTestDomain();

            _settings.SecurityRanges.SetDefault();

            DisableSpamProtection();
            DisableVirusProtection();
            RemoveAllRoutes();
            RemoveAllRules();
            RemoveAllSharedFolders();
            RemoveAllGroups();
            ClearGreyListingWhiteAddresses();
            EnableLogging(true);


            _settings.SSLCertificates.Clear();
            _settings.TCPIPPorts.SetDefault();

            if (_settings.AutoBanOnLogonFailure)
            {
                _settings.AutoBanOnLogonFailure = false;
            }

            if (_settings.SMTPNoOfTries != 0)
            {
                _settings.SMTPNoOfTries = 0;
            }

            if (_settings.SMTPMinutesBetweenTry != 60)
            {
                _settings.SMTPMinutesBetweenTry = 60;
            }

            if (_settings.Scripting.Enabled != false)
            {
                _settings.Scripting.Enabled = false;
            }

            if (_settings.MirrorEMailAddress != "")
            {
                _settings.MirrorEMailAddress = "";
            }

            if (_settings.SMTPRelayer != "")
            {
                _settings.SMTPRelayer = "";
            }

            if (_settings.MaxDeliveryThreads != 50)
            {
                _settings.MaxDeliveryThreads = 50;
            }

            if (_settings.Scripting.Language != "VBScript")
            {
                _settings.Scripting.Language = "VBScript";
            }

            if (_settings.IMAPPublicFolderName != "#Public")
            {
                _settings.IMAPPublicFolderName = "#Public";
            }

            if (_settings.MaxNumberOfInvalidCommands != 3)
            {
                _settings.MaxNumberOfInvalidCommands = 3;
            }

            if (_settings.DisconnectInvalidClients != false)
            {
                _settings.DisconnectInvalidClients = false;
            }

            if (_settings.MaxSMTPRecipientsInBatch != 100)
            {
                _settings.MaxSMTPRecipientsInBatch = 100;
            }

            if (_settings.IMAPHierarchyDelimiter != ".")
            {
                _settings.IMAPHierarchyDelimiter = ".";
            }

            if (_settings.IMAPACLEnabled != true)
            {
                _settings.IMAPACLEnabled = true;
            }

            if (_settings.MaxMessageSize != 20480)
            {
                _settings.MaxMessageSize = 20480;
            }

            if (_settings.MaxNumberOfMXHosts != 15)
            {
                _settings.MaxNumberOfMXHosts = 15;
            }

            hMailServer.AntiVirus antiVirus = _settings.AntiVirus;

            if (antiVirus.ClamAVEnabled)
            {
                antiVirus.ClamAVEnabled = false;
            }

            if (antiVirus.ClamAVPort != 3310)
            {
                antiVirus.ClamAVPort = 3310;
            }

            if (antiVirus.ClamAVHost != "localhost")
            {
                antiVirus.ClamAVHost = "localhost";
            }

            EnableLogging(true);

            if (File.Exists(GetErrorLogFileName()))
            {
                string contents = File.ReadAllText(GetErrorLogFileName());
                Assert.Fail(contents);
            }

            if (File.Exists(GetEventLogFileName()))
            {
                File.Delete(GetEventLogFileName());
            }

            Utilities.AssertRecipientsInDeliveryQueue(0);

            return(domain);
        }
        public new void SetUp()
        {
            Utilities.AssertClamDRunning();

            _antiVirus = _application.Settings.AntiVirus;
        }
Beispiel #10
0
        public new void SetUp()
        {
            Utilities.AssertClamDRunning();

            _antiVirus = _application.Settings.AntiVirus;
        }