Exemplo n.º 1
0
 private void watcher_Disconnected(object sender, RasConnectionEventArgs e)
 {
     appendLog("Disconnected...");
     _shouldStop = false;
     oThread     = new Thread(new ThreadStart(connect));
     oThread.Start();
 }
Exemplo n.º 2
0
        static private void watcher_Connected(object sender, RasConnectionEventArgs e)
        {
            // A connection has successfully connected.
            Log.ProcessDebug("Event " + VpnSelectorLibRes.A_connection_has_successfully_connected_ + e.Connection.EntryName);

            BaseProxyServer oldProxy = NetConnUtils.CurrentProxyServer;

            if (IsSynchMode == false)
            {
                NetConnUtils.CurrentProxyServer = BaseProxyServer.FindFromNames(NetConnUtils.GetActiveConnectionsNames());
            }
            if (VpnConnectedEvent != null)
            {
                VpnConnectedEvent(null, new VpnConnectedEventArgs());
            }
            if (IsSynchMode == false)
            {
                if ((oldProxy == null && NetConnUtils.CurrentProxyServer != null) ||
                    (oldProxy != null && oldProxy != NetConnUtils.CurrentProxyServer))
                {
                    //proxy changed
                    NetConnUtils.ConfirmIpAddressAsync();
                }
            }
        }
Exemplo n.º 3
0
        static private void watcher_Disconnected(object sender, RasConnectionEventArgs e)
        {
            // A connection has disconnected successfully.
            Log.ProcessDebug("Event " + VpnSelectorLibRes.A_connection_has_disconnected_successfully_ + e.Connection.EntryName);

            if (VpnDisconnectedEvent != null)
            {
                VpnDisconnectedEvent(null, new VpnDisconnectedEventArgs());
            }
            if (IsSynchMode == false)
            {
                AppManager.Instance.ProcessNotification(VpnSelectorLibRes.VPN_disconnected);
                BaseProxyServer oldProxy = NetConnUtils.CurrentProxyServer;
                NetConnUtils.CurrentProxyServer = null;
                if (oldProxy != null)
                {
                    //proxy changed
                    NetConnUtils.ConfirmIpAddressAsync();
                }
                //reconnect
                //https://stackoverflow.com/questions/23950702/reconnect-vpn-windows-service
                if (NetConnUtils.CurrentProxyServer != null && IsReconnect == true)
                {
                    OpenConnectLocal(NetConnUtils.CurrentProxyServer, true);
                }
            }
        }
Exemplo n.º 4
0
        private void watcher_Disconnected(object sender, RasConnectionEventArgs e)
        {
            // A connection has disconnected successfully.
            if (connectionLogs.ContainsKey(e.Connection.EntryName))
            {
                connectionLogs[e.Connection.EntryName].End = DateTime.Now;
                data.Logs.Add(connectionLogs[e.Connection.EntryName]);
                connectionLogs.Remove(e.Connection.EntryName);
            }

            for (var i = 0; i < dataGridView1.RowCount; i++)
            {
                if (dataGridView1.Rows[i].Cells[0].Value.ToString() == e.Connection.EntryName)
                {
                    //Update the row info
                    ((DataGridViewCheckBoxCell)dataGridView1.Rows[i].Cells[3]).Value = false;
                    var used = data.Logs.Where(x => x.Name == e.Connection.EntryName).Select(x => x.End - x.Start).ToList();
                    dataGridView1.Rows[i].Cells[1].Value = used.Any() ? used.Aggregate((x, y) => x + y).ToString("g").Split(',')[0] : "00:00:00";
                }
            }

            //Close the widget
            if (connectionsOpened.ContainsKey(e.Connection.EntryName))
            {
                connectionsOpened[e.Connection.EntryName].Close();
            }
        }
Exemplo n.º 5
0
        private void watcher_Connected(object sender, RasConnectionEventArgs e)
        {
            // A connection has successfully connected.
            if (!connectionLogs.ContainsKey(e.Connection.EntryName))
            {
                connectionLogs.Add(e.Connection.EntryName, new ConnectionLog()
                {
                    Name  = e.Connection.EntryName,
                    Start = DateTime.Now
                });
            }

            if (data.OpenConnectionWidgetAutomatically)
            {
                OpenConnectionInfo(e.Connection.EntryName);
            }

            for (var i = 0; i < dataGridView1.RowCount; i++)
            {
                if (dataGridView1.Rows[i].Cells[0].Value.ToString() == e.Connection.EntryName)
                {
                    ((DataGridViewCheckBoxCell)dataGridView1.Rows[i].Cells[3]).Value = true;
                }
            }
        }
Exemplo n.º 6
0
 /// <summary>
 /// Handles what happens when RAS connection is interrupted.
 /// </summary>
 /// <param name="sender">The sender<see cref="object"/>.</param>
 /// <param name="e">The event of type <see cref="DotRas.RasConnectionEventArgs"/>.</param>
 private void Watcher_Disconnected(object sender, RasConnectionEventArgs e)
 {
     _view.UpdateUIWhenDisconnected();
     _view.UpdateToolStripStatus("Disconnected");
     _currentConnection = null;
     _rasConnected      = false;
     SaveTotalStats();
 }
