Example #1
0
 // dump the current settings
 public void dumpSettings()
 {
     // base/network
     AppGlobals.writeConsole("Host name..................: {0}", AppGlobals.hostName);
     AppGlobals.writeConsole("listen IP..................: {0}", AppGlobals.listenAddress);
     AppGlobals.writeConsole("listen port................: {0}", AppGlobals.listenPort);
     AppGlobals.writeConsole("Receive timeout............: {0}", AppGlobals.receiveTimeout);
     // hardlimits
     AppGlobals.writeConsole("Max errors.................: {0}", AppGlobals.maxSmtpErr);
     AppGlobals.writeConsole("Max NOOP...................: {0}", AppGlobals.maxSmtpNoop);
     AppGlobals.writeConsole("Max VRFY/EXPN..............: {0}", AppGlobals.maxSmtpVrfy);
     AppGlobals.writeConsole("Max RCPT TO................: {0}", AppGlobals.maxSmtpRcpt);
     // sessions
     AppGlobals.writeConsole("Max messages per session...: {0}", AppGlobals.maxMessages);
     AppGlobals.writeConsole("Max parallel sessions......: {0}", AppGlobals.maxSessions);
     // messages
     AppGlobals.writeConsole("Store message data.........: {0}", AppGlobals.storeData);
     AppGlobals.writeConsole("Storage path...............: {0}", AppGlobals.storePath);
     AppGlobals.writeConsole("Max message size...........: {0}", AppGlobals.maxDataSize);
     // logs
     AppGlobals.writeConsole("Logfiles path..............: {0}", AppGlobals.logPath);
     AppGlobals.writeConsole("Verbose logging............: {0}", AppGlobals.logVerbose);
     // tarpitting
     AppGlobals.writeConsole("Initial banner delay.......: {0}", AppGlobals.bannerDelay);
     AppGlobals.writeConsole("Error delay................: {0}", AppGlobals.errorDelay);
     // filtering/rejecting
     AppGlobals.writeConsole("Do tempfail (4xx) on DATA..: {0}", AppGlobals.doTempFail);
     AppGlobals.writeConsole("Check for early talkers....: {0}", AppGlobals.earlyTalkers);
     // DNS filtering
     AppGlobals.writeConsole("DNS Whitelists.............: {0}", AppGlobals.whiteLists.Length);
     AppGlobals.writeConsole("DNS Blacklists.............: {0}", AppGlobals.blackLists.Length);
     // local domains/mailboxes
     AppGlobals.writeConsole("Local domains..............: {0}", AppGlobals.LocalDomains.Count);
     AppGlobals.writeConsole("Local mailboxes............: {0}", AppGlobals.LocalMailBoxes.Count);
 }
Example #2
0
 private void button1_Click(object sender, RoutedEventArgs e)
 {
     button1.IsEnabled = false;
     button2.IsEnabled = true;
     button3.IsEnabled = true;
     if (null != listener)
     {
         try { listener.Stop();
               tokenSource.Cancel();
               AppGlobals.writeConsole("Listening for connections on {0}:{1} is ended.", listenAddr, listenPort);
               AppGlobals.writeLogUI("Listening for connections on {0}:{1} is ended.", listenAddr, listenPort); }
         catch { }
     }
 }
Example #3
0
        private async void button2_Click(object sender, RoutedEventArgs e)
        {
            button1.IsEnabled = true;
            button2.IsEnabled = false;
            button3.IsEnabled = false;

            richTextBox1.Document.Blocks.Clear();
            richTextBox2.Document.Blocks.Clear();
            richTextBox3.Document.Blocks.Clear();

            tokenSource = new CancellationTokenSource();
            CancellationToken ct = tokenSource.Token;

            // load the config
            settingClass.loadConfig();

            settingClass.dumpSettingsLive();

            // tell we're starting up and, if verbose, dump config parameters

            AppGlobals.writeConsole("{0} {1} starting up (NET {2})", AppGlobals.appName, AppGlobals.appVersion, AppGlobals.appRuntime);
            AppGlobals.writeLogUI("{0} {1} starting up (NET {2})", AppGlobals.appName, AppGlobals.appVersion, AppGlobals.appRuntime);

            if (AppGlobals.logVerbose)
            {
                settingClass.dumpSettings();
            }

            // setup the listening IP:port
            listenAddr = AppGlobals.listenIP;
            listenPort = AppGlobals.listenPort;


            // try starting the listener
            try
            {
                listener = new TcpListener(listenAddr, listenPort);
                listener.Start();
            }
            catch (Exception ex)
            {
                AppGlobals.writeConsole("Listener::Error: " + ex.Message);
                AppGlobals.writeLogUI("Listener::Error: " + ex.Message);
            }

            // tell we're ready to accept connections
            AppGlobals.writeConsole("Listening for connections on {0}:{1}", listenAddr, listenPort);
            AppGlobals.writeLogUI("Listening for connections on {0}:{1}", listenAddr, listenPort);

            // run until interrupted (Ctrl-C in our case)
            await Task.Run(() =>
            {
                ct.ThrowIfCancellationRequested();
                while (true)
                {
                    if (ct.IsCancellationRequested)
                    {
                        // Clean up here, then...
                        ct.ThrowIfCancellationRequested();
                    }

                    try
                    {
                        // wait for an incoming connection, accept it and spawn a thread to handle it
                        SMTPsession handler = new SMTPsession(listener.AcceptTcpClient());
                        Thread thread       = new System.Threading.Thread(new ThreadStart(handler.handleSession));

                        thread.Start();
                    }
                    catch (Exception ex)
                    {
                        // we got an error

                        AppGlobals.writeConsole("Handler::Error: " + ex.Message);
                        AppGlobals.writeLogUI("Listening for connections on {0}:{1}", listenAddr, listenPort);
                        //timeToStop = true;
                        break;
                    }
                }
            }, tokenSource.Token);

            // finalize
            if (null != listener)
            {
                try {
                    listener.Stop();
                }
                catch { }
                finally
                {
                    tokenSource.Dispose();
                    AppGlobals.writeConsole("{0} {1} shutting down (NET {2})", AppGlobals.appName, AppGlobals.appVersion, AppGlobals.appRuntime);
                    AppGlobals.writeLogUI("{0} {1} shutting down (NET {2})", AppGlobals.appName, AppGlobals.appVersion, AppGlobals.appRuntime);
                }
            }
        }