/* 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())); }
/// <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; }
/// <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); }
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; }
public NetfilterSystem(ISystemFactory system, INetfilterAdapter tableAdapter, IpSetBinaryAdapter setAdapter = null) { _system = system; _tableAdapter = tableAdapter; if (setAdapter == null) { setAdapter = new IpSetBinaryAdapter(system); } _setAdapter = setAdapter; }
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); }
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; }
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); }
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); }
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); } }
public NfTablesSystem(ISystemFactory system, INfTablesAdapter adapter) : base(system, adapter) { }
public IpController(String module, ISystemFactory system) { _module = module; _system = system; }
public IpSetBinaryAdapter(ISystemFactory system) { _system = system; }
public IpRuleController(ISystemFactory system) : base("rule", system) { }
public NfAcct(ISystemFactory system) { _system = system; }
public IpRouteController(ISystemFactory system) : base("route", system) { }
public Sysctl(ISystemFactory system) { _system = system; }
public IpTablesSystem(ISystemFactory system, IIPTablesAdapter tableAdapter, IpSetBinaryAdapter setAdapter = null) : base(system, tableAdapter, setAdapter) { }
/* Prepare method Create System here (add return, arguments and body)*/ static ISystem CreateSystem(ISystemFactory systemFactory) { return(systemFactory.CreateSystem()); }