Skip to content

Commit 5481bc8

Browse files
committed
KeyEquals cidr loose comparison mode
1 parent d116455 commit 5481bc8

2 files changed

Lines changed: 6 additions & 6 deletions

File tree

IPTables.Net/Iptables/IpSet/IpSetEntry.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -161,13 +161,13 @@ public static IpSetEntry Parse(String[] arguments, IpSetSets sets, int startOffs
161161
}
162162
}
163163

164-
public bool KeyEquals(IpSetEntry other)
164+
public bool KeyEquals(IpSetEntry other, bool cidr = true)
165165
{
166-
bool r = _port == other._port && Cidr.Equals(other.Cidr) && string.Equals(_mac, other._mac);
167-
if (!r) return false;
166+
bool r = _port == other._port && (!cidr || Cidr.Equals(other.Cidr)) && Cidr2.Equals(other.Cidr2) && _mac == other._mac;
167+
if (!r)
168+
return false;
168169

169-
return string.Equals(_protocol, other._protocol) ||
170-
(String.IsNullOrEmpty(_protocol) && String.IsNullOrEmpty(other._protocol));
170+
return _protocol == other._protocol;
171171
}
172172

173173
public string GetFullCommand(String command = "add")

IPTables.Net/Iptables/IpSet/IpSetSet.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ protected void SyncEntriesIp(IEnumerable<IpSetEntry> cidrs)
298298
{
299299
foreach (var s2 in entriesClone)
300300
{
301-
if (s.Key.Cidr.Contains(s2.Cidr) && s.Key.KeyEquals(s2))
301+
if (s.Key.Cidr.Contains(s2.Cidr) && s.Key.KeyEquals(s2, false))
302302
{
303303
// size of cidr has changed
304304
_system.SetAdapter.DeleteEntry(s2);

0 commit comments

Comments
 (0)