Beispiel #1
0
        public int GetRulePosition(IpTablesRule rule)
        {
            var index = Rules.IndexOf(rule);

            if (index == -1)
            {
                return(-1);
            }
            return(index + 1);
        }
Beispiel #2
0
        public bool Compare(IpTablesRule y)
        {
            if (!Chain.Equals(y.Chain))
            {
                return(false);
            }

            var diff = _moduleData.DictionaryDiffering(y.ModuleDataInternal);

            return(diff == default(string));
        }
Beispiel #3
0
            public override bool Equals(IpTablesRule x, IpTablesRule y)
            {
                var ret = base.Equals(x, y);

                if (!ret)
                {
                    var diff = x._moduleData.DictionaryDiffering(y.ModuleDataInternal);
                    Console.WriteLine("1: {0}\r\n2: {1}\r\nDifference: {2}", x.GetActionCommand(), y.GetActionCommand(),
                                      diff);
                }

                return(ret);
            }
Beispiel #4
0
        public void ReplaceRule(INetfilterAdapterClient client, IpTablesRule withRule)
        {
            if (Chain == null)
            {
                throw new IpTablesNetException("Unknown Chain");
            }
            int idx = Chain.Rules.IndexOf(this);

            if (idx == -1)
            {
                throw new IpTablesNetException("Could not find rule to replace");
            }
            client.ReplaceRule(withRule);
            Chain.Rules[idx] = withRule;
        }
Beispiel #5
0
        /// <summary>
        /// Add an IPTables rule to the set
        /// </summary>
        /// <param name="rule"></param>
        public void AddRule(IpTablesRule rule)
        {
            IpTablesChain ipchain = _chains.GetChainOrAdd(rule.Chain);

            ipchain.Rules.Add(rule);
        }