public static AntiBotConfig CreateDefault(HttpContext httpContext)
        {
            var config = new AntiBotConfig()
            {
                HttpContext    = httpContext,
                CaptchaPageUrl = CAPTCHA_PAGE_URL,
                SameIpBannedIntervalInSeconds  = SAME_IP_BANNED_INTERVAL_IN_SECONDS,
                SameIpIntervalRequestInSeconds = SAME_IP_INTERVAL_REQUEST_IN_SECONDS,
                SameIpMaxRequestInInterval     = SAME_IP_MAX_REQUEST_IN_INTERVAL,
            };

            return(config);
        }
        public static AntiBot ToAntiBot(this HttpContext httpContext)
        {
            var config = new AntiBotConfig()
            {
                HttpContext    = httpContext,
                CaptchaPageUrl = CAPTCHA_PAGE_URL,
                SameIpBannedIntervalInSeconds  = Config.SAME_IP_BANNED_INTERVAL_IN_SECONDS,
                SameIpIntervalRequestInSeconds = Config.SAME_IP_INTERVAL_REQUEST_IN_SECONDS,
                SameIpMaxRequestInInterval     = Config.SAME_IP_MAX_REQUEST_IN_INTERVAL,
            };
            var antiBot = new AntiBot(config);

            return(antiBot);
        }
            public int  GetWaitRemainSeconds(ref AntiBotConfig config)
            {
                var passSeconds = (DateTime.Now - this.DateTime).TotalSeconds;
                var result      = 0;

                if (this.IsBanned)
                {
                    result = config.SameIpBannedIntervalInSeconds - Convert.ToInt32(passSeconds);   // +1;
                }
                else
                {
                    result = config.SameIpIntervalRequestInSeconds - Convert.ToInt32(passSeconds) + 1;
                }
                return((result > 0) ? result : 0);
            }
        public AntiBot(AntiBotConfig config) : this()
        {
            _Config = config;

            if (string.IsNullOrEmpty(_Config.CaptchaPageUrl))
            {
                _Config.CaptchaPageUrl = AntiBotConfig.CAPTCHA_PAGE_URL;
            }

            if (_Config.SameIpBannedIntervalInSeconds <= 0)
            {
                _Config.SameIpBannedIntervalInSeconds = AntiBotConfig.SAME_IP_BANNED_INTERVAL_IN_SECONDS;
            }

            if (_Config.SameIpIntervalRequestInSeconds <= 0)
            {
                _Config.SameIpIntervalRequestInSeconds = AntiBotConfig.SAME_IP_INTERVAL_REQUEST_IN_SECONDS;
            }

            if (_Config.SameIpMaxRequestInInterval <= 0)
            {
                _Config.SameIpMaxRequestInInterval = AntiBotConfig.SAME_IP_MAX_REQUEST_IN_INTERVAL;
            }
        }