{"id":15056575,"url":"https://github.com/seancfoley/ipaddress","last_synced_at":"2026-02-02T06:10:39.316Z","repository":{"id":37378750,"uuid":"63654268","full_name":"seancfoley/IPAddress","owner":"seancfoley","description":"Java library for handling IP addresses and subnets, both IPv4 and IPv6","archived":false,"fork":false,"pushed_at":"2024-08-26T04:01:54.000Z","size":127844,"stargazers_count":500,"open_issues_count":1,"forks_count":67,"subscribers_count":20,"default_branch":"master","last_synced_at":"2025-05-08T21:14:07.216Z","etag":null,"topics":["android","cidr","go","golang","groovy","ip-address","ipaddress","ipv4","ipv4-address","ipv4-network","ipv4-subnetting","ipv6","ipv6-address","ipv6-network","ipv6-subnetting","java","kotlin","mac-address","scala","subnet"],"latest_commit_sha":null,"homepage":"https://seancfoley.github.io/IPAddress/","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/seancfoley.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-07-19T02:47:57.000Z","updated_at":"2025-04-28T08:13:09.000Z","dependencies_parsed_at":"2024-06-02T21:32:42.574Z","dependency_job_id":"c66daf38-1cb7-4d53-8f84-24cd873d1b55","html_url":"https://github.com/seancfoley/IPAddress","commit_stats":{"total_commits":414,"total_committers":7,"mean_commits":"59.142857142857146","dds":0.3695652173913043,"last_synced_commit":"577bd59c032b74ec6346e5b1c4c20936380fa3f3"},"previous_names":[],"tags_count":32,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/seancfoley%2FIPAddress","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/seancfoley%2FIPAddress/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/seancfoley%2FIPAddress/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/seancfoley%2FIPAddress/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/seancfoley","download_url":"https://codeload.github.com/seancfoley/IPAddress/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254235701,"owners_count":22036964,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["android","cidr","go","golang","groovy","ip-address","ipaddress","ipv4","ipv4-address","ipv4-network","ipv4-subnetting","ipv6","ipv6-address","ipv6-network","ipv6-subnetting","java","kotlin","mac-address","scala","subnet"],"created_at":"2024-09-24T21:53:35.327Z","updated_at":"2026-02-02T06:10:39.310Z","avatar_url":"https://github.com/seancfoley.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# IPAddress\nJava library for handling IP addresses and subnets, both IPv4 and IPv6\n\nIP address and network manipulations, CIDR, address and subnet operations, iterations, containment checks, longest prefix match, subnetting, and address and subnet data structures including address tries, with polymorphic code \n\n[View Project Page](https://seancfoley.github.io/IPAddress/)\n\n[View Code Examples](https://github.com/seancfoley/IPAddress/wiki/Code-Examples)\n\n[View Javadoc](https://seancfoley.github.io/IPAddress/IPAddress/apidocs/)\n\n[View List of Users](https://github.com/seancfoley/IPAddress/wiki)\n\n[In the Maven Central Repository](https://repo1.maven.org/maven2/com/github/seancfoley/ipaddress/), packaged as an OSGI bundle, packaged as a [Linux Fedora rpm](http://rpmfind.net/linux/rpm2html/search.php?query=ipaddress)\n- Maven group id: com.github.seancfoley\n- Maven artifact id: [ipaddress](https://search.maven.org/search?q=ipaddress)\n- Maven versions: [2.0.2](https://search.maven.org/artifact/com.github.seancfoley/ipaddress/2.0.2/jar), [3.0.0](https://search.maven.org/artifact/com.github.seancfoley/ipaddress/3.0.0/jar), [4.3.3](https://search.maven.org/artifact/com.github.seancfoley/ipaddress/4.3.3/jar), [5.6.1](https://search.maven.org/artifact/com.github.seancfoley/ipaddress/5.6.1/jar) \n- Latest Maven version: [![Maven Central](https://img.shields.io/maven-central/v/com.github.seancfoley/ipaddress.svg?label=Maven%20Central)](https://central.sonatype.com/namespace/com.github.seancfoley)\n- OSGI bundle since version 5.3.1: com.github.seancfoley.ipaddress\n\n![Java](https://github.com/seancfoley/IPAddress/blob/gh-pages/images/java_logo.png?raw=true) ![Kotlin](https://github.com/seancfoley/IPAddress/blob/gh-pages/images/kotlin_logo.png?raw=true)![Go](https://github.com/seancfoley/IPAddress/blob/gh-pages/images/go_logo.png?raw=true) ![Scala](https://github.com/seancfoley/IPAddress/blob/gh-pages/images/scala.png?raw=true)![Groovy](https://github.com/seancfoley/IPAddress/blob/gh-pages/images/groovy.png?raw=true)![Clojure](https://github.com/seancfoley/IPAddress/blob/gh-pages/images/clojure.png?raw=true)\n\nAs a [Java](https://www.oracle.com/java/) library, it is also interoperable with [Kotlin](https://kotlinlang.org/), [Scala](https://scala-lang.org/), [Groovy](http://www.groovy-lang.org/) and [Clojure](https://clojure.org/)\n\nAvailable as a [Go](https://go.dev/) library from the [ipaddress-go repository](https://github.com/seancfoley/ipaddress-go)\n\n[Integrate into Development: Intellij, Android, and Eclipse](https://github.com/seancfoley/IPAddress/wiki/Development-IDEs)\n\nBecause IPAddress is 100% Java, it is easy to integrate with your build and deploy process\n\n[Make your IPv4 App work with IPv6](https://seancfoley.github.io/IPAddress/ipaddress.html#make-your-ipv4-app-work-with-ipv6)\n\nVersion | Notes         |\n------- | ------------- |\n[1.0.1](https://github.com/seancfoley/IPAddress/releases/tag/v1.0.1) | Requires Java 6 or higher |\n[2.0.2](https://github.com/seancfoley/IPAddress/releases/tag/v2.0.2) | Requires Java 8 or higher |\n[3.0.0](https://github.com/seancfoley/IPAddress/releases/tag/v3.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 |\n[4.3.3](https://github.com/seancfoley/IPAddress/releases/tag/v4.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. |\n**[Latest Version 5.6.1](https://github.com/seancfoley/IPAddress/releases/tag/v5.6.1)** | 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) in Java 9 or later versions.  You may need (or wish) to [delete the module-info](https://github.com/seancfoley/IPAddress/issues/16#issuecomment-452425235), which can be done [with gradle](https://github.com/seancfoley/IPAddress/issues/16#issuecomment-452564690), when using Java 8 environments.  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, Java 8 stream and spliterator methods, additional parsing options, address tries, associative address tries, containment tries, the prefix block allocator, and sequential range lists.  Other enhancements are listed on the releases page for [5.0.0](https://github.com/seancfoley/IPAddress/releases/tag/v5.0.0), [5.1.0](https://github.com/seancfoley/IPAddress/releases/tag/v5.1.0), [5.2.0](https://github.com/seancfoley/IPAddress/releases/tag/v5.2.0), [5.3.0](https://github.com/seancfoley/IPAddress/releases/tag/v5.3.0), [5.4.0](https://github.com/seancfoley/IPAddress/releases/tag/v5.4.0), [5.5.0](https://github.com/seancfoley/IPAddress/releases/tag/v5.5.0) and [5.6.0](https://github.com/seancfoley/IPAddress/releases/tag/v5.6.0)\n\n\n## Getting Started\n\n## Java\n\nstarting with address or subnet strings\n```java\nString ipv6Str = \"::/64\";\nString ipv4Str = \"1.2.255.4/255.255.0.0\";\ntry {\n\tIPAddress ipv6Address = new IPAddressString(ipv6Str).toAddress();\n\tIPAddress ipv4Address = new IPAddressString(ipv4Str).toAddress();\n        // use addresses\n} catch (AddressStringException e) {\n\tString msg = e.getMessage();//detailed message indicating improper string format\n\t// handle improperly formatted address string\n}\n```\nstarting with host name strings\n```java\nString hostPortStr = \"[a:b:c:d:e:f:a:b]:8080\";\nString hostServiceStr = \"a.b.com:service\";\nString hostAddressStr = \"1.2.3.4\";\nString dnsStr = \"a.b.com\";\ntry {\n\tHostName host = new HostName(hostPortStr);\n\tInetSocketAddress socketAddress = host.asInetSocketAddress();\n\t// use socket address\n\t        \n\thost = new HostName(hostServiceStr);\n\tsocketAddress = host.asInetSocketAddress(\n\t\tservice -\u003e service.equals(\"service\") ? 100 : null);\n\t// use socket address\n\t        \n\thost = new HostName(hostAddressStr);\n\tIPAddress address = host.asAddress(); // does not resolve\n\t// use address\n\t        \n\thost = new HostName(dnsStr);\n\taddress = host.toAddress(); // resolves if necessary\n\t// use address\n\t        \n} catch (HostNameException | UnknownHostException e) {\n\tString msg = e.getMessage();\n\t// handle improperly formatted host name or address string\n}\n```\n## Kotlin\n\nstarting with address or subnet strings, using exceptions for invalid formats\n```kotlin\nval ipv6Str = \"a:b:c:d::a:b/64\"\ntry {\n\tval ipv6AddressStr = IPAddressString(ipv6Str)\n\tval ipv6Addr = ipv6AddressStr.toAddress()\n\t// use address\n\tprintln(ipv6Addr) // a:b:c:d::a:b/64\n} catch(e: AddressStringException) {\n\t// handle improperly formatted address string\n\tprintln(e.message)\n}\n```\n starting with address or subnet strings, using nullable types and safe calls to handle invalid or unexpected formats\n```kotlin\nval ipv6v4Str = \"a:b:c:d:e:f:1.2.3.4/112\"\nval ipv6v4AddressStr = IPAddressString(ipv6v4Str)\nval ipAddr: IPAddress? = ipv6v4AddressStr.address\nprintln(ipAddr) // a:b:c:d:e:f:102:304/112\n\nval ipv4Addr = ipAddr?.toIPv6()?.embeddedIPv4Address\nprintln(ipv4Addr) // 1.2.3.4/16\n```\n## Scala\n\nstarting with address strings, using exceptions for invalid formats\n```scala\nimport scala.util.{Failure, Success, Try}\n\nval addressStr = new IPAddressString(\"a:b:c:d::/64\")\nTry(addressStr.toAddress) match {\n    case Success(userInfo) =\u003e\n        // use address\n    case Failure(exception: AddressStringException) =\u003e\n        // handle improperly formatted address string\n}\n```\n## Groovy\n\nstarting with address or subnet strings, using exceptions for invalid formats\n```groovy\ndef addressStr = new IPAddressString('a:b:c:d:e:f:1.2.3.4')\ntry {\n    def address = addressStr.toAddress()\n    // use address\n} catch (AddressStringException e) {\n    // handle improperly formatted address string\n}\n```\nstarting with address or subnet strings, checking for null for invalid formats\n```groovy\ndef subnetStr = new IPAddressString('108.30-31.*.*')\ndef subnet = subnetStr.getAddress()\nif(subnet != null) {\n    // use address\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fseancfoley%2Fipaddress","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fseancfoley%2Fipaddress","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fseancfoley%2Fipaddress/lists"}