All Projects → seancfoley → Ipaddress

seancfoley / Ipaddress

Licence: apache-2.0
Java library for handling IP addresses and subnets, both IPv4 and IPv6

Programming Languages

java
68154 projects - #9 most used programming language
kotlin
9241 projects
scala
5932 projects
groovy
2714 projects

Projects that are alternatives of or similar to Ipaddress

PHP-IPAddress
IP Address utility classes for PHP
Stars: ✭ 63 (-68.02%)
Mutual labels:  ipv6, ipv4, ip-address, subnet
IP2Location-PHP-Module
This module is a PHP module that enables the user to find the country, region, city, coordinates, zip code, ISP, domain name, timezone, connection speed, IDD code, area code, weather station code, weather station name, mobile, usage types, address type, IAB category, etc that any IP address or host name originates from.
Stars: ✭ 154 (-21.83%)
Mutual labels:  ipv6, ipv4, ip-address
Iptools
PHP Library for manipulating network addresses (IPv4 and IPv6)
Stars: ✭ 163 (-17.26%)
Mutual labels:  ipv6, ipv4, subnet
Ip Num
A TypeScript/JavaScript library for working with ASN, IPv4, and IPv6 numbers. It provides representations of these internet protocol numbers with the ability to perform various IP related operations like parsing, validating etc. on them
Stars: ✭ 113 (-42.64%)
Mutual labels:  ipv6, ipv4, ip-address
IP2Location-C-Library
IP2Location C library enables the user to find the country, region, city, coordinates, zip code, time zone, ISP, domain name, connection type, area code, weather station code, weather station name, mobile, usage types, etc that any IP address or hostname originates from.
Stars: ✭ 37 (-81.22%)
Mutual labels:  ipv6, ipv4, ip-address
ipapi-python
Python bindings for https://ipapi.co (IP Address Location) - Use with python / django / flask for IP address location lookup
Stars: ✭ 42 (-78.68%)
Mutual labels:  ipv6, ipv4, ip-address
ip
Immutable value object for IPv4 and IPv6 addresses, including helper methods and Doctrine support.
Stars: ✭ 212 (+7.61%)
Mutual labels:  ipv6, ipv4, ip-address
private-ip
Check if IP address is private.
Stars: ✭ 26 (-86.8%)
Mutual labels:  ipv6, ipv4, ip-address
ipcalc.el
IP calculator in Emacs Lisp
Stars: ✭ 23 (-88.32%)
Mutual labels:  ipv4, ip-address, subnet
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 (+40.1%)
Mutual labels:  ipv6, ipv4, subnet
Ipwhois
Retrieve and parse whois data for IPv4 and IPv6 addresses
Stars: ✭ 432 (+119.29%)
Mutual labels:  ipv6, ipv4, ip-address
ip2location-nginx
Nginx module that allows user to lookup for geolocation information using IP2Location database.
Stars: ✭ 33 (-83.25%)
Mutual labels:  ipv6, ipv4, ip-address
Ineter
Fast Java library for working with IP addresses, ranges, and subnets
Stars: ✭ 39 (-80.2%)
Mutual labels:  ipv6, ipv4, subnet
ipaddress
Data analysis of IP addresses and networks
Stars: ✭ 20 (-89.85%)
Mutual labels:  ipv6, ipv4, ip-address
php-ip-anonymizer
IP address anonymizer library for PHP
Stars: ✭ 55 (-72.08%)
Mutual labels:  ipv6, ipv4, ip-address
Geolocate-IP-Browser-Extension
A browser extension, which shows you the origin of your IP address.
Stars: ✭ 21 (-89.34%)
Mutual labels:  ipv6, ipv4, ip-address
IPpy
🚀 Ping IP addresses and domains in parallel to find the accessible and inaccessible ones.
Stars: ✭ 54 (-72.59%)
Mutual labels:  ipv6, ipv4, ip-address
freebind
IPv4 and IPv6 address rate limiting evasion tool
Stars: ✭ 88 (-55.33%)
Mutual labels:  ipv6, ipv4, subnet
Netaddr
A network address manipulation library for Python
Stars: ✭ 648 (+228.93%)
Mutual labels:  ipv6, ipv4, subnet
Ipnetwork
A library to work with CIDRs in rust
Stars: ✭ 64 (-67.51%)
Mutual labels:  ipv6, ipv4, ip-address

IPAddress

Library for handling IP addresses and subnets, both IPv4 and IPv6

View Project Page

View Javadoc

View Code Examples

In the Maven Central Repository, packaged as an OSGI bundle, packaged as a Linux Fedora rpm, in Apache Archiva on Wikimedia

  • Maven group id: com.github.seancfoley
  • Maven artifact id: ipaddress
  • Maven versions: 2.0.2, 3.0.0, 4.3.3, 5.3.3
  • OSGI bundle since version 5.3.1: com.github.seancfoley.ipaddress

As a Java library, it is also interoperable with Kotlin, Scala, Groovy and Clojure.

