Exemplo n.º 1
0
        public ucIPRange(int securityRangeID)
        {
            InitializeComponent();

            if (securityRangeID > 0)
            {
                hMailServer.SecurityRanges securityRanges = APICreator.SecurityRanges;

                try
                {
                    _representedObject = securityRanges.get_ItemByDBID(securityRangeID);
                }
                catch (Exception)
                {
                    MessageBox.Show(Strings.Localize("The IP range does not exist."), EnumStrings.hMailServerAdministrator, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);

                    this.Enabled = false;
                }

                Marshal.ReleaseComObject(securityRanges);
            }

            DirtyChecker.SubscribeToChange(this, OnContentChanged);
            new TabOrderManager(this).SetTabOrder(TabOrderManager.TabScheme.AcrossFirst);
            dateTimeExpiresTime.Value = DateTime.Now;

            EnableDisable();
        }
Exemplo n.º 2
0
        public void OnDeleteObject(object sender, EventArgs args)
        {
            if (Utility.AskDeleteItem(_securityRangeTitle))
            {
                hMailServer.SecurityRanges securityRanges = APICreator.SecurityRanges;
                securityRanges.DeleteByDBID(_securityRangeID);
                Marshal.ReleaseComObject(securityRanges);

                Instances.MainForm.RefreshParentNode();
            }
        }
Exemplo n.º 3
0
        private void buttonDefault_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show(Strings.Localize("This operation will change the configuration of the IP ranges back to their default values. Are you sure you want to do this?"), EnumStrings.hMailServerAdministrator, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
            {
                hMailServer.Application app = APICreator.Application;

                hMailServer.Settings       settings       = app.Settings;
                hMailServer.SecurityRanges securityRanges = settings.SecurityRanges;

                securityRanges.SetDefault();

                Marshal.ReleaseComObject(settings);
                Marshal.ReleaseComObject(securityRanges);

                LoadList();

                Instances.MainForm.RefreshCurrentNode(null);
            }
        }
Exemplo n.º 4
0
        private void DisplayWarnings()
        {
            listWarnings.Items.Clear();

            hMailServer.Settings settings = APICreator.Application.Settings;

            if (settings.HostName.Length == 0)
            {
                AddWarning("W001", Strings.Localize("High"), Strings.Localize("You haven't specified the public host name for this computer in the SMTP settings."));
            }

            if (settings.DenyMailFromNull)
            {
                AddWarning("W002", Strings.Localize("High"), Strings.Localize("You have configured hMailServer not to allow email with empty sender address. Many email server will not accept email from your server with this configuration."));
            }

            int autobanRanges = 0;

            // Check if External to external is enabled in any of the IP ranges.
            hMailServer.SecurityRanges ranges = settings.SecurityRanges;
            for (int i = 0; i < ranges.Count; i++)
            {
                hMailServer.SecurityRange range = ranges[i];

                if (range.AllowDeliveryFromRemoteToRemote && !range.RequireSMTPAuthExternalToExternal)
                {
                    string warning =
                        Strings.Localize("hMailServer is configured to allow deliveries from external to external accounts in the IP range %s. This may make the server vulnerable to spam. It is recommended that you disable this option.");

                    warning = warning.Replace("%s", range.Name);

                    AddWarning("W003", Strings.Localize("Critical"), warning);
                }

                if (range.LowerIP == "127.0.0.1" && range.UpperIP == "127.0.0.1" && range.Expires)
                {
                    string warning =
                        Strings.Localize("Localhost is currently banned in the IP ranges.");

                    AddWarning("W004", Strings.Localize("High"), warning);
                }

                if (range.Expires)
                {
                    autobanRanges += 1;
                }

                Marshal.ReleaseComObject(range);
            }

            if (autobanRanges > 0)
            {
                string warning =
                    Strings.Localize("There is a total of %s auto-ban IP ranges.");

                warning = warning.Replace("%s", autobanRanges.ToString());

                AddWarning("W005", Strings.Localize("Medium"), warning);
            }


            Marshal.ReleaseComObject(ranges);
            Marshal.ReleaseComObject(settings);
        }
Exemplo n.º 5
0
        public bool SaveData()
        {
            bool newObject = false;

            if (_representedObject == null)
            {
                hMailServer.Application    app            = APICreator.Application;
                hMailServer.Settings       settings       = app.Settings;
                hMailServer.SecurityRanges securityRanges = settings.SecurityRanges;
                _representedObject = securityRanges.Add();

                newObject = true;

                Marshal.ReleaseComObject(settings);
                Marshal.ReleaseComObject(securityRanges);
            }

            _representedObject.Name     = textName.Text;
            _representedObject.Priority = textPriority.Number;

            _representedObject.LowerIP = textLowerIPAddress.Text;
            _representedObject.UpperIP = textUpperIPAddress.Text;

            _representedObject.AllowSMTPConnections = checkAllowSMTP.Checked;
            _representedObject.AllowPOP3Connections = checkAllowPOP3.Checked;
            _representedObject.AllowIMAPConnections = checkAllowIMAP.Checked;

            _representedObject.RequireSMTPAuthLocalToLocal       = checkRequireSMTPAuthLocalToLocal.Checked;
            _representedObject.RequireSMTPAuthLocalToExternal    = checkRequireSMTPAuthLocalToExternal.Checked;
            _representedObject.RequireSMTPAuthExternalToLocal    = checkRequireSMTPAuthExternalToLocal.Checked;
            _representedObject.RequireSMTPAuthExternalToExternal = checkRequireSMTPAuthExternalToExternal.Checked;

            _representedObject.AllowDeliveryFromLocalToLocal   = checkAllowDeliveiesFromL2L.Checked;
            _representedObject.AllowDeliveryFromLocalToRemote  = checkAllowDeliveiesFromL2R.Checked;
            _representedObject.AllowDeliveryFromRemoteToLocal  = checkAllowDeliveiesFromR2L.Checked;
            _representedObject.AllowDeliveryFromRemoteToRemote = checkAllowDeliveiesFromR2R.Checked;

            _representedObject.EnableSpamProtection = checkSpamProtection.Checked;
            _representedObject.EnableAntiVirus      = checkAntiVirus.Checked;

            _representedObject.Expires     = checkExpires.Checked;
            _representedObject.ExpiresTime = dateTimeExpiresTime.Value;

            try
            {
                _representedObject.Save();
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message, EnumStrings.hMailServerAdministrator, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return(false);
            }


            // Refresh the node in the tree if the name has changed.
            IMainForm mainForm = Instances.MainForm;

            mainForm.RefreshCurrentNode(checkExpires.Checked ? Color.Red : Color.Black, textName.Text);

            // Set the object to clean.
            DirtyChecker.SetClean(this);

            if (newObject)
            {
                SearchNodeText crit = new SearchNodeText(_representedObject.Name);
                mainForm.SelectNode(crit);
            }

            return(true);
        }
Exemplo n.º 6
0
 public new void SetUp()
 {
     _ipRanges = SingletonProvider <Utilities> .Instance.GetApp().Settings.SecurityRanges;
 }
Exemplo n.º 7
0
 public new void SetUp()
 {
     _ipRanges = SingletonProvider<Utilities>.Instance.GetApp().Settings.SecurityRanges;
 }