示例#1
0
        public async Task Connect(VPNConnection conn)
        {
            VpnManagementAgent mgr = new VpnManagementAgent();

            VpnNativeProfile profile = new VpnNativeProfile()
            {
                AlwaysOn                   = true,
                NativeProtocolType         = VpnNativeProtocolType.Pptp,
                ProfileName                = conn.ConnectionName,
                RememberCredentials        = true,
                RequireVpnClientAppUI      = false,
                RoutingPolicyType          = VpnRoutingPolicyType.ForceAllTrafficOverVpn,
                TunnelAuthenticationMethod = VpnAuthenticationMethod.PresharedKey,
                UserAuthenticationMethod   = VpnAuthenticationMethod.PresharedKey
            };

            profile.Servers.Add(conn.ServerName);

            VpnManagementErrorStatus profileStatus = await mgr.AddProfileFromObjectAsync(profile);

            PasswordCredential credentials = new PasswordCredential
            {
                UserName = conn.UserName,
                Password = conn.Password,
            };

            VpnManagementErrorStatus connectStatus = await mgr.ConnectProfileWithPasswordCredentialAsync(profile, credentials);

            activeProfile = profile;
        }
示例#2
0
        public VPNConnection Get()
        {
            var html  = new HtmlWeb().Load(URLconstants.GermanyPPTPServer);
            var div   = html.DocumentNode.SelectSingleNode("//div[@id='u120944']");
            var table = div.SelectNodes("//table//td");
            var conn  = new VPNConnection()
            {
                ServerName = table[1].InnerText,
                UserName   = table[2].InnerText,
                Password   = table[3].InnerText
            };

            return(conn);
        }
示例#3
0
 /// <summary>
 /// connect to the VPN <br />
 /// show message box on error
 /// </summary>
 public void Connect()
 {
     try
     {
         VPNConnection.Connect();
     }
     catch (InvalidOperationException e)
     {
         /*
          * TODO it would be nicer if the message would hold less detail
          * about the problem
          */
         RTLMessageBox.Show(m_parent,
                            Program.res.GetString("BOX_Error_Connect") +
                            Environment.NewLine + e.Message,
                            MessageBoxIcon.Error);
     }
 }
示例#4
0
        /// <summary>
        /// disconnect from vpn
        /// </summary>
        /// <param name="closeForm">
        ///     close status window, this is important if you
        ///     change the configuration, because the status window will
        ///     still use the old configuration
        /// </param>
        public void Disconnect(bool closeForm)
        {
            // disconnect if needed
            if (VPNConnection != null)
            {
                try
                {
                    VPNConnection.Disconnect();
                }
                catch (InvalidOperationException)
                {
                }
            }

            if (m_frmlpw != null)
            {
                m_frmlpw.Invoke(new UtilsHelper.Action <Form>(closeSubForm), m_frmlpw);
            }
        }
示例#5
0
        private void Dispose(bool disposing)
        {
            if (!disposed)
            {
                if (disposing)
                {
                    m_disconnectTimer.Dispose();
                    m_frmlpw.Dispose();
                    m_parent.Dispose();
                    VPNConnection.Dispose();
                }

                VPNConnection     = null;
                m_parent          = null;
                m_frmlpw          = null;
                m_disconnectTimer = null;

                disposed = true;
            }
        }
示例#6
0
 public static VPNConnection CreateVPNConnection(global::System.Guid stampId, global::System.Guid ID, global::System.Collections.ObjectModel.ObservableCollection<string> cloudVPNIPAddresses)
 {
     VPNConnection vPNConnection = new VPNConnection();
     vPNConnection.StampId = stampId;
     vPNConnection.ID = ID;
     if ((cloudVPNIPAddresses == null))
     {
         throw new global::System.ArgumentNullException("cloudVPNIPAddresses");
     }
     vPNConnection.CloudVPNIPAddresses = cloudVPNIPAddresses;
     return vPNConnection;
 }