Example #1
1
 /// <summary>
 /// Ping an email to check if email is valid
 /// </summary>
 /// <param name="address">email address to check</param>
 /// <param name="server">mx server to check</param>
 /// <param name="timeout">check timeout</param>
 /// <returns></returns>
 public static async Task<PingStatus> PingAsync(string address, string server, TimeSpan timeout)
 {
     using (var client = new Client(server, 25, new CancellationToken()))
     {
         if (!client.IsConnected) return PingStatus.NotConnected;
         await client.WriteLine("HELO here.com");
         var s = await client.TerminatedReadAsync(">", timeout);
         if (!s.Contains("250")) return PingStatus.NotConnected;
         await client.WriteLine("MAIL FROM:<*****@*****.**>");
         s = await client.TerminatedReadAsync(">", timeout);
         if (!s.Contains("250")) return PingStatus.NotConnected;
         await client.WriteLine($"RCPT TO:<{address}>");
         s = await client.TerminatedReadAsync(">", timeout);
         if (!s.Contains("250")) return PingStatus.Invalid;
     }
     return PingStatus.Valid;
 }
Example #2
0
        static async Task<EmailInfo> CheckEmailAddresses(
            string email,
            string mxHostAddress,
            int port,
            ProgressBar pbar
        )
        {
            pbar.Tick($"Currently processing: #{pbar.CurrentTick} emails searched...");

            var mailInfo = new EmailInfo
            {
                Email = email,
                ProviderExists = false,
                EmailResolution = EmailResolutionType.CantDetemine
            };

            try
            {
                if (!string.IsNullOrEmpty(mxHostAddress) && !string.IsNullOrEmpty(email))
                {
                    using (var telnetClient = new Client(
                        mxHostAddress,
                        port,
                        CancellationToken.None
                    ))
                    {
                        if (mailInfo.ProviderExists = telnetClient.IsConnected)
                        {
                            mailInfo.Email = email;
                            await telnetClient.Write("HELO localhost\r\n");
                            await telnetClient.ReadAsync(new TimeSpan(0, 0, 10));

                            await telnetClient.Write("MAIL FROM:<*****@*****.**>\r\n");
                            await telnetClient.ReadAsync(new TimeSpan(0, 0, 10));

                            await telnetClient.Write(
                                string.Format("RCPT TO:<{0}>\r\n", email)
                            );

                            var response = await telnetClient.ReadAsync(new TimeSpan(0, 1, 0));

                            if (response.StartsWith("2"))
                                mailInfo.EmailResolution = EmailResolutionType.Exist;
                            else if (response.StartsWith("5") && response.Contains("exist"))
                                mailInfo.EmailResolution = EmailResolutionType.NotExist;
                            else
                                mailInfo.EmailResolution = EmailResolutionType.CantDetemine;
                        }

                        await telnetClient.Write("QUIT");
                    }
                }
            }
            catch (Exception ex)
            {
                _log.Error(string.Empty, ex);
            }

            return mailInfo;
        }
Example #3
0
    /// <summary>
    /// Set style of console window and initialises variables
    /// </summary>
    public static void Init()
    {
        Console.Title = $"Project loudmouth ({getCommit()})";
        //Console.SetWindowSize(56, 15);
        //Console.SetBufferSize(56, 15);
        Console.ForegroundColor = ConsoleColor.White;
        string cfg = readConfig();

        if (cfg == "")
        {
            log(2, $"Could not find configuration");
            Environment.Exit(1);
        }
        else if (cfg == "notwindows")
        {
            log(1, "attempted to do windows specific config on nonwindows platform");
        }

        bool connected = false;

        while (!connected) // 30s timeout loop
        {
            try
            {
                client    = new PrimS.Telnet.Client("localhost", netPort, new System.Threading.CancellationToken()); // blocking
                connected = true;
                run($"PASS anim#");                                                                                  // password?
                break;
            }
            catch (Exception e)
            {
                log(1, "Could not connect to remote console... retrying...");
                if (_testing)
                {
                    log(1, $"{e}");
                }
            }
        }

        if (client.IsConnected)
        {
            echo("RCON Connected!");
        }
        me = getMyCommunityID();
        initTimer();
        cookPasta();
        createAliases();
        Thread logger = new Thread((new ThreadStart(rconParser)));

        logger.Start();

        /*
         * if (bGameActive(gameState))
         * {
         *  players.AddRange(gameState.AllPlayers.PlayerList);
         *  players.ForEach(p =>
         *  {
         *      if (p.SteamID == me)
         *          myNode = p;
         *  });
         * }*/


        syncPlayAudio(new int[0], new int[0]); // should default to song of storms

        if (_testing)
        {
            Console.Title = $"[dev] {Console.Title} ({me})";
            log(0, "test string 1");
            log(1, "test string 2");
            log(2, "test string 3");
        }
    }
Example #4
-1
        private async void TelnetConnect_Button_Click(object sender, EventArgs e)
        {
            client = new Client(IPAdress_Textbox.Text, 23, new System.Threading.CancellationToken());

            while (true)
            {
                string s = await client.ReadAsync(TimeSpan.FromMilliseconds(1));
                if (!s.Equals(""))
                {
                    Console_ListBox.Items.Add(s);
                    int itemsPerPage = Console_ListBox.Height / Console_ListBox.ItemHeight;
                    Console_ListBox.TopIndex = Console_ListBox.Items.Count - itemsPerPage;
                }
                    
            }
        }
Example #5
-2
 public static void SendMessage()
 {
     using (var client = new Client ("192.168.123.111", 10000, new System.Threading.CancellationToken ())) {
         if (client.IsConnected) {
             var s = new StringBuilder ();
             s.Append ("Datum: " + DateTime.Now.ToShortDateString () + "\n");
             s.Append ("Uhrzeit: " + DateTime.Now.ToLongTimeString () + "\n");
             s.Append ("Status: " + "EIN" + "\n");
             s.Append ("Meldung: " + "Ich bin eine einfache Meldung" + "\n");
             s.Append ("55A2A7A9");
             client.Write (s.ToString ());
         }
     }
 }