Exemplo n.º 7
0
 /// <summary>
 /// 连接断开处理
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void ConnWatcher_Disconnected(object sender, RasConnectionEventArgs e)
 {
     if (e.Connection.EntryName == sEntryName && !haveStopped)
     {
         haveStopped = true;
         DoAfterDisconnected();
     }
 }
 private void Watcher_Connected(object sender, RasConnectionEventArgs e)
 {
     isConnected = true;
     isBusy      = false;
     if (ConnectionComplete != null)
     {
         ConnectionComplete(true);
     }
 }
 private void Watcher_Disconnected(object sender, RasConnectionEventArgs e)
 {
     isConnected     = false;
     isBusy          = false;
     portAlreadyOpen = false;
     if (DisconnectionComplete != null)
     {
         DisconnectionComplete(true);
     }
 }
Exemplo n.º 10
0
 private void OnConnection(object?sender, RasConnectionEventArgs e)
 {
     MainForm !.Invoke((MethodInvoker) delegate
     {
         UpdateTrayIcon();
         _trayIcon.ShowBalloonTip(
             2000,
             null,
             $"Connected to {e.ConnectionInformation.EntryName}",
             ToolTipIcon.Info);
     });
 }
Exemplo n.º 11
0
        private static void ProcessRoutes(bool isConnected, RasConnectionEventArgs connectionEventInfo)
        {
            if (connectionEventInfo.Connection.Device.DeviceType == RasDeviceType.Vpn)
            {
                string gatewayIpAddress;

                if (isConnected)
                {
                    gatewayIpAddress = ((RasIPInfo)connectionEventInfo.Connection.GetProjectionInfo(RasProjectionType.IP)).IPAddress.ToString();

                    Logger.Instance.Log(LogLevel.Info, "Connected to \"{0}\". Client IP: {1}.", connectionEventInfo.Connection.EntryName, gatewayIpAddress);
                }
                else
                {
                    gatewayIpAddress = null;

                    Logger.Instance.Log(LogLevel.Info, "Disconnected from \"{0}\".", connectionEventInfo.Connection.EntryName);
                }

                Vpn configuredVpn = ConfigurationManager.Configuration.Vpns.SingleOrDefault(vpn => !vpn.IsOnlyTriggeredManually && vpn.IsValid && vpn.Name.Equals(connectionEventInfo.Connection.EntryName, StringComparison.OrdinalIgnoreCase));
                if (configuredVpn != null)
                {
                    if (configuredVpn.IsEnabled)
                    {
                        Route[] validAndEnabledRoutes;
                        if (HasValidAndEnabledRoutes(isConnected, configuredVpn, out validAndEnabledRoutes))
                        {
                            ProcessRoutes(isConnected, connectionEventInfo.Connection.EntryName, validAndEnabledRoutes, gatewayIpAddress);
                        }
                    }
                    else
                    {
                        Logger.Instance.Log(LogLevel.Info, "No routes will be {0} for \"{1}\" because it is not enabled.", isConnected ? "added" : "deleted", connectionEventInfo.Connection.EntryName);
                    }
                }
                else
                {
                    Logger.Instance.Log(LogLevel.Info, "No routes will be {0} for \"{1}\" because it has not been configured.", isConnected ? "added" : "deleted", connectionEventInfo.Connection.EntryName);
                }
            }
        }
Exemplo n.º 12
0
 private void _rasConnectionWatcher_Disconnected(object sender, RasConnectionEventArgs e)
 {
     Console.WriteLine("Disconnected");
     this._taskCompletionSource.SetResult(null);
 }
Exemplo n.º 13
0
 private void _rasConnectionWatcher_Disconnected(object sender, RasConnectionEventArgs e)
 {
     ProcessRoutes(false, e);
 }
Exemplo n.º 14
0
 private void rasConnectionWatcher1_Disconnected(object sender, RasConnectionEventArgs e)
 {
     this.Dial();
 }
Exemplo n.º 15
0
 private void watcher_Connected(object sender, RasConnectionEventArgs e)
 {
     // A connection has successfully connected.
 }
Exemplo n.º 16
0
 // Token: 0x0600005A RID: 90 RVA: 0x00004ED2 File Offset: 0x000030D2
 private void watcher_Connected(object sender, RasConnectionEventArgs e)
 {
     this.SetDefaultState(true);
 }
Exemplo n.º 17
0
 // Token: 0x06000059 RID: 89 RVA: 0x00004EAA File Offset: 0x000030AA
 private void watcher_Disconnected(object sender, RasConnectionEventArgs e)
 {
     this.lstServerRouting.ClearRoutingList();
     this.SetDefaultState(false);
     this.lblStatus.Text = "";
 }
Exemplo n.º 18
0
 private void OnConnectionDisconnected(object sender, RasConnectionEventArgs e)
 {
     Console.WriteLine($"Disconnected: [{e.ConnectionInformation.EntryName}] @ {e.ConnectionInformation.Handle}");
 }
Exemplo n.º 19
0
 private void watcher_Disconnected(object sender, RasConnectionEventArgs e)
 {
     OnDisconnected?.Invoke();
 }
Exemplo n.º 20
0
Arquivo: PPPoE.cs Projeto: qcyb/pppoed
 private void OnConnectionDisconnected(object sender, RasConnectionEventArgs e)
 {
     Logger.Write($"Disconnected: [{e.ConnectionInformation.EntryName}] @ {e.ConnectionInformation.Handle}");
     ReDial();
 }
Exemplo n.º 21
0
 public new void RaiseDisconnectedEvent(RasConnectionEventArgs e)
 {
     base.RaiseDisconnectedEvent(e);
 }
Exemplo n.º 22
0
 private void OnDisconnected(object sender, RasConnectionEventArgs e)
 {
     Console.WriteLine($"Disconnected: {e.ConnectionInformation.EntryName}");
     SetNotConnected();
 }