public async Task userCheck(string server, int port = 25, int TimeOutMs = 2000)
        {
            try
            {
                //TelNetManager telnet = new TelNetManager(server,port);
                string result = "";
                //telnet.write("Helo hi");

                //result = telnet.read();
                //telnet.write("mail from:<*****@*****.**>");
                //result = telnet.read();
                //telnet.write("rcpt to:<" + _emailaddres + ">");
                //result = telnet.read();
                //telnet.write("quit");

                MinimalisticTelnet.TelnetConnection telnet1 = new MinimalisticTelnet.TelnetConnection(server, port);

                telnet1.WriteLine("Helo hi");

                telnet1.Read();
                result = telnet1.Read();
                telnet1.WriteLine("mail from:<*****@*****.**>");
                result = telnet1.Read();
                telnet1.WriteLine("rcpt to:<" + _emailaddres + ">");
                result = telnet1.Read();
                telnet1.WriteLine("quit");

                #region
                //Client client = new Client(server, port, new System.Threading.CancellationToken());


                ////await client.TryLoginAsync("username", "password", TimeoutMs);
                /////////////////////////////

                //string result = "";
                //await client.WriteLine("Helo hi");

                //result = client.ReadAsync().Result;
                //await client.WriteLine("mail from:<*****@*****.**>");
                //result = client.ReadAsync().Result;
                //await client.WriteLine("rcpt to:<" + _emailaddres + ">");
                //result = client.ReadAsync().Result;
                //await client.WriteLine("quit");


                //string response = await client.TerminatedReadAsync(">", TimeSpan.FromMilliseconds(TimeOutMs));
                //client.Dispose();
                #endregion

                _result = result;
            }
            catch (Exception ex)
            {
            }
        }
Beispiel #2
0
 public void Pdu()
 {
     var pdu = "0011000891097891150000AA0BCA309B1D0689C36C7618";
     var telnet = new MinimalisticTelnet.TelnetConnection("localhost", 5554);
     Console.WriteLine(telnet.Read());
     telnet.WriteLine("sms pdu " + pdu);
     Console.WriteLine(telnet.Read());
 }
Beispiel #3
0
        public void SendSMSPDU()
        {
            var telnet = new MinimalisticTelnet.TelnetConnection("localhost", 5554);
            Console.WriteLine(telnet.Read());

            var time = DateTime.Now;
            var pdu = "04 20 08 81 09 78 91 15 00 00" + time.ToPDUTimeStamp().ToHexString();

            var udh = "06 05 04 15 82 00 00";
            var opl = "00 04 04 01 33 CC";
            //var opl = "00 48 1C 01 7F FF EF FF EF FF FB FF FE 40 3F E8 38 2F FF FB FF FE 48 3F A8 38 2F 9F FB FF FE 4C FF A9 FF 2F 8F FA DA DA 4E FF 29 01 2F 80 FA 52 52 5E 7F 69 31 2F BF 7B 07 06 4F FF 69 79 2F BE FB 77 76 47 FF 69 79 2F BE 7B 07 06 47 FE EF 7D EF BE 7B FF FE 47 FC EF 7D E7 BC F1 FF FC 40 F0 EF 7D E7 7C F1 ED BC 21 E7 C9 79 27 98 F1 E5 3C 21 E7 C9 39 27 C8 F1 F0 7C 16 6F 89 39 23 E6 E0 F7 78 15 2F 88 82 23 F3 E0 F0 78 08 3F 04 44 43 D7 E0 FF F8 04 3E 02 28 81 EF C0 7F F0 02 3C 01 39 00 FF 80 3F E0 01 38 00 BA 00 7F 00 1F C0 00 F0 00 7C 00 3E 00 0F 80 FF C0 00 38 00 1C 00 07 FF 55 FF FF FF FF FF FF FF AA 2A F3 87 87 3F 1E 67 0F 54 15 F3 93 9F 3E 4E 27 27 A8 2A F3 87 8F 3E 4E 07 27 54 55 F3 93 9F 3E 0E 47 27 AA FF F3 9B 87 0E 4E 67 0F FF 00 FF FF FF FF FF FF FF 00";
            var userdata = (udh + opl).Replace(" ", "");

            pdu = pdu.Replace(" ", "") + (userdata.Length / 2).ToString("X2") + userdata;

            telnet.WriteLine("sms pdu 0420098109789115F200003130416101304005A2A0702802");
            //telnet.WriteLine("sms pdu " + pdu);
            Console.WriteLine(telnet.Read());
        }
Beispiel #4
0
 public void SendSMS()
 {
     var telnet = new MinimalisticTelnet.TelnetConnection("localhost", 5554);
     telnet.WriteLine("sms send 908719512 \"ABC\"");
     Console.WriteLine(telnet.Read());
 }
        /// <summary>
        /// Ping le serveur et fournit le nombre de clients connectés
        /// </summary>
        /// <returns>Retourne l'état du serveur</returns>
        public bool PingAndGetClientsAndAverragePing()
        {
            try
            {
                Console.WriteLine("Connexion au serveur " + this.ServerType + "...");
                MinimalisticTelnet.TelnetConnection connection = new MinimalisticTelnet.TelnetConnection(this.ServerIP, 10011);

                string response = connection.Read();

                if (response.Length > 0)
                {
                    /* Utilisation de l'id 1 */
                    connection.WriteLine("use 1");
                    connection.Read();

                    /* Récupération des informations */
                    connection.WriteLine("serverinfo");
                    System.Threading.Thread.Sleep(150);

                    string serverinfo      = connection.Read();
                    string serverinfoCopy  = serverinfo;
                    string serverinfoCopy2 = serverinfo;

                    /* Recherche de la valeur dans le string */
                    string searchForThis  = "virtualserver_clientsonline=";
                    int    firstCharacter = serverinfo.IndexOf(searchForThis);
                    string s = serverinfo.Substring(firstCharacter + searchForThis.Length, 2);

                    /* Recherche de la valeur dans le string */
                    string searchForThis2  = "virtualserver_total_ping=";
                    int    firstCharacter2 = serverinfoCopy.IndexOf(searchForThis2);
                    string s2 = serverinfoCopy.Substring(firstCharacter2 + searchForThis2.Length, 7);

                    /* Recherche de la valeur dans le string */
                    string searchForThis3  = "virtualserver_total_packetloss_total=";
                    int    firstCharacter3 = serverinfoCopy2.IndexOf(searchForThis3);
                    string s3 = serverinfoCopy2.Substring(firstCharacter3 + searchForThis3.Length, 6);

                    connection.WriteLine("logout");       // Déconnexion

                    this.ClientsConnected = int.Parse(s); // Conversion de la chaîne de caractère en int
                    Console.WriteLine(s2);
                    this.AverragePing = double.Parse(s2.Replace('.', ','));
                    this.PacketLoss   = System.Math.Round(double.Parse(s3.Replace('.', ',')), 2);

                    /* Destruction des variables */
                    connection     = null;
                    serverinfo     = null;
                    s              = null;
                    firstCharacter = 0;
                    searchForThis  = null;

                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception e) {
                Console.WriteLine(e);
                return(false);
            }
        }