Example #1
0
 /* Prepare method Create System here (add return, arguments and body)*/
 static ISystem CreateSystem(ISystemFactory factory)
 {
     // tworze tylko jedną konkrecję system generaal
     //bo nie ma według mnie sensu rozkładać tego na dwie klasy różniące się tylko nazwą
     // ale wrazie co konkrecje są stworzone w Interfaces.cs wystarczy odkomentować
     return(new SystemGeneral(factory.CreateForm(), factory.CreateDisplay()));
 }
Example #2
0
        /// <summary>
        /// Does the Linux Kernel support SYNPROXY
        /// </summary>
        /// <param name="system"></param>
        /// <returns></returns>
        public static bool KernelSupported(ISystemFactory system)
        {
            String output, error;
            using (var process = system.StartProcess("uname", "-r"))
            {
                ProcessHelper.ReadToEnd(process, out output, out error);
                if (process.ExitCode != 0)
                {
                    throw new IpTablesNetException("Unable to execute uname and retreive the kenel version");
                }
            }
            var regex = new Regex(@"([0-9]+)\.([0-9]+)\.([0-9]+)\-([0-9]+)");
            if (regex.IsMatch(output))
            {
                var match = regex.Match(output);
                var version = new Version(int.Parse(match.Groups[1].Value), int.Parse(match.Groups[2].Value),
                    int.Parse(match.Groups[3].Value), int.Parse(match.Groups[4].Value));

                if (version >= new Version(3, 12))
                {
                    return true;
                }
            }

            return false;
        }
Example #3
0
        /// <summary>
        /// Does the Linux Kernel support SYNPROXY
        /// </summary>
        /// <param name="system"></param>
        /// <returns></returns>
        public static bool KernelSupported(ISystemFactory system)
        {
            String output, error;

            using (var process = system.StartProcess("uname", "-r"))
            {
                ProcessHelper.ReadToEnd(process, out output, out error);
                if (process.ExitCode != 0)
                {
                    throw new IpTablesNetException("Unable to execute uname and retreive the kenel version");
                }
            }
            var regex = new Regex(@"([0-9]+)\.([0-9]+)\.([0-9]+)\-([0-9]+)");

            if (regex.IsMatch(output))
            {
                var match   = regex.Match(output);
                var version = new Version(int.Parse(match.Groups[1].Value), int.Parse(match.Groups[2].Value),
                                          int.Parse(match.Groups[3].Value), int.Parse(match.Groups[4].Value));

                if (version >= new Version(3, 12))
                {
                    return(true);
                }
            }

            return(false);
        }
Example #4
0
        public SystemIO(ISystemFactory factory)
        {
            if (factory == null)
            {
                throw new ArgumentNullException(nameof(factory));
            }

            _directory = new Lazy <ISystemIODirectory>(factory.CreateSystemIODirectory);
        }
 public FileConfigurationLoggingSystemInitializer(
     IFileConfigurationContainerGetterFactory<Configuration.Configuration> configurationContainerGetterFactory,
     IFileReaderFactory<Configuration.Configuration> fileConfigurationReaderFactory,
     ISystemFactory systemFactory)
 {
     _configurationContainerGetterFactory = configurationContainerGetterFactory;
     _fileConfigurationReaderFactory = fileConfigurationReaderFactory;
     _systemFactory = systemFactory;
 }
 public FileConfigurationLoggingSystemInitializer(
     IFileConfigurationContainerGetterFactory <Configuration.Configuration> configurationContainerGetterFactory,
     IFileReaderFactory <Configuration.Configuration> fileConfigurationReaderFactory,
     ISystemFactory systemFactory)
 {
     _configurationContainerGetterFactory = configurationContainerGetterFactory;
     _fileConfigurationReaderFactory      = fileConfigurationReaderFactory;
     _systemFactory = systemFactory;
 }
Example #7
0
 public NetfilterSystem(ISystemFactory system, INetfilterAdapter tableAdapter, IpSetBinaryAdapter setAdapter = null)
 {
     _system       = system;
     _tableAdapter = tableAdapter;
     if (setAdapter == null)
     {
         setAdapter = new IpSetBinaryAdapter(system);
     }
     _setAdapter = setAdapter;
 }
Example #8
0
 public NetfilterSystem(ISystemFactory system, INetfilterAdapter tableAdapter, IpSetBinaryAdapter setAdapter = null)
 {
     _system = system;
     _tableAdapter = tableAdapter;
     if (setAdapter == null)
     {
         setAdapter = new IpSetBinaryAdapter(system);
     }
     _setAdapter = setAdapter;
 }
Example #9
0
        public System(ISystemFactory factory)
        {
            if (factory == null)
            {
                throw new ArgumentNullException(nameof(factory));
            }

            _dateTime    = new Lazy <ISystemDateTime>(factory.CreateSystemDateTime);
            _environment = new Lazy <ISystemEnvironment>(factory.CreateSystemEnvironment);
            _io          = new Lazy <ISystemIO>(factory.CreateSystemIO);
        }
Example #10
0
 public NetfilterSystem(ISystemFactory system, INetfilterAdapter tableAdapter, IpSetBinaryAdapter setAdapter = null)
 {
     _system        = system;
     _tableAdapter4 = tableAdapter == null ? null : tableAdapter.GetClient(this, 4);
     _tableAdapter6 = tableAdapter == null ? null : tableAdapter.GetClient(this, 6);
     if (setAdapter == null)
     {
         setAdapter = new IpSetBinaryAdapter(system);
     }
     _setAdapter = setAdapter;
 }
