public void StartRerouting(VPNControl vpnControl) { if (!isRerouting && vpnControl.isConnected()) { new Thread(() => { Thread.CurrentThread.IsBackground = true; if (getGateWay()) { isRerouting = true; StringCollection urls = Properties.Settings.Default.rerouteURLs; lock (_LOCK) { foreach (string url in urls) { addRerouteItem(url); } } if (Properties.Settings.Default.rerouteNetflix) { RerouteNetflix(); } if (Properties.Settings.Default.rerouteHulu) { RerouteHulu(); } new Thread(() => { Thread.CurrentThread.IsBackground = true; do { Thread.Sleep(500); CheckDNSCache(); } while (Properties.Settings.Default.streamReroute && vpnControl.isConnected()); isRerouting = false; removeAllReroute(); }).Start(); } }).Start(); } }
private void connectCheckTimer(object sender, EventArgs e) { if (connectionAttempts == -1) { connectionTimer.Stop(); } else if (vpnControl.isConnected() != wantsConnect) { // try to reconnect if (wantsConnect) { if (connectionAttempts >= 3) { wantsConnect = false; this.notifyIcon.BalloonTipText = "Unable to connect with VPN"; this.notifyIcon.BalloonTipTitle = "Confirmed VPN"; this.notifyIcon.ShowBalloonTip(3); setDisconnected(); connectionAttempts = 0; } else { setConnecting(); connectionAttempts++; } } else { setConnected(); } } else if (vpnControl.isConnected() && vpnControl.isVerified()) // checkbox and actual checked vpn match { connectionAttempts = 0; //toggledToConnect = false; //bluePowerCenter.Visibility = Visibility.Visible; // sometimes missed if (isConnecting) { setConnected(); } if (Properties.Settings.Default.streamReroute) { sReroute.StartRerouting(vpnControl); } } /*if(isConnecting && vpnControl.isConnected() && vpnControl.isVerified()) * { * isConnecting = false; * OnPropertyChanged("isConnecting"); * bluePowerCenter.Visibility = Visibility.Visible; * * connectionLabel.Content = "CONNECTED"; * } * else if(isConnecting && !vpnControl.isConnected()) * { * isConnecting = false; * wantsConnect = false; * * blueCircle.Visibility = Visibility.Hidden; * grayCircle.Visibility = Visibility.Visible; * * connectionLabel.Content = "DISCONNECTED"; * }*/ }