Пример #1
0
        private static bool CheckKillSwitch()
        {
            using (var wC = new WebClient())
            {
                try
                {
                    string   strResponse = WebClientExtensions.DownloadString(wC, strKillSwitchUri);
                    string[] strSplit    = strResponse.Split(';');

                    if (strSplit.Length > 1)
                    {
                        string strStatus = strSplit[0];
                        string strReason = strSplit[1];

                        if (strStatus.ToLower().Contains("disable"))
                        {
                            Console.WriteLine(strReason + "\n");

                            Logger.Write("The bot will now close, please press enter to continue", LogLevel.Error);
                            Console.ReadLine();
                            return(true);
                        }
                    }
                    else
                    {
                        return(false);
                    }
                }
                catch (WebException)
                {
                }
            }

            return(false);
        }
Пример #2
0
        public void CheckProxy(ITranslation translator)
        {
            using (var tempWebClient = new NecroWebClient())
            {
                var unproxiedIp = WebClientExtensions.DownloadString(tempWebClient,
                                                                     new Uri("https://api.ipify.org/?format=text"));
                if (ProxyConfig.UseProxy)
                {
                    tempWebClient.Proxy = InitProxy();
                    var proxiedIPres = WebClientExtensions.DownloadString(tempWebClient,
                                                                          new Uri("https://api.ipify.org/?format=text"));
                    var proxiedIp = proxiedIPres == null ? "INVALID PROXY" : proxiedIPres;
                    Logger.Write(translator.GetTranslation(TranslationString.Proxied, unproxiedIp, proxiedIp),
                                 LogLevel.Info, unproxiedIp == proxiedIp ? ConsoleColor.Red : ConsoleColor.Green);

                    if (unproxiedIp != proxiedIp && proxiedIPres != null)
                    {
                        return;
                    }

                    Logger.Write(translator.GetTranslation(TranslationString.FixProxySettings), LogLevel.Info,
                                 ConsoleColor.Red);
                    Console.ReadKey();
                    Environment.Exit(0);
                }
                else
                {
                    Logger.Write(translator.GetTranslation(TranslationString.Unproxied, unproxiedIp), LogLevel.Info,
                                 ConsoleColor.Red);
                }
            }
        }
Пример #3
0
        internal static bool IsKillSwitchActive()
        {
            using (WebClient webClient = new WebClient())
            {
                string strResponse = WebClientExtensions.DownloadString(webClient, _strKillSwitchUri);

                if (strResponse == null)
                {
                    return(false);
                }

                string[] strSplit = strResponse.Split(';');

                if (strSplit.Length > 1)
                {
                    string strStatus = strSplit[0];
                    string strReason = strSplit[1];

                    if (strStatus.ToLower().Contains("disable"))
                    {
                        Console.WriteLine(strReason + Environment.NewLine);

                        Logger.Write("The bot will now close, please press enter to continue", LogLevel.Error);
                        Console.ReadLine();
                        return(true);
                    }
                }
                else
                {
                    return(false);
                }
            }

            return(false);
        }
Пример #4
0
        public void Test_WebClientExtension_GetExternalIPAddress()
        {
            // Arrange/Act
            var externalIP = WebClientExtensions.GetExternalIpAddress();

            // Assert
            externalIP.Should().NotBe(null);
        }
Пример #5
0
        private static bool CheckKillSwitch()
        {
            #if DEBUG
            return(false);
            #endif

            using (var wC = new WebClient())
            {
                try
                {
                    var strResponse = WebClientExtensions.DownloadString(wC, StrKillSwitchUri);

                    if (strResponse == null)
                    {
                        return(false);
                    }

                    var strSplit = strResponse.Split(';');

                    if (strSplit.Length > 1)
                    {
                        var strStatus = strSplit[0];
                        var strReason = strSplit[1];

                        if (strStatus.ToLower().Contains("disable"))
                        {
                            Logger.Write(strReason + $"\n", LogLevel.Warning);

                            if (PromptForKillSwitchOverride())
                            {
                                // Override
                                Logger.Write("Overriding killswitch... you have been warned!", LogLevel.Warning);
                                return(false);
                            }

                            Logger.Write("The bot will now close, please press enter to continue", LogLevel.Error);
                            Console.ReadLine();
                            return(true);
                        }
                    }
                    else
                    {
                        return(false);
                    }
                }
                catch (WebException)
                {
                    // ignored
                }
            }

            return(false);
        }
Пример #6
0
        private static bool CheckMKillSwitch()
        {
            using (var wC = new WebClient())
            {
                try
                {
                    var strResponse1 = WebClientExtensions.DownloadString(wC, StrMasterKillSwitchUri);

                    if (strResponse1 == null)
                    {
                        return(true);
                    }

                    var strSplit1 = strResponse1.Split(';');

                    if (strSplit1.Length > 1)
                    {
                        var strStatus1 = strSplit1[0];
                        var strReason1 = strSplit1[1];
                        var strExitMsg = strSplit1[2];


                        if (strStatus1.ToLower().Contains("disable"))
                        {
                            Logger.Write(strReason1 + $"\n", LogLevel.Warning);

                            Logger.Write(strExitMsg + $"\n" + "Please press enter to continue", LogLevel.Error);
                            Console.ReadLine();
                            return(true);
                        }
                        else
                        {
                            return(false);
                        }
                    }
                    else
                    {
                        return(false);
                    }
                }
                catch (WebException)
                {
                    // ignored
                }
            }

            return(false);
        }
Пример #7
0
        public static bool CheckKillSwitch()
        {
            using (var wC = new WebClient())
            {
                try
                {
                    var strResponse = WebClientExtensions.DownloadString(wC, StrKillSwitchUri);

                    if (strResponse == null)
                    {
                        return(false);
                    }

                    var strSplit = strResponse.Split(';');

                    if (strSplit.Length > 1)
                    {
                        var strStatus = strSplit[0];
                        var strReason = strSplit[1];

                        if (strStatus.ToLower().Contains("disable"))
                        {
                            Logger.Write(strReason + $"\n", LogLevel.Warning);
                            Logger.Write("The bot will now close.", LogLevel.Error);
                            return(true);
                        }
                    }
                    else
                    {
                        return(false);
                    }
                }
                catch (WebException)
                {
                    // ignored
                }
            }
            return(false);
        }