Exemplo n.º 1
0
        private void dialer_DialCompleted(object sender, DialCompletedEventArgs e)
        {
            if (e.Cancelled)
            {
                this.AppendStatusText("Cancelled!");
            }
            else if (e.Connected)
            {
                this.AppendStatusText("Connected!");
            }
            else if (e.TimedOut)
            {
                this.AppendStatusText("Connection attempt timed out!");
            }
            else if (e.Error != null)
            {
                this.AppendStatusText(e.Error.ToString());
            }

            this.IsConnectionsComboBoxEnabled = true;
            this.IsDisconnectButtonEnabled    = false;
            this.IsDialButtonEnabled          = true;
        }
Exemplo n.º 2
0
        void rasDialer_DialCompleted(object sender, DialCompletedEventArgs e)
        {
            if (e.Cancelled)
            {
                LogManager.InfoWithCallback(string.Format("-> VPN 拨号:名称={0},IP={1} 拨号被取消!", this.VPNItem.EntryName, this.VPNItem.IP));
            }
            else if (e.TimedOut)
            {
                LogManager.InfoWithCallback(string.Format("-> VPN 拨号:名称={0},IP={1} 拨号超时!", this.VPNItem.EntryName, this.VPNItem.IP));
            }
            else if (e.Error != null)
            {
                LogManager.InfoWithCallback(string.Format("-> VPN 拨号:名称={0},IP={1} 拨号出错:{2}!", this.VPNItem.EntryName, this.VPNItem.IP, e.Error));
            }
            else if (e.Connected)
            {
                this.IsDialSucceed = true;
                LogManager.InfoWithCallback(string.Format("-> 恭喜,VPN 拨号:名称={0},IP={1} 拨号成功!", this.VPNItem.EntryName, this.VPNItem.IP));
            }

            this.isDialing = false;
            this.vpnManualReset.Set();
        }
Exemplo n.º 3
0
        private void _rasDialer_DialCompleted(object sender, DialCompletedEventArgs e)
        {
            Console.WriteLine("Dial completed");

            if (e.Cancelled)
            {
                Console.WriteLine("\tConnection canceled");
            }
            else if (e.TimedOut)
            {
                Console.WriteLine("\tConnection timeout");
            }
            else if (e.Error != null)
            {
                this._taskCompletionSource.SetException(e.Error);

                //if (this._rasDialer.IsBusy)
                //{
                //    Console.WriteLine("\trasDialer is BUSY");
                //}
            }
            else
            {
                // Start monitoring the connection
                var rasConnection = this.IpSecActiveConnectionGet(this._vpnConnectionName);
                if (rasConnection != null)
                {
                    RasIPInfo rasInfo = (RasIPInfo)rasConnection.GetProjectionInfo(RasProjectionType.IP);

                    this._rasConnectionWatcher.Handle = rasConnection.Handle;
                    this._rasConnectionWatcher.EnableRaisingEvents = true;
                }

                Console.WriteLine("\tConnection established");
                this._taskCompletionSource.SetResult(null);
            }
        }
