All Projects → jgonian → Commons Ip Math

jgonian / Commons Ip Math

Licence: mit

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to Commons Ip Math

Ip Address
💻 a library for parsing and manipulating IPv4 and IPv6 addresses in JavaScript
Stars: ✭ 353 (+553.7%)
Mutual labels:  ipv6, ipv4
Enet Csharp
Reliable UDP networking library
Stars: ✭ 464 (+759.26%)
Mutual labels:  ipv6, ipv4
Dsnet
Simple command to manage a centralised wireguard VPN. Think wg-quick but quicker: key generation + address allocation.
Stars: ✭ 365 (+575.93%)
Mutual labels:  ipv6, ipv4
Bgp Dashboard
BGP Dashboard and Monitoring Web Application
Stars: ✭ 268 (+396.3%)
Mutual labels:  ipv6, ipv4
Nsupdate.info
Dynamic DNS service
Stars: ✭ 720 (+1233.33%)
Mutual labels:  ipv6, ipv4
Valvesockets Csharp
Managed C# abstraction of GameNetworkingSockets library by Valve Software
Stars: ✭ 273 (+405.56%)
Mutual labels:  ipv6, ipv4
Ipwhois
Retrieve and parse whois data for IPv4 and IPv6 addresses
Stars: ✭ 432 (+700%)
Mutual labels:  ipv6, ipv4
v6dns
A DNS Server which lets IPv4-prioritized devices to use IPv6 first, or lets IPv6-prioritized devices to use IPv4 first.
Stars: ✭ 16 (-70.37%)
Mutual labels:  ipv6, ipv4
Ineter
Fast Java library for working with IP addresses, ranges, and subnets
Stars: ✭ 39 (-27.78%)
Mutual labels:  ipv6, ipv4
Netaddr
A network address manipulation library for Python
Stars: ✭ 648 (+1100%)
Mutual labels:  ipv6, ipv4
Hev Socks5 Server
A simple, lightweight socks5 server for Unix (Linux/BSD/macOS)
Stars: ✭ 33 (-38.89%)
Mutual labels:  ipv6, ipv4
Edgeos Blacklist
Automatically updates IP blacklist for EdgeOS (supports IPv4 & IPv6)
Stars: ✭ 34 (-37.04%)
Mutual labels:  ipv6, ipv4
Vedetta
OpenBSD Router Boilerplate
Stars: ✭ 260 (+381.48%)
Mutual labels:  ipv6, ipv4
Ipnetwork
IPNetwork command line and C# library take care of complex network, IP, IPv4, IPv6, netmask, CIDR, subnet, subnetting, supernet, and supernetting calculation for .NET developers. It works with IPv4 as well as IPv6, is written in C#, has a light and clean API, and is fully unit-tested
Stars: ✭ 276 (+411.11%)
Mutual labels:  ipv6, ipv4
pac
Proxy Auto Config generator,自动代理配置生成PAC,可配合ss小飞机使用
Stars: ✭ 40 (-25.93%)
Mutual labels:  ipv6, ipv4
Plibsys
Highly portable C system library: threads and synchronization primitives, sockets (TCP, UDP, SCTP), IPv4 and IPv6, IPC, hash functions (MD5, SHA-1, SHA-2, SHA-3, GOST), binary trees (RB, AVL) and more. Native code performance.
Stars: ✭ 402 (+644.44%)
Mutual labels:  ipv6, ipv4
geoip
🌚 🌍 🌝 GeoIP 规则文件加强版,同时支持定制 V2Ray dat 格式路由规则文件 geoip.dat 和 MaxMind mmdb 格式文件 Country.mmdb。Enhanced edition of GeoIP files for V2Ray, Xray-core, Trojan-Go, Clash and Leaf, with replaced CN IPv4 CIDR available from ipip.net, appended CIDR lists and more.
Stars: ✭ 524 (+870.37%)
Mutual labels:  ipv6, ipv4
cidr
golang to calculate CIDR network
Stars: ✭ 51 (-5.56%)
Mutual labels:  ipv6, ipv4
Ddos Deflate
Fork of DDoS Deflate with fixes, improvements and new features.
Stars: ✭ 568 (+951.85%)
Mutual labels:  ipv6, ipv4
Vflow
Enterprise Network Flow Collector (IPFIX, sFlow, Netflow) from Verizon Media
Stars: ✭ 776 (+1337.04%)
Mutual labels:  ipv6, ipv4

