Esempio n. 1
0
 public SniProxy(SniProxyInfo info)
 {
     m_info = info;
 }
Esempio n. 2
0
        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);
        }