IPAddressRange 6.1.0
IPAddressRange Class Library
This library allows you to parse range of IP address string such as "192.168.0.0/24" and "192.168.0.0/255.255.255.0" and "192.168.0.0-192.168.0.255", and can contains check. This library supports both IPv4 and IPv6.
Examples
using NetTools;
...
// rangeA.Begin is "192.168.0.0", and rangeA.End is "192.168.0.255".
var rangeA = IPAddressRange.Parse("192.168.0.0/255.255.255.0");
rangeA.Contains(IPAddress.Parse("192.168.0.34")); // is True.
rangeA.Contains(IPAddress.Parse("192.168.10.1")); // is False.
rangeA.ToCidrString(); // is 192.168.0.0/24
// rangeB.Begin is "192.168.0.10", and rangeB.End is "192.168.10.20".
var rangeB1 = IPAddressRange.Parse("192.168.0.10 - 192.168.10.20");
rangeB1.Contains(IPAddress.Parse("192.168.3.45")); // is True.
rangeB1.Contains(IPAddress.Parse("192.168.0.9")); // is False.
// Support shortcut range description.
// ("192.168.10.10-20" means range of begin:192.168.10.10 to end:192.168.10.20.)
var rangeB2 = IPAddressRange.Parse("192.168.10.10-20");
// Support CIDR expression and IPv6.
var rangeC = IPAddressRange.Parse("fe80::/10");
rangeC.Contains(IPAddress.Parse("fe80::d503:4ee:3882:c586%3")); // is True.
rangeC.Contains(IPAddress.Parse("::1")); // is False.
// "Contains()" method also support IPAddressRange argument.
var rangeD1 = IPAddressRange.Parse("192.168.0.0/16");
var rangeD2 = IPAddressRange.Parse("192.168.10.0/24");
rangeD1.Contains(rangeD2); // is True.
// IEnumerable<IPAddress> support, it's lazy evaluation.
foreach (var ip in IPAddressRange.Parse("192.168.0.1/23"))
{
Console.WriteLine(ip);
}
// You can use LINQ via "AsEnumerable()" method.
var longValues = IPAddressRange.Parse("192.168.0.1/23")
.AsEnumerable()
.Select(ip => BitConvert.ToInt32(ip.GetAddressBytes(), 0))
.Select(adr => adr.ToString("X8"));
Console.WriteLine(string.Join(",", longValues);
// Constructors from IPAddress objects.
var ipBegin = IPAddress.Parse("192.168.0.1");
var ipEnd = IPAddress.Parse("192.168.0.128");
var ipSubnet = IPAddress.Parse("255.255.255.0");
var rangeE = new IPAddressRange(); // This means "0.0.0.0/0".
var rangeF = new IPAddressRange(ipBegin, ipEnd);
var rangeG = new IPAddressRange(ipBegin, maskLength: 24);
var rangeH = new IPAddressRange(ipBegin, IPAddressRange.SubnetMaskLength(ipSubnet));
// Calculates Cidr subnets
var rangeI = IPAddressRange.Parse("192.168.0.0-192.168.0.254");
rangeI.ToCidrString(); // is 192.168.0.0/24
Release Note
The release notes is here.
License
Showing the top 20 packages that depend on IPAddressRange.
Packages | Downloads |
---|---|
Ocelot
Ocelot is an API gateway based on .NET stack.
|
1 |
Ocelot
Ocelot is an API gateway based on .NET stack.
|
3 |
Ocelot
Ocelot is an API gateway based on .NET stack.
|
4 |
Ocelot
Ocelot is an API gateway based on .NET stack.
|
5 |
Ocelot
Ocelot is an API gateway based on .NET stack.
|
7 |
Ocelot
Ocelot is an API Gateway. The project is aimed at people using .NET running a micro services / service orientated architecture that need a unified point of entry into their system. In particular I want easy integration with IdentityServer reference and bearer tokens. reference tokens. Ocelot is a bunch of middlewares in a specific order. Ocelot manipulates the HttpRequest object into a state specified by its configuration until it reaches a request builder middleware where it creates a HttpRequestMessage object which is used to make a request to a downstream service. The middleware that makes the request is the last thing in the Ocelot pipeline. It does not call the next middleware. The response from the downstream service is stored in a per request scoped repository and retrived as the requests goes back up the Ocelot pipeline. There is a piece of middleware that maps the HttpResponseMessage onto the HttpResponse object and that is returned to the client. That is basically it with a bunch of other features.
|
3 |
Ocelot
Ocelot is an API Gateway. The project is aimed at people using .NET running a micro services / service orientated architecture that need a unified point of entry into their system. In particular I want easy integration with IdentityServer reference and bearer tokens. reference tokens. Ocelot is a bunch of middlewares in a specific order. Ocelot manipulates the HttpRequest object into a state specified by its configuration until it reaches a request builder middleware where it creates a HttpRequestMessage object which is used to make a request to a downstream service. The middleware that makes the request is the last thing in the Ocelot pipeline. It does not call the next middleware. The response from the downstream service is stored in a per request scoped repository and retrived as the requests goes back up the Ocelot pipeline. There is a piece of middleware that maps the HttpResponseMessage onto the HttpResponse object and that is returned to the client. That is basically it with a bunch of other features.
|
4 |
Ocelot
Ocelot is an API Gateway. The project is aimed at people using .NET running a micro services / service orientated architecture that need a unified point of entry into their system. In particular I want easy integration with IdentityServer reference and bearer tokens. reference tokens. Ocelot is a bunch of middlewares in a specific order. Ocelot manipulates the HttpRequest object into a state specified by its configuration until it reaches a request builder middleware where it creates a HttpRequestMessage object which is used to make a request to a downstream service. The middleware that makes the request is the last thing in the Ocelot pipeline. It does not call the next middleware. The response from the downstream service is stored in a per request scoped repository and retrived as the requests goes back up the Ocelot pipeline. There is a piece of middleware that maps the HttpResponseMessage onto the HttpResponse object and that is returned to the client. That is basically it with a bunch of other features.
|
5 |
Ocelot
Ocelot is an API Gateway. The project is aimed at people using .NET running a micro services / service orientated architecture that need a unified point of entry into their system. In particular I want easy integration with IdentityServer reference and bearer tokens. reference tokens. Ocelot is a bunch of middlewares in a specific order. Ocelot manipulates the HttpRequest object into a state specified by its configuration until it reaches a request builder middleware where it creates a HttpRequestMessage object which is used to make a request to a downstream service. The middleware that makes the request is the last thing in the Ocelot pipeline. It does not call the next middleware. The response from the downstream service is stored in a per request scoped repository and retrived as the requests goes back up the Ocelot pipeline. There is a piece of middleware that maps the HttpResponseMessage onto the HttpResponse object and that is returned to the client. That is basically it with a bunch of other features.
|
6 |
Ocelot
Ocelot is an API Gateway. The project is aimed at people using .NET running a micro services / service orientated architecture that need a unified point of entry into their system. In particular I want easy integration with IdentityServer reference and bearer tokens. reference tokens. Ocelot is a bunch of middlewares in a specific order. Ocelot manipulates the HttpRequest object into a state specified by its configuration until it reaches a request builder middleware where it creates a HttpRequestMessage object which is used to make a request to a downstream service. The middleware that makes the request is the last thing in the Ocelot pipeline. It does not call the next middleware. The response from the downstream service is stored in a per request scoped repository and retrived as the requests goes back up the Ocelot pipeline. There is a piece of middleware that maps the HttpResponseMessage onto the HttpResponse object and that is returned to the client. That is basically it with a bunch of other features.
|
8 |
Ocelot
Ocelot is an API Gateway. The project is aimed at people using .NET running a micro services / service orientated architecture that need a unified point of entry into their system. In particular I want easy integration with IdentityServer reference and bearer tokens. reference tokens. Ocelot is a bunch of middlewares in a specific order. Ocelot manipulates the HttpRequest object into a state specified by its configuration until it reaches a request builder middleware where it creates a HttpRequestMessage object which is used to make a request to a downstream service. The middleware that makes the request is the last thing in the Ocelot pipeline. It does not call the next middleware. The response from the downstream service is stored in a per request scoped repository and retrived as the requests goes back up the Ocelot pipeline. There is a piece of middleware that maps the HttpResponseMessage onto the HttpResponse object and that is returned to the client. That is basically it with a bunch of other features.
|
11 |
v.6.1.0
- Add support for .NET 9.0
To see all the change logs, please visit the following URL.
- https://github.com/jsakamoto/IPAddressRange/blob/master/RELEASE-NOTES.txt
.NET 5.0
- No dependencies.
.NET 6.0
- No dependencies.
.NET 7.0
- No dependencies.
.NET 8.0
- No dependencies.
.NET 9.0
- No dependencies.
.NET Framework 4.6.2
- No dependencies.
.NET Standard 1.4
- NETStandard.Library (>= 1.6.1)
.NET Standard 2.1
- No dependencies.
Version | Downloads | Last updated |
---|---|---|
6.1.0 | 3 | 12/05/2024 |
6.0.0 | 15 | 05/13/2024 |
4.0.0 | 3 | 12/03/2024 |
3.2.2 | 3 | 12/03/2024 |
3.2.1 | 3 | 12/10/2024 |
3.2.0 | 3 | 12/02/2024 |
3.1.1 | 3 | 12/02/2024 |
3.1.0 | 3 | 12/16/2024 |
3.0.0.1 | 2 | 12/09/2024 |
3.0.0-beta | 5 | 12/09/2024 |
2.2.0 | 3 | 12/03/2024 |
2.1.1 | 3 | 12/12/2024 |
2.1.1-beta | 5 | 12/10/2024 |
2.1.0.1 | 3 | 12/02/2024 |
2.1.0-alpha | 5 | 12/08/2024 |
2.0.0.4 | 6 | 11/23/2024 |
2.0.0.3 | 3 | 12/11/2024 |
2.0.0.3-beta | 2 | 12/12/2024 |
2.0.0-beta | 3 | 12/03/2024 |
1.6.2.7 | 2 | 12/04/2024 |
1.6.2.6-beta | 0 | 03/01/2017 |
1.6.2.1-beta | 5 | 12/04/2024 |
1.6.1 | 3 | 12/03/2024 |
1.6.0 | 3 | 12/04/2024 |
1.5.0 | 3 | 11/28/2024 |
1.4.0.1 | 3 | 12/03/2024 |
1.4.0 | 3 | 12/12/2024 |
1.3.0.1 | 2 | 12/04/2024 |
1.3.0 | 0 | 04/01/2015 |
1.2.1 | 3 | 12/04/2024 |
1.2.0 | 3 | 12/02/2024 |
1.1.0-beta | 3 | 12/12/2024 |
1.0.6 | 3 | 12/04/2024 |
1.0.5 | 3 | 12/13/2024 |
1.0.4 | 5 | 12/10/2024 |
1.0.3 | 3 | 12/02/2024 |
1.0.2 | 3 | 12/04/2024 |
1.0.1 | 5 | 12/09/2024 |
1.0.0 | 1 | 12/08/2024 |