From 834b35bdc7e8cd2b2d348ca4accd85e4811ccc1e Mon Sep 17 00:00:00 2001 From: Shreyas Zare Date: Sat, 15 Jun 2019 18:06:27 +0530 Subject: [PATCH] Lease: implemented IComparable and added ':' as allowed char for hardware address parsing. --- DnsServerCore/Dhcp/Lease.cs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/DnsServerCore/Dhcp/Lease.cs b/DnsServerCore/Dhcp/Lease.cs index f91250c3..e2c9db10 100644 --- a/DnsServerCore/Dhcp/Lease.cs +++ b/DnsServerCore/Dhcp/Lease.cs @@ -27,7 +27,7 @@ using TechnitiumLibrary.Net; namespace DnsServerCore.Dhcp { - public class Lease + public class Lease : IComparable { #region variables @@ -89,7 +89,7 @@ namespace DnsServerCore.Dhcp private static byte[] ParseHardwareAddress(string hardwareAddress) { - string[] parts = hardwareAddress.Split('-'); + string[] parts = hardwareAddress.Split(new char[] { '-', ':' }); byte[] address = new byte[parts.Length]; for (int i = 0; i < parts.Length; i++) @@ -140,6 +140,11 @@ namespace DnsServerCore.Dhcp return _hostName + " [" + hardwareAddress + "]"; } + public int CompareTo(Lease other) + { + return _address.ConvertIpToNumber().CompareTo(other._address.ConvertIpToNumber()); + } + #endregion #region properties