IFireWall Interface
Interface IFireWall provides access to the FireWall management framework.
Namespace:
Walter.Web.FireWallAssembly: Walter.Web.FireWall (in Walter.Web.FireWall.dll)
Examples
Use dependency injection in your controller to gain access to the firewall's properties and methods
using Microsoft.AspNetCore.Mvc; using System.Collections.Generic; using Walter.Web.FireWall; namespace ASP_WAF.Controllers { public class FireWallController : Controller { IFireWall _fireWall; public FireWallController(IFireWall fireWall) { _fireWall = fireWall; } public IActionResult Index() { return View(); } public IActionResult LookWhoIsTalking() { var report = _fireWall.GetReport(Walter.Web.FireWall.Reporting.ReportTypes.Talking); IEnumerable<Walter.Net.LookWhosTalking.TcpProcessHistoricRecord> talking = report.Details.Talking; return View(talking); } } }
You can use the firewall by registering it with dependency injection as shown in the following code sample. The code sample generates the same registration as what would occur when you configure the application via setup
[ClassInitialize] public static void ClassInitialize(TestContext context) { var conf = new FireWallConfig(FireWallTrial.License, FireWallTrial.DomainKey, new System.Uri("https://localhost:5001", System.UriKind.Absolute)) { AppDataFolder = datafolder, }; conf.Geography.DataDetailLevels = GeoDataDetailLevels.County | GeoDataDetailLevels.City; conf.Geography.UseMethod = GeoMethod.UseFile; conf.Geography.ConnectionString = @"D:\MaxMind"; conf.Geography[ContentType.GeoData.ToString()] = Path.Combine(conf.Geography.ConnectionString, "GeoLite2-Country.mmdb"); conf.Geography[ContentType.CityData.ToString()] = Path.Combine(conf.Geography.ConnectionString, "GeoLite2-City.mmdb"); DIContainer.SetDefaultInstance<IFireWallConfig>(conf); var state = new DbState("dbo", "Data Source=LocalHost;Initial Catalog=AspWafFireWallState;Integrated Security=True;", TimeSpan.FromDays(365 * 3)); DIContainer.SetDefaultInstance<DbState>(state); conf.Cashing.BufferFirewallData = TimeSpan.FromSeconds(3); var serviceProvider = new ServiceCollection() .AddLogging() .AddMemoryCache() .AddSingleton<IFireWallConfig>(conf) .AddSingleton(typeof(IFireWall), typeof(MyFireWall)) .AddSingleton(typeof(ILatLongRepository),typeof(MaxMindRepository)) .BuildServiceProvider(); DIContainer.ServiceProvider = serviceProvider; } [TestMethod()] public void FlushTest() { var firewall = DIContainer.GetDefaultInstance<IFireWall>(); // your test }