public UCIPAddressTextBox() { InitializeComponent(); // 处理粘贴 DataObject.AddPastingHandler(this, new DataObjectPastingEventHandler(IPTextBox_Paste)); // 设置textBox次序 IPAddress1.SetNeighbour(null, IPAddress2); IPAddress2.SetNeighbour(IPAddress1, IPAddress3); IPAddress3.SetNeighbour(IPAddress2, IPAddress4); IPAddress4.SetNeighbour(IPAddress3, null); ButtonMoreInformation.Click += ButtonMoreInformation_Click; }
private ProxyService() { mCurrent = this; ProxyDomains = new SourceList <AccelerateProjectGroupDTO>(); ProxyScripts = new SourceList <ScriptDTO>(); ProxyDomains .Connect() .ObserveOn(RxApp.MainThreadScheduler) .Sort(SortExpressionComparer <AccelerateProjectGroupDTO> .Ascending(x => x.Order).ThenBy(x => x.Name)) .Bind(out _ProxyDomainsList) .Subscribe(_ => SelectGroup = ProxyDomains.Items.FirstOrDefault()); this.WhenValueChanged(x => x.ProxyStatus, false) .Subscribe(async x => { if (x) { httpProxyService.ProxyDomains = EnableProxyDomains; httpProxyService.IsEnableScript = ProxySettings.IsEnableScript.Value; httpProxyService.Scripts = EnableProxyScripts; if (IApplication.IsDesktopPlatform) { httpProxyService.IsOnlyWorkSteamBrowser = ProxySettings.IsOnlyWorkSteamBrowser.Value; httpProxyService.IsSystemProxy = ProxySettings.EnableWindowsProxy.Value; httpProxyService.IsProxyGOG = ProxySettings.IsProxyGOG.Value; } else { httpProxyService.IsSystemProxy = true; } // macOS 上目前因权限问题仅支持 0.0.0.0(IPAddress.Any) httpProxyService.ProxyIp = (!OperatingSystem2.IsMacOS && IPAddress2.TryParse(ProxySettings.SystemProxyIp.Value, out var ip)) ? ip : IPAddress.Any; httpProxyService.Socks5ProxyEnable = ProxySettings.Socks5ProxyEnable.Value; httpProxyService.Socks5ProxyPortId = ProxySettings.Socks5ProxyPortId.Value; if (!ModelValidatorProvider.IsPortId(httpProxyService.Socks5ProxyPortId)) { httpProxyService.Socks5ProxyPortId = ProxySettings.DefaultSocks5ProxyPortId; } //httpProxyService.HostProxyPortId = ProxySettings.HostProxyPortId; httpProxyService.TwoLevelAgentEnable = ProxySettings.TwoLevelAgentEnable.Value; httpProxyService.TwoLevelAgentProxyType = (ExternalProxyType)ProxySettings.TwoLevelAgentProxyType.Value; if (!httpProxyService.TwoLevelAgentProxyType.IsDefined()) { httpProxyService.TwoLevelAgentProxyType = IHttpProxyService.DefaultTwoLevelAgentProxyType; } httpProxyService.TwoLevelAgentIp = IPAddress2.TryParse(ProxySettings.TwoLevelAgentIp.Value, out var ip_t) ? ip_t.ToString() : IPAddress.Loopback.ToString(); httpProxyService.TwoLevelAgentPortId = ProxySettings.TwoLevelAgentPortId.Value; if (!ModelValidatorProvider.IsPortId(httpProxyService.TwoLevelAgentPortId)) { httpProxyService.TwoLevelAgentPortId = ProxySettings.DefaultTwoLevelAgentPortId; } httpProxyService.TwoLevelAgentUserName = ProxySettings.TwoLevelAgentUserName.Value; httpProxyService.TwoLevelAgentPassword = ProxySettings.TwoLevelAgentPassword.Value; httpProxyService.ProxyDNS = IPAddress2.TryParse(ProxySettings.ProxyMasterDns.Value, out var dns) ? dns : null; this.RaisePropertyChanged(nameof(EnableProxyDomains)); this.RaisePropertyChanged(nameof(EnableProxyScripts)); if (!httpProxyService.IsSystemProxy) { const ushort httpsPort = 443; var inUse = httpProxyService.PortInUse(httpsPort); if (inUse) { string?error_CommunityFix_StartProxyFaild443 = null; if (OperatingSystem2.IsWindows) { var p = SocketHelper.GetProcessByTcpPort(httpsPort); if (p != null) { error_CommunityFix_StartProxyFaild443 = AppResources.CommunityFix_StartProxyFaild443___.Format(httpsPort, p.ProcessName, p.Id); } } error_CommunityFix_StartProxyFaild443 ??= AppResources.CommunityFix_StartProxyFaild443_.Format(httpsPort); Toast.Show(error_CommunityFix_StartProxyFaild443); return; } } var isRun = await httpProxyService.StartProxy(); if (isRun) { if (!httpProxyService.IsSystemProxy) { if (httpProxyService.ProxyDomains.Any_Nullable()) { var localhost = IPAddress.Any.Equals(httpProxyService.ProxyIp) ? IPAddress.Loopback.ToString() : httpProxyService.ProxyIp.ToString(); var hosts = httpProxyService.ProxyDomains !.SelectMany(s => { if (s == null) { return(default !);