Example #1
0
        private static async Task IpSecConnectionDisconnectionDemoAsync()
        {
            using (var ipSecClient = new IpSecClient())
            {
                try
                {
                    Console.Write("IPSec connection name: ");
                    var ipSecConnectionName = Console.ReadLine();

                    Console.Write("IPSec Server IP address: ");
                    var ipAddress = Console.ReadLine();

                    Console.Write("Username: "******"Password: "******"username", username },
                        { "password", password },
                        { "IpSecConnectionName", ipSecConnectionName }
                    };

                    Console.WriteLine("Press <ENTER> to Connect...");
                    Console.ReadLine();

                    await ipSecClient.ConnectAsync(vpnEndPoint, parameters, CancellationToken.None);

                    Program.PublicIpAddressVerify();
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.ToString());
                }

                Console.WriteLine("Press <ENTER> to Disconnect...");
                Console.ReadLine();

                try
                {
                    await ipSecClient.DisconnectAsync();

                    Program.PublicIpAddressVerify();
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.ToString());
                }
            }
        }
Example #2
0
        private static async Task IpSecConnectionDisconnectionDemoAsync()
        {
            using (var ipSecClient = new IpSecClient())
            {
                try
                {
                    Console.Write("IPSec connection name: ");
                    var ipSecConnectionName = Console.ReadLine();

                    Console.Write("IPSec Server IP address: ");
                    var ipAddress = Console.ReadLine();

                    Console.Write("Username: "******"Password: "******"username", username},
                        {"password", password},
                        {"IpSecConnectionName", ipSecConnectionName}
                    };

                    Console.WriteLine("Press <ENTER> to Connect...");
                    Console.ReadLine();

                    await ipSecClient.ConnectAsync(vpnEndPoint, parameters, CancellationToken.None);
                    Program.PublicIpAddressVerify();
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.ToString());
                }

                Console.WriteLine("Press <ENTER> to Disconnect...");
                Console.ReadLine();

                try
                {
                    await ipSecClient.DisconnectAsync();
                    Program.PublicIpAddressVerify();
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.ToString());
                }
            }
        }