public FormViewer() { InitializeComponent(); if (Environment.Is64BitOperatingSystem) { Xpcom.Initialize("firefox64"); } else { Xpcom.Initialize("firefox"); } GeckoPreferences.Default["network.proxy.type"] = 1; GeckoPreferences.Default["network.proxy.socks"] = "127.0.0.1"; GeckoPreferences.Default["network.proxy.socks_port"] = 9050; GeckoPreferences.Default["network.proxy.socks_remote_dns"] = true; GeckoPreferences.Default["network.proxy.socks_version"] = 5; _allRouters = null; _closing = false; this.FormClosing += this_FormClosing; //this.Shown += this_Shown; niViewer.DoubleClick += ni_DoubleClick; tsmiOpen.Click += tsmiOpen_Click; tsmiClose.Click += tsmiClose_Click; txtAddress.KeyDown += address_KeyDown; txtAddress.TextChanged += address_TextChanged; _wssClient = new WebSocket("wss://pushansiber.com:2222"); _wssClient.OnOpen += client_Connected; _wssClient.OnMessage += client_MessageReceived; _wssClient.OnError += client_Error; gwbMain.Navigated += gwbMain_Navigated; }
private async void ChromiumBrowser_OnFrameLoadEndAsync(object sender, FrameLoadEndEventArgs e) { wbPrzegladarka.FrameLoadEnd -= ChromiumBrowser_OnFrameLoadEndAsync; if (!client.IsRunning) { await Task.Delay(5000); } else { await Task.Delay(10000); RouterCollection routers = client.Status.GetAllRouters(); Kontynuacja(); } }
/// <summary> /// Initializes a new instance of the <see cref="ProgramUI"/> class. /// </summary> public ProgramUI() { InitializeComponent(); InitializeFonts(); allRouters = null; closing = false; browserControl.CanGoBackChanged += (s, e) => backButton.Enabled = browserControl.CanGoBack; browserControl.CanGoForwardChanged += (s, e) => forwardButton.Enabled = browserControl.CanGoForward; browserControl.StatusTextChanged += new EventHandler(OnBrowserControlStatusTextChanged); browserControl.ProgressChanged += (s, e) => SetStatusProgress((int)Math.Floor(e.CurrentProgress * 100.00 / e.MaximumProgress)); routerList.MouseDoubleClick += (s, e) => { int index = routerList.SelectedIndex; if (index < 0 || allRouters.Count <= index) { return; } Router router = allRouters[index]; if (router == null) { return; } string countryCode = client.Status.GetCountryCode(router); MessageBox.Show( "Router information\n" + "---------------------------\n" + "Nickname: " + router.Nickname + "\n" + "Identity: " + router.Identity + "\n" + "IP Address: " + router.IPAddress + "\n" + "Digest: " + router.Digest + "\n" + "Published: " + (router.Publication == DateTime.MinValue ? "Unknown" : Convert.ToString(router.Publication)) + "\n" + "Bandwidth: " + (router.Bandwidth) + "\n" + "Country: " + (countryCode != null ? countryCode : "Unknown") + "\n" + "---------------------------\n" + "Flags:\n" + router.Flags.ToString(), "Information", MessageBoxButtons.OK, MessageBoxIcon.Information ); }; backButton.Click += (s, e) => browserControl.GoBack(); forwardButton.Click += (s, e) => browserControl.GoForward(); }
/// <summary> /// Initializes the tor client. /// </summary> private void InitializeTor() { Process[] previous = Process.GetProcessesByName("tor"); SetStatusProgress(PROGRESS_INDETERMINATE); if (previous != null && previous.Length > 0) { SetStatusText("Killing previous tor instances.."); foreach (Process process in previous) { process.Kill(); } } SetStatusText("Creating the tor client.."); ClientCreateParams createParameters = new ClientCreateParams(); createParameters.ConfigurationFile = ConfigurationManager.AppSettings["torConfigurationFile"]; createParameters.ControlPassword = ConfigurationManager.AppSettings["torControlPassword"]; createParameters.ControlPort = Convert.ToInt32(ConfigurationManager.AppSettings["torControlPort"]); createParameters.DefaultConfigurationFile = ConfigurationManager.AppSettings["torDefaultConfigurationFile"]; createParameters.Path = ConfigurationManager.AppSettings["torPath"]; createParameters.SetConfig(ConfigurationNames.AvoidDiskWrites, true); createParameters.SetConfig(ConfigurationNames.GeoIPFile, Path.Combine(Environment.CurrentDirectory, @"Tor\Data\Tor\geoip")); createParameters.SetConfig(ConfigurationNames.GeoIPv6File, Path.Combine(Environment.CurrentDirectory, @"Tor\Data\Tor\geoip6")); client = Client.Create(createParameters); if (!client.IsRunning) { SetStatusProgress(PROGRESS_DISABLED); SetStatusText("The tor client could not be created"); return; } client.Status.BandwidthChanged += OnClientBandwidthChanged; client.Status.CircuitsChanged += OnClientCircuitsChanged; client.Status.ORConnectionsChanged += OnClientConnectionsChanged; client.Status.StreamsChanged += OnClientStreamsChanged; client.Configuration.PropertyChanged += (s, e) => { Invoke((Action) delegate { configGrid.Refresh(); }); }; client.Shutdown += new EventHandler(OnClientShutdown); if (!Program.SetConnectionProxy(string.Format("127.0.0.1:{0}", client.Proxy.Port))) { MessageBox.Show("The application could not set the default connection proxy. The browser control is not using the tor service as a proxy!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } SetStatusProgress(PROGRESS_DISABLED); SetStatusText("Ready"); configGrid.SelectedObject = client.Configuration; SetStatusText("Downloading routers"); SetStatusProgress(PROGRESS_INDETERMINATE); ThreadPool.QueueUserWorkItem(state => { allRouters = client.Status.GetAllRouters(); if (allRouters == null) { SetStatusText("Could not download routers"); SetStatusProgress(PROGRESS_DISABLED); } else { Invoke((Action) delegate { routerList.BeginUpdate(); foreach (Router router in allRouters) { routerList.Items.Add(string.Format("{0} [{1}] ({2}/s)", router.Nickname, router.IPAddress, router.Bandwidth)); } routerList.EndUpdate(); }); SetStatusText("Ready"); SetStatusProgress(PROGRESS_DISABLED); } }); }
private void initializeTor() { Process[] previous = Process.GetProcessesByName("tor"); SetStatusProgress(Constants.PROGRESS_INDETERMINATE); if (previous != null && previous.Length > 0) { SetStatusText("Killing previous tor instances.."); foreach (Process process in previous) { process.Kill(); } } SetStatusText("Creating the tor client.."); ClientCreateParams createParameters = new ClientCreateParams(); createParameters.ConfigurationFile = ConfigurationManager.AppSettings["torConfigurationFile"]; // Gets values from app.config createParameters.ControlPassword = ConfigurationManager.AppSettings["torControlPassword"]; createParameters.ControlPort = Convert.ToInt32(ConfigurationManager.AppSettings["torControlPort"]); createParameters.DefaultConfigurationFile = ConfigurationManager.AppSettings["torDefaultConfigurationFile"]; createParameters.Path = ConfigurationManager.AppSettings["torPath"]; createParameters.SetConfig(ConfigurationNames.AvoidDiskWrites, true); createParameters.SetConfig(ConfigurationNames.GeoIPFile, Path.Combine(Environment.CurrentDirectory, @"Tor\Data\geoip")); createParameters.SetConfig(ConfigurationNames.GeoIPv6File, Path.Combine(Environment.CurrentDirectory, @"Tor\Data\geoip6")); client = Client.Create(createParameters); if (!client.IsRunning) { SetStatusProgress(Constants.PROGRESS_DISABLED); SetStatusText("The tor client could not be created"); return; } client.Status.BandwidthChanged += OnClientBandwidthChanged; client.Status.CircuitsChanged += OnClientCircuitsChanged; client.Status.ORConnectionsChanged += OnClientConnectionsChanged; client.Status.StreamsChanged += OnClientStreamsChanged; client.Configuration.PropertyChanged += (s, e) => { Invoke((Action) delegate { configGrid.Refresh(); }); }; client.Shutdown += new EventHandler(OnClientShutdown); SetStatusProgress(Constants.PROGRESS_DISABLED); SetStatusText("Ready"); configGrid.SelectedObject = client.Configuration; SetStatusText("Downloading routers"); SetStatusProgress(Constants.PROGRESS_INDETERMINATE); try { ThreadPool.QueueUserWorkItem(state => { allRouters = client.Status.GetAllRouters(); if (allRouters == null) { SetStatusText("Could not download routers"); SetStatusProgress(Constants.PROGRESS_DISABLED); } else { Invoke((Action) delegate { foreach (Router router in allRouters) { routerGridView.Rows.Add(router.Nickname, router.IPAddress, string.Format("{0}/s", router.Bandwidth)); } }); SetStatusText("Ready"); SetStatusProgress(Constants.PROGRESS_DISABLED); ShowTorReady(); } }); } catch (Exception e) { MessageBox.Show(e.ToString()); } }
/// <summary> /// Initializes a new instance of the <see cref="GetAllRouterStatusResponse"/> class. /// </summary> /// <param name="success">A value indicating whether the command was received and processed successfully.</param> /// <param name="routers">The collection of routers.</param> public GetAllRouterStatusResponse(bool success, IList <Router> routers) : base(success) { this.routers = new RouterCollection(routers); }
/// <summary> /// Initializes a new instance of the <see cref="GetAllRouterStatusResponse"/> class. /// </summary> /// <param name="success">A value indicating whether the command was received and processed successfully.</param> public GetAllRouterStatusResponse(bool success) : base(success) { this.routers = null; }