Integrate into Development: Intellij, Android, and Eclipse

Make your IPv4 App work with IPv6

Version Notes
1.0.1 Requires Java 6 or higher
2.0.2 Requires Java 8 or higher
3.0.0 Requires Java 8 or higher, features MAC address support, EUI-48 and EUI-64 MAC integration with IPv6, new address framework, new IP string formats parsed and produced, and other additions
4.3.3 Requires Java 8 or higher. Features new prefix length handling. IPv4-network/IPv6-subnet-router-anycast/zero-host addresses are interpreted as the prefix block subnet, while other prefixed addresses are individual addresses. There exists the option to preserve the version 3 behaviour. Version 4.2.0 has additional methods for managing prefix blocks. Version 4.3 features improved parsing performance and a change to increment(long) behaviour for subnets.
Latest Version 5.3.3 Requires Java 8 or higher. Compatible with Android using Android API level 24 or higher. The code is compiled with Java 8 but provides a Java 9 compiled module-info.class file for those using the Java Platform Module System (JPMS). You may need (or wish) to delete the module-info, which can be done with gradle, when using Android, other Java 8 environments, or Java version 9 and up environments that do not properly support modules. Since Android Studio 3.3, deleting the module-info is no longer necessary. Version 5 features the addition of IPAddress sequential range classes IP*AddressSeqRange, the reorganization of classes and interfaces in inet.ipaddr.format package to standard, large, and string subpackages, enhanced address block splitting and merging functionality, the improved parsing performance introduced with version 4.3.0, Java 8 stream and spliterator methods, additional parsing options, address tries, and associative address tries. Other enhancements are listed on the releases page for 5.0.0, 5.1.0, 5.2.0 and 5.3.0

Planned future additions: ports to JavaScript and Go.

Getting Started

Java

starting with address or subnet strings

String ipv6Str = "::/64";
String ipv4Str = "1.2.255.4/255.255.0.0";
try {
	IPAddress ipv6Address = new IPAddressString(ipv6Str).toAddress();
	IPAddress ipv4Address = new IPAddressString(ipv4Str).toAddress();
        // use addresses
} catch (AddressStringException e) {
	String msg = e.getMessage();//detailed message indicating improper string format
	// handle improperly formatted address string
}

starting with host name strings

String hostPortStr = "[a🅱️c:d:e:f:a:b]:8080";
String hostServiceStr = "a.b.com:service";
String hostAddressStr = "1.2.3.4";
String dnsStr = "a.b.com";
try {
	HostName host = new HostName(hostPortStr);
	InetSocketAddress socketAddress = host.asInetSocketAddress();
	// use socket address
	        
	host = new HostName(hostServiceStr);
	socketAddress = host.asInetSocketAddress(
		service -> service.equals("service") ? 100 : null);
	// use socket address
	        
	host = new HostName(hostAddressStr);
	IPAddress address = host.asAddress(); // does not resolve
	// use address
	        
	host = new HostName(dnsStr);
	address = host.toAddress(); // resolves if necessary
	// use address
	        
} catch (HostNameException | UnknownHostException e) {
	String msg = e.getMessage();
	// handle improperly formatted host name or address string
}

Kotlin

starting with address or subnet strings, using exceptions for invalid formats

val ipv6Str = "a🅱️c:d:🅰️b/64"
try {
	val ipv6AddressStr = IPAddressString(ipv6Str)
	val ipv6Addr = ipv6AddressStr.toAddress()
	// use address
	println(ipv6Addr) // a🅱️c:d:🅰️b/64
} catch(e: AddressStringException) {
	// handle improperly formatted address string
	println(e.message)
}

starting with address or subnet strings, using nullable types and safe calls to handle invalid or unexpected formats

val ipv6v4Str = "a🅱️c:d:e:f:1.2.3.4/112"
val ipv6v4AddressStr = IPAddressString(ipv6v4Str)
val ipAddr: IPAddress? = ipv6v4AddressStr.address
println(ipAddr) // a🅱️c:d:e:f:102:304/112

val ipv4Addr = ipAddr?.toIPv6()?.embeddedIPv4Address
println(ipv4Addr) // 1.2.3.4/16

Scala

starting with address strings, using exceptions for invalid formats

import scala.util.{Failure, Success, Try}

val addressStr = new IPAddressString("a🅱️c:d::/64")
Try(addressStr.toAddress) match {
    case Success(userInfo) =>
        // use address
    case Failure(exception: AddressStringException) =>
        // handle improperly formatted address string
}

Groovy

starting with address or subnet strings, using exceptions for invalid formats

def addressStr = new IPAddressString('a🅱️c:d:e:f:1.2.3.4')
try {
    def address = addressStr.toAddress()
    // use address
} catch (AddressStringException e) {
    // handle improperly formatted address string
}

starting with address or subnet strings, checking for null for invalid formats

def subnetStr = new IPAddressString('108.30-31.*.*')
def subnet = subnetStr.getAddress()
if(subnet != null) {
    // use address
}
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].