public static void Init(ShadowsocksController controller) { _hotKeyManager = new HotKeyManager(); _hotKeyManager.KeyPressed += HotKeyManagerPressed; HotkeyCallbacks.InitInstance(controller); }
public StatisticsStrategy(ShadowsocksController 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 static void InitInstance(ShadowsocksController controller) { if (Instance != null) { return; } Instance = new HotkeyCallbacks(controller); }
public ConfigForm(ShadowsocksController 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(); }
public ConfigWindow(ShadowsocksController controller, int focusIndex) { InitializeComponent(); SizeChanged += (o, args) => { GenQr(LinkTextBox.Text); }; Splitter2.DragDelta += (o, args) => { GenQr(LinkTextBox.Text); }; Closed += (o, e) => { _controller.ConfigChanged -= controller_ConfigChanged; }; _controller = controller; foreach (var name in EncryptorFactory.GetEncryptor().Keys) { var info = EncryptorFactory.GetEncryptorInfo(name); if (info.display) { EncryptionComboBox.Items.Add(name); } } foreach (var protocol in Protocols) { ProtocolComboBox.Items.Add(protocol); } foreach (var obfs in ObfsStrings) { ObfsComboBox.Items.Add(obfs); } _controller.ConfigChanged += controller_ConfigChanged; LoadCurrentConfiguration(); ServerViewModel.ServersChanged += (o, e) => { ApplyButton.IsEnabled = true; }; if (focusIndex == -1) { var index = _modifiedConfiguration.index + 1; if (index < 0 || index > _modifiedConfiguration.configs.Count) { index = _modifiedConfiguration.configs.Count; } focusIndex = index; } if (focusIndex >= 0 && focusIndex < _modifiedConfiguration.configs.Count) { SetServerListSelectedIndex(focusIndex); } }
public MenuViewController(ShadowsocksController 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.ShowPluginOutputChanged += controller_ShowPluginOutputChanged; controller.EnableGlobalChanged += controller_EnableGlobalChanged; controller.Errored += controller_Errored; controller.UpdatePACFromGFWListCompleted += controller_UpdatePACFromGFWListCompleted; controller.UpdatePACFromGFWListError += controller_UpdatePACFromGFWListError; _notifyIcon = new NotifyIcon(); UpdateTrayIconAndNotifyText(); _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); } }
private void QRCodeForm_Load(object sender, EventArgs e) { var servers = Configuration.Load(); var serverDatas = servers.configs.Select( server => new KeyValuePair <string, string>(ShadowsocksController.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(ShadowsocksController 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.ShowPluginOutputChanged += controller_ShowPluginOutputChanged; controller.EnableGlobalChanged += controller_EnableGlobalChanged; controller.Errored += controller_Errored; controller.UpdatePACFromGeositeCompleted += controller_UpdatePACFromGeositeCompleted; controller.UpdatePACFromGeositeError += controller_UpdatePACFromGeositeError; _notifyIcon = new NotifyIcon(); UpdateTrayIconAndNotifyText(); _notifyIcon.Visible = true; _notifyIcon.ContextMenuStrip = contextMenu1; _notifyIcon.BalloonTipClicked += notifyIcon1_BalloonTipClicked; _notifyIcon.MouseClick += notifyIcon1_Click; _notifyIcon.MouseDoubleClick += notifyIcon1_DoubleClick; _notifyIcon.BalloonTipClosed += _notifyIcon_BalloonTipClosed; controller.TrafficChanged += controller_TrafficChanged; updateChecker = new UpdateChecker(); updateChecker.CheckUpdateCompleted += updateChecker_CheckUpdateCompleted; LoadCurrentConfiguration(); Configuration config = controller.GetCurrentConfiguration(); if (config.firstRun) { ShowConfigForm(); } else if (config.autoCheckUpdate) { _isStartupCheck = true; Dispatcher.CurrentDispatcher.Invoke(() => updateChecker.CheckForVersionUpdate(3000)); } }
public HotkeySettingsForm(ShadowsocksController 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 AwsEc2(ShadowsocksController controller, string accessKey, string secretKey) { // aws 配置用户名和密码 AddOrUpdateAppSettings("AWSProfileName", "aws_profile"); var options = new CredentialProfileOptions { AccessKey = accessKey, SecretKey = secretKey }; var profile = new Amazon.Runtime.CredentialManagement.CredentialProfile("aws_profile", options); var netSDKFile = new NetSDKCredentialsFile(); netSDKFile.RegisterProfile(profile); // 初始化客户端 ec2Client = new AmazonEC2Client(RegionEndpoint.USWest2); this.controller = controller; }
public PingForm(ShadowsocksController sc) { InitializeComponent(); var qqwryPath = Environment.CurrentDirectory + "\\qqwry.dat"; if (Util.Utils.qqwry == null && File.Exists(qqwryPath)) { Util.Utils.qqwry = new QQWry(qqwryPath); } controller = sc; Font = Util.Utils.GetFont(); PerformLayout(); UpdateTexts(); Icon = Icon.FromHandle(Resources.ssw128.GetHicon()); LoadConfiguration(controller.GetConfiguration()); if (dgvMain.Rows.Count <= 5) { foreach (var row in dgvMain.Rows) { var t = new Thread(Ping) { IsBackground = true }; t.Start(row); } } else { ChangeStatus(I18N.GetString("DoSomething")); var t = new Thread(Go) { IsBackground = true }; t.Start(dgvMain.Rows); } }
public ConfigForm(ShadowsocksController controller) { Font = SystemFonts.MessageBoxFont; InitializeComponent(); // a dirty hack ServersListBox.Dock = DockStyle.Fill; tableLayoutPanel5.Dock = DockStyle.Fill; PerformLayout(); UpdateTexts(); SetupValueChangedListeners(); Icon = Icon.FromHandle(Resources.ssw128.GetHicon()); this.controller = controller; controller.ConfigChanged += Controller_ConfigChanged; LoadCurrentConfiguration(); }
static void Main() { Util.Utils.ReleaseMemory(true); using (Mutex mutex = new Mutex(false, "Global\\ShadowsocksElder_" + 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; Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); var processesName = Process.GetCurrentProcess().MainModule?.ModuleName ?? "Shadowsocks.exe"; var processesNameWithoutExtension = Path.GetFileNameWithoutExtension(processesName); if (!mutex.WaitOne(0, false)) { Process[] oldProcesses = Process.GetProcessesByName(processesNameWithoutExtension); if (oldProcesses.Length > 0) { Process oldProcess = oldProcesses[0]; } MessageBox.Show(I18N.GetString("Find Shadowsocks icon in your notify tray.") + "\n" + I18N.GetString("If you want to start multiple Shadowsocks, make a copy in another directory."), I18N.GetString("Shadowsocks is already running.")); return; } Directory.SetCurrentDirectory(Application.StartupPath); Logging.OpenLogFile(); ShadowsocksController controller = new ShadowsocksController(); MenuViewController viewController = new MenuViewController(controller); Controller.Hotkeys.HotKeys.Init(controller, viewController); controller.Start(); Application.Run(); } }
public ConfigForm() { this.Font = System.Drawing.SystemFonts.MessageBoxFont; InitializeComponent(); this._trfThread = new Thread(new ThreadStart(this.UpdateTrafficDynamic)); this._trfThread.IsBackground = true; this._trfThread.Start(); // a dirty hack this.ServersListBox.Dock = System.Windows.Forms.DockStyle.Fill; this.PerformLayout(); UpdateTexts(); this.Icon = Resources.icon_128_b; ShadowsocksController.one().ConfigChanged += controller_ConfigChanged; LoadCurrentConfiguration(); this.SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint, true); }
public ApiForm(ShadowsocksController controller) { this.Font = System.Drawing.SystemFonts.MessageBoxFont; InitializeComponent(); this.Icon = Icon.FromHandle(Resources.ssw128.GetHicon()); this.controller = controller; LoadCurrentConfiguration(); UpdateTexts(); updateSubscribeManager = new UpdateSubscribeManager(); backgroundWorker = new BackgroundWorker(); backgroundWorker.WorkerReportsProgress = true; backgroundWorker.WorkerSupportsCancellation = true; backgroundWorker.DoWork += backgroundWorker_DoWork; backgroundWorker.ProgressChanged += backgroundWorker_ProgressChanged; backgroundWorker.RunWorkerCompleted += backgroundWorker1_RunWorkerCompleted; //backgroundWorker.CancelAsync(); }
public NewMainForm(ShadowsocksController controller) { this.Font = System.Drawing.SystemFonts.MessageBoxFont; InitializeComponent(); this.Icon = Icon.FromHandle(Resources.ssw128.GetHicon()); this.controller = controller; LoadCurrentConfiguration(); UpdateTexts(); LoadServer(); updateChecker = new UpdateChecker(); //Thread t = new Thread(new ThreadStart(show_ping_start)); //t.Start(); controller.ConfigChanged += controller_ConfigChanged; updateFreeNodeChecker = new UpdateFreeNode(); updateFreeNodeChecker.NewFreeNodeFound += updateFreeNodeChecker_NewFreeNodeFound; updateSubscribeManager = new UpdateSubscribeManager(); _notifyIcon = new NotifyIcon(); }
public SettingsForm(ShadowsocksController controller) { this.Font = System.Drawing.SystemFonts.MessageBoxFont; InitializeComponent(); this.Icon = Icon.FromHandle(Resources.ssw128.GetHicon()); this.controller = controller; UpdateTexts(); controller.ConfigChanged += controller_ConfigChanged; int dpi_mul = Util.Utils.GetDpiMul(); //comment ////int font_height = 9; ////Font new_font = new Font("Arial", (float)(9.0 * dpi_mul / 4)); ////this.Font = new_font; ////comboProxyType.Height = comboProxyType.Height - font_height + font_height * dpi_mul / 4; //comboProxyType.Width = comboProxyType.Width * dpi_mul / 4; ////RandomComboBox.Height = RandomComboBox.Height - font_height + font_height * dpi_mul / 4; //RandomComboBox.Width = RandomComboBox.Width * dpi_mul / 4; //TextS5Server.Width = TextS5Server.Width * dpi_mul / 4; //NumS5Port.Width = NumS5Port.Width * dpi_mul / 4; //TextS5User.Width = TextS5User.Width * dpi_mul / 4; //TextS5Pass.Width = TextS5Pass.Width * dpi_mul / 4; //TextUserAgent.Width = TextUserAgent.Width * dpi_mul / 4; //NumProxyPort.Width = NumProxyPort.Width * dpi_mul / 4; //TextAuthUser.Width = TextAuthUser.Width * dpi_mul / 4; //TextAuthPass.Width = TextAuthPass.Width * dpi_mul / 4; //buttonDefault.Height = buttonDefault.Height * dpi_mul / 4; //buttonDefault.Width = buttonDefault.Width * dpi_mul / 4; //DNSText.Width = DNSText.Width * dpi_mul / 4; //LocalDNSText.Width = LocalDNSText.Width * dpi_mul / 4; //NumReconnect.Width = NumReconnect.Width * dpi_mul / 4; //NumTimeout.Width = NumTimeout.Width * dpi_mul / 4; //NumTTL.Width = NumTTL.Width * dpi_mul / 4; LoadCurrentConfiguration(); }
public PortSettingsForm(ShadowsocksController controller) { InitializeComponent(); this.Icon = Icon.FromHandle(Resources.ssw128.GetHicon()); this.controller = controller; controller.ConfigChanged += controller_ConfigChanged; comboBoxType.DisplayMember = "Text"; comboBoxType.ValueMember = "Value"; var items = new[] { new { Text = "Port Forward", Value = PortMapType.Forward }, new { Text = "Force Proxy", Value = PortMapType.ForceProxy }, new { Text = "Proxy With Rule", Value = PortMapType.RuleProxy } }; comboBoxType.DataSource = items; LoadCurrentConfiguration(); }
public StatisticsStrategy(ShadowsocksController controller) { _controller = controller; var servers = controller.GetCurrentConfiguration().configs; #region SSD var randomIndex = InitIndex(); //var randomIndex = new Random().Next() % servers.Count; #endregion //如果servers中一个服务器都没有,那说明用户先订阅成功然后再删除了默认节点,因此将第一个订阅的第一台服务器置为默认服务器 if (servers.Count == 0) { _currentServer = controller.GetCurrentConfiguration().subscriptions[0].servers[0]; } else { _currentServer = servers[randomIndex]; //choose a server randomly at first } _timer = new Timer(ReloadStatisticsAndChooseAServer); }
public SubscriptionManagementForm(ShadowsocksController controllerSet) { InitializeComponent(); Controller = controllerSet; ConfigurationCopy = Controller.GetConfigurationCopy(); Text = I18N.GetString("Subscription Management"); Label_url.Text = I18N.GetString("Subscription URL"); Label_name.Text = I18N.GetString("Airport Name"); Button_add.Text = I18N.GetString("&Add"); Button_save.Text = I18N.GetString("&Save"); Button_delete.Text = I18N.GetString("&Delete"); CheckBox_use_proxy.Text = I18N.GetString("Use Proxy"); Label_traffic_used.Text = I18N.GetString("Traffic Used:"); Label_expiry_date.Text = I18N.GetString("Expiry Date:"); Label_proxy_tips.Text = I18N.GetString("* Proxy will always be used in Global Mode"); ResetShowed(); Icon = Icon.FromHandle(Resources.ssw128.GetHicon()); }
public LogForm(ShadowsocksController controller, string filename) { this.controller = controller; this.filename = filename; InitializeComponent(); Icon = Icon.FromHandle(Resources.ssw128_green.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 ServerLogWindow(ShadowsocksController controller, WindowStatus status) { InitializeComponent(); _controller = controller; Closed += (o, e) => { _controller.ConfigChanged -= controller_ConfigChanged; }; _controller.ConfigChanged += controller_ConfigChanged; LoadLanguage(); LoadConfig(); if (status == null) { SizeToContent = SizeToContent.Width; Height = 400; WindowStartupLocation = WindowStartupLocation.CenterScreen; } else { SizeToContent = SizeToContent.Manual; WindowStartupLocation = WindowStartupLocation.Manual; status.SetStatus(this); } }
public MenuViewController(ShadowsocksController 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.SelectRandomStatusChanged += controller_SelectRandomStatusChanged; controller.EnableGlobalChanged += controller_EnableGlobalChanged; controller.Errored += controller_Errored; controller.UpdatePACFromGFWListCompleted += controller_UpdatePACFromGFWListCompleted; controller.UpdatePACFromGFWListError += controller_UpdatePACFromGFWListError; controller.ShowConfigFormEvent += Config_Click; _notifyIcon = new NotifyIcon(); UpdateTrayIcon(); _notifyIcon.Visible = true; _notifyIcon.ContextMenu = contextMenu1; _notifyIcon.MouseClick += notifyIcon1_Click; //_notifyIcon.MouseDoubleClick += notifyIcon1_DoubleClick; this.updateChecker = new UpdateChecker(); updateChecker.NewVersionFound += updateChecker_NewVersionFound; LoadCurrentConfiguration(); if (controller.GetConfiguration().isDefault) { _isFirstRun = true; ShowConfigForm(); } timerDelayCheckUpdate = new System.Timers.Timer(1000 * 10.0); timerDelayCheckUpdate.Elapsed += timer_Elapsed; timerDelayCheckUpdate.Start(); }
static void Main() { Utils.ReleaseMemory(true); using (Mutex mutex = new Mutex(false, "Global\\Shadowsocks_" + Application.StartupPath.GetHashCode())) { AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); if (!mutex.WaitOne(0, false)) { Process[] oldProcesses = Process.GetProcessesByName("Shadowsocks"); if (oldProcesses.Length > 0) { Process oldProcess = oldProcesses[0]; } MessageBox.Show(I18N.GetString("Find Shadowsocks icon in your notify tray.") + "\n" + I18N.GetString("If you want to start multiple Shadowsocks, make a copy in another directory."), I18N.GetString("Shadowsocks 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 ShadowsocksController controller = new ShadowsocksController(); MenuViewController viewController = new MenuViewController(controller); controller.Start(); Application.Run(); } }
public LogForm(ShadowsocksController controller, string filename) { this.controller = controller; this.filename = filename; InitializeComponent(); this.Icon = Icon.FromHandle(Resources.ssw128.GetHicon()); LogViewerConfig config = controller.GetConfigurationCopy().logViewer; if (config == null) { config = new LogViewerConfig(); } topMostTrigger = config.topMost; wrapTextTrigger = config.wrapText; toolbarTrigger = config.toolbarShown; LogMessageTextBox.BackColor = config.GetBackgroundColor(); LogMessageTextBox.ForeColor = config.GetTextColor(); LogMessageTextBox.Font = config.GetFont(); UpdateTexts(); }
public ConfigForm(ShadowsocksController controller, UpdateChecker updateChecker) { this.Font = System.Drawing.SystemFonts.MessageBoxFont; InitializeComponent(); // a dirty hack //this.ServersListBox.Dock = System.Windows.Forms.DockStyle.Fill; //this.PerformLayout(); this.Icon = Icon.FromHandle(Resources.ssw128.GetHicon()); this.controller = controller; this.updateChecker = updateChecker; if (updateChecker.LatestVersionURL == null) { LinkUpdate.Visible = false; } UpdateTexts(); controller.ConfigChanged += controller_ConfigChanged; LoadCurrentConfiguration(); }
public ConfigForm(ShadowsocksController controller) { this.Font = System.Drawing.SystemFonts.MessageBoxFont; InitializeComponent(); // a dirty hack this.ServersListBox.Dock = System.Windows.Forms.DockStyle.Fill; this.PerformLayout(); /****************************** <Start> add by Ian.May,Oct.16 **************************************/ //adjust the sequence because the modified UpdatTexts() relies on controller's instance /***************************** <Start> add by Ian.May,Oct.16 **************************************/ this.controller = controller; controller.ConfigChanged += controller_ConfigChanged; UpdateTexts(); this.Icon = Icon.FromHandle(Resources.ssw128.GetHicon()); ShadowFogModeFormWidth = this.Width; /*******************************<End> add by Ian.May,Oct.16***************************************/ LoadCurrentConfiguration(); }
public MenuViewController(ShadowsocksController controller) { this.controller = controller; LoadMenu(); controller.ToggleModeChanged += controller_ToggleModeChanged; controller.ToggleRuleModeChanged += controller_ToggleRuleModeChanged; controller.ConfigChanged += controller_ConfigChanged; controller.PACFileReadyToOpen += controller_FileReadyToOpen; controller.UserRuleFileReadyToOpen += controller_FileReadyToOpen; controller.Errored += controller_Errored; controller.UpdatePACFromGFWListCompleted += controller_UpdatePACFromGFWListCompleted; controller.UpdatePACFromGFWListError += controller_UpdatePACFromGFWListError; controller.ShowConfigFormEvent += Config_Click; _notifyIcon = new NotifyIcon(); UpdateTrayIcon(); _notifyIcon.Visible = true; _notifyIcon.ContextMenu = contextMenu1; _notifyIcon.MouseClick += notifyIcon1_Click; //_notifyIcon.MouseDoubleClick += notifyIcon1_DoubleClick; updateChecker = new UpdateChecker(); updateChecker.NewVersionFound += updateChecker_NewVersionFound; LoadCurrentConfiguration(); Configuration cfg = controller.GetConfiguration(); if (cfg.isDefaultConfig()) { ShowConfigForm(false); } timerDelayCheckUpdate = new System.Timers.Timer(1000.0 * 10); timerDelayCheckUpdate.Elapsed += timer_Elapsed; timerDelayCheckUpdate.Start(); }
static void Main(string[] args) { #if !_CONSOLE using (Mutex mutex = new Mutex(false, "Global\\ShadowsocksV_" + Application.StartupPath.GetHashCode())) { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); if (!mutex.WaitOne(0, false)) { MessageBox.Show(I18N.GetString("Find Shadowsocks icon in your notify tray.") + "\n" + I18N.GetString("If you want to start multiple Shadowsocks, make a copy in another directory."), I18N.GetString("ShadowsocksV is already running.")); return; } #endif Directory.SetCurrentDirectory(Application.StartupPath); //#if !DEBUG Logging.OpenLogFile(); //#endif ShadowsocksController controller = new ShadowsocksController(); #if !_CONSOLE MenuViewController viewController = new MenuViewController(controller); #endif controller.Start(); #if !_CONSOLE Util.Utils.ReleaseMemory(); Application.Run(); } #else Console.ReadLine(); controller.Stop(); #endif }
public MenuViewController(ShadowsocksController controller) { this.controller = controller; LoadMenu(); controller.ToggleModeChanged += controller_ToggleModeChanged; controller.ToggleRuleModeChanged += controller_ToggleRuleModeChanged; controller.ConfigChanged += controller_ConfigChanged; controller.Errored += controller_Errored; _notifyIcon = new NotifyIcon(); UpdateTrayIcon(); _notifyIcon.Visible = true; _notifyIcon.ContextMenu = contextMenu1; _notifyIcon.MouseClick += notifyIcon1_Click; updateNodeChecker = new UpdateNode(); updateNodeChecker.NewNodeFound += updateNodeChecker_NewNodeFound; updateSubscribeManager = new UpdateSubscribeManager(); updateChinaIPChecker = new UpdateChinaIP(); updateChinaIPChecker.NewChinaIPFound += updateChinaIPChecker_NewChinaIPFound; updateChinaIPManager = new UpdateChinaIPManager(); LoadCurrentConfiguration(); Configuration config = controller.GetCurrentConfiguration(); if (config.nodeFeedAutoUpdate) { updateSubscribeManager.CreateTask(config, updateNodeChecker); } timerDelayCheckUpdate = new System.Timers.Timer(1000.0 * 10); timerDelayCheckUpdate.Elapsed += timer_Elapsed; timerDelayCheckUpdate.Start(); }
public static bool canUrlConnect(string testUrl, string toMatch, bool useProxy) { try { WebClient wclient = new WebClient(); // wclient.BaseAddress = test_web; wclient.Encoding = Encoding.UTF8; wclient.Headers.Add("User-Agent", "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.117 Safari/537.36"); //wclient.Headers.Add("Content-Type", "application/x-www-form-urlencoded"); if (useProxy) { ShadowsocksController controller = new ShadowsocksController(); Configuration config = controller.GetCurrentConfiguration(); WebProxy proxy = new WebProxy(IPAddress.Loopback.ToString(), config.localPort); if (!string.IsNullOrEmpty(config.authPass)) { proxy.Credentials = new NetworkCredential(config.authUser, config.authPass); } wclient.Proxy = proxy; } else { // 默认使用ie代理,需要手动取消 wclient.Proxy = null; } //Console.WriteLine(testUrl); Console.WriteLine(useProxy); string source = wclient.DownloadString(testUrl); return(source.Contains(toMatch)); } catch (Exception api_e) { //MessageBox.Show(api_e.ToString()); Console.WriteLine(api_e.ToString()); return(false); } }
public static void StartTcping(ShadowsocksController _controller, string str) { if (mtListControl != null) { mtListControl.WaitOne(-1); } Init(_controller); if (listTCPingList1.Count == 0 && listInTCPing.Count == 0) { Logging.Debug("Update latency started."); } listTCPingList2.Add(new List <string>()); listTCPingList_backup.Add(new List <string>()); listTCPingList1.Add(str); listTCPingList2[listTCPingList2.Count - 1].Add(str); listTCPingList_backup[listTCPingList_backup.Count - 1].Add(str); mtListControl.ReleaseMutex(); Thread thStart = new Thread(new ParameterizedThreadStart(Start)); thStart.Start(new object[] { false }); }
public SettingsForm(ShadowsocksController controller) { InitializeComponent(); Font = SystemFonts.MessageBoxFont; Icon = Icon.FromHandle(Resources.ssw128.GetHicon()); _controller = controller; UpdateTexts(); controller.ConfigChanged += controller_ConfigChanged; int dpi_mul = Util.Utils.GetDpiMul(); NumProxyPort.Width = NumProxyPort.Width * dpi_mul / 4; TextAuthUser.Width = TextAuthUser.Width * dpi_mul / 4; TextAuthPass.Width = TextAuthPass.Width * dpi_mul / 4; DNSText.Width = DNSText.Width * dpi_mul / 4; NumReconnect.Width = NumReconnect.Width * dpi_mul / 4; NumTimeout.Width = NumTimeout.Width * dpi_mul / 4; NumTTL.Width = NumTTL.Width * dpi_mul / 4; LoadCurrentConfiguration(); }
public HighAvailabilityStrategy(ShadowsocksController controller) { _controller = controller; _random = new Random(); _serverStatus = new Dictionary<SsServerInfo, ServerStatus>(); }
private HotkeyCallbacks(ShadowsocksController controller) { _controller = controller; }
public Socks5Handler(ShadowsocksController controller, Configuration config, TCPRelay tcprelay, Socket socket) : base(controller, config, tcprelay, socket, false) { }
public TCPRelay(ShadowsocksController controller, Configuration conf) { _controller = controller; _config = conf; _lastSweepTime = DateTime.Now; _factories.Add(new Socks5HandlerFactory()); _factories.Add(new HttpHandlerHandlerFactory()); }
public TCPHandler NewHandler(ShadowsocksController controller, Configuration config, TCPRelay tcprelay, Socket socket) { return new HttpHandler(controller, config, tcprelay, socket); }
public HttpHandler(ShadowsocksController controller, Configuration config, TCPRelay tcprelay, Socket socket) : base(controller, config, tcprelay, socket) { _localSocket = new WrappedSocket(socket); }