Git Product home page Git Product logo

javascript-ipv6's Introduction

javascript-ipv6 Build Status

javascript-ipv6 is a library for manipulating IPv6 addresses in JavaScript.

Examples

For node:

var v6 = require('ipv6').v6;

var address = new v6.Address('2001:0:ce49:7601:e866:efff:62c3:fffe');

console.log(address.isValid()); // Prints "true"

var teredo = address.teredo();

console.log(teredo.client4);    // Prints "157.60.0.1"

For a browser:

<!DOCTYPE html>
<html lang="en">
 <head>
  <title>Simple IPv6 test</title>

  <script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>

  <script type="text/javascript" src="/lib/jsbn.js"></script>
  <script type="text/javascript" src="/lib/jsbn2.js"></script>

  <script type="text/javascript" src="/lib/sprintf.js"></script>

  <script type="text/javascript" src="/ipv6/ipv6.js"></script>

  <script type="text/javascript">
   $(function() {
    var address6 = new v6.Address('a::b');

    $('#output').text(address6.canonicalForm());
   });
  </script>
 </head>

 <body>
  The canonical form of <code>a::b</code> is: <code id="output"></code>
 </body>
</html>

Current functionality

  • Parsing of most IPv6 notations
  • Validity checking
  • Decoding of the Teredo information in an address
  • Whether one address is a valid subnet of another
  • What special properties a given address has (multicast prefix, unique local address prefix, etc.)
  • Number of subnets of a certain size in a given address
  • Display methods
    • Hex, binary, and decimal
    • Canonical form
    • Correct form
    • IPv4-compatible (i.e. ::ffff:192.168.0.1)
  • Works in node.js and the browser
  • Unit tests with node.js and Mocha

Used by

Future functionality

  • Investigate procstreams for the CLI tool
  • Base 64/85 encoding?
  • Reverse lookups? (Whether a domain name has IPv6 glue)

TODO

  • Documentation

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.