Skip to content

Commit

Permalink
Adjust some properties
Browse files Browse the repository at this point in the history
  • Loading branch information
jjxtra committed Apr 25, 2022
1 parent c6139ac commit 55250ec
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 15 deletions.
26 changes: 19 additions & 7 deletions IPBanCore/Core/Interfaces/IIPBanFirewall.cs
Original file line number Diff line number Diff line change
Expand Up @@ -175,29 +175,41 @@ public interface IIPBanFirewall : IUpdater, IDisposable
/// </summary>
public struct PacketEvent
{
/// <summary>
/// FQDN of machine sending the event
/// </summary>
[System.Text.Json.Serialization.JsonPropertyName("f")]
public string FQDN { get; init; }

/// <summary>
/// Source ip address of the packet
/// </summary>
[System.Text.Json.Serialization.JsonPropertyName("s")]
public string SourceIpAddress { get; init; }
[System.Text.Json.Serialization.JsonPropertyName("l")]
public string LocalIpAddress { get; init; }

/// <summary>
/// Source port of the packet or 0 if unknown/not applicable
/// </summary>
[System.Text.Json.Serialization.JsonPropertyName("p")]
public int SourcePort { get; init; }
public int LocalPort { get; init; }

/// <summary>
/// Remote country (if known)
/// </summary>
[System.Text.Json.Serialization.JsonPropertyName("c")]
public string RemoteCountry { get; set; }

/// <summary>
/// Destination ip address of the packet
/// </summary>
[System.Text.Json.Serialization.JsonPropertyName("d")]
public string DestinationIpAddress { get; init; }
[System.Text.Json.Serialization.JsonPropertyName("r")]
public string RemoteIpAddress { get; init; }

/// <summary>
/// Destination port of the packet or 0 if unknown/not applicable
/// </summary>
[System.Text.Json.Serialization.JsonPropertyName("r")]
public int DestinationPort { get; init; }
[System.Text.Json.Serialization.JsonPropertyName("o")]
public int RemotePort { get; init; }

/// <summary>
/// Rule name if known, otherwise null
Expand Down
16 changes: 8 additions & 8 deletions IPBanTests/IPBanFirewallTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -298,19 +298,19 @@ void PacketCallback(in PacketEvent e)
firewall.SendPacketEvent(new PacketEvent
{
Allowed = false,
SourceIpAddress = "2.2.2.2",
SourcePort = 1234,
DestinationIpAddress = "3.3.3.3",
DestinationPort = 8000,
LocalIpAddress = "2.2.2.2",
LocalPort = 1234,
RemoteIpAddress = "3.3.3.3",
RemotePort = 8000,
Outbound = false,
Protocol = System.Net.Sockets.ProtocolType.Tcp,
RuleName = "test"
}).Sync();
Assert.IsNotNull(packetEvent);
Assert.AreEqual("2.2.2.2", packetEvent.Value.SourceIpAddress);
Assert.AreEqual(1234, packetEvent.Value.SourcePort);
Assert.AreEqual("3.3.3.3", packetEvent.Value.DestinationIpAddress);
Assert.AreEqual(8000, packetEvent.Value.DestinationPort);
Assert.AreEqual("2.2.2.2", packetEvent.Value.LocalIpAddress);
Assert.AreEqual(1234, packetEvent.Value.LocalPort);
Assert.AreEqual("3.3.3.3", packetEvent.Value.RemoteIpAddress);
Assert.AreEqual(8000, packetEvent.Value.RemotePort);
Assert.AreEqual(System.Net.Sockets.ProtocolType.Tcp, packetEvent.Value.Protocol);
Assert.AreEqual("test", packetEvent.Value.RuleName);
Assert.AreEqual(false, packetEvent.Value.Allowed);
Expand Down

0 comments on commit 55250ec

Please sign in to comment.