Build Status Coverage Status Maven Central

Commons IP Math

Description

This library contains a representation of internet resources:

  • IPv4 and IPv6 addresses and ranges
  • Autonomous System Numbers (ASNs)

It provides a rich, type-safe API for dealing with the most common operations performed with IP resources, such as: parsing, printing in several notations, checking if ranges are overlapping or can be merged, etc.

It also provides Comparators, Set collections and other utilities for working with IP ranges and Prefixes.

Dependency Information

Maven:

<dependency>
    <groupId>com.github.jgonian</groupId>
    <artifactId>commons-ip-math</artifactId>
    <version>${version}</version>
</dependency>

SBT:

libraryDependencies += "com.github.jgonian" % "commons-ip-math" % s"${version}"

For the latest released version, check the Central Repository.

Examples

IPv4 addresses

Ipv4 start = Ipv4.of("192.168.0.0");
Ipv4 end = Ipv4.of("192.168.0.255");

// Fluent API for creating new instances
Ipv4Range a = Ipv4Range.from(start).to(end);
Ipv4Range b = Ipv4Range.from("192.168.0.0").andPrefixLength(24);
Ipv4Range c = Ipv4Range.parse("192.168.0.0/24");
Ipv4Range d = Ipv4Range.parse("192.168.1.0/24");

a.equals(b);        // true
a.isEmpty();        // false
a.size();           // 256
a.contains(b);      // true
a.overlaps(d);      // false
a.isConsecutive(d); // true
a.merge(d);         // 192.168.0.0/23

IPv6 addresses

Ipv6 start = Ipv6.of("2001:db8:0:0:0:0:0:0");       // 2001:db8::
Ipv6 end   = IPv6.of("2001:db8:0:0:0:0:0:ffff");    // 2001:db8::ffff

// Fluent API for creating new instances
Ipv6Range a = Ipv6Range.from(start).to(end);
Ipv6Range b = Ipv6Range.from(start).andPrefixLength(112);
Ipv6Range c = Ipv6Range.parse("2001:db8::/112");
Ipv6Range d = Ipv6Range.parse("2001:db8::1:0/112");

a.equals(b);        // true
a.isEmpty();        // false
a.size();           // 65536
a.contains(b);      // true
a.overlaps(d);      // false
a.isConsecutive(d); // true
a.merge(d);         // 2001:db8::/111

Printing of IPv6 addresses complies with RFC 5952.

Autonomous System Numbers (ASNs)

Asn.of("AS65546");  // AS65546
Asn.of(65546l);     // AS65546
Asn.of("1.10");     // AS65546

Asn.of("AS65546").is32Bit() // true

Parsing of AS numbers complies with RFC 5396.

Sets

SortedResourceSet<Ipv4, Ipv4Range> set = new SortedResourceSet<Ipv4, Ipv4Range>();
set.add(Ipv4Range.parse("192.168.0.0/16"));
set.add(Ipv4Range.parse("10.0.0.0-10.0.0.253"));
set.add(Ipv4.of("10.0.0.254"));
set.add(Ipv4.of("10.0.0.255"));
System.out.println(set);           // [10.0.0.0/24, 192.168.0.0/16]

Comparators

Ipv6Range a = Ipv6Range.parse("2001::/64");
Ipv6Range b = Ipv6Range.parse("2001::/65");
SizeComparator.<Ipv6Range>get().compare(a, b);  // 1

Iterable ranges

for (Ipv4 ip : Ipv4Range.parse("10.0.0.0/30")) {
    System.out.println(ip);
}
// will print:
// 10.0.0.0
// 10.0.0.1
// 10.0.0.2
// 10.0.0.3

and more

License

The commons-ip-math is released under the MIT license.

Acknowledgements

The project started as a fork of IP Resource and it has been evolved to the extent that most of the logic was rewritten. Special thanks for the inspiration to many contributors of the IP resource library and in particular Erik Rozendaal, Szabolcs Andrasi, Oleg Muravskiy, Johan Ählen and Katie Petrusha.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].