static void SetAutoPac(IPEndPoint endPoint) { if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { if (endPoint.Address.ToString() == IPAddress.Any.ToString()) { endPoint = new IPEndPoint(IPAddress.Loopback, endPoint.Port); } SetProxy.Set(PacServer.CreatePacUri(endPoint)); } }
static void Main(string[] args) { ConfigFile cfg = new ConfigFile( #if DEBUG "proxy-configurer.cfg" #else "/etc/proxy-configurer.cfg" #endif ); CTS = new CancellationTokenSource(); Console.CancelKeyPress += Interrupted; using (DnsServer dns = new DnsServer(cfg)) { using (PacServer pac = new PacServer(cfg)) { Console.WriteLine("Server is running!"); Task.Delay(int.MaxValue, CTS.Token).Wait(); } } }
public void Run(VgcApis.IService api) { orgSysProxySetting = Lib.Sys.ProxySetter.GetProxySetting(); this.vgcApi = api; var vgcSetting = api.GetVgcSettingService(); var vgcServer = api.GetVgcServersService(); pacServer = new PacServer(); setting = new PsSettings(); serverTracker = new ServerTracker(); // dependency injection setting.Run(vgcSetting); pacServer.Run(setting); serverTracker.Run(setting, pacServer, vgcServer); setting.DebugLog("call Luncher.run"); }
public void Run(VgcApis.Models.IServices.IApiService api) { orgSysProxySetting = Lib.Sys.ProxySetter.GetProxySetting(); VgcApis.Libs.Sys.FileLogger.Info("ProxySetter: save sys proxy settings"); this.vgcApi = api; var vgcSetting = api.GetSettingService(); var vgcServer = api.GetServersService(); pacServer = new PacServer(); setting = new PsSettings(); serverTracker = new ServerTracker(); // dependency injection setting.Run(vgcSetting); pacServer.Run(setting); serverTracker.Run(setting, pacServer, vgcServer); setting.DebugLog("call Luncher.run"); }
EventClicked CreateEventClicked() { return(new EventClicked { CopyPacUriTo = () => { Xamarin.Essentials.Clipboard.SetTextAsync(PacServer.CreatePacUri(ServerInfo.ExportPacServerEndPoint).AbsoluteUri); }, Start = () => { Intent intent = new Intent(this, typeof(ProxyServer)); ServerHelper.StartServer(this, intent); }, Open = () => { Browser.OpenAsync("https://cn.pornhub.com/", BrowserLaunchMode.External); }, }); }
static void Main(string[] args) { Task.Run(async() => { while (true) { await Task.Delay(new TimeSpan(0, 0, 10)).ConfigureAwait(false); GC.Collect(); } }); //AppDomain.CurrentDomain.FirstChanceException += CurrentDomain_FirstChanceException; //TaskScheduler.UnobservedTaskException += TaskScheduler_UnobservedTaskException; const string PORNHUB_HOST = "www.livehub.com"; const string IWARA_HOST = "iwara.tv"; var ip = Dns.GetHostAddresses(Dns.GetHostName()).Where((item) => item.AddressFamily == AddressFamily.InterNetwork).FirstOrDefault() ?? IPAddress.Loopback; var pornhubListensEndPoint = new IPEndPoint(ip, 1080); var pacListensEndPoint = new IPEndPoint(ip, 8080); var adErrorEndpoint = new IPEndPoint(IPAddress.Loopback, 80); var iwaraLsitensPoint = new IPEndPoint(ip, 6456); var adVido = File.ReadAllBytes("ad.mp4"); PacServer pacServer = PacServer.Start(pacListensEndPoint, PacHelper.Create((host) => host == "www.pornhub.com", ProxyMode.CreateHTTP(adErrorEndpoint)), PacHelper.Create((host) => host == "hubt.pornhub.com", ProxyMode.CreateHTTP(adErrorEndpoint)), PacHelper.Create((host) => host == "ajax.googleapis.com", ProxyMode.CreateHTTP(adErrorEndpoint)), PacHelper.Create((host) => PacMethod.dnsDomainIs(host, "pornhub.com"), ProxyMode.CreateHTTP(pornhubListensEndPoint)), PacHelper.Create((host) => PacMethod.dnsDomainIs(host, "adtng.com"), ProxyMode.CreateHTTP(pornhubListensEndPoint)), PacHelper.Create((host) => PacMethod.dnsDomainIs(host, IWARA_HOST), ProxyMode.CreateHTTP(iwaraLsitensPoint))); SetProxy.Set(PacServer.CreatePacUri(pacListensEndPoint)); var ca = File.ReadAllBytes("myCA.pfx"); X509Certificate2 mainCert = TLSBouncyCastleHelper.GenerateTls(ca, "pornhub.com", 2048, 2, new string[] { "pornhub.com", "*.pornhub.com" }); X509Certificate2 adCert = TLSBouncyCastleHelper.GenerateTls(ca, "adtng.com", 2048, 2, new string[] { "adtng.com", "*.adtng.com" }); X509Certificate2 iwaraCert = TLSBouncyCastleHelper.GenerateTls(ca, "iwara.tv", 2048, 2, new string[] { "*.iwara.tv" }); PornhubProxyInfo info = new PornhubProxyInfo { MainPageStreamCreate = Connect.CreateLocalStream(new X509Certificate2(mainCert), SslProtocols.Tls12), ADPageStreamCreate = Connect.CreateLocalStream(new X509Certificate2(adCert), SslProtocols.Tls12), RemoteStreamCreate = Connect.CreateRemoteStream(PORNHUB_HOST, 443, PORNHUB_HOST, (a, b) => new MHttpStream(a, b), SslProtocols.Tls12), MaxContentSize = 1024 * 1024 * 5, ADVideoBytes = adVido, CheckingVideoHtml = Connect.CheckingVideoHtml, MaxRefreshRequestCount = 30, ReplaceResponseHtml = Connect.ReplaceResponseHtml, }; PornhubProxyServer server = new PornhubProxyServer(info); Task t1 = server.Start(pornhubListensEndPoint); SniProxyInfo iwaraSniInfo = new SniProxyInfo( iwaraLsitensPoint, Connect.CreateDnsLocalStream(), Connect.CreateDnsRemoteStream("104.20.27.25", 443)); SniProxy iwaraSniProxy = new SniProxy(iwaraSniInfo); Task t2 = iwaraSniProxy.Start(); Task.WaitAll(t1, t2); }