<commit_before>﻿using System;
using System.Collections.Generic;
using System.Text;
using IPTables.Net.Iptables.DataTypes;

namespace IPTables.Net.Iptables.Modules.Ct
{
    public class CtTargetModule : ModuleBase, IIpTablesModule, IEquatable<CtTargetModule>
    {
        private const String OptionHelperLong = "--helper";

        private String Helper;

        public CtTargetModule(int version) : base(version)
        {
        }

        public bool Equals(CtTargetModule other)
        {
            if (ReferenceEquals(null, other)) return false;
            if (ReferenceEquals(this, other)) return true;
            return Helper.Equals(other.Helper);
        }

        public bool NeedsLoading
        {
            get { return false; }
        }

        public int Feed(RuleParser parser, bool not)
        {
            int bits;
            switch (parser.GetCurrentArg())
            {
                case OptionHelperLong:
                    Helper = parser.GetNextArg();
                    return 1;
            }

            return 0;
        }

        public String GetRuleString()
        {
            var sb = new StringBuilder();

            if (Helper != null)
            {
                sb.Append(OptionHelperLong + " ");
                sb.Append(Helper);
            }

            return sb.ToString();
        }

        public static HashSet<String> GetOptions()
        {
            var options = new HashSet<string>
            {
                OptionHelperLong
            };
            return options;
        }

        public static ModuleEntry GetModuleEntry()
        {
            return GetTargetModuleEntryInternal("CT", typeof(CtTargetModule), GetOptions);
        }<commit_msg>added ctevents to CT target<commit_after>﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using IPTables.Net.Iptables.DataTypes;

namespace IPTables.Net.Iptables.Modules.Ct
{
    public class CtTargetModule : ModuleBase, IIpTablesModule, IEquatable<CtTargetModule>
    {
        private const String OptionHelperLong = "--helper";
        private const String OptionCtEventsLong = "--ctevents";

        private String Helper;
        private List<String> CtEvents = new List<string>(); 

        public CtTargetModule(int version) : base(version)
        {
        }

        public bool Equals(CtTargetModule other)
        {
            if (ReferenceEquals(null, other)) return false;
            if (ReferenceEquals(this, other)) return true;
            return Helper.Equals(other.Helper) && CtEvents.OrderBy((a)=>a).SequenceEqual(other.CtEvents.OrderBy((a)=>a));
        }

        public bool NeedsLoading
        {
            get { return false; }
        }

        public int Feed(RuleParser parser, bool not)
        {
            switch (parser.GetCurrentArg())
            {
                case OptionHelperLong:
                    Helper = parser.GetNextArg();
                    return 1;
                case OptionCtEventsLong:
                    CtEvents = parser.GetNextArg().Split(new char[]{','}).Select((a)=>a.Trim()).ToList();
                    return 1;
            }

            return 0;
        }

        public String GetRuleString()
        {
            var sb = new StringBuilder();

            if (Helper != null)
            {
                sb.Append(OptionHelperLong + " ");
                sb.Append(Helper);
            }

            if (CtEvents.Any())
            {
                sb.Append(OptionCtEventsLong + " ");
                sb.Append(string.Join(",",CtEvents));
            }

            return sb.ToString();
        }

        public static HashSet<String> GetOptions()
        {
            var options = new HashSet<string>
            {
                OptionHelperLong,
                OptionCtEventsLong
            };
            return options;
        }

        public static ModuleEntry GetModuleEntry()
        {
            return GetTargetModuleEntryInternal("CT", typeof(CtTargetModule), GetOptions);
        }
{'fraction_non_alphanumeric': 0.0918040856509968, 'fraction_numerical': 0.0012306177701206006, 'mean_word_length': 1.5770450221940393, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 14, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5557111', 'n_tokens_mistral': 1064, 'n_tokens_neox': 991, 'n_words': 229}