Exemplo n.º 4
0
        private void DialCompleted(object sender, DialCompletedEventArgs e)
        {
            if (_dialog != null && !_dialog.IsStoredCredential)
            {
                _dialog.ConfirmCredentials(e.Connected);
            }
            else if (!e.Connected)
            {
                CredentialDialog.DeleteCredential(Unique);
            }

            IsConnected = e.Connected;

            if (IsConnected)
            {
                var ifn = NetworkInterface.GetAllNetworkInterfaces().FirstOrDefault(i => i.Name == VpnName);
                if (ifn != null)
                {
                    var ifprop = ifn.GetIPProperties();
                    var ifip   = ifprop.UnicastAddresses.FirstOrDefault(ip => ip.Address.AddressFamily == AddressFamily.InterNetwork && !IPAddress.IsLoopback(ip.Address));
                    var prop   = ifprop.GetIPv4Properties();

                    var ifindex = ifprop.GetIPv4Properties().Index;

                    // add routes
                    var ips = Hosts.SelectMany(hst => hst.IPAddresses);

                    foreach (var ipAddress in ips)
                    {
                        string message = string.Empty;

                        NativeMethods.ModifyIpForwardEntry(true, ipAddress.ToString(), "255.255.255.255", ifip.Address.ToString(), (uint)ifindex, /* todo: proper metric */ (uint)ifindex, out message);
                        Debug.WriteLine(message);
                    }
                }
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// Handles the event when dialing has been completed.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The event of type <see cref="DialCompletedEventArgs"/>.</param>
        private void Dialer_DialCompleted(object sender, DialCompletedEventArgs e)
        {
            if (e.Connected)
            {
                _rasConnected      = true;
                _currentConnection = RasConnection.GetActiveConnections()
                                     .Single(p => p.EntryName == _view.SelectedProfile);

                _view.UpdateUIWhenConnected();
                _view.UpdateToolStripStatus($"Connected: [{_view.SelectedProfile}]");
            }
            else if (e.TimedOut)
            {
                _view.UpdateToolStripStatus("Connection attempt timed out");
            }
            else if (e.Error != null)
            {
                _view.UpdateToolStripStatus(e.Error.Message);
                _view.UpdateUIWhenDisconnected();

                // Retry connection if there's an error while connecting
                if (_view.Retry)
                {
                    TryRasConnection();
                }
            }
            else if (e.Cancelled)
            {
                _view.UpdateToolStripStatus("Connection attempt cancelled");
                _view.UpdateUIWhenDisconnected();
            }
            else if (!e.Connected)
            {
                _view.UpdateUIWhenDisconnected();
            }
        }
Exemplo n.º 6
0
 private void Dialer_DialCompleted(object sender, DialCompletedEventArgs e)
 {
     if (e.Cancelled)
     {
         this.flagConnected = false;
     }
     else if (e.TimedOut)
     {
         this.flagConnected = false;
     }
     else if (e.Error != null)
     {
         this.flagConnected = false;
     }
     else if (e.Connected)
     {
         this.flagConnected = true;
     }
     if (!e.Connected)
     {
         this.flagConnected = false;
     }
     OnClientDialCompleted(sender, e);
 }
Exemplo n.º 7
0
 private void dialer_DialCompleted(object sender, DialCompletedEventArgs e)
 {
     DialAsyncComplete((RasDialer)sender, e);
 }
Exemplo n.º 8
0
 // Token: 0x06000055 RID: 85 RVA: 0x00004A44 File Offset: 0x00002C44
 private void Dialer_DialCompleted(object sender, DialCompletedEventArgs e)
 {
     if (e.Cancelled)
     {
         this.SetDefaultState(false);
         this.lstServerRouting.ClearRoutingList();
     }
     else if (e.TimedOut)
     {
         if (this.bAutoMode)
         {
             if (!this.lstServerRouting.IsAllAutoTried())
             {
                 this.lstServerRouting.SetNextFailed();
                 this.ConnectToVPN(this.edtLogin.Text, this.edtPassword.Text);
             }
             else
             {
                 this.ShowStatus(this.rm.GetString("noServerAvailable"), true);
                 this.lstServerRouting.ClearRoutingList();
                 this.SetDefaultState(false);
             }
         }
         else
         {
             this.ShowStatus(this.rm.GetString("errTimeOut"), true);
             this.lstServerRouting.ClearRoutingList();
             this.SetDefaultState(false);
         }
     }
     else if (e.Error != null)
     {
         if (((RasDialException)e.Error).ErrorCode == 691)
         {
             this.ShowStatus(this.rm.GetString("wrongLogin"), true);
             this.lstServerRouting.ClearRoutingList();
             this.SetDefaultState(false);
             this.ShowSettings(true);
         }
         else if (this.bAutoMode)
         {
             if (!this.lstServerRouting.IsAllAutoTried())
             {
                 this.lstServerRouting.SetNextFailed();
                 this.ConnectToVPN(this.edtLogin.Text, this.edtPassword.Text);
             }
             else
             {
                 this.ShowStatus(this.rm.GetString("noServerAvailable"), true);
                 this.lstServerRouting.ClearRoutingList();
                 this.SetDefaultState(false);
             }
         }
         else
         {
             this.ShowStatus(this.rm.GetString("errConnectionOther"), true);
             this.lstServerRouting.ClearRoutingList();
             this.SetDefaultState(false);
         }
     }
     else if (e.Connected)
     {
         this.SetDefaultState(true);
         this.lstServerRouting.ClearRoutingList();
     }
 }
Exemplo n.º 9
0
 public virtual void Dialer_DialCompleted(object sender, DialCompletedEventArgs e)
 {
 }