Esempio n. 1
0
        public String GetRuleString()
        {
            StringBuilder sb = new StringBuilder();

            if (!MatchSet.Null)
            {
                sb.Append((MatchSet.Not ? "! " : "") + OptionMatchSet + " " +
                          ShellHelper.EscapeArguments(MatchSet.Value));
                sb.Append(" " + MatchSetFlags);
            }

            if (ReturnNoMatch)
            {
                sb.Append(" " + OptionNoMatch);
            }

            if (!UpdateCounters)
            {
                sb.Append(" ! " + OptionUpdateCounters);
            }

            if (!UpdateSubCounters)
            {
                sb.Append(" ! " + OptionUpdateSubCounters);
            }

            if (PacketsMatch != MatchMode.None)
            {
                sb.Append(" " + GetMatch("packets", PacketsMatch) + " " + PacketsValue);
            }

            if (BytesMatch != MatchMode.None)
            {
                sb.Append(" " + GetMatch("bytes", BytesMatch) + " " + BytesValue);
            }

            return(sb.ToString());
        }
 public void TestPipe()
 {
     Assert.AreEqual("'|'", ShellHelper.EscapeArguments("|"));
     Assert.AreEqual("'a|word'", ShellHelper.EscapeArguments("a|word"));
     Assert.AreEqual("singleword", ShellHelper.EscapeArguments("singleword"));
 }
 public void TestSpaces()
 {
     Assert.AreEqual("'a word'", ShellHelper.EscapeArguments("a word"));
     Assert.AreEqual("singleword", ShellHelper.EscapeArguments("singleword"));
 }
Esempio n. 4
0
        public String GetRuleString()
        {
            var sb = new StringBuilder();

            sb.Append(OptionHashLimitName);
            sb.Append(" ");
            sb.Append(ShellHelper.EscapeArguments(Name));

            sb.Append(" ");
            if (LimitMode == HashLimitMode.Upto)
            {
                sb.Append(OptionHashLimitUpto);
            }
            else
            {
                sb.Append(OptionHashLimitAbove);
            }
            sb.Append(" ");
            sb.Append(LimitRate);
            sb.Append("/");
            sb.Append(GetUnit(Unit));

            sb.Append(" ");
            sb.Append(OptionHashLimitBurst);
            sb.Append(" ");
            sb.Append(Burst);

            sb.Append(" ");
            sb.Append(OptionHashLimitMode);
            sb.Append(" ");
            sb.Append(Mode);

            sb.Append(" ");
            sb.Append(OptionHashLimitSrcMask);
            sb.Append(" ");
            sb.Append(SrcMask);

            sb.Append(" ");
            sb.Append(OptionHashLimitDstMask);
            sb.Append(" ");
            sb.Append(DstMask);

            sb.Append(" ");
            sb.Append(OptionHashLimitHtableSize);
            sb.Append(" ");
            sb.Append(HtableSize);

            sb.Append(" ");
            sb.Append(OptionHashLimitHtableMax);
            sb.Append(" ");
            sb.Append(HtableMax);

            sb.Append(" ");
            sb.Append(OptionHashLimitHtableExpire);
            sb.Append(" ");
            sb.Append(HtableExpire);

            sb.Append(" ");
            sb.Append(OptionHashLimitHtableGcInterval);
            sb.Append(" ");
            sb.Append(HtableGcInterval);

            return(sb.ToString());
        }