Walter.BOM Namespace
Walter.Web.FireWall Namespace
ASP-WAF | .Net API for WAF Systems

IFireWall Interface

Interface IFireWall provides access to the FireWall management framework.

Namespace:  Walter.Web.FireWall
Assembly:  Walter.Web.FireWall (in Walter.Web.FireWall.dll)

Syntax


public interface IFireWall : IFireWallDiskGuard

Remarks


The interface can be used with dependency injection to gain access to the firewall.

Examples


The firewall can easily be integrated into your code via dependency injection
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

}

Thread Safety


Static members of this type are safe for multi-threaded operations. Instance members of this type are safe for multi-threaded operations.