/// <summary>
 /// Check if equal to another object
 /// </summary>
 /// <param name="obj">Other object</param>
 /// <returns>True if equal, false otherwise</returns>
 public override bool Equals(object obj)
 {
     if (!(obj is IPBanUriFirewallRule rule))
     {
         return(false);
     }
     return(RulePrefix.Equals(rule.RulePrefix) && Uri.Equals(rule.Uri) && Interval.Equals(rule.Interval));
 }
Exemple #2
0
 // update loop state, return true if ok
 internal bool AddLoop(RulePrefix loop)
 {
     _inloop = !_inloop;
     if (_inloop)
     {
         ++_loopcounter;
     }
     Logger.WriteLine(2, $"Add Loop '{loop}'");
     return(_inloop == (loop == RulePrefix.Startloop_));
 }
Exemple #3
0
        public override IEnumerable <string> GetRuleNames(string ruleNamePrefix = null)
        {
            List <string> names = new List <string>();

            lock (this)
            {
                string prefix = ScrubRuleNamePrefix(ruleNamePrefix);
                foreach (string key in blockRules.Keys.Union(blockRulesRanges.Keys).Where(k => k.StartsWith(prefix, StringComparison.OrdinalIgnoreCase)))
                {
                    names.Add(key);
                }
                if (RulePrefix.StartsWith(prefix, StringComparison.OrdinalIgnoreCase) ||
                    RulePrefix.StartsWith(prefix + "Allow", StringComparison.OrdinalIgnoreCase))
                {
                    names.Add(RulePrefix + "Allow");
                }
            }
            return(names);
        }