Example #11
0
 public RuleBuilder(IpTablesSystem system, String nfbpf, Dictionary<int, IpTablesRuleSet> ruleSets, FunctionRegistry functions = null)
 {
     if (functions == null)
     {
         functions = new FunctionRegistry();
     }
     _system = system.System;
     _nfbpf = nfbpf;
     var chainsDict =
         ruleSets.Select((a) => new KeyValuePair<int, IpTablesChainSet>(a.Key, a.Value.Chains))
             .ToDictionary((a) => a.Key, (a) => a.Value);
     _dcr = new DynamicChainRegister(system, chainsDict);
     _formatDb = new DynamicDictionary<object>(_mappings);
     _ruleSets = ruleSets;
     _interpreter = new Interpreter();
     _interpreter.SetVariable("var", _mappings);
     functions.LoadFunctions(_interpreter);
 }
Example #12
0
        public RuleBuilder(IpTablesSystem system, String nfbpf, Dictionary <int, IpTablesRuleSet> ruleSets, FunctionRegistry functions = null)
        {
            if (functions == null)
            {
                functions = new FunctionRegistry();
            }
            _system = system.System;
            _nfbpf  = nfbpf;
            var chainsDict =
                ruleSets.Select((a) => new KeyValuePair <int, IpTablesChainSet>(a.Key, a.Value.Chains))
                .ToDictionary((a) => a.Key, (a) => a.Value);

            _dcr         = new DynamicChainRegister(system, chainsDict);
            _formatDb    = new DynamicDictionary <object>(_mappings);
            _ruleSets    = ruleSets;
            _interpreter = new Interpreter();
            _interpreter.SetVariable("var", _mappings);
            functions.LoadFunctions(_interpreter);
        }
Example #13
0
        public OutputFileHelper(string outputDirectory, ISystemFactory systemFactory)
        {
            if (systemFactory == null)
            {
                throw new ArgumentNullException(nameof(systemFactory));
            }

            _dateTime = systemFactory.CreateSystemDateTime();
            if (_dateTime == null)
            {
                throw new InvalidOperationException($"Expected {nameof(_dateTime)} not to be null");
            }

            var environment = systemFactory.CreateSystemEnvironment();

            if (environment == null)
            {
                throw new InvalidOperationException($"Expected {nameof(environment)} not to be null");
            }

            var directory = systemFactory.CreateSystemIODirectory();

            if (directory == null)
            {
                throw new InvalidOperationException($"Expected {nameof(directory)} not to be null");
            }

            if (!string.IsNullOrWhiteSpace(outputDirectory))
            {
                VerifyPathOrThrow(outputDirectory);
                _outputDirectory = outputDirectory;
            }
            else
            {
                _outputDirectory = Path.Combine(environment.CurrentDirectory, DefaultOutputDirectoryName);
            }

            if (!directory.Exists(_outputDirectory))
            {
                directory.CreateDirectory(_outputDirectory);
            }
        }
Example #14
0
 public NfTablesSystem(ISystemFactory system, INfTablesAdapter adapter)
     : base(system, adapter)
 {
 }
Example #15
0
 public IpController(String module, ISystemFactory system)
 {
     _module = module;
     _system = system;
 }
 public IpSetBinaryAdapter(ISystemFactory system)
 {
     _system = system;
 }
Example #17
0
 public IpController(String module, ISystemFactory system)
 {
     _module = module;
     _system = system;
 }
Example #18
0
 public IpRuleController(ISystemFactory system) : base("rule", system)
 {
 }
Example #19
0
 public NfAcct(ISystemFactory system)
 {
     _system = system;
 }
 public IpRouteController(ISystemFactory system) : base("route", system)
 {
 }
Example #21
0
 public NfTablesSystem(ISystemFactory system, INfTablesAdapter adapter)
     : base(system, adapter)
 {
 }
Example #22
0
 public Sysctl(ISystemFactory system)
 {
     _system = system;
 }
Example #23
0
 public IpRuleController(ISystemFactory system) : base("rule", system)
 {
 }
Example #24
0
 public IpTablesSystem(ISystemFactory system, IIPTablesAdapter tableAdapter, IpSetBinaryAdapter setAdapter = null)
     : base(system, tableAdapter, setAdapter)
 {
 }
 public IpSetBinaryAdapter(ISystemFactory system)
 {
     _system = system;
 }
 public IpRouteController(ISystemFactory system) : base("route", system)
 {
 }
Example #27
0
 /* Prepare method Create System here (add return, arguments and body)*/
 static ISystem CreateSystem(ISystemFactory systemFactory)
 {
     return(systemFactory.CreateSystem());
 }
Example #28
0
 public IpTablesSystem(ISystemFactory system, IIPTablesAdapter tableAdapter, IpSetBinaryAdapter setAdapter = null)
     : base(system, tableAdapter, setAdapter)
 {
 }
Example #29
0
 public NfAcct(ISystemFactory system)
 {
     _system = system;
 }
Example #30
0
 public Sysctl(ISystemFactory system)
 {
     _system = system;
 }