Beispiel #1
0
        public void TestDNSSafeSearch()
        {
            int testsPassed = 0;
            int testsFailed = 0;

            try
            {
                string ip1, ip2, ip3, details;
                bool   result;

                ip3 = "";

                result  = doUrlIpsMatch("https://www.google.com", "https://forcesafesearch.google.com", out ip1, out ip2);
                details = string.Format("IP {0} {1} IP {2}", ip1, result ? "matches" : "does not match expected", ip2);

                OnFilterTestResult?.Invoke(new DiagnosticsEntry(FilterTest.GoogleSafeSearchTest, result, details));

                result  = doUrlIpsMatch("https://www.bing.com", "https://strict.bing.com", out ip1, out ip2);
                details = string.Format("IP {0} {1} IP {2}", ip1, result ? "matches" : "does not match expected", ip2);

                OnFilterTestResult?.Invoke(new DiagnosticsEntry(FilterTest.BingSafeSearchTest, result, details));

                result = doUrlIpsMatch("https://www.youtube.com", "https://restrict.youtube.com", out ip1, out ip2);
                if (result)
                {
                    details = string.Format("IP {0} {1} IP {2}, type: restrict", ip1, "matches", ip2);
                }
                else
                {
                    result  = doUrlIpsMatch("https://www.youtube.com", "https://restrictmoderate.youtube.com", out ip1, out ip3);
                    details = string.Format("IP {0} {1} IP {2}, type: restrict/moderate", ip1, "matches", ip3);
                }
                if (!result)
                {
                    details = string.Format("IP {0} {1} IP {2} or {3}", ip1, "does not match expected", ip2, ip3);
                }

                OnFilterTestResult?.Invoke(new DiagnosticsEntry(FilterTest.YoutubeSafeSearchTest, result, details));

                OnFilterTestResult?.Invoke(new DiagnosticsEntry(FilterTest.AllTestsCompleted, true, ""));
            }
            catch (Exception ex)
            {
                OnFilterTestResult?.Invoke(new DiagnosticsEntry(FilterTest.ExceptionOccurred, false, ex.ToString())
                {
                    Exception = ex
                });
            }
        }
Beispiel #2
0
        /*public void TestInternet()
         * {
         *  try
         *  {
         *      IPHostEntry ipEntry = Dns.GetHostEntry("connectivitycheck.cloudveil.org");
         *  }
         *  catch(Exception ex)
         *  {
         *
         *  }
         *
         *  try
         *  {
         *      var webRequest = WebRequest.CreateHttp("http://connectivitycheck.cloudveil.org/ncsi.txt");]
         *
         *      HttpWebResponse response = (HttpWebResponse)webRequest.GetResponse();
         *
         *      using (StreamReader reader = new StreamReader(response.GetResponseStream()))
         *      {
         *
         *      }
         *  }
         * }*/

        public void TestFilter()
        {
            try
            {
                var webRequest = WebRequest.CreateHttp("http://test.cloudveil.org");

                HttpWebResponse response = (HttpWebResponse)webRequest.GetResponse();

                using (StreamReader reader = new StreamReader(response.GetResponseStream()))
                {
                    string ret = reader.ReadToEnd();
                    if (ret.Contains(filterMagicString))
                    {
                        OnFilterTestResult?.Invoke(new DiagnosticsEntry(FilterTest.BlockingTest, true, "Your filter is up and running!"));
                    }
                    else
                    {
                        OnFilterTestResult?.Invoke(new DiagnosticsEntry(FilterTest.BlockingTest, false, "Your filter did not block the test site. Please reboot to see if that fixes the problem."));
                    }
                }
            }
            catch (WebException ex)
            {
                if (ex.Response == null)
                {
                    OnFilterTestResult?.Invoke(new DiagnosticsEntry(FilterTest.BlockingTest, false, "No response detected from test site. Check your internet connection and try again.")
                    {
                        Exception = ex
                    });
                }
                else
                {
                    OnFilterTestResult?.Invoke(new DiagnosticsEntry(FilterTest.BlockingTest, false, "Unexpected error occurred. " + ex.Message + ". Check your internet connection and try again later.")
                    {
                        Exception = ex
                    });
                }
            }
            catch (Exception ex)
            {
                // FIXME: Any exception needs to get logged for transmission to the cloudveil server.
                OnFilterTestResult?.Invoke(new DiagnosticsEntry(FilterTest.BlockingTest, false, "Unexpected error occurred. " + ex.Message + ". Please contact support.")
                {
                    Exception = ex
                });
            }
        }
Beispiel #3
0
        public void TestDNS()
        {
            int testsPassed = 0;
            int testsFailed = 0;

            try
            {
                string ip = this.getIpFromRequest("https://www.google.com");
                if (ip == GoogleSafeSearchIp)
                {
                    OnFilterTestResult?.Invoke(new DiagnosticsEntry(FilterTest.GoogleSafeSearchTest, true, string.Format("IP {0} matches IP {1}", ip, GoogleSafeSearchIp)));
                }
                else
                {
                    OnFilterTestResult?.Invoke(new DiagnosticsEntry(FilterTest.GoogleSafeSearchTest, false, string.Format("IP {0} does not match expected IP {1}", ip, GoogleSafeSearchIp)));
                }

                string ip1, ip2, details;
                bool   result;

                result  = doUrlIpsMatch("https://www.bing.com", "https://strict.bing.com", out ip1, out ip2);
                details = string.Format("IP {0} {1} IP {2}", ip1, result ? "matches" : "does not match expected", ip2);

                OnFilterTestResult?.Invoke(new DiagnosticsEntry(FilterTest.BingSafeSearchTest, result, details));

                result  = doUrlIpsMatch("https://www.youtube.com", "https://restrict.youtube.com", out ip1, out ip2);
                details = string.Format("IP {0} {1} IP {2}", ip1, result ? "matches" : "does not match expected", ip2);

                OnFilterTestResult?.Invoke(new DiagnosticsEntry(FilterTest.YoutubeSafeSearchTest, result, details));

                result  = doUrlIpsMatch("https://pixabay.com", "https://safesearch.pixabay.com", out ip1, out ip2);
                details = string.Format("IP {0} {1} IP {2}", ip1, result ? "matches" : "does not match expected", ip2);

                OnFilterTestResult?.Invoke(new DiagnosticsEntry(FilterTest.PixabaySafeSearchTest, result, details));

                OnFilterTestResult?.Invoke(new DiagnosticsEntry(FilterTest.AllTestsCompleted, true, ""));
            }
            catch (Exception ex)
            {
                OnFilterTestResult?.Invoke(new DiagnosticsEntry(FilterTest.ExceptionOccurred, false, ex.ToString())
                {
                    Exception = ex
                });
            }
        }
Beispiel #4
0
        public void TestDNS()
        {
            try
            {
                string ip1, ip2, details;
                bool   result;

                result  = doUrlIpsMatch("http://testdns.cloudveil.org", "http://block.cloudveil.org", out ip1, out ip2);
                details = result ? "DNS filtering is currently active on your computer." : "DNS filtering is not currently active on your computer.";

                OnFilterTestResult?.Invoke(new DiagnosticsEntry(FilterTest.DnsFilterTest, result, details));
            }
            catch (Exception ex)
            {
                OnFilterTestResult?.Invoke(new DiagnosticsEntry(FilterTest.ExceptionOccurred, false, ex.ToString())
                {
                    Exception = ex
                });
            }
        }