Exemplo n.º 1
0
        public void TestPortInUse()
        {
            hMailServer.Application application = SingletonProvider <Utilities> .Instance.GetApp();

            application.Stop();

            var serverSocket = new ServerSocket(1, 25);

            serverSocket.StartListen();

            application.Start();
            TCPSocket sock = new TCPSocket();

            // make sure it's possible to connect to the non blocked port.

            sock.CanConnect(110);
            sock.CanConnect(143);

            //let this our temp server die.
            sock.CanConnect(25);

            // make sure that hMailServer reported an error during start up because the ports were blocked.
            Utilities.AssertReportedError();

            // restart hMailServer again. everything is now back to normal.
            application.Stop();
            application.Start();
            sock.CanConnect(25);
        }
Exemplo n.º 2
0
        public void RestartServer()
        {
            hMailServer.Application application = SingletonProvider <Utilities> .Instance.GetApp();

            for (int i = 0; i < 3; i++)
            {
                application.Stop();

                application.Start();
            }
        }
Exemplo n.º 3
0
        static internal void AskRestartServer()
        {
            if (MessageBox.Show(Strings.Localize("hMailServer needs to be restarted for the changes to take effect.") + Environment.NewLine +
                                Strings.Localize("Do you want to restart hMailServer now?"), EnumStrings.hMailServerAdministrator, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
            {
                using (new WaitCursor())
                {
                    hMailServer.Application application = APICreator.Application;
                    application.Stop();
                    application.Start();

                    MessageBox.Show(Strings.Localize("The hMailServer server has been restarted."), EnumStrings.hMailServerAdministrator, MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
        }
Exemplo n.º 4
0
        private void buttonStartStop_Click(object sender, System.EventArgs e)
        {
            WaitCursor cursor = new WaitCursor();

            switch (_application.ServerState)
            {
            case eServerState.hStateRunning:
                _application.Stop();
                break;

            case eServerState.hStateStopped:
                _application.Start();
                break;
            }

            DisplayServerState();
        }
Exemplo n.º 5
0
        public bool SaveData()
        {
            if (_representedObject == null)
            {
                hMailServer.TCPIPPorts tcpIPPorts = APICreator.TCPIPPortsSettings;
                _representedObject = tcpIPPorts.Add();
                Marshal.ReleaseComObject(tcpIPPorts);
            }

            _representedObject.Address    = textIPAddress.Text;
            _representedObject.PortNumber = textTCPIPPort.Number;
            _representedObject.UseSSL     = checkEnableSSL.Checked;
            _representedObject.Protocol   = (hMailServer.eSessionType)comboProtocol.SelectedValue;

            if (comboSSLCertificate.SelectedValue == null)
            {
                _representedObject.SSLCertificateID = 0;
            }
            else
            {
                _representedObject.SSLCertificateID = (int)comboSSLCertificate.SelectedValue;
            }

            _representedObject.Save();

            DirtyChecker.SetClean(this);

            Utility.RefreshNode(InternalNames.GetPortName(_representedObject));

            if (MessageBox.Show(Strings.Localize("hMailServer needs to be restarted for the changes to take effect.") + Environment.NewLine +
                                Strings.Localize("Do you want to restart hMailServer now?"), EnumStrings.hMailServerAdministrator, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
            {
                using (new WaitCursor())
                {
                    hMailServer.Application application = APICreator.Application;
                    application.Stop();
                    application.Start();

                    MessageBox.Show(Strings.Localize("The hMailServer server has been restarted."), EnumStrings.hMailServerAdministrator, MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }

            return(true);
        }
Exemplo n.º 6
0
        public void TestPortOpening()
        {
            hMailServer.Application oApp = SingletonProvider <Utilities> .Instance.GetApp();

            oApp.Settings.TCPIPPorts.SetDefault();

            SMTPClientSimulator pSMTPSimulator = new SMTPClientSimulator();
            POP3Simulator       pPOP3Simulator = new POP3Simulator();
            IMAPSimulator       pIMAPSimulator = new IMAPSimulator();

            oApp.Stop();

            hMailServer.TCPIPPorts oPorts = oApp.Settings.TCPIPPorts;
            for (int i = 0; i < oPorts.Count; i++)
            {
                hMailServer.TCPIPPort oTestPort = oPorts[i];
                if (oTestPort.Protocol == hMailServer.eSessionType.eSTIMAP)
                {
                    oTestPort.PortNumber = 14300;
                }
                else if (oTestPort.Protocol == hMailServer.eSessionType.eSTSMTP)
                {
                    oTestPort.PortNumber = 11000;
                }
                else if (oTestPort.Protocol == hMailServer.eSessionType.eSTPOP3)
                {
                    oTestPort.PortNumber = 2500;
                }

                oTestPort.Save();
            }

            oApp.Start();

            Assert.IsTrue(pSMTPSimulator.TestConnect(2500));
            Assert.IsTrue(pSMTPSimulator.TestConnect(11000));
            Assert.IsTrue(pSMTPSimulator.TestConnect(14300));

            oApp.Stop();

            hMailServer.TCPIPPort oPort = oApp.Settings.TCPIPPorts.Add();
            oPort.Protocol   = hMailServer.eSessionType.eSTSMTP;
            oPort.PortNumber = 25000;
            oPort.Save();

            oApp.Start();

            // Try to connect to the new port
            Assert.IsTrue(pSMTPSimulator.TestConnect(25000));

            oApp.Stop();

            // Delete the port again
            oApp.Settings.TCPIPPorts.DeleteByDBID(oPort.ID);

            // Change back the ports
            for (int i = 0; i < oPorts.Count; i++)
            {
                hMailServer.TCPIPPort oTestPort = oPorts[i];
                if (oTestPort.Protocol == hMailServer.eSessionType.eSTIMAP)
                {
                    oTestPort.PortNumber = 143;
                }
                else if (oTestPort.Protocol == hMailServer.eSessionType.eSTSMTP)
                {
                    oTestPort.PortNumber = 25;
                }
                else if (oTestPort.Protocol == hMailServer.eSessionType.eSTPOP3)
                {
                    oTestPort.PortNumber = 110;
                }

                oTestPort.Save();
            }

            oApp.Start();

            Assert.IsTrue(pSMTPSimulator.TestConnect(25));
            Assert.IsTrue(pPOP3Simulator.TestConnect(110));
            Assert.IsTrue(pPOP3Simulator.TestConnect(143));
        }
Exemplo n.º 7
0
 public void Stop()
 {
     _object.Stop();
 }