Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jchristn/ipmatcher
C# library for maintaining a match list of IP addresses and networks and comparing inputs to see if a match exists.
https://github.com/jchristn/ipmatcher
address ip ipv4 matching nuget
Last synced: 9 days ago
JSON representation
C# library for maintaining a match list of IP addresses and networks and comparing inputs to see if a match exists.
- Host: GitHub
- URL: https://github.com/jchristn/ipmatcher
- Owner: jchristn
- License: mit
- Created: 2018-03-09T22:39:17.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2025-01-07T15:04:34.000Z (28 days ago)
- Last Synced: 2025-01-26T03:04:36.848Z (9 days ago)
- Topics: address, ip, ipv4, matching, nuget
- Language: C#
- Homepage:
- Size: 78.1 KB
- Stars: 15
- Watchers: 3
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- Funding: .github/FUNDING.yml
- License: LICENSE.md
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# IpMatcher
[![NuGet Version](https://img.shields.io/nuget/v/IpMatcher.svg?style=flat)](https://www.nuget.org/packages/IpMatcher/) [![NuGet](https://img.shields.io/nuget/dt/IpMatcher.svg)](https://www.nuget.org/packages/IpMatcher)
C# library for maintaining a match list of IP addresses and networks and comparing inputs to see if a match exists.
Effective v1.0.1, IpMatcher targets .NET Core 2.0 and .NET Framework 4.5.2.
## Help and Contribution
Please file an issue for any bugs you encounter or requested features. Want to contribute? Please create a branch, commit, and submit a pull request!
## Usage
```csharp
using IpMatcher;Matcher matcher = new Matcher();
matcher.Add("192.168.1.0", "255.255.255.0");
matcher.Add("192.168.2.0", "255.255.255.0");
matcher.Remove("192.168.2.0");
matcher.Exists("192.168.1.0", "255.255.255.0"); // true
matcher.Match("192.168.1.34"); // true
matcher.Match("10.10.10.10"); // false
```## Implementation
The matcher uses two primary internal objects. The first is a Dictionary which acts as a faster cache. Success responses to ```Match``` will update this Dictionary. On ```Match``` requests, the Dictionary is checked first for a match. Behind the Dictionary cache, a list of ```Address``` objects are stored.
## Helpful Link
A lot of the internal matching code was adapted from: https://social.msdn.microsoft.com/Forums/en-US/c0ecc0de-b45e-4ca4-8d57-fc9babd4c221/evaluate-if-ip-address-is-part-of-a-subnet?forum=netfxnetcom
## Version History
Refer to CHANGELOG.md