Ejemplo n.º 1
0
        public void addRerouteItem(string url)
        {
            if (isRerouting)
            {
                // check no duplicate
                bool found = false;
                lock (_LOCK)
                {
                    foreach (RouteItem rItem in changedRoutes)
                    {
                        if (rItem.URL == url)
                        {
                            found = true;
                            break;
                        }
                    }

                    if (!found)
                    {
                        RouteItem newItem = new RouteItem(url);
                        changedRoutes.Add(newItem);

                        List <String> results = DnsFuncs.GetDnsRecords(url, false);
                        foreach (string ipAddress in results)
                        {
                            if (newItem.AddIpAddress(IPAddress.Parse(ipAddress)))
                            {
                                RouteInterop.AddRoute(ipAddress.Trim(), "255.255.255.255", gateway.ToString(), gatewayIndex);
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 2
0
        void AddRerouteByDNSName(string name)
        {
            var results = DnsFuncs.GetDnsRecords(name);

            foreach (string ipAddress in results)
            {
                /*System.Diagnostics.Process process = new System.Diagnostics.Process();
                 * System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo();
                 * startInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
                 * startInfo.FileName = "cmd.exe";
                 * startInfo.Arguments = "/C route add " + ipAddress.Trim() + " mask 255.255.255.255 " + gateway;
                 * startInfo.Verb = "runas";
                 * process.StartInfo = startInfo;
                 * process.Start();
                 * process.WaitForExit();*/
                RouteInterop.AddRoute(ipAddress.Trim(), "255.255.255.255", gateway.ToString(), gatewayIndex);
            }
        }
Ejemplo n.º 3
0
        public void RerouteNetflix()
        {
            if (isRerouting)
            {
                foreach (IPAddressRange range in netflixRanges)
                {
                    RouteInterop.AddRoute(range.ipAddressLower, range.mask, gateway, gatewayIndex);
                }

                lock (_LOCK)
                {
                    addRerouteItem("netflix.com");
                    addRerouteItem("nflxext.com");
                }

                // Go ahead and ping these urls so they go in cache
                DnsFuncs.GetDnsRecords("secure.netflix.com", false);
                DnsFuncs.GetDnsRecords("codex.nflxext.com", false);
                DnsFuncs.GetDnsRecords("assets.nflxext.com", false);
                DnsFuncs.GetDnsRecords("api-global.netflix.com", false);
                DnsFuncs.GetDnsRecords("customerevents.netflix.com", false);
            }
        }
Ejemplo n.º 4
0
        public void RerouteHulu()
        {
            if (isRerouting)
            {
                /*System.Diagnostics.Process process = new System.Diagnostics.Process();
                 * System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo();
                 * startInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
                 * startInfo.FileName = "cmd.exe";
                 * startInfo.Arguments = "/C nslookup player.hulu.com";
                 * startInfo.CreateNoWindow = true;
                 * //startInfo.Verb = "runas";
                 * process.StartInfo = startInfo;
                 * process.StartInfo.UseShellExecute = false;
                 * process.StartInfo.RedirectStandardOutput = true;
                 * process.Start();
                 * string output = process.StandardOutput.ReadToEnd();
                 * process.WaitForExit();
                 *
                 * var result = output.Split(new[] { '\r', '\n' });
                 * bool sawFirst = false;
                 * string theAddress = null;
                 *
                 * foreach (string line in result)
                 * {
                 *  if (line.Length > 7)
                 *  {
                 *      if (line.Substring(0, 7) == "Address")
                 *      {
                 *          // second address is what we want
                 *          if (sawFirst)
                 *          {
                 *              var addressSplit = line.Trim().Split(':');
                 *              theAddress = addressSplit[1].Trim();
                 *              break;
                 *          }
                 *          else
                 *          {
                 *              sawFirst = true;
                 *          }
                 *      }
                 *  }
                 * }
                 *
                 * if (theAddress != null)
                 * {
                 *  /*process = new System.Diagnostics.Process();
                 *  startInfo = new System.Diagnostics.ProcessStartInfo();
                 *  startInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
                 *  startInfo.FileName = "cmd.exe";
                 *  startInfo.Arguments = "/C route add " + theAddress + " " + gateway;
                 *  startInfo.Verb = "runas";
                 *  process.StartInfo = startInfo;
                 *  process.Start();
                 *  process.WaitForExit();*/
                /*RouteInterop.AddRoute(theAddress, "255.255.255.255", gateway.ToString(), gatewayIndex);
                 * }*/

                lock (_LOCK)
                {
                    addRerouteItem("hulu.com");
                }

                // need to get this subdomain specifically
                DnsFuncs.GetDnsRecords("player.hulu.com", false);
            }
        }