public static void Init(FuckshadowsController controller) { _hotKeyManager = new HotKeyManager(); _hotKeyManager.KeyPressed += HotKeyManagerPressed; HotkeyCallbacks.InitInstance(controller); }
static void Main() { // setup profile optimization System.Runtime.ProfileOptimization.SetProfileRoot(Utils.GetTempPath()); System.Runtime.ProfileOptimization.StartProfile("fs-runtime-opt.profile"); TFOSupported = Utils.IsTcpFastOpenSupported(); using (Mutex mutex = new Mutex(false, $"Global\\Fuckshadows_{Application.StartupPath.GetHashCode()}")) { Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException); // handle UI exceptions Application.ThreadException += Application_ThreadException; // handle non-UI exceptions AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; // handle unobserved Task exceptions TaskScheduler.UnobservedTaskException += TaskScheduler_UnobservedTaskException; Application.ApplicationExit += Application_ApplicationExit; Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); if (!mutex.WaitOne(0, false)) { Process[] oldProcesses = Process.GetProcessesByName("Fuckshadows"); if (oldProcesses.Length > 0) { Process oldProcess = oldProcesses[0]; } MessageBox.Show(I18N.GetString("Find Fuckshadows icon in your notify tray.") + Environment.NewLine + I18N.GetString( "If you want to start multiple Fuckshadows, make a copy in another directory."), I18N.GetString("Fuckshadows is already running.")); return; } Directory.SetCurrentDirectory(Application.StartupPath); #if DEBUG Logging.OpenLogFile(); // truncate privoxy log file while debugging string privoxyLogFilename = Utils.GetTempPath("privoxy.log"); if (File.Exists(privoxyLogFilename)) { using (new FileStream(privoxyLogFilename, FileMode.Truncate)) { } } #else Logging.OpenLogFile(); #endif MainController = new FuckshadowsController(); MenuController = new MenuViewController(MainController); HotKeys.Init(MainController); MainController.Start(); Application.Run(); } }
public StrategyManager(FuckshadowsController controller) { _strategies = new List <IStrategy>(); _strategies.Add(new BalancingStrategy(controller)); _strategies.Add(new HighAvailabilityStrategy(controller)); _strategies.Add(new StatisticsStrategy(controller)); // TODO: load DLL plugins }
public static void InitInstance(FuckshadowsController controller) { if (Instance != null) { return; } Instance = new HotkeyCallbacks(controller); }
public StatisticsStrategy(FuckshadowsController controller) { _controller = controller; var servers = controller.GetCurrentConfiguration().configs; var randomIndex = new Random().Next() % servers.Count; _currentServer = servers[randomIndex]; //choose a server randomly at first _timer = new Timer(ReloadStatisticsAndChooseAServer); }
public ProxyForm(FuckshadowsController controller) { this.Font = System.Drawing.SystemFonts.MessageBoxFont; InitializeComponent(); UpdateTexts(); this.Icon = Icon.FromHandle(Resources.ssw128.GetHicon()); this.controller = controller; controller.ConfigChanged += controller_ConfigChanged; UpdateEnabled(); LoadCurrentConfiguration(); }
public StatisticsStrategyConfigurationForm(FuckshadowsController controller) { if (controller == null) { return; } InitializeComponent(); _speedSeries = StatisticsChart.Series["Speed"]; _packageLossSeries = StatisticsChart.Series["Package Loss"]; _pingSeries = StatisticsChart.Series["Ping"]; _controller = controller; _controller.ConfigChanged += (sender, args) => LoadConfiguration(); LoadConfiguration(); Load += (sender, args) => InitData(); }
public ConfigForm(FuckshadowsController controller) { this.Font = System.Drawing.SystemFonts.MessageBoxFont; InitializeComponent(); // a dirty hack this.ServersListBox.Dock = System.Windows.Forms.DockStyle.Fill; this.PerformLayout(); UpdateTexts(); this.Icon = Icon.FromHandle(Resources.ssw128.GetHicon()); this.controller = controller; controller.ConfigChanged += controller_ConfigChanged; LoadCurrentConfiguration(); }
private void QRCodeForm_Load(object sender, EventArgs e) { var servers = Configuration.Load(); var serverDatas = servers.configs.Select( server => new KeyValuePair <string, string>(FuckshadowsController.GetQRCode(server), server.FriendlyName()) ).ToList(); listBox1.DataSource = serverDatas; var selectIndex = serverDatas.FindIndex(serverData => serverData.Key.StartsWith(code)); if (selectIndex >= 0) { listBox1.SetSelected(selectIndex, true); } }
public MenuViewController(FuckshadowsController controller) { this.controller = controller; LoadMenu(); controller.EnableStatusChanged += controller_EnableStatusChanged; controller.ConfigChanged += controller_ConfigChanged; controller.PacFileReadyToOpen += controller_FileReadyToOpen; controller.UserRuleFileReadyToOpen += controller_FileReadyToOpen; controller.ShareOverLanStatusChanged += controller_ShareOverLANStatusChanged; controller.VerboseLoggingStatusChanged += controller_VerboseLoggingStatusChanged; controller.EnableGlobalChanged += controller_EnableGlobalChanged; controller.Errored += controller_Errored; controller.UpdatePacFromGfwListCompleted += controller_UpdatePACFromGFWListCompleted; controller.UpdatePacFromGfwListError += controller_UpdatePACFromGFWListError; _notifyIcon = new NotifyIcon(); UpdateTrayIcon(); _notifyIcon.Visible = true; _notifyIcon.ContextMenu = _contextMenu1; _notifyIcon.BalloonTipClicked += notifyIcon1_BalloonTipClicked; _notifyIcon.MouseClick += notifyIcon1_Click; _notifyIcon.MouseDoubleClick += notifyIcon1_DoubleClick; _notifyIcon.BalloonTipClosed += _notifyIcon_BalloonTipClosed; controller.TrafficChanged += controller_TrafficChanged; this.updateChecker = new UpdateChecker(); updateChecker.CheckUpdateCompleted += updateChecker_CheckUpdateCompleted; LoadCurrentConfiguration(); Configuration config = controller.GetConfigurationCopy(); if (config.isDefault) { _isFirstRun = true; ShowConfigForm(); } else if (config.autoCheckUpdate) { _isStartupChecking = true; updateChecker.CheckUpdate(config, 3000); } }
public HotkeySettingsForm(FuckshadowsController controller) { InitializeComponent(); UpdateTexts(); Icon = Icon.FromHandle(Resources.ssw128.GetHicon()); _controller = controller; _controller.ConfigChanged += controller_ConfigChanged; LoadCurrentConfiguration(); // get all textboxes belong to this form _allTextBoxes = tableLayoutPanel1.GetChildControls <TextBox>(); if (!_allTextBoxes.Any()) { throw new Exception("Cannot get all textboxes"); } }
public LogForm(FuckshadowsController controller, string filename) { this.controller = controller; this.filename = filename; InitializeComponent(); Icon = Icon.FromHandle(Resources.ssw128.GetHicon()); LogViewerConfig config = controller.GetConfigurationCopy().logViewer; topMostTrigger = config.topMost; wrapTextTrigger = config.wrapText; toolbarTrigger = config.toolbarShown; LogMessageTextBox.BackColor = config.BackgroundColor; LogMessageTextBox.ForeColor = config.TextColor; LogMessageTextBox.Font = config.Font; controller.TrafficChanged += controller_TrafficChanged; UpdateTexts(); }
public HighAvailabilityStrategy(FuckshadowsController controller) { _controller = controller; _random = new Random(); _serverStatus = new Dictionary <Server, ServerStatus>(); }
private HotkeyCallbacks(FuckshadowsController controller) { _controller = controller; }
static void Main() { // Check OS since we are using dual-mode socket if (!Utils.IsWinVistaOrHigher()) { MessageBox.Show(I18N.GetString("Unsupported operating system, use Windows Vista at least."), "Fuckshadows Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } // Check .NET Framework version if (!Utils.IsSupportedRuntimeVersion()) { MessageBox.Show(I18N.GetString("Unsupported .NET Framework, please update to 4.6.2 or later."), "Fuckshadows Error", MessageBoxButtons.OK, MessageBoxIcon.Error); Process.Start( "http://dotnetsocial.cloudapp.net/GetDotnet?tfm=.NETFramework,Version=v4.6.2"); return; } using (Mutex mutex = new Mutex(false, $"Global\\Fuckshadows_{Application.StartupPath.GetHashCode()}")) { Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException); // handle UI exceptions Application.ThreadException += Application_ThreadException; // handle non-UI exceptions AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; Application.ApplicationExit += Application_ApplicationExit; SystemEvents.PowerModeChanged += SystemEvents_PowerModeChanged; Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); if (!mutex.WaitOne(0, false)) { Process[] oldProcesses = Process.GetProcessesByName("Fuckshadows"); if (oldProcesses.Length > 0) { Process oldProcess = oldProcesses[0]; } MessageBox.Show(I18N.GetString("Find Fuckshadows icon in your notify tray.") + Environment.NewLine + I18N.GetString( "If you want to start multiple Fuckshadows, make a copy in another directory."), I18N.GetString("Fuckshadows is already running.")); return; } Directory.SetCurrentDirectory(Application.StartupPath); #if DEBUG Logging.OpenLogFile(); // truncate privoxy log file while debugging string privoxyLogFilename = Utils.GetTempPath("privoxy.log"); if (File.Exists(privoxyLogFilename)) { using (new FileStream(privoxyLogFilename, FileMode.Truncate)) { } } #else Logging.OpenLogFile(); #endif MainController = new FuckshadowsController(); MenuController = new MenuViewController(MainController); HotKeys.Init(MainController); MainController.Start(); Application.Run(); } }
public BalancingStrategy(FuckshadowsController controller) { _controller = controller; _random = new Random(); }