public KillSwitch( IFirewall firewall, IServiceSettings serviceSettings) { _firewall = firewall; _serviceSettings = serviceSettings; }
/// <summary> /// Register an instance of a third party firewall management class /// </summary> /// <param name="firewall">An instance of the firewall management class</param> public static void RegisterFirewall(IFirewall firewall) { if (!ThirdPartyFirewallsBackField.Contains(firewall)) { ThirdPartyFirewallsBackField.Add(firewall); } }
static IFirewallRule CreateRule(IFirewall inst, string path) { var rule = inst.CreateApplicationRule(RuleName, FirewallAction.Block, path); rule.Direction = FirewallDirection.Outbound; rule.IsEnable = false; inst.Rules.Add(rule); return(rule); }
public HttpServer(IHttpRequestHandler requestHandler, IClientFactory clientFactory, IClientContainer clientContainer, IFirewall firewall) : this(requestHandler, clientFactory, clientContainer, firewall, null) { string serialized = System.IO.File.ReadAllText("rimserver.json"); Options = JsonConvert.DeserializeObject <ServerOptions>(serialized); }
public HostEntity(IList<IHost> hosts, string nameOs, string hostName, IPorts ports, IServer server, IFirewall firewall, IOS OS) { _hosts = new ReadOnlyCollection<IHost>(hosts); _nameOS = nameOs; _hostName = hostName; _ports = ports; _server = server; _firewall = firewall; _OS = OS; }
/// <summary> /// Attempts to get an instance of the active firewall. /// </summary> /// <param name="instance">Outputs the active firewall instance, if successful.</param> /// <returns>Returns true if successful, otherwise false.</returns> public static bool TryGetInstance(out IFirewall instance) { try { instance = Instance; return(true); } catch { instance = null; return(false); } }
public Ipv6HandlingWrapper( IServiceSettings serviceSettings, IFirewall firewall, ObservableNetworkInterfaces networkInterfaces, Ipv6 ipv6, ITaskQueue taskQueue, IVpnConnection origin) { _serviceSettings = serviceSettings; _firewall = firewall; _ipv6 = ipv6; _taskQueue = taskQueue; _origin = origin; _origin.StateChanged += Origin_StateChanged; _serviceSettings.SettingsChanged += OnServiceSettingsChanged; networkInterfaces.NetworkInterfacesAdded += NetworkInterfaces_NetworkInterfacesAdded; }
public void MultiMTAThreadAccessTest() { string[] rules1 = null; string[] rules2 = null; IFirewall instance1 = null; IFirewall instance2 = null; var threadId1 = 0; var threadId2 = 0; var thread1 = new Thread(() => { Thread.Sleep(1000); threadId1 = Thread.CurrentThread.ManagedThreadId; instance1 = FirewallManager.Instance; rules1 = FirewallManager.Instance.Rules.Select(rule => rule.Name).ToArray(); }); var thread2 = new Thread(() => { Thread.Sleep(2000); threadId2 = Thread.CurrentThread.ManagedThreadId; instance2 = FirewallManager.Instance; rules2 = FirewallManager.Instance.Rules.Select(rule => rule.Name).ToArray(); }); thread1.SetApartmentState(ApartmentState.MTA); thread2.SetApartmentState(ApartmentState.MTA); thread1.IsBackground = false; thread2.IsBackground = false; thread1.Start(); thread2.Start(); while (thread1.IsAlive || thread2.IsAlive) { Thread.Sleep(100); } Assert.AreNotEqual(threadId1, threadId2); Assert.AreSame(instance1, instance2); Assert.IsTrue(rules1.SequenceEqual(rules2)); }
public HttpServer(IHttpRequestHandler requestHandler, IClientFactory clientFactory, IClientContainer clientContainer, IFirewall firewall, ServerOptions options) { RequestHandler = requestHandler; ClientFactory = clientFactory; Container = Container; if (firewall != null) { Firewall = firewall; } if (options != null) { Options = options; } Logger = new ErrorLogger(this); }
public void Setup() { _firewall = Substitute.For <IFirewall>(); _serviceSettings = Substitute.For <IServiceSettings>(); _networkInterfaceLoader = Substitute.For <INetworkInterfaceLoader>(); }
public void Setup() { _firewall = Substitute.For <IFirewall>(); _serviceSettings = Substitute.For <IServiceSettings>(); }
public void Setup() { _firewall = Substitute.For <IFirewall>(); _serviceSettings = Substitute.For <IServiceSettings>(); _currentNetworkInterface = Substitute.For <ICurrentNetworkInterface>(); }
private Firewall(IFirewall _inst, IFirewallRule _rule) { inst = _inst; rule = _rule; Console.WriteLine("Firewall instance has been created"); }