Coder Social home page Coder Social logo

deepaks829 / ipaddress Goto Github PK

View Code? Open in Web Editor NEW

This project forked from seancfoley/ipaddress

0.0 2.0 0.0 53.11 MB

Java library for handling IP addresses and subnets, both IPv4 and IPv6

Home Page: https://seancfoley.github.io/IPAddress/

License: Apache License 2.0

TypeScript 0.01% Java 99.99% Go 0.01%

ipaddress's Introduction

IPAddress

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

View Project Page

View Javadoc

In the Maven Central Repository

Developed as an Eclipse project, the project files are checked in so it can be easily be imported into an Eclipse workspace.

Version Notes
v1.0.1 Requires Java 6 or higher
v2.0.2 Requires Java 8 or higher
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
v4.3.0 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 v5.0.2 Requires Java 8 or higher. Support for Java 9, 10, 11 JPMS modules - the code is compiled with Java 8 but provides a Java 9 compiled module-info.class file. Compatible with Android using Android API level 24 or higher. Delete the module-info when using Android, it should be ignored when using Java 8. 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, and the improved parsing performance introduced with version 4.3.0. Other enhancements listed on the releases page

Planned future additions: ports to TypeScript / JavaScript and Go.

Getting Started

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 format in address string
    // handle improperly formatted address string
}

starting with host name strings

String hostPortStr = "[a:b: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
}

ipaddress's People

Contributors

seancfoley avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.