Skip to content
Permalink
Browse files Browse the repository at this point in the history
NuGet v1.0.4.2, fix for SICK-2021-060
  • Loading branch information
jchristn committed Aug 18, 2021
1 parent b697b9c commit 81d77c2
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 3 deletions.
10 changes: 7 additions & 3 deletions IpMatcher/IpMatcher.csproj
Expand Up @@ -3,21 +3,25 @@
<PropertyGroup>
<TargetFrameworks>netstandard2.0;netstandard2.1;netcoreapp3.1;net452;net5.0</TargetFrameworks>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Version>1.0.4.1</Version>
<Version>1.0.4.2</Version>
<Authors>Joel Christner</Authors>
<Description>Library for maintaining a match list of IP addresses and networks and comparing inputs to see if a match exists.</Description>
<Copyright>(c)2021 Joel Christner</Copyright>
<PackageProjectUrl>https://github.com/jchristn/ipmatcher</PackageProjectUrl>
<RepositoryUrl>https://github.com/jchristn/ipmatcher</RepositoryUrl>
<RepositoryType>Github</RepositoryType>
<PackageLicenseUrl></PackageLicenseUrl>
<PackageReleaseNotes>XML documentation</PackageReleaseNotes>
<PackageReleaseNotes>Fix for SICK-2021-060</PackageReleaseNotes>
<PackageTags>ip address match netmask network mask subnet cidr</PackageTags>
<PackageLicenseFile>LICENSE.md</PackageLicenseFile>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|netstandard2.0|AnyCPU'">
<DocumentationFile>C:\Code\Misc\IpMatcher\IpMatcher\IpMatcher.xml</DocumentationFile>
<DocumentationFile>IpMatcher.xml</DocumentationFile>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|netstandard2.0|AnyCPU'">
<DocumentationFile>IpMatcher.xml</DocumentationFile>
</PropertyGroup>

<ItemGroup>
Expand Down
11 changes: 11 additions & 0 deletions IpMatcher/IpMatcher.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions IpMatcher/Matcher.cs
Expand Up @@ -59,6 +59,9 @@ public void Add(string ip, string netmask)
if (String.IsNullOrEmpty(ip)) throw new ArgumentNullException(nameof(ip));
if (String.IsNullOrEmpty(netmask)) throw new ArgumentNullException(nameof(netmask));

ip = IPAddress.Parse(ip).ToString();
netmask = IPAddress.Parse(netmask).ToString();

string baseAddress = GetBaseIpAddress(ip, netmask);
IPAddress parsed = IPAddress.Parse(baseAddress);
if (Exists(baseAddress, netmask)) return;
Expand All @@ -83,6 +86,9 @@ public bool Exists(string ip, string netmask)
if (String.IsNullOrEmpty(ip)) throw new ArgumentNullException(nameof(ip));
if (String.IsNullOrEmpty(netmask)) throw new ArgumentNullException(nameof(netmask));

ip = IPAddress.Parse(ip).ToString();
netmask = IPAddress.Parse(netmask).ToString();

lock (_CacheLock)
{
if (_Cache.ContainsKey(ip))
Expand Down Expand Up @@ -116,6 +122,8 @@ public void Remove(string ip)
{
if (String.IsNullOrEmpty(ip)) throw new ArgumentNullException(nameof(ip));

ip = IPAddress.Parse(ip).ToString();

lock (_CacheLock)
{
_Cache = _Cache.Where(d => !d.Key.Equals(ip)).ToDictionary(d => d.Key, d => d.Value);
Expand All @@ -140,6 +148,8 @@ public bool MatchExists(string ip)
{
if (String.IsNullOrEmpty(ip)) throw new ArgumentNullException(nameof(ip));

ip = IPAddress.Parse(ip).ToString();

IPAddress parsed = IPAddress.Parse(ip);

lock (_CacheLock)
Expand Down

0 comments on commit 81d77c2

Please sign in to comment.