Skip to content

Commit

Permalink
KeyEquals cidr loose comparison mode
Browse files Browse the repository at this point in the history
  • Loading branch information
splitice committed May 29, 2021
1 parent d116455 commit 5481bc8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
10 changes: 5 additions & 5 deletions IPTables.Net/Iptables/IpSet/IpSetEntry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -161,13 +161,13 @@ public static IpSetEntry Parse(String[] arguments, IpSetSets sets, int startOffs
}
}

public bool KeyEquals(IpSetEntry other)
public bool KeyEquals(IpSetEntry other, bool cidr = true)
{
bool r = _port == other._port && Cidr.Equals(other.Cidr) && string.Equals(_mac, other._mac);
if (!r) return false;
bool r = _port == other._port && (!cidr || Cidr.Equals(other.Cidr)) && Cidr2.Equals(other.Cidr2) && _mac == other._mac;
if (!r)
return false;

return string.Equals(_protocol, other._protocol) ||
(String.IsNullOrEmpty(_protocol) && String.IsNullOrEmpty(other._protocol));
return _protocol == other._protocol;
}

public string GetFullCommand(String command = "add")
Expand Down
2 changes: 1 addition & 1 deletion IPTables.Net/Iptables/IpSet/IpSetSet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ protected void SyncEntriesIp(IEnumerable<IpSetEntry> cidrs)
{
foreach (var s2 in entriesClone)
{
if (s.Key.Cidr.Contains(s2.Cidr) && s.Key.KeyEquals(s2))
if (s.Key.Cidr.Contains(s2.Cidr) && s.Key.KeyEquals(s2, false))
{
// size of cidr has changed
_system.SetAdapter.DeleteEntry(s2);
Expand Down

0 comments on commit 5481bc8

Please sign in to comment.