diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..c2658d7 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +node_modules/ diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..c139bce --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,15 @@ +{ + // Verwendet IntelliSense zum Ermitteln möglicher Attribute. + // Zeigen Sie auf vorhandene Attribute, um die zugehörigen Beschreibungen anzuzeigen. + // Weitere Informationen finden Sie unter https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "type": "node", + "request": "launch", + "name": "Start Test", + "program": "${workspaceFolder}/test/test.js", + "cwd": "${workspaceFolder}" + } + ] +} \ No newline at end of file diff --git a/README.md b/README.md index 0db1e69..af31817 100644 --- a/README.md +++ b/README.md @@ -7,13 +7,13 @@ SOCKS protocol version 5 server and client implementations for node.js Requirements ============ -* [node.js](http://nodejs.org/) -- v0.10.0 or newer +* [node.js](http://nodejs.org/) -- v10.x or newer Install ======= - npm install socksv5 + npm install @outtacontrol/socks Examples @@ -22,7 +22,7 @@ Examples * Server with no authentication and allowing all connections: ```javascript -var socks = require('socksv5'); +var socks = require('@outtacontrol/socks'); var srv = socks.createServer(function(info, accept, deny) { accept(); @@ -37,7 +37,7 @@ srv.useAuth(socks.auth.None()); * Server with username/password authentication and allowing all (authenticated) connections: ```javascript -var socks = require('socksv5'); +var socks = require('@outtacontrol/socks'); var srv = socks.createServer(function(info, accept, deny) { accept(); @@ -54,7 +54,7 @@ srv.useAuth(socks.auth.UserPassword(function(user, password, cb) { * Server with no authentication and redirecting all connections to localhost: ```javascript -var socks = require('socksv5'); +var socks = require('@outtacontrol/socks'); var srv = socks.createServer(function(info, accept, deny) { info.dstAddr = 'localhost'; @@ -70,7 +70,7 @@ srv.useAuth(socks.auth.None()); * Server with no authentication and denying all connections not made to port 80: ```javascript -var socks = require('socksv5'); +var socks = require('@outtacontrol/socks'); var srv = socks.createServer(function(info, accept, deny) { if (info.dstPort === 80) @@ -88,7 +88,7 @@ srv.useAuth(socks.auth.None()); * Server with no authentication, intercepting all connections to port 80, and passing through all others: ```javascript -var socks = require('socksv5'); +var socks = require('@outtacontrol/socks'); var srv = socks.createServer(function(info, accept, deny) { if (info.dstPort === 80) { @@ -117,7 +117,7 @@ srv.useAuth(socks.auth.None()); * Client with no authentication: ```javascript -var socks = require('socksv5'); +var socks = require('@outtacontrol/socks'); var client = socks.connect({ host: 'google.com', @@ -135,7 +135,7 @@ var client = socks.connect({ * HTTP(s) client requests using a SOCKS Agent: ```javascript -var socks = require('socksv5'); +var socks = require('@outtacontrol/socks'); var http = require('http'); var socksConfig = { diff --git a/index.d.ts b/index.d.ts new file mode 100644 index 0000000..66b13b8 --- /dev/null +++ b/index.d.ts @@ -0,0 +1,418 @@ + +declare module "@outtacontrol/socks/lib/Agents" { + import { EventEmitter } from "events"; + import { Client, createConnection } from "@outtacontrol/socks/lib/client"; + import { Socket } from "net"; + import { ClientRequest, ClientRequestArgs } from "http"; + + export interface SocksAgentOptions { + /** + * Keep sockets around in a pool to be used by other requests in the future. Default = false + */ + keepAlive?: boolean; + /** + * When using HTTP KeepAlive, how often to send TCP KeepAlive packets over sockets being kept alive. Default = 1000. + * Only relevant if keepAlive is set to true. + */ + keepAliveMsecs?: number; + /** + * Maximum number of sockets to allow per host. Default for Node 0.10 is 5, default for Node 0.12 is Infinity + */ + maxSockets?: number; + /** + * Maximum number of sockets to leave open in a free state. Only relevant if keepAlive is set to true. Default = 256. + */ + maxFreeSockets?: number; + } + + export interface SocksAgentNameOptions { + host?: string; + port?: number | string; + localAddress?: string; + } + + export interface SocksHttpsAgentNameOptions extends SocksAgentNameOptions { + ca?: string; + cert?: string; + ciphers?: string; + key?: string; + pfx?: string; + rejectUnauthorized?: string | undefined; + } + + export interface SocksNamedSocketList { + [key: string]: Client[]; + } + + export class Agent extends EventEmitter { + defaultPort: number; + protocol: string; + + keepAliveMsecs: number; + keepAlive: boolean; + maxSockets: number; + maxFreeSockets: number; + sockets: SocksNamedSocketList; + freeSockets: SocksNamedSocketList; + requests: any; + + constructor(options?: SocksAgentOptions); + + createConnection(port: number, host?: string, listener?: () => void): Client; + createConnection(path: string, listener?: () => void): Client; + + getName(options?: SocksAgentNameOptions): string; + + addRequest(req: ClientRequest, options?: SocksAgentNameOptions): void; + createSocket(req: ClientRequest, options?: ClientRequestArgs): Client; + removeSocket(socket: Socket, options?: ClientRequestArgs): void; + + destroy(): void; + } + + export class HttpsAgent extends Agent { } +} + +declare module "@outtacontrol/socks/lib/auth" { + import { Socket } from "net"; + + export { None } from "@outtacontrol/socks/lib/auth/None"; + export { UserPassword } from "@outtacontrol/socks/lib/auth/UserPassword"; + + export interface AuthCallback { + (done: boolean): void; + (error: Error): void; + } + + export interface Auth { + client(stream: Socket, callback: AuthCallback): void; + server(stream: Socket, callback: AuthCallback): void; + } +} + +declare module "@outtacontrol/socks/lib/auth/None" { + import { Auth } from "@outtacontrol/socks/lib/auth"; + export function None(): Auth; +} + +declare module "@outtacontrol/socks/lib/auth/UserPassword" { + import { Auth } from "@outtacontrol/socks/lib/auth"; + + export interface DoneCallback { + (success: boolean): void; + } + + export interface AuthCallback { + (username: string, password: string, callback: DoneCallback): void; + } + + export function UserPassword(username: string, password: string): Auth; + export function UserPassword(authCallback: AuthCallback): Auth; +} + +declare module "@outtacontrol/socks/lib/client" { + import { EventEmitter } from "events"; + + export interface SocksClientOptions { + host?: string; + port?: number; + localAddress?: string; + proxyHost?: string; + proxyPort?: number; + localDNS?: string; + strictLocalDNS?: string; + auths?: any[]; + } + + export class Client extends EventEmitter { + constructor(options?: SocksClientOptions); + + useAuth(auth: any): this; + + connect(options: SocksClientOptions, listener?: () => void): this; + connect(port: number, host?: string, listener?: () => void): this; + connect(path: string, listener?: () => void): this; + + addListener(event: string, listener: (...args: any[]) => void): this; + addListener(event: "close", listener: (had_error: boolean) => void): this; + addListener(event: "connect", listener: () => void): this; + addListener(event: "data", listener: (data: Buffer) => void): this; + addListener(event: "drain", listener: () => void): this; + addListener(event: "end", listener: () => void): this; + addListener(event: "error", listener: (err: Error) => void): this; + addListener(event: "lookup", listener: (err: Error, address: string, family: string | number, host: string) => void): this; + addListener(event: "timeout", listener: () => void): this; + + emit(event: string | symbol, ...args: any[]): boolean; + emit(event: "close", had_error: boolean): boolean; + emit(event: "connect"): boolean; + emit(event: "data", data: Buffer): boolean; + emit(event: "drain"): boolean; + emit(event: "end"): boolean; + emit(event: "error", err: Error): boolean; + emit(event: "lookup", err: Error, address: string, family: string | number, host: string): boolean; + emit(event: "timeout"): boolean; + + on(event: string, listener: (...args: any[]) => void): this; + on(event: "close", listener: (had_error: boolean) => void): this; + on(event: "connect", listener: () => void): this; + on(event: "data", listener: (data: Buffer) => void): this; + on(event: "drain", listener: () => void): this; + on(event: "end", listener: () => void): this; + on(event: "error", listener: (err: Error) => void): this; + on(event: "lookup", listener: (err: Error, address: string, family: string | number, host: string) => void): this; + on(event: "timeout", listener: () => void): this; + + once(event: string, listener: (...args: any[]) => void): this; + once(event: "close", listener: (had_error: boolean) => void): this; + once(event: "connect", listener: () => void): this; + once(event: "data", listener: (data: Buffer) => void): this; + once(event: "drain", listener: () => void): this; + once(event: "end", listener: () => void): this; + once(event: "error", listener: (err: Error) => void): this; + once(event: "lookup", listener: (err: Error, address: string, family: string | number, host: string) => void): this; + once(event: "timeout", listener: () => void): this; + + prependListener(event: string, listener: (...args: any[]) => void): this; + prependListener(event: "close", listener: (had_error: boolean) => void): this; + prependListener(event: "connect", listener: () => void): this; + prependListener(event: "data", listener: (data: Buffer) => void): this; + prependListener(event: "drain", listener: () => void): this; + prependListener(event: "end", listener: () => void): this; + prependListener(event: "error", listener: (err: Error) => void): this; + prependListener(event: "lookup", listener: (err: Error, address: string, family: string | number, host: string) => void): this; + prependListener(event: "timeout", listener: () => void): this; + + prependOnceListener(event: string, listener: (...args: any[]) => void): this; + prependOnceListener(event: "close", listener: (had_error: boolean) => void): this; + prependOnceListener(event: "connect", listener: () => void): this; + prependOnceListener(event: "data", listener: (data: Buffer) => void): this; + prependOnceListener(event: "drain", listener: () => void): this; + prependOnceListener(event: "end", listener: () => void): this; + prependOnceListener(event: "error", listener: (err: Error) => void): this; + prependOnceListener(event: "lookup", listener: (err: Error, address: string, family: string | number, host: string) => void): this; + prependOnceListener(event: "timeout", listener: () => void): this; + } + + export function connect(port: number, host?: string, listener?: () => void): Client; + export function connect(path: string, listener?: () => void): Client; + export function createConnection(port: number, host?: string, listener?: () => void): Client; + export function createConnection(path: string, listener?: () => void): Client; +} + +declare module "@outtacontrol/socks/lib/client.parser" { + import { Socket } from "net"; + import { EventEmitter } from "events"; + import { SocksBoundAddress, SocksProxyInfo } from "@outtacontrol/socks"; + + export default class Parser extends EventEmitter { + constructor(stream: Socket); + start(): void; + stop(): void; + + addListener(event: string, listener: (...args: any[]) => void): this; + addListener(event: "method", listener: (method: number) => void): this; + addListener(event: "reply", listener: (info: SocksBoundAddress) => void): this; + addListener(event: "error", listener: (err: Error) => void): this; + + emit(event: string | symbol, ...args: any[]): boolean; + emit(event: "method", method: number): boolean; + emit(event: "request", info: SocksProxyInfo): boolean; + emit(event: "error", err: Error): boolean; + + on(event: string, listener: (...args: any[]) => void): this; + on(event: "method", listener: (method: number) => void): this; + on(event: "reply", listener: (info: SocksBoundAddress) => void): this; + on(event: "error", listener: (err: Error) => void): this; + + once(event: string, listener: (...args: any[]) => void): this; + once(event: "method", listener: (method: number) => void): this; + once(event: "reply", listener: (info: SocksBoundAddress) => void): this; + once(event: "error", listener: (err: Error) => void): this; + + prependListener(event: string, listener: (...args: any[]) => void): this; + prependListener(event: "method", listener: (method: number) => void): this; + prependListener(event: "reply", listener: (info: SocksBoundAddress) => void): this; + prependListener(event: "error", listener: (err: Error) => void): this; + + prependOnceListener(event: string, listener: (...args: any[]) => void): this; + prependOnceListener(event: "method", listener: (method: number) => void): this; + prependOnceListener(event: "reply", listener: (info: SocksBoundAddress) => void): this; + prependOnceListener(event: "error", listener: (err: Error) => void): this; + } +} + +declare module "@outtacontrol/socks/lib/constants" { + + interface SocksCMD { + CONNECT: number; + BIND: number; + UDP: number; + } + + interface SocksATYP { + IPv4: number; + NAME: number; + IPv6: number; + } + + interface SocksREP { + SUCCESS: number; + GENFAIL: number; + DISALLOW: number; + NETUNREACH: number; + HOSTUNREACH: number; + CONNREFUSED: number; + TTLEXPIRED: number; + CMDUNSUPP: number; + ATYPUNSUPP: number; + } + + export const CMD: SocksCMD; + export const ATYP: SocksATYP; + export const REP: SocksREP; +} + +declare module "@outtacontrol/socks/lib/server" { + import { EventEmitter } from "events"; + import { Auth } from "@outtacontrol/socks/lib/auth"; + import { Socket, AddressInfo } from "net"; + import { SocksProxyInfo } from "@outtacontrol/socks"; + + export interface SocksAcceptCallback { + (intercept?: false): void; + (intercept: true): Socket; + } + + export interface SocksDenyCallback { + (): void; + } + + export interface SocksConnectionCallback { + (info: SocksProxyInfo, accept: SocksAcceptCallback, deny: SocksDenyCallback): void; + } + + export interface SocksServerOptions { + allowHalfOpen?: boolean; + pauseOnConnect?: boolean; + auths?: Auth[]; + debug?: boolean; + } + + export class Server extends EventEmitter { + constructor(connectionCallback: SocksConnectionCallback); + constructor(options?: SocksServerOptions, connectionCallback?: SocksConnectionCallback); + + useAuth(auth: Auth): this; + + address(): AddressInfo | string; + close(callback?: Function): this; + getConnections(cb: (error: Error | null, count: number) => void): void; + + listen(port: number, host?: string, listeningCallback?: () => void): this; + listen(path: string, listeningCallback?: () => void): this; + + ref(): this; + unref(): this; + + addListener(event: string, listener: (...args: any[]) => void): this; + addListener(event: "close", listener: () => void): this; + addListener(event: "connection", listener: (socket: Socket) => void): this; + addListener(event: "error", listener: (err: Error) => void): this; + addListener(event: "listening", listener: () => void): this; + + emit(event: string | symbol, ...args: any[]): boolean; + emit(event: "close"): boolean; + emit(event: "connection", socket: Socket): boolean; + emit(event: "error", err: Error): boolean; + emit(event: "listening"): boolean; + + on(event: string, listener: (...args: any[]) => void): this; + on(event: "close", listener: () => void): this; + on(event: "connection", listener: (socket: Socket) => void): this; + on(event: "error", listener: (err: Error) => void): this; + on(event: "listening", listener: () => void): this; + + once(event: string, listener: (...args: any[]) => void): this; + once(event: "close", listener: () => void): this; + once(event: "connection", listener: (socket: Socket) => void): this; + once(event: "error", listener: (err: Error) => void): this; + once(event: "listening", listener: () => void): this; + + prependListener(event: string, listener: (...args: any[]) => void): this; + prependListener(event: "close", listener: () => void): this; + prependListener(event: "connection", listener: (socket: Socket) => void): this; + prependListener(event: "error", listener: (err: Error) => void): this; + prependListener(event: "listening", listener: () => void): this; + + prependOnceListener(event: string, listener: (...args: any[]) => void): this; + prependOnceListener(event: "close", listener: () => void): this; + prependOnceListener(event: "connection", listener: (socket: Socket) => void): this; + prependOnceListener(event: "error", listener: (err: Error) => void): this; + prependOnceListener(event: "listening", listener: () => void): this; + } + + export function createServer(): Server; + export function createServer(connectionListener: SocksConnectionCallback): Server; + export function createServer(options: SocksServerOptions, connectionListener: SocksConnectionCallback): Server; +} + +declare module "@outtacontrol/socks/lib/server.parser" { + import { Socket } from "net"; + import { SocksProxyInfo, SocksBoundAddress } from "@outtacontrol/socks"; + export default class Parser { + constructor(stream: Socket); + start(): void; + stop(): void; + + addListener(event: string, listener: (...args: any[]) => void): this; + addListener(event: "methods", listener: (methods: Buffer) => void): this; + addListener(event: "request", listener: (info: SocksProxyInfo) => void): this; + addListener(event: "error", listener: (err: Error) => void): this; + + emit(event: string | symbol, ...args: any[]): boolean; + emit(event: "methods", methods: Buffer): boolean; + emit(event: "request", info: SocksProxyInfo): boolean; + emit(event: "error", err: Error): boolean; + + on(event: string, listener: (...args: any[]) => void): this; + on(event: "methods", listener: (methods: Buffer) => void): this; + on(event: "request", listener: (info: SocksProxyInfo) => void): this; + on(event: "error", listener: (err: Error) => void): this; + + once(event: string, listener: (...args: any[]) => void): this; + once(event: "methods", listener: (methods: Buffer) => void): this; + once(event: "request", listener: (info: SocksProxyInfo) => void): this; + once(event: "error", listener: (err: Error) => void): this; + + prependListener(event: string, listener: (...args: any[]) => void): this; + prependListener(event: "methods", listener: (methods: Buffer) => void): this; + prependListener(event: "request", listener: (info: SocksProxyInfo) => void): this; + prependListener(event: "error", listener: (err: Error) => void): this; + + prependOnceListener(event: string, listener: (...args: any[]) => void): this; + prependOnceListener(event: "methods", listener: (methods: Buffer) => void): this; + prependOnceListener(event: "request", listener: (info: SocksProxyInfo) => void): this; + prependOnceListener(event: "error", listener: (err: Error) => void): this; + } +} + +declare module "@outtacontrol/socks" { + export interface SocksBoundAddress { + bndAddr: string; + bndPort: number; + } + + export interface SocksProxyInfo { + cmd: string; + srcAddr?: string | undefined; + srcPort?: number | undefined; + dstAddr: string; + dstPort: number; + } + + export * from "@outtacontrol/socks/lib/Agents"; + export * from "@outtacontrol/socks/lib/client"; + export * from "@outtacontrol/socks/lib/server"; + export * from "@outtacontrol/socks/lib/auth"; +} diff --git a/index.js b/index.js index 84ca1f4..97fa4b1 100644 --- a/index.js +++ b/index.js @@ -1,15 +1,16 @@ -var fs = require('fs'), - path = require('path'); +const { HttpAgent, HttpsAgent } = require('./lib/Agents'); +const { None, UserPassword } = require('./lib/auth'); +const { Client, connect, createConnection } = require('./lib/client'); +const { Server, createServer } = require('./lib/server'); -['server', 'client', 'Agents'].forEach(function(f) { - var exp = require(__dirname + '/lib/' + f), - keys = Object.keys(exp); - for (var i = 0, len = keys.length; i < len; ++i) - exports[keys[i]] = exp[keys[i]]; -}); +exports.auth = { None, UserPassword }; -exports.auth = {}; +exports.HttpAgent = HttpAgent; +exports.HttpsAgent = HttpsAgent; -fs.readdirSync(__dirname + '/lib/auth').forEach(function(f) { - exports.auth[path.basename(f, '.js')] = require(__dirname + '/lib/auth/' + f); -}); \ No newline at end of file +exports.Client = Client; +exports.connect = connect; +exports.createConnection = createConnection; + +exports.Server = Server; +exports.createServer = createServer; diff --git a/lib/Agents.js b/lib/Agents.js index 6d79453..ed772ed 100644 --- a/lib/Agents.js +++ b/lib/Agents.js @@ -23,7 +23,6 @@ var socks = require('../index'); -var net = require('net'); var tls = require('tls'); var util = require('util'); var EventEmitter = require('events').EventEmitter; @@ -315,6 +314,8 @@ function HttpsAgent(options) { } util.inherits(HttpsAgent, Agent); exports.HttpsAgent = HttpsAgent; + +// TODO: probably an artifact. Should be deleted. HttpsAgent.prototype.createConnection = function(port, host, options) { if (typeof port === 'object' && port !== null) { options = port; diff --git a/lib/auth.js b/lib/auth.js new file mode 100644 index 0000000..85976b2 --- /dev/null +++ b/lib/auth.js @@ -0,0 +1,5 @@ +const { None } = require('./auth/None'); +const { UserPassword } = require('./auth/UserPassword'); + +exports.None = None; +exports.UserPassword = UserPassword; diff --git a/lib/auth/None.js b/lib/auth/None.js index 75c3f52..10131b9 100644 --- a/lib/auth/None.js +++ b/lib/auth/None.js @@ -1,4 +1,4 @@ -module.exports = function NoneAuthHandlers() { +exports.None = function None() { return { METHOD: 0x00, server: function serverHandler(stream, cb) { diff --git a/lib/auth/UserPassword.js b/lib/auth/UserPassword.js index 0f17eb9..4bf97cd 100644 --- a/lib/auth/UserPassword.js +++ b/lib/auth/UserPassword.js @@ -8,10 +8,10 @@ var STATE_VERSION = 0, STATE_STATUS = 5; // server -var BUF_SUCCESS = new Buffer([0x01, 0x00]), - BUF_FAILURE = new Buffer([0x01, 0x01]); +var BUF_SUCCESS = Buffer.from([0x01, 0x00]), + BUF_FAILURE = Buffer.from([0x01, 0x01]); -module.exports = function UserPasswordAuthHandlers() { +exports.UserPassword = function UserPassword() { var authcb, user, pass, @@ -75,7 +75,7 @@ module.exports = function UserPasswordAuthHandlers() { } ++i; ++state; - user = new Buffer(ulen); + user = Buffer.alloc(ulen); userp = 0; break; case STATE_UNAME: @@ -102,7 +102,7 @@ module.exports = function UserPasswordAuthHandlers() { } ++i; ++state; - pass = new Buffer(plen); + pass = Buffer.alloc(plen); passp = 0; break; case STATE_PASSWD: @@ -178,7 +178,7 @@ module.exports = function UserPasswordAuthHandlers() { } stream.on('data', onData); - var buf = new Buffer(3 + userlen + passlen); + var buf = Buffer.alloc(3 + userlen + passlen); buf[0] = 0x01; buf[1] = userlen; buf.write(user, 2, userlen); diff --git a/lib/client.js b/lib/client.js index ff212e5..3e0ccb6 100644 --- a/lib/client.js +++ b/lib/client.js @@ -1,5 +1,5 @@ var net = require('net'), - normalizeConnectArgs = net._normalizeConnectArgs, + normalizeConnectArgs = net._normalizeArgs, dns = require('dns'), util = require('util'), inherits = util.inherits, @@ -66,7 +66,7 @@ Client.prototype._onConnect = function() { var auths = self._auths, alen = auths.length, - authsbuf = new Buffer(2 + alen); + authsbuf = Buffer.alloc(2 + alen); authsbuf[0] = 0x05; authsbuf[1] = alen; for (var a = 0, p = 2; a < alen; ++a, ++p) @@ -123,7 +123,7 @@ Client.prototype._sendRequest = function() { var addrlen = (iptype === 0 ? Buffer.byteLength(self._dstaddr) : (iptype === 4 ? 4 : 16)), - reqbuf = new Buffer(6 + (iptype === 0 ? 1 : 0) + addrlen), + reqbuf = Buffer.alloc(6 + (iptype === 0 ? 1 : 0) + addrlen), p; reqbuf[0] = 0x05; reqbuf[1] = CMD.CONNECT; diff --git a/lib/client.parser.js b/lib/client.parser.js index 7763b4f..45538ac 100644 --- a/lib/client.parser.js +++ b/lib/client.parser.js @@ -1,20 +1,20 @@ var inherits = require('util').inherits, - EventEmitter = require('events').EventEmitter; + EventEmitter = require('events').EventEmitter; var ATYP = require('./constants').ATYP, - REP = require('./constants').REP; + REP = require('./constants').REP; var STATE_VERSION = 0, - STATE_METHOD = 1, - STATE_REP_STATUS = 2, - STATE_REP_RSV = 3, - STATE_REP_ATYP = 4, - STATE_REP_BNDADDR = 5, - STATE_REP_BNDADDR_VARLEN = 6, - STATE_REP_BNDPORT = 7; + STATE_METHOD = 1, + STATE_REP_STATUS = 2, + STATE_REP_RSV = 3, + STATE_REP_ATYP = 4, + STATE_REP_BNDADDR = 5, + STATE_REP_BNDADDR_VARLEN = 6, + STATE_REP_BNDPORT = 7; var ERRORS = {}, - ERROR_UNKNOWN = ['unknown error', 'EUNKNOWN']; + ERROR_UNKNOWN = ['unknown error', 'EUNKNOWN']; ERRORS[REP.GENFAIL] = ['general SOCKS server failure', 'EGENFAIL']; ERRORS[REP.DISALLOW] = ['connection not allowed by ruleset', 'EACCES']; ERRORS[REP.NETUNREACH] = ['network is unreachable', 'ENETUNREACH']; @@ -29,7 +29,7 @@ function Parser(stream) { this._stream = stream; this._listening = false; - this.__onData = function(chunk) { + this.__onData = function (chunk) { self._onData(chunk); }; @@ -45,13 +45,13 @@ function Parser(stream) { } inherits(Parser, EventEmitter); -Parser.prototype._onData = function(chunk) { +Parser.prototype._onData = function (chunk) { var state = this._state, - i = 0, - len = chunk.length, - left, - chunkLeft, - minLen; + i = 0, + len = chunk.length, + left, + chunkLeft, + minLen; while (i < len) { switch (state) { @@ -65,8 +65,8 @@ Parser.prototype._onData = function(chunk) { case STATE_VERSION: if (chunk[i] !== 0x05) { this.emit('error', - new Error('Incompatible SOCKS protocol version: ' - + chunk[i])); + new Error('Incompatible SOCKS protocol version: ' + + chunk[i])); return; } ++i; @@ -74,7 +74,7 @@ Parser.prototype._onData = function(chunk) { state = STATE_REP_STATUS; else ++state; - break; + break; case STATE_METHOD: var method = chunk[i]; ++i; @@ -84,7 +84,7 @@ Parser.prototype._onData = function(chunk) { this._stream.unshift(chunk.slice(i)); this.emit('method', method); return; - break; + break; // ======================================================================= /* +----+-----+-------+------+----------+----------+ @@ -119,7 +119,7 @@ Parser.prototype._onData = function(chunk) { var status = chunk[i]; if (status !== REP.SUCCESS) { var errinfo = ERRORS[status] || ERROR_UNKNOWN, - err = new Error(errinfo[0]); + err = new Error(errinfo[0]); err.code = errinfo[1]; this.stop(); @@ -128,47 +128,47 @@ Parser.prototype._onData = function(chunk) { } ++i; ++state; - break; + break; case STATE_REP_RSV: ++i; ++state; - break; + break; case STATE_REP_ATYP: var atyp = chunk[i]; state = STATE_REP_BNDADDR; if (atyp === ATYP.IPv4) - this._bndaddr = new Buffer(4); + this._bndaddr = Buffer.alloc(4); else if (atyp === ATYP.IPv6) - this._bndaddr = new Buffer(16); + this._bndaddr = Buffer.alloc(16); else if (atyp === ATYP.NAME) state = STATE_REP_BNDADDR_VARLEN; else { this.stop(); this.emit('error', - new Error('Invalid request address type: ' + atyp)); + new Error('Invalid request address type: ' + atyp)); return; } this._atyp = atyp; ++i; - break; + break; case STATE_REP_BNDADDR: left = this._bndaddr.length - this._bndaddrp; chunkLeft = len - i; minLen = (left < chunkLeft ? left : chunkLeft); chunk.copy(this._bndaddr, - this._bndaddrp, - i, - i + minLen); + this._bndaddrp, + i, + i + minLen); this._bndaddrp += minLen; i += minLen; if (this._bndaddrp === this._bndaddr.length) state = STATE_REP_BNDPORT; - break; + break; case STATE_REP_BNDADDR_VARLEN: - this._bndaddr = new Buffer(chunk[i]); + this._bndaddr = Buffer.alloc(chunk[i]); state = STATE_REP_BNDADDR; ++i; - break; + break; case STATE_REP_BNDPORT: if (this._bndport === undefined) this._bndport = chunk[i]; @@ -185,7 +185,7 @@ Parser.prototype._onData = function(chunk) { this._bndaddr = Array.prototype.join.call(this._bndaddr, '.'); else if (this._atyp === ATYP.IPv6) { var ipv6str = '', - addr = this._bndaddr; + addr = this._bndaddr; for (var b = 0; b < 16; ++b) { if (b % 2 === 0 && b > 0) ipv6str += ':'; @@ -202,7 +202,7 @@ Parser.prototype._onData = function(chunk) { return; } ++i; - break; + break; // =================================================================== } } @@ -210,7 +210,7 @@ Parser.prototype._onData = function(chunk) { this._state = state; }; -Parser.prototype.start = function() { +Parser.prototype.start = function () { if (this._listening) return; this._listening = true; @@ -218,7 +218,7 @@ Parser.prototype.start = function() { this._stream.resume(); }; -Parser.prototype.stop = function() { +Parser.prototype.stop = function () { if (!this._listening) return; this._listening = false; diff --git a/lib/server.js b/lib/server.js index bcac647..cc75a80 100644 --- a/lib/server.js +++ b/lib/server.js @@ -10,15 +10,15 @@ var Parser = require('./server.parser'), var ATYP = require('./constants').ATYP, REP = require('./constants').REP; -var BUF_AUTH_NO_ACCEPT = new Buffer([0x05, 0xFF]), - BUF_REP_INTR_SUCCESS = new Buffer([0x05, +var BUF_AUTH_NO_ACCEPT = Buffer.from([0x05, 0xFF]), + BUF_REP_INTR_SUCCESS = Buffer.from([0x05, REP.SUCCESS, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]), - BUF_REP_DISALLOW = new Buffer([0x05, REP.DISALLOW]), - BUF_REP_CMDUNSUPP = new Buffer([0x05, REP.CMDUNSUPP]); + BUF_REP_DISALLOW = Buffer.from([0x05, REP.DISALLOW]), + BUF_REP_CMDUNSUPP = Buffer.from([0x05, REP.CMDUNSUPP]); function Server(options, listener) { if (!(this instanceof Server)) @@ -86,7 +86,7 @@ Server.prototype._onConnection = function(socket) { socket.end(); } }); - socket.write(new Buffer([0x05, auths[a].METHOD])); + socket.write(Buffer.from([0x05, auths[a].METHOD])); socket.resume(); return; } @@ -215,7 +215,7 @@ function proxySocket(socket, req) { if (socket.writable) { var localbytes = ipbytes(dstSock.localAddress || '127.0.0.1'), len = localbytes.length, - bufrep = new Buffer(6 + len), + bufrep = Buffer.alloc(6 + len), p = 4; bufrep[0] = 0x05; bufrep[1] = REP.SUCCESS; @@ -238,7 +238,7 @@ function proxySocket(socket, req) { function handleProxyError(socket, err) { if (socket.writable) { - var errbuf = new Buffer([0x05, REP.GENFAIL]); + var errbuf = Buffer.from([0x05, REP.GENFAIL]); if (err.code) { switch (err.code) { case 'ENOENT': diff --git a/lib/server.parser.js b/lib/server.parser.js index 025d6b8..2c235e4 100644 --- a/lib/server.parser.js +++ b/lib/server.parser.js @@ -76,7 +76,7 @@ Parser.prototype._onData = function(chunk) { } ++i; ++state; - this._methods = new Buffer(nmethods); + this._methods = Buffer.alloc(nmethods); this._methodsp = 0; break; case STATE_METHODS: @@ -148,9 +148,9 @@ Parser.prototype._onData = function(chunk) { var atyp = chunk[i]; state = STATE_REQ_DSTADDR; if (atyp === ATYP.IPv4) - this._dstaddr = new Buffer(4); + this._dstaddr = Buffer.alloc(4); else if (atyp === ATYP.IPv6) - this._dstaddr = new Buffer(16); + this._dstaddr = Buffer.alloc(16); else if (atyp === ATYP.NAME) state = STATE_REQ_DSTADDR_VARLEN; else { @@ -176,7 +176,7 @@ Parser.prototype._onData = function(chunk) { state = STATE_REQ_DSTPORT; break; case STATE_REQ_DSTADDR_VARLEN: - this._dstaddr = new Buffer(chunk[i]); + this._dstaddr = Buffer.alloc(chunk[i]); state = STATE_REQ_DSTADDR; ++i; break; diff --git a/lib/utils.js b/lib/utils.js index b5c2457..cf840d1 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -1,11 +1,11 @@ -var net = require('net'), - ipv6 = require('ipv6').v6; +const net = require('net'); +const { Address6 } = require('ip-address'); -exports.ipbytes = function(str) { - var type = net.isIP(str), - nums, - bytes, - i; +exports.ipbytes = function (str) { + const type = net.isIP(str); + let nums; + let bytes; + let i; if (type === 4) { nums = str.split('.', 4); @@ -15,9 +15,9 @@ exports.ipbytes = function(str) { throw new Error('Error parsing IP: ' + str); } } else if (type === 6) { - var addr = new ipv6.Address(str), - b = 0, - group; + var addr = new Address6(str), + b = 0, + group; if (!addr.valid) throw new Error('Error parsing IP: ' + str); nums = addr.parsedAddress; diff --git a/node_modules/ipv6/.npmignore b/node_modules/ipv6/.npmignore deleted file mode 100644 index c79b932..0000000 --- a/node_modules/ipv6/.npmignore +++ /dev/null @@ -1,3 +0,0 @@ -*/*.swp -node_modules -npm-debug.log diff --git a/node_modules/ipv6/.travis.yml b/node_modules/ipv6/.travis.yml deleted file mode 100644 index 4ad4411..0000000 --- a/node_modules/ipv6/.travis.yml +++ /dev/null @@ -1,6 +0,0 @@ -language: node_js -node_js: - - 0.6 - - 0.8 - - 0.10 - - 0.11 diff --git a/node_modules/ipv6/LICENSE b/node_modules/ipv6/LICENSE deleted file mode 100644 index ec79adb..0000000 --- a/node_modules/ipv6/LICENSE +++ /dev/null @@ -1,19 +0,0 @@ -Copyright (C) 2011 by Beau Gunderson - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. diff --git a/node_modules/ipv6/README.md b/node_modules/ipv6/README.md deleted file mode 100644 index 355dba6..0000000 --- a/node_modules/ipv6/README.md +++ /dev/null @@ -1,89 +0,0 @@ -javascript-ipv6 [](http://travis-ci.org/beaugunderson/javascript-ipv6) -=============== - -javascript-ipv6 is a library for manipulating IPv6 addresses in JavaScript. - -Examples --------- - -For node: - -```js -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: - -```html - - -
-a::b is:
-
-
-```
-
-Current functionality
----------------------
-
-- Parsing of most IPv6 notations
-- Parsing of IPv6 Addresses and Ports from URLs with `v6.Address.fromURL(url)`
-- Validity checking
-- Decoding of the [Teredo information](http://en.wikipedia.org/wiki/Teredo_tunneling#IPv6_addressing) 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](http://nodejs.org/) and the browser
-- Unit tests with [node.js](http://nodejs.org/) and [Mocha](http://visionmedia.github.com/mocha/)
-
-Used by
--------
-
-- [Rackspace](http://www.rackspace.com/) in [node-swiz](https://github.com/racker/node-swiz)
-- [node-socksified](https://github.com/vially/node-socksified)
-
-Future functionality
---------------------
-
-- Investigate `procstreams` for the CLI tool
-- Base 64/85 encoding?
-- Reverse lookups? (Whether a domain name has IPv6 glue)
-
-TODO
-----
-
-- Documentation
diff --git a/node_modules/ipv6/bin/ipv6.js b/node_modules/ipv6/bin/ipv6.js
deleted file mode 100644
index 8385465..0000000
--- a/node_modules/ipv6/bin/ipv6.js
+++ /dev/null
@@ -1,39 +0,0 @@
-#!/usr/bin/env node
-
-var v6 = require('../ipv6.js').v6;
-var v4 = require('../ipv6.js').v4;
-
-var sprintf = require('sprintf').sprintf;
-var cli = require('cli');
-var cliff = require('cliff');
-
-var options = cli.parse();
-
-var rows = [['Address', 'Valid', 'Correct Form', 'Canonical Form']];
-
-cli.withStdinLines(function(lines, newline) {
- for (var i = 0; i < lines.length; i++) {
- if (lines[i] == '') {
- continue;
- }
-
- var address = new v6.Address(lines[i]);
-
- if (options.v) {
- this.output(sprintf('%s = %s\n', lines[i], cliff.inspect(address)));
- } else if (options.c) {
- rows.push([
- lines[i],
- address.isValid() ? 'Yes' : 'No'.red,
- address.isValid() ? address.correctForm() : '',
- address.isValid() ? address.canonicalForm() : ''
- ]);
- } else {
- this.output(sprintf('%s,%s\n', lines[i], address.isValid() ? 'valid' : 'invalid'));
- }
- }
-
- if (options.c) {
- console.log(cliff.stringifyRows(rows, ['green', 'green', 'green', 'green']));
- }
-});
diff --git a/node_modules/ipv6/bin/ipv6grep.js b/node_modules/ipv6/bin/ipv6grep.js
deleted file mode 100644
index 3586e05..0000000
--- a/node_modules/ipv6/bin/ipv6grep.js
+++ /dev/null
@@ -1,74 +0,0 @@
-#!/usr/bin/env node
-
-var v6 = require('../ipv6.js').v6;
-var v4 = require('../ipv6.js').v4;
-
-var sprintf = require('sprintf').sprintf;
-var cli = require('cli');
-var cliff = require('cliff');
-
-var util = require('util');
-var spawn = require('child_process').spawn;
-
-cli.enable('version', 'status', 'glob');
-
-cli.parse({
- all: ['a', 'Find all addresses'],
- validate: ['v', 'Validate found addresses'],
- substring: ['s', 'Substring match']
-});
-
-cli.debug('script: ' + process.ARGV[1]);
-
-cli.main(function(args, options) {
- cli.debug('args: ' + util.inspect(args));
- cli.debug('options: ' + util.inspect(options));
-
- var grepArguments = ['-E', '-n', '--color=always'];
- var stdin = false;
-
- if (args.length == 0 && options.all) {
- // STDIN with all addresses
- grepArguments.push('ADDRESS');
- stdin = true;
- } else if (args.length == 1) {
- // STDIN
- var address = new v6.Address(new v6.Address(args[0]).correctForm());
- var regex = address.regularExpressionString(options.substring);
-
- cli.debug('address: ' + util.inspect(address.regularExpression()));
-
- grepArguments.push(regex);
- stdin = true;
- } else if (args.length > 1) {
- // filename
- var address = new v6.Address(new v6.Address(args[0]).correctForm());
- var regex = address.regularExpressionString(options.substring);
-
- var files = args.slice(1, args.length);
-
- cli.debug('address: ' + util.inspect(address.regularExpression()));
- cli.debug('files: ' + util.inspect(files));
-
- grepArguments = grepArguments.concat(regex, files)
- }
-
- cli.debug('grep arguments: ' + util.inspect(grepArguments));
-
- if (!stdin) {
- var grep = spawn('grep', grepArguments);
-
- grep.stdout.on('data', function (data) {
- console.log(String(data).trim());
- });
-
- grep.on('exit', function (code) {
- cli.debug('grep exited: ' + code);
- });
-
- //grep.stdin.end();
- }
-
- //cli.withStdinLines(function(lines, newline) {
- //});
-});
diff --git a/node_modules/ipv6/examples/browser/simple.html b/node_modules/ipv6/examples/browser/simple.html
deleted file mode 100644
index 39406fa..0000000
--- a/node_modules/ipv6/examples/browser/simple.html
+++ /dev/null
@@ -1,29 +0,0 @@
-
-
-
-
-
- a::b is:
-
-
diff --git a/node_modules/ipv6/examples/node/simple.js b/node_modules/ipv6/examples/node/simple.js
deleted file mode 100644
index 082ff80..0000000
--- a/node_modules/ipv6/examples/node/simple.js
+++ /dev/null
@@ -1,5 +0,0 @@
-var v6 = require('ipv6').v6;
-
-var address = new v6.Address('a::b');
-
-console.log(address.canonicalForm());
diff --git a/node_modules/ipv6/index.js b/node_modules/ipv6/index.js
deleted file mode 100644
index c7929b9..0000000
--- a/node_modules/ipv6/index.js
+++ /dev/null
@@ -1 +0,0 @@
-exports = module.exports = require('./ipv6.js');
\ No newline at end of file
diff --git a/node_modules/ipv6/ipv6.js b/node_modules/ipv6/ipv6.js
deleted file mode 100644
index 7e3c4cd..0000000
--- a/node_modules/ipv6/ipv6.js
+++ /dev/null
@@ -1,1314 +0,0 @@
-if (typeof exports !== 'undefined') {
- var sprintf = require('sprintf').sprintf;
- var BigInteger = require('./lib/node/bigint').BigInteger;
-}
-
-var v4 = this.v4 = {};
-var v6 = this.v6 = {};
-
-v4.GROUPS = 4;
-v6.GROUPS = 8;
-
-v4.BITS = 32;
-v6.BITS = 128;
-
-v6.SCOPES = {
- 0: 'Reserved',
- 1: 'Interface local',
- 2: 'Link local',
- 4: 'Admin local',
- 5: 'Site local',
- 8: 'Organization local',
- 15: 'Global',
- 16: 'Reserved'
-};
-
-v4.RE_ADDRESS = /^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/g;
-v4.RE_SUBNET_STRING = /\/\d{1,2}$/;
-
-v6.RE_BAD_CHARACTERS = /([^0-9a-f:\/%])/ig;
-v6.RE_BAD_ADDRESS = /([0-9a-f]{5,}|:{3,}|[^:]:$|^:[^:]|\/$)/ig;
-
-v6.RE_SUBNET_STRING = /\/\d{1,3}(?=%|$)/;
-v6.RE_ZONE_STRING = /%.*$/;
-
-v6.RE_URL = new RegExp(/([0-9a-f:]+)/);
-v6.RE_URL_WITH_PORT = new RegExp(/\[([0-9a-f:]+)\]:([0-9]{1,5})/);
-
-// Convenience functions
-function map(array, fn) {
- var results = [];
- var i;
-
- for (i = 0; i < array.length; i++) {
- results.push(fn(array[i], i));
- }
-
- return results;
-}
-
-function repeatString(s, n) {
- var result = '';
- var i;
-
- for (i = 0; i < n; i++) {
- result += s;
- }
-
- return result;
-}
-
-function addCommas(number) {
- var r = /(\d+)(\d{3})/;
-
- while (r.test(number)) {
- number = number.replace(r, '$1,$2');
- }
-
- return number;
-}
-
-function spanLeadingZeroesSimple(group) {
- return group.replace(/^(0+)/, '$1');
-}
-
-function spanLeadingZeroes4(n) {
- n = n.replace(/^(0{1,})([1-9]+)$/, '$1$2');
- n = n.replace(/^(0{1,})(0)$/, '$1$2');
-
- return n;
-}
-
-function simpleRegularExpression(addressArray) {
- var output = [];
- var i;
-
- for (i = 0; i < addressArray.length; i++) {
- var segment = addressArray[i];
-
- if (segment.length < 4) {
- output.push(sprintf('0{0,%d}%s', 4 - segment.length, segment));
- } else {
- output.push(segment);
- }
- }
-
- return output.join(':');
-}
-
-function zeroPad(s, n) {
- return String(repeatString(0, n) + s).slice(n * -1);
-}
-
-function isInSubnet(address) {
- // XXX: This is a hunch
- if (this.subnetMask < address.subnetMask) {
- return false;
- }
-
- if (this.mask(address.subnetMask) === address.mask()) {
- return true;
- }
-
- return false;
-}
-
-/*
- * Instantiates an IPv4 address
- */
-v4.Address = function (address) {
- this.valid = false;
- this.address = address;
- this.groups = v4.GROUPS;
-
- this.v4 = true;
-
- this.subnet = '/32';
- this.subnetMask = 32;
-
- var subnet = v4.RE_SUBNET_STRING.exec(address);
-
- if (subnet) {
- this.parsedSubnet = subnet[0].replace('/', '');
- this.subnetMask = parseInt(this.parsedSubnet, 10);
- this.subnet = '/' + this.subnetMask;
-
- if (this.subnetMask < 0 || this.subnetMask > v4.BITS) {
- this.valid = false;
- this.error = "Invalid subnet mask.";
-
- return;
- }
-
- address = address.replace(v4.RE_SUBNET_STRING, '');
- }
-
- this.addressMinusSuffix = address;
-
- this.parsedAddress = this.parse(address);
-};
-
-/*
- * Parses a v4 address
- */
-v4.Address.prototype.parse = function (address) {
- var groups = address.split('.');
-
- if (address.match(v4.RE_ADDRESS)) {
- this.valid = true;
- } else {
- this.error = 'Invalid IPv4 address.';
- }
-
- return groups;
-};
-
-/*
- * Returns true if the address is valid
- */
-v4.Address.prototype.isValid = function () {
- return this.valid;
-};
-
-/*
- * Returns the correct form of an address
- */
-v4.Address.prototype.correctForm = function () {
- return this.parsedAddress.map(function (part) {
- return parseInt(part, 10);
- }).join('.');
-};
-
-/*
- * Returns true if the address is correct, false otherwise
- */
-v4.Address.prototype.isCorrect = function () {
- return this.addressMinusSuffix === this.correctForm() &&
- (this.subnetMask === 32 ||
- this.parsedSubnet === String(this.subnet.replace('/')));
-};
-
-/*
- * Converts a hex string to an IPv4 address object
- */
-v4.Address.fromHex = function (hex) {
- var padded = zeroPad(hex.replace(/:/g, ''), 8);
- var groups = [];
- var i;
-
- for (i = 0; i < 8; i += 2) {
- var h = padded.slice(i, i + 2);
-
- groups.push(parseInt(h, 16));
- }
-
- return new v4.Address(groups.join('.'));
-};
-
-/*
- * Converts an integer into a IPv4 address object
- */
-v4.Address.fromInteger = function (integer) {
- return v4.Address.fromHex(integer.toString(16));
-};
-
-/*
- * Converts an IPv4 address object to a hex string
- */
-v4.Address.prototype.toHex = function () {
- return this.parsedAddress.map(function (part) {
- return sprintf('%02x', parseInt(part, 10));
- }).join(':');
-};
-
-/*
- * Converts an IPv4 address object to an array of bytes
- */
-v4.Address.prototype.toArray = function () {
- return this.parsedAddress.map(function (part) {
- return parseInt(part, 10);
- });
-};
-
-/*
- * Converts an IPv4 address object to an IPv6 address group
- */
-v4.Address.prototype.toV6Group = function () {
- var output = [];
- var i;
-
- for (i = 0; i < v4.GROUPS; i += 2) {
- var hex = sprintf('%02x%02x',
- parseInt(this.parsedAddress[i], 10),
- parseInt(this.parsedAddress[i + 1], 10));
-
- output.push(sprintf('%x', parseInt(hex, 16)));
- }
-
- return output.join(':');
-};
-
-/*
- * Returns the address as a BigInteger
- */
-v4.Address.prototype.bigInteger = function () {
- if (!this.valid) {
- return;
- }
-
- return new BigInteger(map(this.parsedAddress, function (n) {
- return sprintf("%02x", parseInt(n, 10));
- }).join(''), 16);
-};
-
-/*
- * The first address in the range given by this address' subnet.
- * Often referred to as the Network Address.
- */
-v4.Address.prototype.startAddress = function () {
- var startAddress = new BigInteger(this.mask() + repeatString(0,
- v4.BITS - this.subnetMask), 2);
-
- return v4.Address.fromBigInteger(startAddress);
-};
-
-/*
- * The last address in the range given by this address' subnet
- * Often referred to as the Broadcast
- */
-v4.Address.prototype.endAddress = function () {
- var endAddress = new BigInteger(this.mask() + repeatString(1,
- v4.BITS - this.subnetMask), 2);
-
- return v4.Address.fromBigInteger(endAddress);
-};
-
-/*
- * Converts a BigInteger to a v4 address object
- */
-v4.Address.fromBigInteger = function (bigInteger) {
- return v4.Address.fromInteger(parseInt(bigInteger.toString(), 10));
-};
-
-/*
- * Returns the first n bits of the address, defaulting to the
- * subnet mask
- */
-v4.Address.prototype.mask = function (opt_mask) {
- if (opt_mask === undefined) {
- opt_mask = this.subnetMask;
- }
-
- return this.getBitsBase2(0, opt_mask);
-};
-
-/*
- * Returns the bits in the given range as a base-2 string
- */
-v4.Address.prototype.getBitsBase2 = function (start, end) {
- return this.binaryZeroPad().slice(start, end);
-};
-
-/*
- * Returns true if the given address is in the subnet of the current address
- */
-v4.Address.prototype.isInSubnet = isInSubnet;
-
-/*
- * Returns a zero-padded base-2 string representation of the address
- */
-v4.Address.prototype.binaryZeroPad = function () {
- return zeroPad(this.bigInteger().toString(2), v4.BITS);
-};
-
-/*
- * Instantiates an IPv6 address
- */
-v6.Address = function (address, opt_groups) {
- if (opt_groups === undefined) {
- this.groups = v6.GROUPS;
- } else {
- this.groups = opt_groups;
- }
-
- this.v4 = false;
-
- this.subnet = '/128';
- this.subnetMask = 128;
-
- this.zone = '';
-
- this.address = address;
-
- var subnet = v6.RE_SUBNET_STRING.exec(address);
-
- if (subnet) {
- this.parsedSubnet = subnet[0].replace('/', '');
- this.subnetMask = parseInt(this.parsedSubnet, 10);
- this.subnet = '/' + this.subnetMask;
-
- if (isNaN(this.subnetMask) ||
- this.subnetMask < 0 ||
- this.subnetMask > v6.BITS) {
- this.valid = false;
- this.error = "Invalid subnet mask.";
-
- return;
- }
-
- address = address.replace(v6.RE_SUBNET_STRING, '');
- } else if (/\//.test(address)) {
- this.valid = false;
- this.error = "Invalid subnet mask.";
-
- return;
- }
-
- var zone = v6.RE_ZONE_STRING.exec(address);
-
- if (zone) {
- this.zone = zone[0];
-
- address = address.replace(v6.RE_ZONE_STRING, '');
- }
-
- this.addressMinusSuffix = address;
-
- this.parsedAddress = this.parse(this.addressMinusSuffix);
-};
-
-/*
- * Converts a BigInteger to a v6 address object
- */
-v6.Address.fromBigInteger = function (bigInteger) {
- var hex = zeroPad(bigInteger.toString(16), 32);
- var groups = [];
- var i;
-
- for (i = 0; i < 8; i++) {
- groups.push(hex.slice(i * 4, (i + 1) * 4));
- }
-
- return new v6.Address(groups.join(':'));
-};
-
-/*
- * Converts a URL (optional port number) to an address object
- */
-v6.Address.fromURL = function (url) {
- var host;
- var port;
- var result;
-
- // If we have brackets parse them and find a port
- if (url.indexOf('[') !== -1 && url.indexOf(']') !== -1) {
- result = v6.RE_URL_WITH_PORT.exec(url);
-
- if (result === null) {
- return {
- error: 'failed to parse address with port',
- address: null,
- port: null
- };
- }
-
- host = result[1];
- port = result[2];
- // If there's a URL extract the address
- } else if (url.indexOf('/') !== -1) {
- // Remove the protocol prefix
- url = url.replace(/^[a-z0-9]+:\/\//, '');
-
- // Parse the address
- result = v6.RE_URL.exec(url);
-
- if (result === null) {
- return {
- error: 'failed to parse address from URL',
- address: null,
- port: null
- };
- }
-
- host = result[1];
- // Otherwise just assign the URL to the host and let the library parse it
- } else {
- host = url;
- }
-
- // If there's a port convert it to an integer
- if (port) {
- port = parseInt(port, 10);
-
- //squelch out of range ports
- if (port < 0 || port > 65536) {
- port = null;
- }
- } else {
- // Standardize `undefined` to `null`
- port = null;
- }
-
- return {
- address: new v6.Address(host),
- port: port
- };
-};
-
-/*
- * A helper function to compact an array
- */
-v6.Address.compact = function (address, slice) {
- var s1 = [];
- var s2 = [];
- var i;
-
- for (i = 0; i < address.length; i++) {
- if (i < slice[0]) {
- s1.push(address[i]);
- } else if (i > slice[1]) {
- s2.push(address[i]);
- }
- }
-
- return s1.concat(['compact']).concat(s2);
-};
-
-/*
- * Returns true if the address is valid, false otherwise
- */
-v6.Address.prototype.isValid = function () {
- return this.valid;
-};
-
-/*
- * Returns true if the address is correct, false otherwise
- */
-v6.Address.prototype.isCorrect = function () {
- return this.addressMinusSuffix === this.correctForm() &&
- (this.subnetMask === 128 ||
- this.parsedSubnet === String(this.subnet.replace('/')));
-};
-
-/*
- * Returns true if the address is a link local address, false otherwise
- */
-v6.Address.prototype.isLinkLocal = function () {
- // Zeroes are required, i.e. we can't check isInSubnet with 'fe80::/10'
- if (this.getBitsBase2(0, 64) ===
- "1111111010000000000000000000000000000000000000000000000000000000") {
- return true;
- }
-
- return false;
-};
-
-/*
- * Returns true if the address is in the canonical form, false otherwise
- */
-v6.Address.prototype.isCanonical = function () {
- return this.addressMinusSuffix === this.canonicalForm();
-};
-
-/*
- * Returns true if the address is a multicast address, false otherwise
- */
-v6.Address.prototype.isMulticast = function () {
- return this.getType() === 'Multicast';
-};
-
-/*
- * Returns true if the address is a v4-in-v6 address, false otherwise
- */
-v6.Address.prototype.is4 = function () {
- return this.v4;
-};
-
-/*
- * Returns true if the address is a Teredo address, false otherwise
- */
-v6.Address.prototype.isTeredo = function () {
- if (this.isInSubnet(new v6.Address('2001::/32'))) {
- return true;
- }
-
- return false;
-};
-
-/*
- * Returns true if the address is a 6to4 address, false otherwise
- */
-v6.Address.prototype.is6to4 = function () {
- if (this.isInSubnet(new v6.Address('2002::/16'))) {
- return true;
- }
-
- return false;
-};
-
-/*
- * Returns true if the address is a loopback address, false otherwise
- */
-v6.Address.prototype.isLoopback = function () {
- return this.getType() === 'Loopback';
-};
-
-/*
- * Returns the Microsoft UNC transcription of the address
- */
-v6.Address.prototype.microsoftTranscription = function () {
- return sprintf('%s.ipv6-literal.net',
- this.correctForm().replace(/:/g, '-'));
-};
-
-/*
- * Returns the address in link form with a default port of 80
- */
-v6.Address.prototype.href = function (opt_port) {
- if (opt_port === undefined) {
- opt_port = '';
- } else {
- opt_port = sprintf(':%s', opt_port);
- }
-
- return sprintf('http://[%s]%s/', this.correctForm(), opt_port);
-};
-
-/*
- * Returns the first n bits of the address, defaulting to the
- * subnet mask
- */
-v6.Address.prototype.mask = function (opt_mask) {
- if (opt_mask === undefined) {
- opt_mask = this.subnetMask;
- }
-
- return this.getBitsBase2(0, opt_mask);
-};
-
-/*
- * Returns a link suitable for conveying the address via a URL hash
- */
-v6.Address.prototype.link = function (options) {
- if (!options) {
- options = {};
- }
-
- if (options.className === undefined) {
- options.className = '';
- }
-
- if (options.prefix === undefined) {
- options.prefix = '/#address=';
- }
-
- if (options.v4 === undefined) {
- options.v4 = false;
- }
-
- var formFunction = this.correctForm;
-
- if (options.v4) {
- formFunction = this.v4inv6;
- }
-
- if (options.className) {
- return sprintf('%2$s',
- options.prefix, formFunction.call(this), options.className);
- }
-
- return sprintf('%2$s', options.prefix,
- formFunction.call(this));
-};
-
-/*
- * Returns the number of possible subnets of a given size in the address
- */
-v6.Address.prototype.possibleAddresses = function (opt_subnetSize) {
- if (opt_subnetSize === undefined) {
- opt_subnetSize = 0;
- }
-
- return addCommas(new BigInteger('2', 10).pow((v6.BITS - this.subnetMask) -
- (v6.BITS - opt_subnetSize)).toString(10));
-};
-
-/*
- * Returns true if the given address is in the subnet of the current address
- */
-v6.Address.prototype.isInSubnet = isInSubnet;
-
-/*
- * Create an IPv6-mapped address given an IPv4 address
- */
-v6.Address.fromAddress4 = function (address4) {
- return new v6.Address('::ffff:' + address4);
-};
-
-/*
- * The first address in the range given by this address' subnet
- */
-v6.Address.prototype.startAddress = function () {
- var startAddress = new BigInteger(this.mask() + repeatString(0,
- v6.BITS - this.subnetMask), 2);
-
- return v6.Address.fromBigInteger(startAddress);
-};
-
-/*
- * The last address in the range given by this address' subnet
- */
-v6.Address.prototype.endAddress = function () {
- var endAddress = new BigInteger(this.mask() + repeatString(1,
- v6.BITS - this.subnetMask), 2);
-
- return v6.Address.fromBigInteger(endAddress);
-};
-
-/*
- * Returns the scope of the address
- */
-v6.Address.prototype.getScope = function () {
- var scope = v6.SCOPES[this.getBits(12, 16)];
-
- if (this.getType() === "Global unicast") {
- if (scope !== "Link local") {
- scope = "Global";
- }
- }
-
- return scope;
-};
-
-/*
- * Returns the type of the address
- */
-v6.Address.prototype.getType = function () {
- // TODO: Refactor this
- // TODO: Add ff0x::fb, etc. for multicast DNS
- var TYPES = {
- 'ff01::1/128': 'Multicast (All nodes on this interface)',
- 'ff01::2/128': 'Multicast (All routers on this interface)',
- 'ff02::1/128': 'Multicast (All nodes on this link)',
- 'ff02::2/128': 'Multicast (All routers on this link)',
- 'ff05::2/128': 'Multicast (All routers in this site)',
- 'ff02::5/128': 'Multicast (OSPFv3 AllSPF routers)',
- 'ff02::6/128': 'Multicast (OSPFv3 AllDR routers)',
- 'ff02::9/128': 'Multicast (RIP routers)',
- 'ff02::a/128': 'Multicast (EIGRP routers)',
- 'ff02::d/128': 'Multicast (PIM routers)',
- 'ff02::16/128': 'Multicast (MLDv2 reports)',
- 'ff01::fb/128': 'Multicast (mDNSv6)',
- 'ff02::fb/128': 'Multicast (mDNSv6)',
- 'ff05::fb/128': 'Multicast (mDNSv6)',
- 'ff02::1:2/128': 'Multicast (All DHCP servers and relay agents on this link)',
- 'ff05::1:2/128': 'Multicast (All DHCP servers and relay agents in this site)',
- 'ff02::1:3/128': 'Multicast (All DHCP servers on this link)',
- 'ff05::1:3/128': 'Multicast (All DHCP servers in this site)',
- '::/128': 'Unspecified',
- '::1/128': 'Loopback',
- 'ff00::/8': 'Multicast',
- 'fe80::/10': 'Link-local unicast'
- };
-
- var type = 'Global unicast';
- var p;
-
- for (p in TYPES) {
- if (TYPES.hasOwnProperty(p)) {
- if (this.isInSubnet(new v6.Address(p))) {
- type = TYPES[p];
-
- break;
- }
- }
- }
-
- return type;
-};
-
-/*
- * Returns the bits in the given range as a BigInteger
- */
-v6.Address.prototype.getBits = function (start, end) {
- return new BigInteger(this.getBitsBase2(start, end), 2);
-};
-
-/*
- * Returns the bits in the given range as a base-2 string
- */
-v6.Address.prototype.getBitsBase2 = function (start, end) {
- return this.binaryZeroPad().slice(start, end);
-};
-
-/*
- * Returns the bits in the given range as a base-16 string
- */
-v6.Address.prototype.getBitsBase16 = function (start, end) {
- var length = end - start;
-
- if (length % 4 !== 0) {
- return;
- }
-
- return zeroPad(this.getBits(start, end).toString(16), length / 4);
-};
-
-/*
- * Returns the bits that are set past the subnet mask length
- */
-v6.Address.prototype.getBitsPastSubnet = function () {
- return this.getBitsBase2(this.subnetMask, v6.BITS);
-};
-
-/*
- * Returns the string with each character contained in a
- */
-v6.Address.spanAll = function (s, opt_offset) {
- if (opt_offset === undefined) {
- opt_offset = 0;
- }
-
- var letters = s.split('');
-
- return map(letters, function (n, i) {
- return sprintf('%s', n,
- i + opt_offset,
- v6.Address.spanAllZeroes(n)); // XXX Use #base-2 .value-0 instead?
- }).join('');
-};
-
-/*
- * Returns the string with all zeroes contained in a
- */
-v6.Address.spanAllZeroes = function (s) {
- return s.replace(/(0+)/g, '$1');
-};
-
-/*
- * Returns the string with leading zeroes contained in a
- */
-v6.Address.spanLeadingZeroes = function (address) {
- var groups = address.split(':');
-
- groups = map(groups, function (g) {
- return spanLeadingZeroesSimple(g);
- });
-
- return groups.join(':');
-};
-
-/*
- * Groups an address
- */
-v6.Address.simpleGroup = function (addressString, offset) {
- var groups = addressString.split(':');
-
- if (!offset) {
- offset = 0;
- }
-
- groups = map(groups, function (g, i) {
- if (/group-v4/.test(g)) {
- return g;
- }
-
- return sprintf('%s',
- i + offset,
- spanLeadingZeroesSimple(g));
- });
-
- return groups.join(':');
-};
-
-/*
- * Groups an address
- */
-v6.Address.group = function (addressString) {
- var address6 = new v6.Address(addressString);
- var address4 = address6.address.match(v4.RE_ADDRESS);
- var i;
-
- if (address4) {
- // The IPv4 case
- var segments = address4[0].split('.');
-
- address6.address = address6.address.replace(v4.RE_ADDRESS,
- sprintf('%s' +
- '.' +
- '%s',
- segments.slice(0, 2).join('.'),
- segments.slice(2, 4).join('.')));
- }
-
- if (address6.elidedGroups === 0) {
- // The simple case
- return v6.Address.simpleGroup(address6.address);
- }
-
- // The elided case
- var output = [];
-
- var halves = address6.address.split('::');
-
- if (halves[0].length) {
- output.push(v6.Address.simpleGroup(halves[0]));
- } else {
- output.push('');
- }
-
- var classes = ['hover-group'];
-
- for (i = address6.elisionBegin; i < address6.elisionBegin +
- address6.elidedGroups; i++) {
- classes.push(sprintf('group-%d', i));
- }
-
- output.push(sprintf('', classes.join(' ')));
-
- if (halves[1].length) {
- output.push(v6.Address.simpleGroup(halves[1], address6.elisionEnd));
- } else {
- output.push('');
- }
-
- return output.join(':');
-};
-
-/*
- * Returns the reversed ip6.arpa form of the address
- */
-v6.Address.prototype.reverseForm = function () {
- var characters = Math.floor(this.subnetMask / 4);
-
- var reversed = this.canonicalForm()
- .replace(/:/g, '')
- .split('')
- .slice(0, characters)
- .reverse()
- .join('.');
-
- if (characters > 0) {
- return sprintf("%s.ip6.arpa.", reversed);
- }
-
- return 'ip6.arpa.';
-};
-
-/*
- * Returns the correct form of the address
- */
-v6.Address.prototype.correctForm = function () {
- if (!this.parsedAddress) {
- return;
- }
-
- var i;
- var groups = [];
-
- var zeroCounter = 0;
- var zeroes = [];
-
- for (i = 0; i < this.parsedAddress.length; i++) {
- var value = parseInt(this.parsedAddress[i], 16);
-
- if (value === 0) {
- zeroCounter++;
- }
-
- if (value !== 0 && zeroCounter > 0) {
- if (zeroCounter > 1) {
- zeroes.push([i - zeroCounter, i - 1]);
- }
-
- zeroCounter = 0;
- }
- }
-
- // Do we end with a string of zeroes?
- if (zeroCounter > 1) {
- zeroes.push([this.parsedAddress.length - zeroCounter,
- this.parsedAddress.length - 1]);
- }
-
- var zeroLengths = map(zeroes, function (n) {
- return (n[1] - n[0]) + 1;
- });
-
- if (zeroes.length > 0) {
- var max = Math.max.apply(Math, zeroLengths);
- var index = zeroLengths.indexOf(max);
-
- groups = v6.Address.compact(this.parsedAddress, zeroes[index]);
- } else {
- groups = this.parsedAddress;
- }
-
- for (i = 0; i < groups.length; i++) {
- if (groups[i] !== 'compact') {
- groups[i] = parseInt(groups[i], 16).toString(16);
- }
- }
-
- var correct = groups.join(':');
-
- correct = correct.replace(/^compact$/, '::');
- correct = correct.replace(/^compact|compact$/, ':');
- correct = correct.replace(/compact/, '');
-
- return correct;
-};
-
-/*
- * Returns a zero-padded base-2 string representation of the address
- */
-v6.Address.prototype.binaryZeroPad = function () {
- return zeroPad(this.bigInteger().toString(2), v6.BITS);
-};
-
-// TODO: Improve the semantics of this helper function
-v6.Address.prototype.parse4in6 = function (address) {
- var groups = address.split(':');
- var lastGroup = groups.slice(-1)[0];
-
- var address4 = lastGroup.match(v4.RE_ADDRESS);
-
- if (address4) {
- var temp4 = new v4.Address(address4[0]);
-
- for (var i = 0; i < temp4.groups; i++) {
- if (/^0[0-9]+/.test(temp4.parsedAddress[i])) {
- this.valid = false;
- this.error = 'IPv4 addresses can not have leading zeroes.';
-
- this.parseError = address.replace(v4.RE_ADDRESS,
- map(temp4.parsedAddress, spanLeadingZeroes4).join('.'));
-
- return;
- }
- }
-
- this.v4 = true;
-
- groups[groups.length - 1] = temp4.toV6Group();
-
- address = groups.join(':');
- }
-
- return address;
-};
-
-// TODO: Make private?
-v6.Address.prototype.parse = function (address) {
- address = this.parse4in6(address);
-
- if (this.error) {
- return;
- }
-
- var badCharacters = address.match(v6.RE_BAD_CHARACTERS);
-
- if (badCharacters) {
- this.valid = false;
- this.error = sprintf("Bad character%s detected in address: %s",
- badCharacters.length > 1 ? 's' : '', badCharacters.join(''));
-
- this.parseError = address.replace(v6.RE_BAD_CHARACTERS,
- '$1');
-
- return;
- }
-
- var badAddress = address.match(v6.RE_BAD_ADDRESS);
-
- if (badAddress) {
- this.valid = false;
- this.error = sprintf("Address failed regex: %s", badAddress.join(''));
-
- this.parseError = address.replace(v6.RE_BAD_ADDRESS,
- '$1');
-
- return;
- }
-
- var groups = [];
-
- var halves = address.split('::');
-
- if (halves.length === 2) {
- var first = halves[0].split(':');
- var last = halves[1].split(':');
-
- if (first.length === 1 &&
- first[0] === '') {
- first = [];
- }
-
- if (last.length === 1 &&
- last[0] === '') {
- last = [];
- }
-
- var remaining = this.groups - (first.length + last.length);
-
- if (!remaining) {
- this.valid = false;
- this.error = "Error parsing groups";
-
- return;
- }
-
- this.elidedGroups = remaining;
-
- this.elisionBegin = first.length;
- this.elisionEnd = first.length + this.elidedGroups;
-
- first.forEach(function (group) {
- groups.push(group);
- });
-
- for (var i = 0; i < remaining; i++) {
- groups.push(0);
- }
-
- last.forEach(function (group) {
- groups.push(group);
- });
- } else if (halves.length === 1) {
- groups = address.split(':');
-
- this.elidedGroups = 0;
- } else {
- this.valid = false;
- this.error = "Too many :: groups found";
-
- return;
- }
-
- groups = map(groups, function (g) {
- return sprintf('%x', parseInt(g, 16));
- });
-
- if (groups.length !== this.groups) {
- this.valid = false;
- this.error = "Incorrect number of groups found";
-
- return;
- }
-
- groups.forEach(function (group, i) {
- if (groups.length > 4 && !this.v4) {
- this.valid = false;
- this.error = sprintf("Group %d is too long", i + 1);
-
- return;
- }
- });
-
- this.valid = true;
-
- return groups;
-};
-
-/*
- * Generate a regular expression string that can be used to find or validate all
- * variations of this address.
- */
-v6.Address.prototype.regularExpressionString = function (opt_subString) {
- if (opt_subString === undefined) {
- opt_subString = false;
- }
-
- var i;
- var output = [];
-
- var address6 = new v6.Address(this.correctForm());
-
- if (address6.elidedGroups === 0) {
- // The simple case
- output = simpleRegularExpression(address6.parsedAddress);
- } else if (address6.elidedGroups === 8) {
- output.push('::|');
-
- // TODO: Validate this
- for (i = 0; i < address6.elidedGroups; i++) {
- var pipe = '|';
-
- if (i === address6.elidedGroups - 1) {
- pipe = '';
- }
-
- output.push(sprintf('(0{1,4}:){%d}:%s', address6.elidedGroups, pipe));
- }
- } else {
- // The elided case
-
- // TODO: Allow sloppy elision
- // TODO: Compute all possible elisions
- var halves = address6.address.split('::');
-
- if (halves[0].length) {
- output = output.concat(simpleRegularExpression(halves[0].split(':')));
- output.push(':');
- }
-
- output.push(sprintf('((0{1,4}:){%d}|:)', address6.elidedGroups));
-
- if (halves[1].length) {
- output = output.concat(simpleRegularExpression(halves[1].split(':')));
- }
- }
-
- if (!opt_subString) {
- output = [].concat('\\b', output, '\\b');
- }
-
- return output.join('');
-};
-
-/*
- * Generate a regular expression that can be used to find or validate all
- * variations of this address.
- */
-v6.Address.prototype.regularExpression = function () {
- return new RegExp(this.regularExpressionString(), 'i');
-};
-
-/*
- * Returns the canonical form of the address
- */
-v6.Address.prototype.canonicalForm = function () {
- if (!this.valid) {
- return;
- }
-
- return map(this.parsedAddress, function (n) {
- return sprintf("%04x", parseInt(n, 16));
- }).join(':');
-};
-
-/*
- * Returns the decimal form of the address
- */
-v6.Address.prototype.decimal = function () {
- if (!this.valid) {
- return;
- }
-
- return map(this.parsedAddress, function (n) {
- return sprintf("%05d", parseInt(n, 16));
- }).join(':');
-};
-
-/*
- * Returns the address as a BigInteger
- */
-v6.Address.prototype.bigInteger = function () {
- if (!this.valid) {
- return;
- }
-
- return new BigInteger(map(this.parsedAddress, function (n) {
- return sprintf("%04x", parseInt(n, 16));
- }).join(''), 16);
-};
-
-/*
- * Returns the v4-in-v6 form of the address
- */
-v6.Address.prototype.v4inv6 = function () {
- var binary = this.binaryZeroPad().split('');
-
- var address4 = v4.Address.fromHex(new BigInteger(binary.slice(96, 128)
- .join(''), 2).toString(16));
- var address6 = new v6.Address(this.parsedAddress.slice(0, 6).join(':'), 6);
-
- var correct = address6.correctForm();
-
- var infix = '';
-
- if (!/:$/.test(correct)) {
- infix = ':';
- }
-
- return address6.correctForm() + infix + address4.address;
-};
-
-/*
- * Returns an object containing the Teredo properties of the address
- */
-v6.Address.prototype.teredo = function () {
- /*
- - Bits 0 to 31 are set to the Teredo prefix (normally 2001:0000::/32).
- - Bits 32 to 63 embed the primary IPv4 address of the Teredo server that
- is used.
- - Bits 64 to 79 can be used to define some flags. Currently only the
- higher order bit is used; it is set to 1 if the Teredo client is
- located behind a cone NAT, 0 otherwise. For Microsoft's Windows Vista
- and Windows Server 2008 implementations, more bits are used. In those
- implementations, the format for these 16 bits is "CRAAAAUG AAAAAAAA",
- where "C" remains the "Cone" flag. The "R" bit is reserved for future
- use. The "U" bit is for the Universal/Local flag (set to 0). The "G" bit
- is Individual/Group flag (set to 0). The A bits are set to a 12-bit
- randomly generated number chosen by the Teredo client to introduce
- additional protection for the Teredo node against IPv6-based scanning
- attacks.
- - Bits 80 to 95 contains the obfuscated UDP port number. This is the
- port number that is mapped by the NAT to the Teredo client with all
- bits inverted.
- - Bits 96 to 127 contains the obfuscated IPv4 address. This is the
- public IPv4 address of the NAT with all bits inverted.
- */
-
- var prefix = this.getBitsBase16(0, 32);
-
- var udpPort = this.getBits(80, 96).xor(new BigInteger('ffff', 16)).toString();
-
- var server4 = v4.Address.fromHex(this.getBitsBase16(32, 64));
- var client4 = v4.Address.fromHex(this.getBits(96, 128)
- .xor(new BigInteger('ffffffff', 16)).toString(16));
-
- var flags = this.getBits(64, 80);
- var flagsBase2 = this.getBitsBase2(64, 80);
-
- var coneNat = flags.testBit(15);
- var reserved = flags.testBit(14);
- var groupIndividual = flags.testBit(8);
- var universalLocal = flags.testBit(9);
- var nonce = new BigInteger(flagsBase2.slice(2, 6) +
- flagsBase2.slice(8, 16), 2).toString(10);
-
- return {
- prefix: sprintf('%s:%s', prefix.slice(0, 4), prefix.slice(4, 8)),
- server4: server4.address,
- client4: client4.address,
- flags: flagsBase2,
- coneNat: coneNat,
- microsoft: {
- reserved: reserved,
- universalLocal: universalLocal,
- groupIndividual: groupIndividual,
- nonce: nonce
- },
- udpPort: udpPort
- };
-};
-
-/*
- * Returns an object containing the 6to4 properties of the address
- */
-v6.Address.prototype.six2four = function () {
- /*
- - Bits 0 to 15 are set to the 6to4 prefix (2002::/16).
- - Bits 16 to 48 embed the IPv4 address of the 6to4 gateway that is used.
- */
-
- var prefix = this.getBitsBase16(0, 16);
-
- var gateway = v4.Address.fromHex(this.getBitsBase16(16, 48));
-
- return {
- prefix: sprintf('%s', prefix.slice(0, 4)),
- gateway: gateway.address
- };
-};
diff --git a/node_modules/ipv6/lib/browser/jsbn-combined.js b/node_modules/ipv6/lib/browser/jsbn-combined.js
deleted file mode 100644
index ff89bdd..0000000
--- a/node_modules/ipv6/lib/browser/jsbn-combined.js
+++ /dev/null
@@ -1,1211 +0,0 @@
-// Copyright (c) 2005 Tom Wu
-// All Rights Reserved.
-// See "LICENSE" for details.
-
-// Basic JavaScript BN library - subset useful for RSA encryption.
-
-// Bits per digit
-var dbits;
-
-// JavaScript engine analysis
-var canary = 0xdeadbeefcafe;
-var j_lm = ((canary&0xffffff)==0xefcafe);
-
-// (public) Constructor
-function BigInteger(a,b,c) {
- if(a != null)
- if("number" == typeof a) this.fromNumber(a,b,c);
- else if(b == null && "string" != typeof a) this.fromString(a,256);
- else this.fromString(a,b);
-}
-
-// return new, unset BigInteger
-function nbi() { return new BigInteger(null); }
-
-// am: Compute w_j += (x*this_i), propagate carries,
-// c is initial carry, returns final carry.
-// c < 3*dvalue, x < 2*dvalue, this_i < dvalue
-// We need to select the fastest one that works in this environment.
-
-// am1: use a single mult and divide to get the high bits,
-// max digit bits should be 26 because
-// max internal value = 2*dvalue^2-2*dvalue (< 2^53)
-function am1(i,x,w,j,c,n) {
- while(--n >= 0) {
- var v = x*this[i++]+w[j]+c;
- c = Math.floor(v/0x4000000);
- w[j++] = v&0x3ffffff;
- }
- return c;
-}
-// am2 avoids a big mult-and-extract completely.
-// Max digit bits should be <= 30 because we do bitwise ops
-// on values up to 2*hdvalue^2-hdvalue-1 (< 2^31)
-function am2(i,x,w,j,c,n) {
- var xl = x&0x7fff, xh = x>>15;
- while(--n >= 0) {
- var l = this[i]&0x7fff;
- var h = this[i++]>>15;
- var m = xh*l+h*xl;
- l = xl*l+((m&0x7fff)<<15)+w[j]+(c&0x3fffffff);
- c = (l>>>30)+(m>>>15)+xh*h+(c>>>30);
- w[j++] = l&0x3fffffff;
- }
- return c;
-}
-// Alternately, set max digit bits to 28 since some
-// browsers slow down when dealing with 32-bit numbers.
-function am3(i,x,w,j,c,n) {
- var xl = x&0x3fff, xh = x>>14;
- while(--n >= 0) {
- var l = this[i]&0x3fff;
- var h = this[i++]>>14;
- var m = xh*l+h*xl;
- l = xl*l+((m&0x3fff)<<14)+w[j]+c;
- c = (l>>28)+(m>>14)+xh*h;
- w[j++] = l&0xfffffff;
- }
- return c;
-}
-if(j_lm && (navigator.appName == "Microsoft Internet Explorer")) {
- BigInteger.prototype.am = am2;
- dbits = 30;
-}
-else if(j_lm && (navigator.appName != "Netscape")) {
- BigInteger.prototype.am = am1;
- dbits = 26;
-}
-else { // Mozilla/Netscape seems to prefer am3
- BigInteger.prototype.am = am3;
- dbits = 28;
-}
-
-BigInteger.prototype.DB = dbits;
-BigInteger.prototype.DM = ((1<>(p+=this.DB-k);
- }
- else {
- d = (this[i]>>(p-=k))&km;
- if(p <= 0) { p += this.DB; --i; }
- }
- if(d > 0) m = true;
- if(m) r += int2char(d);
- }
- }
- return m?r:"0";
-}
-
-// (public) -this
-function bnNegate() { var r = nbi(); BigInteger.ZERO.subTo(this,r); return r; }
-
-// (public) |this|
-function bnAbs() { return (this.s<0)?this.negate():this; }
-
-// (public) return + if this > a, - if this < a, 0 if equal
-function bnCompareTo(a) {
- var r = this.s-a.s;
- if(r != 0) return r;
- var i = this.t;
- r = i-a.t;
- if(r != 0) return r;
- while(--i >= 0) if((r=this[i]-a[i]) != 0) return r;
- return 0;
-}
-
-// returns bit length of the integer x
-function nbits(x) {
- var r = 1, t;
- if((t=x>>>16) != 0) { x = t; r += 16; }
- if((t=x>>8) != 0) { x = t; r += 8; }
- if((t=x>>4) != 0) { x = t; r += 4; }
- if((t=x>>2) != 0) { x = t; r += 2; }
- if((t=x>>1) != 0) { x = t; r += 1; }
- return r;
-}
-
-// (public) return the number of bits in "this"
-function bnBitLength() {
- if(this.t <= 0) return 0;
- return this.DB*(this.t-1)+nbits(this[this.t-1]^(this.s&this.DM));
-}
-
-// (protected) r = this << n*DB
-function bnpDLShiftTo(n,r) {
- var i;
- for(i = this.t-1; i >= 0; --i) r[i+n] = this[i];
- for(i = n-1; i >= 0; --i) r[i] = 0;
- r.t = this.t+n;
- r.s = this.s;
-}
-
-// (protected) r = this >> n*DB
-function bnpDRShiftTo(n,r) {
- for(var i = n; i < this.t; ++i) r[i-n] = this[i];
- r.t = Math.max(this.t-n,0);
- r.s = this.s;
-}
-
-// (protected) r = this << n
-function bnpLShiftTo(n,r) {
- var bs = n%this.DB;
- var cbs = this.DB-bs;
- var bm = (1< >(p+=this.DB-8);
- }
- else {
- d = (this[i]>>(p-=8))&0xff;
- if(p <= 0) { p += this.DB; --i; }
- }
- if((d&0x80) != 0) d |= -256;
- if(k == 0 && (this.s&0x80) != (d&0x80)) ++k;
- if(k > 0 || d != this.s) r[k++] = d;
- }
- }
- return r;
-}
-
-function bnEquals(a) { return(this.compareTo(a)==0); }
-function bnMin(a) { return(this.compareTo(a)<0)?this:a; }
-function bnMax(a) { return(this.compareTo(a)>0)?this:a; }
-
-// (protected) r = this op a (bitwise)
-function bnpBitwiseTo(a,op,r) {
- var i, f, m = Math.min(a.t,this.t);
- for(i = 0; i < m; ++i) r[i] = op(this[i],a[i]);
- if(a.t < this.t) {
- f = a.s&this.DM;
- for(i = m; i < this.t; ++i) r[i] = op(this[i],f);
- r.t = this.t;
- }
- else {
- f = this.s&this.DM;
- for(i = m; i < a.t; ++i) r[i] = op(f,a[i]);
- r.t = a.t;
- }
- r.s = op(this.s,a.s);
- r.clamp();
-}
-
-// (public) this & a
-function op_and(x,y) { return x&y; }
-function bnAnd(a) { var r = nbi(); this.bitwiseTo(a,op_and,r); return r; }
-
-// (public) this | a
-function op_or(x,y) { return x|y; }
-function bnOr(a) { var r = nbi(); this.bitwiseTo(a,op_or,r); return r; }
-
-// (public) this ^ a
-function op_xor(x,y) { return x^y; }
-function bnXor(a) { var r = nbi(); this.bitwiseTo(a,op_xor,r); return r; }
-
-// (public) this & ~a
-function op_andnot(x,y) { return x&~y; }
-function bnAndNot(a) { var r = nbi(); this.bitwiseTo(a,op_andnot,r); return r; }
-
-// (public) ~this
-function bnNot() {
- var r = nbi();
- for(var i = 0; i < this.t; ++i) r[i] = this.DM&~this[i];
- r.t = this.t;
- r.s = ~this.s;
- return r;
-}
-
-// (public) this << n
-function bnShiftLeft(n) {
- var r = nbi();
- if(n < 0) this.rShiftTo(-n,r); else this.lShiftTo(n,r);
- return r;
-}
-
-// (public) this >> n
-function bnShiftRight(n) {
- var r = nbi();
- if(n < 0) this.lShiftTo(-n,r); else this.rShiftTo(n,r);
- return r;
-}
-
-// return index of lowest 1-bit in x, x < 2^31
-function lbit(x) {
- if(x == 0) return -1;
- var r = 0;
- if((x&0xffff) == 0) { x >>= 16; r += 16; }
- if((x&0xff) == 0) { x >>= 8; r += 8; }
- if((x&0xf) == 0) { x >>= 4; r += 4; }
- if((x&3) == 0) { x >>= 2; r += 2; }
- if((x&1) == 0) ++r;
- return r;
-}
-
-// (public) returns index of lowest 1-bit (or -1 if none)
-function bnGetLowestSetBit() {
- for(var i = 0; i < this.t; ++i)
- if(this[i] != 0) return i*this.DB+lbit(this[i]);
- if(this.s < 0) return this.t*this.DB;
- return -1;
-}
-
-// return number of 1 bits in x
-function cbit(x) {
- var r = 0;
- while(x != 0) { x &= x-1; ++r; }
- return r;
-}
-
-// (public) return number of set bits
-function bnBitCount() {
- var r = 0, x = this.s&this.DM;
- for(var i = 0; i < this.t; ++i) r += cbit(this[i]^x);
- return r;
-}
-
-// (public) true iff nth bit is set
-function bnTestBit(n) {
- var j = Math.floor(n/this.DB);
- if(j >= this.t) return(this.s!=0);
- return((this[j]&(1<<(n%this.DB)))!=0);
-}
-
-// (protected) this op (1< >(p+=this.DB-k);
- }
- else {
- d = (this[i]>>(p-=k))&km;
- if(p <= 0) { p += this.DB; --i; }
- }
- if(d > 0) m = true;
- if(m) r += int2char(d);
- }
- }
- return m?r:"0";
-}
-
-// (public) -this
-function bnNegate() { var r = nbi(); BigInteger.ZERO.subTo(this,r); return r; }
-
-// (public) |this|
-function bnAbs() { return (this.s<0)?this.negate():this; }
-
-// (public) return + if this > a, - if this < a, 0 if equal
-function bnCompareTo(a) {
- var r = this.s-a.s;
- if(r != 0) return r;
- var i = this.t;
- r = i-a.t;
- if(r != 0) return r;
- while(--i >= 0) if((r=this[i]-a[i]) != 0) return r;
- return 0;
-}
-
-// returns bit length of the integer x
-function nbits(x) {
- var r = 1, t;
- if((t=x>>>16) != 0) { x = t; r += 16; }
- if((t=x>>8) != 0) { x = t; r += 8; }
- if((t=x>>4) != 0) { x = t; r += 4; }
- if((t=x>>2) != 0) { x = t; r += 2; }
- if((t=x>>1) != 0) { x = t; r += 1; }
- return r;
-}
-
-// (public) return the number of bits in "this"
-function bnBitLength() {
- if(this.t <= 0) return 0;
- return this.DB*(this.t-1)+nbits(this[this.t-1]^(this.s&this.DM));
-}
-
-// (protected) r = this << n*DB
-function bnpDLShiftTo(n,r) {
- var i;
- for(i = this.t-1; i >= 0; --i) r[i+n] = this[i];
- for(i = n-1; i >= 0; --i) r[i] = 0;
- r.t = this.t+n;
- r.s = this.s;
-}
-
-// (protected) r = this >> n*DB
-function bnpDRShiftTo(n,r) {
- for(var i = n; i < this.t; ++i) r[i-n] = this[i];
- r.t = Math.max(this.t-n,0);
- r.s = this.s;
-}
-
-// (protected) r = this << n
-function bnpLShiftTo(n,r) {
- var bs = n%this.DB;
- var cbs = this.DB-bs;
- var bm = (1< >(p+=this.DB-8);
- }
- else {
- d = (this[i]>>(p-=8))&0xff;
- if(p <= 0) { p += this.DB; --i; }
- }
- if((d&0x80) != 0) d |= -256;
- if(k == 0 && (this.s&0x80) != (d&0x80)) ++k;
- if(k > 0 || d != this.s) r[k++] = d;
- }
- }
- return r;
-}
-
-function bnEquals(a) { return(this.compareTo(a)==0); }
-function bnMin(a) { return(this.compareTo(a)<0)?this:a; }
-function bnMax(a) { return(this.compareTo(a)>0)?this:a; }
-
-// (protected) r = this op a (bitwise)
-function bnpBitwiseTo(a,op,r) {
- var i, f, m = Math.min(a.t,this.t);
- for(i = 0; i < m; ++i) r[i] = op(this[i],a[i]);
- if(a.t < this.t) {
- f = a.s&this.DM;
- for(i = m; i < this.t; ++i) r[i] = op(this[i],f);
- r.t = this.t;
- }
- else {
- f = this.s&this.DM;
- for(i = m; i < a.t; ++i) r[i] = op(f,a[i]);
- r.t = a.t;
- }
- r.s = op(this.s,a.s);
- r.clamp();
-}
-
-// (public) this & a
-function op_and(x,y) { return x&y; }
-function bnAnd(a) { var r = nbi(); this.bitwiseTo(a,op_and,r); return r; }
-
-// (public) this | a
-function op_or(x,y) { return x|y; }
-function bnOr(a) { var r = nbi(); this.bitwiseTo(a,op_or,r); return r; }
-
-// (public) this ^ a
-function op_xor(x,y) { return x^y; }
-function bnXor(a) { var r = nbi(); this.bitwiseTo(a,op_xor,r); return r; }
-
-// (public) this & ~a
-function op_andnot(x,y) { return x&~y; }
-function bnAndNot(a) { var r = nbi(); this.bitwiseTo(a,op_andnot,r); return r; }
-
-// (public) ~this
-function bnNot() {
- var r = nbi();
- for(var i = 0; i < this.t; ++i) r[i] = this.DM&~this[i];
- r.t = this.t;
- r.s = ~this.s;
- return r;
-}
-
-// (public) this << n
-function bnShiftLeft(n) {
- var r = nbi();
- if(n < 0) this.rShiftTo(-n,r); else this.lShiftTo(n,r);
- return r;
-}
-
-// (public) this >> n
-function bnShiftRight(n) {
- var r = nbi();
- if(n < 0) this.lShiftTo(-n,r); else this.rShiftTo(n,r);
- return r;
-}
-
-// return index of lowest 1-bit in x, x < 2^31
-function lbit(x) {
- if(x == 0) return -1;
- var r = 0;
- if((x&0xffff) == 0) { x >>= 16; r += 16; }
- if((x&0xff) == 0) { x >>= 8; r += 8; }
- if((x&0xf) == 0) { x >>= 4; r += 4; }
- if((x&3) == 0) { x >>= 2; r += 2; }
- if((x&1) == 0) ++r;
- return r;
-}
-
-// (public) returns index of lowest 1-bit (or -1 if none)
-function bnGetLowestSetBit() {
- for(var i = 0; i < this.t; ++i)
- if(this[i] != 0) return i*this.DB+lbit(this[i]);
- if(this.s < 0) return this.t*this.DB;
- return -1;
-}
-
-// return number of 1 bits in x
-function cbit(x) {
- var r = 0;
- while(x != 0) { x &= x-1; ++r; }
- return r;
-}
-
-// (public) return number of set bits
-function bnBitCount() {
- var r = 0, x = this.s&this.DM;
- for(var i = 0; i < this.t; ++i) r += cbit(this[i]^x);
- return r;
-}
-
-// (public) true iff nth bit is set
-function bnTestBit(n) {
- var j = Math.floor(n/this.DB);
- if(j >= this.t) return(this.s!=0);
- return((this[j]&(1<<(n%this.DB)))!=0);
-}
-
-// (protected) this op (1< >(p+=BI_DB-k);
- }
- else {
- d = (this_array[i]>>(p-=k))&km;
- if(p <= 0) { p += BI_DB; --i; }
- }
- if(d > 0) m = true;
- if(m) r += int2char(d);
- }
- }
- return m?r:"0";
-}
-
-// (public) -this
-function bnNegate() { var r = nbi(); BigInteger.ZERO.subTo(this,r); return r; }
-
-// (public) |this|
-function bnAbs() { return (this.s<0)?this.negate():this; }
-
-// (public) return + if this > a, - if this < a, 0 if equal
-function bnCompareTo(a) {
- var this_array = this.array;
- var a_array = a.array;
-
- var r = this.s-a.s;
- if(r != 0) return r;
- var i = this.t;
- r = i-a.t;
- if(r != 0) return r;
- while(--i >= 0) if((r=this_array[i]-a_array[i]) != 0) return r;
- return 0;
-}
-
-// returns bit length of the integer x
-function nbits(x) {
- var r = 1, t;
- if((t=x>>>16) != 0) { x = t; r += 16; }
- if((t=x>>8) != 0) { x = t; r += 8; }
- if((t=x>>4) != 0) { x = t; r += 4; }
- if((t=x>>2) != 0) { x = t; r += 2; }
- if((t=x>>1) != 0) { x = t; r += 1; }
- return r;
-}
-
-// (public) return the number of bits in "this"
-function bnBitLength() {
- var this_array = this.array;
- if(this.t <= 0) return 0;
- return BI_DB*(this.t-1)+nbits(this_array[this.t-1]^(this.s&BI_DM));
-}
-
-// (protected) r = this << n*DB
-function bnpDLShiftTo(n,r) {
- var this_array = this.array;
- var r_array = r.array;
- var i;
- for(i = this.t-1; i >= 0; --i) r_array[i+n] = this_array[i];
- for(i = n-1; i >= 0; --i) r_array[i] = 0;
- r.t = this.t+n;
- r.s = this.s;
-}
-
-// (protected) r = this >> n*DB
-function bnpDRShiftTo(n,r) {
- var this_array = this.array;
- var r_array = r.array;
- for(var i = n; i < this.t; ++i) r_array[i-n] = this_array[i];
- r.t = Math.max(this.t-n,0);
- r.s = this.s;
-}
-
-// (protected) r = this << n
-function bnpLShiftTo(n,r) {
- var this_array = this.array;
- var r_array = r.array;
- var bs = n%BI_DB;
- var cbs = BI_DB-bs;
- var bm = (1< >(p+=BI_DB-8);
- }
- else {
- d = (this_array[i]>>(p-=8))&0xff;
- if(p <= 0) { p += BI_DB; --i; }
- }
- if((d&0x80) != 0) d |= -256;
- if(k == 0 && (this.s&0x80) != (d&0x80)) ++k;
- if(k > 0 || d != this.s) r[k++] = d;
- }
- }
- return r;
-}
-
-function bnEquals(a) { return(this.compareTo(a)==0); }
-function bnMin(a) { return(this.compareTo(a)<0)?this:a; }
-function bnMax(a) { return(this.compareTo(a)>0)?this:a; }
-
-// (protected) r = this op a (bitwise)
-function bnpBitwiseTo(a,op,r) {
- var this_array = this.array;
- var a_array = a.array;
- var r_array = r.array;
- var i, f, m = Math.min(a.t,this.t);
- for(i = 0; i < m; ++i) r_array[i] = op(this_array[i],a_array[i]);
- if(a.t < this.t) {
- f = a.s&BI_DM;
- for(i = m; i < this.t; ++i) r_array[i] = op(this_array[i],f);
- r.t = this.t;
- }
- else {
- f = this.s&BI_DM;
- for(i = m; i < a.t; ++i) r_array[i] = op(f,a_array[i]);
- r.t = a.t;
- }
- r.s = op(this.s,a.s);
- r.clamp();
-}
-
-// (public) this & a
-function op_and(x,y) { return x&y; }
-function bnAnd(a) { var r = nbi(); this.bitwiseTo(a,op_and,r); return r; }
-
-// (public) this | a
-function op_or(x,y) { return x|y; }
-function bnOr(a) { var r = nbi(); this.bitwiseTo(a,op_or,r); return r; }
-
-// (public) this ^ a
-function op_xor(x,y) { return x^y; }
-function bnXor(a) { var r = nbi(); this.bitwiseTo(a,op_xor,r); return r; }
-
-// (public) this & ~a
-function op_andnot(x,y) { return x&~y; }
-function bnAndNot(a) { var r = nbi(); this.bitwiseTo(a,op_andnot,r); return r; }
-
-// (public) ~this
-function bnNot() {
- var this_array = this.array;
- var r = nbi();
- var r_array = r.array;
-
- for(var i = 0; i < this.t; ++i) r_array[i] = BI_DM&~this_array[i];
- r.t = this.t;
- r.s = ~this.s;
- return r;
-}
-
-// (public) this << n
-function bnShiftLeft(n) {
- var r = nbi();
- if(n < 0) this.rShiftTo(-n,r); else this.lShiftTo(n,r);
- return r;
-}
-
-// (public) this >> n
-function bnShiftRight(n) {
- var r = nbi();
- if(n < 0) this.lShiftTo(-n,r); else this.rShiftTo(n,r);
- return r;
-}
-
-// return index of lowest 1-bit in x, x < 2^31
-function lbit(x) {
- if(x == 0) return -1;
- var r = 0;
- if((x&0xffff) == 0) { x >>= 16; r += 16; }
- if((x&0xff) == 0) { x >>= 8; r += 8; }
- if((x&0xf) == 0) { x >>= 4; r += 4; }
- if((x&3) == 0) { x >>= 2; r += 2; }
- if((x&1) == 0) ++r;
- return r;
-}
-
-// (public) returns index of lowest 1-bit (or -1 if none)
-function bnGetLowestSetBit() {
- var this_array = this.array;
- for(var i = 0; i < this.t; ++i)
- if(this_array[i] != 0) return i*BI_DB+lbit(this_array[i]);
- if(this.s < 0) return this.t*BI_DB;
- return -1;
-}
-
-// return number of 1 bits in x
-function cbit(x) {
- var r = 0;
- while(x != 0) { x &= x-1; ++r; }
- return r;
-}
-
-// (public) return number of set bits
-function bnBitCount() {
- var this_array = this.array;
- var r = 0, x = this.s&BI_DM;
- for(var i = 0; i < this.t; ++i) r += cbit(this_array[i]^x);
- return r;
-}
-
-// (public) true iff nth bit is set
-function bnTestBit(n) {
- var this_array = this.array;
- var j = Math.floor(n/BI_DB);
- if(j >= this.t) return(this.s!=0);
- return((this_array[j]&(1<<(n%BI_DB)))!=0);
-}
-
-// (protected) this op (1<a::b is: \n \n\n```\n\nCurrent functionality\n---------------------\n\n- Parsing of most IPv6 notations\n- Parsing of IPv6 Addresses and Ports from URLs with `v6.Address.fromURL(url)`\n- Validity checking\n- Decoding of the [Teredo information](http://en.wikipedia.org/wiki/Teredo_tunneling#IPv6_addressing) in an address\n- Whether one address is a valid subnet of another\n- What special properties a given address has (multicast prefix, unique local address prefix, etc.)\n- Number of subnets of a certain size in a given address\n- Display methods\n - Hex, binary, and decimal\n - Canonical form\n - Correct form\n - IPv4-compatible (i.e. `::ffff:192.168.0.1`)\n- Works in [node.js](http://nodejs.org/) and the browser\n- Unit tests with [node.js](http://nodejs.org/) and [Mocha](http://visionmedia.github.com/mocha/)\n\nUsed by\n-------\n\n- [Rackspace](http://www.rackspace.com/) in [node-swiz](https://github.com/racker/node-swiz)\n- [node-socksified](https://github.com/vially/node-socksified)\n\nFuture functionality\n--------------------\n\n- Investigate `procstreams` for the CLI tool\n- Base 64/85 encoding?\n- Reverse lookups? (Whether a domain name has IPv6 glue)\n\nTODO\n----\n\n- Documentation\n",
- "readmeFilename": "README.md",
- "bugs": {
- "url": "https://github.com/beaugunderson/javascript-ipv6/issues"
- },
- "homepage": "https://github.com/beaugunderson/javascript-ipv6",
- "_id": "ipv6@3.1.1",
- "dist": {
- "shasum": "46da0e260af36fd9beb41297c987b7c21a2d9e1c",
- "tarball": "http://registry.npmjs.org/ipv6/-/ipv6-3.1.1.tgz"
- },
- "_from": "ipv6@",
- "_npmVersion": "1.3.17",
- "_npmUser": {
- "name": "beaugunderson",
- "email": "beau@beaugunderson.com"
- },
- "maintainers": [
- {
- "name": "beaugunderson",
- "email": "beau@beaugunderson.com"
- }
- ],
- "directories": {},
- "_shasum": "46da0e260af36fd9beb41297c987b7c21a2d9e1c",
- "_resolved": "https://registry.npmjs.org/ipv6/-/ipv6-3.1.1.tgz"
-}
diff --git a/node_modules/ipv6/test/address-test.js b/node_modules/ipv6/test/address-test.js
deleted file mode 100644
index 2996c34..0000000
--- a/node_modules/ipv6/test/address-test.js
+++ /dev/null
@@ -1,164 +0,0 @@
-var should = require('chai').should();
-
-var v4 = require('../ipv6').v4;
-var v6 = require('../ipv6').v6;
-
-function addressIs(addressString, descriptors) {
- var address4 = new v4.Address(addressString);
- var address6 = new v6.Address(addressString);
-
- describe(addressString, function () {
- descriptors.forEach(function (descriptor) {
- if (descriptor === 'valid-ipv4') {
- it('is valid', function () {
- address4.should.be.an('object');
-
- address4.parsedAddress.should.be.an.instanceOf(Array);
- address4.parsedAddress.length.should.equal(4);
-
- address4.subnetMask.should.be.a('number');
-
- address4.subnetMask.should.be.at.least(0);
- address4.subnetMask.should.be.at.most(128);
-
- should.not.exist(address4.error);
- should.not.exist(address4.parseError);
-
- address4.isValid().should.equal(true);
- });
- }
-
- if (descriptor === 'valid-ipv6') {
- it('is valid', function () {
- address6.should.be.an('object');
-
- address6.zone.should.be.a('string');
-
- address6.subnet.should.be.a('string');
-
- address6.subnetMask.should.be.a('number');
-
- address6.subnetMask.should.be.at.least(0);
- address6.subnetMask.should.be.at.most(128);
-
- address6.parsedAddress.should.be.an.instanceOf(Array);
- address6.parsedAddress.length.should.equal(8);
-
- should.not.exist(address6.error);
- should.not.exist(address6.parseError);
-
- address6.isValid().should.equal(true);
- });
-
- // TODO: These aren't quite ready for primetime yet.
- /*
- it('validates the correct form via regex', function () {
- var re = address.regularExpression();
-
- re.test(address.correctForm()).should.equal(true);
- });
-
- it('validates the canonical form via regex', function () {
- var re = address.regularExpression();
-
- re.test(address.canonicalForm()).should.equal(true);
- });
- */
- }
-
- if (descriptor === 'invalid-ipv4') {
- it('is invalid as parsed by v4', function () {
- address4.error.should.be.a('string');
-
- address4.isValid().should.equal(false);
- });
- }
-
- if (descriptor === 'invalid-ipv6') {
- it('is invalid as parsed by v6', function () {
- address6.error.should.be.a('string');
-
- address6.isValid().should.equal(false);
- });
- }
-
- if (descriptor === 'canonical') {
- it('is canonical', function () {
- address6.isCanonical().should.equal(true);
-
- should.equal(address6.addressMinusSuffix.length, 39);
- });
- }
-
- if (descriptor === 'correct') {
- it('is correct', function () {
- address6.isCorrect().should.equal(true);
- });
- }
-
- if (descriptor === 'correct-ipv4') {
- it('is correct', function () {
- address4.isCorrect().should.equal(true);
- });
- }
-
- if (descriptor === 'incorrect') {
- it('is incorrect', function () {
- address6.isCorrect().should.equal(false);
- });
- }
-
- if (descriptor === 'incorrect-ipv4') {
- it('is incorrect', function () {
- address4.isCorrect().should.equal(false);
- });
- }
-
- if (descriptor === 'has-subnet') {
- it('parses the subnet', function () {
- address6.subnet.should.match(/^\/\d{1,3}/);
- });
- }
-
- if (descriptor === 'v4-in-v6') {
- it('is an ipv4-in-ipv6 address', function () {
- address6.is4().should.equal(true);
- });
- }
- });
- });
-}
-
-function loadJsonBatch(file, classes, noMerge) {
- // Load the list of test addresses
- var addresses = require(file);
-
- addresses.forEach(function (address) {
- if (address.conditions === undefined ||
- !address.conditions.length || noMerge) {
- address.conditions = classes;
- } else {
- address.conditions = address.conditions.concat(classes);
- }
-
- addressIs(address.address, address.conditions);
- });
-}
-
-describe('Valid IPv4 addresses', function () {
- loadJsonBatch('./data/valid-ipv4-addresses.json', ['valid-ipv4']);
- loadJsonBatch('./data/valid-ipv4-addresses.json', ['invalid-ipv6'], true);
-});
-
-describe('Valid IPv6 addresses', function () {
- loadJsonBatch('./data/valid-ipv6-addresses.json', ['valid-ipv6']);
- loadJsonBatch('./data/valid-ipv6-addresses.json', ['invalid-ipv4'], true);
-});
-
-describe('Invalid IPv4 addresses', function () {
- loadJsonBatch('./data/invalid-ipv4-addresses.json', ['invalid-ipv4']);
-});
-
-describe('Invalid IPv6 addresses', function () {
- loadJsonBatch('./data/invalid-ipv6-addresses.json', ['invalid-ipv6']);
-});
diff --git a/node_modules/ipv6/test/data/invalid-ipv4-addresses.json b/node_modules/ipv6/test/data/invalid-ipv4-addresses.json
deleted file mode 100644
index 6486cea..0000000
--- a/node_modules/ipv6/test/data/invalid-ipv4-addresses.json
+++ /dev/null
@@ -1,46 +0,0 @@
-[
- {
- "address": " 127.0.0.1",
- "conditions": []
- },
- {
- "address": "127.0.0.1 ",
- "conditions": []
- },
- {
- "address": "127.0.0.1 127.0.0.1",
- "conditions": []
- },
- {
- "address": "127.0.0.256",
- "conditions": []
- },
- {
- "address": "127.0.0.1//1",
- "conditions": []
- },
- {
- "address": "127.0.0.1/0x1",
- "conditions": []
- },
- {
- "address": "127.0.0.1/-1",
- "conditions": []
- },
- {
- "address": "127.0.0.1/ab",
- "conditions": []
- },
- {
- "address": "127.0.0.1/",
- "conditions": []
- },
- {
- "address": "127.0.0.256/32",
- "conditions": []
- },
- {
- "address": "127.0.0.1/33",
- "conditions": []
- }
-]
diff --git a/node_modules/ipv6/test/data/invalid-ipv6-addresses.json b/node_modules/ipv6/test/data/invalid-ipv6-addresses.json
deleted file mode 100644
index 1cca25f..0000000
--- a/node_modules/ipv6/test/data/invalid-ipv6-addresses.json
+++ /dev/null
@@ -1,1282 +0,0 @@
-[
- {
- "address": "':10.0.0.1",
- "conditions": []
- },
- {
- "address": "-1",
- "conditions": []
- },
- {
- "address": "::1 ::1",
- "conditions": []
- },
- {
- "address": "02001:0000:1234:0000:0000:C1C0:ABCD:0876",
- "conditions": []
- },
- {
- "address": "1.2.3.4",
- "conditions": []
- },
- {
- "address": "1.2.3.4:1111:2222:3333:4444::5555",
- "conditions": []
- },
- {
- "address": "1.2.3.4:1111:2222:3333::5555",
- "conditions": []
- },
- {
- "address": "1.2.3.4:1111:2222::5555",
- "conditions": []
- },
- {
- "address": "1.2.3.4:1111::5555",
- "conditions": []
- },
- {
- "address": "1.2.3.4::",
- "conditions": []
- },
- {
- "address": "1.2.3.4::5555",
- "conditions": []
- },
- {
- "address": "1111",
- "conditions": []
- },
- {
- "address": "11112222:3333:4444:5555:6666:1.2.3.4",
- "conditions": []
- },
- {
- "address": "11112222:3333:4444:5555:6666:7777:8888",
- "conditions": []
- },
- {
- "address": "::1//64",
- "conditions": []
- },
- {
- "address": "::1/0001",
- "conditions": []
- },
- {
- "address": "1111:",
- "conditions": []
- },
- {
- "address": "1111:1.2.3.4",
- "conditions": []
- },
- {
- "address": "1111:2222",
- "conditions": []
- },
- {
- "address": "1111:22223333:4444:5555:6666:1.2.3.4",
- "conditions": []
- },
- {
- "address": "1111:22223333:4444:5555:6666:7777:8888",
- "conditions": []
- },
- {
- "address": "1111:2222:",
- "conditions": []
- },
- {
- "address": "1111:2222:1.2.3.4",
- "conditions": []
- },
- {
- "address": "1111:2222:3333",
- "conditions": []
- },
- {
- "address": "1111:2222:33334444:5555:6666:1.2.3.4",
- "conditions": []
- },
- {
- "address": "1111:2222:33334444:5555:6666:7777:8888",
- "conditions": []
- },
- {
- "address": "1111:2222:3333:",
- "conditions": []
- },
- {
- "address": "1111:2222:3333:1.2.3.4",
- "conditions": []
- },
- {
- "address": "1111:2222:3333:4444",
- "conditions": []
- },
- {
- "address": "1111:2222:3333:44445555:6666:1.2.3.4",
- "conditions": []
- },
- {
- "address": "1111:2222:3333:44445555:6666:7777:8888",
- "conditions": []
- },
- {
- "address": "1111:2222:3333:4444:",
- "conditions": []
- },
- {
- "address": "1111:2222:3333:4444:1.2.3.4",
- "conditions": []
- },
- {
- "address": "1111:2222:3333:4444:5555",
- "conditions": []
- },
- {
- "address": "1111:2222:3333:4444:55556666:1.2.3.4",
- "conditions": []
- },
- {
- "address": "1111:2222:3333:4444:55556666:7777:8888",
- "conditions": []
- },
- {
- "address": "1111:2222:3333:4444:5555:",
- "conditions": []
- },
- {
- "address": "1111:2222:3333:4444:5555:1.2.3.4",
- "conditions": []
- },
- {
- "address": "1111:2222:3333:4444:5555:6666",
- "conditions": []
- },
- {
- "address": "1111:2222:3333:4444:5555:66661.2.3.4",
- "conditions": []
- },
- {
- "address": "1111:2222:3333:4444:5555:66667777:8888",
- "conditions": []
- },
- {
- "address": "1111:2222:3333:4444:5555:6666:",
- "conditions": []
- },
- {
- "address": "1111:2222:3333:4444:5555:6666:00.00.00.00",
- "conditions": []
- },
- {
- "address": "1111:2222:3333:4444:5555:6666:000.000.000.000",
- "conditions": []
- },
- {
- "address": "1111:2222:3333:4444:5555:6666:1.2.3.4.5",
- "conditions": []
- },
- {
- "address": "1111:2222:3333:4444:5555:6666:255.255.255255",
- "conditions": []
- },
- {
- "address": "1111:2222:3333:4444:5555:6666:255.255255.255",
- "conditions": []
- },
- {
- "address": "1111:2222:3333:4444:5555:6666:255255.255.255",
- "conditions": []
- },
- {
- "address": "1111:2222:3333:4444:5555:6666:256.256.256.256",
- "conditions": []
- },
- {
- "address": "1111:2222:3333:4444:5555:6666:7777",
- "conditions": []
- },
- {
- "address": "1111:2222:3333:4444:5555:6666:77778888",
- "conditions": []
- },
- {
- "address": "1111:2222:3333:4444:5555:6666:7777:",
- "conditions": []
- },
- {
- "address": "1111:2222:3333:4444:5555:6666:7777:1.2.3.4",
- "conditions": []
- },
- {
- "address": "1111:2222:3333:4444:5555:6666:7777:8888:",
- "conditions": []
- },
- {
- "address": "1111:2222:3333:4444:5555:6666:7777:8888:1.2.3.4",
- "conditions": []
- },
- {
- "address": "1111:2222:3333:4444:5555:6666:7777:8888:9999",
- "conditions": []
- },
- {
- "address": "1111:2222:3333:4444:5555:6666:7777:8888::",
- "conditions": []
- },
- {
- "address": "1111:2222:3333:4444:5555:6666:7777:::",
- "conditions": []
- },
- {
- "address": "1111:2222:3333:4444:5555:6666::1.2.3.4",
- "conditions": []
- },
- {
- "address": "1111:2222:3333:4444:5555:6666::8888:",
- "conditions": []
- },
- {
- "address": "1111:2222:3333:4444:5555:6666:::",
- "conditions": []
- },
- {
- "address": "1111:2222:3333:4444:5555:6666:::8888",
- "conditions": []
- },
- {
- "address": "1111:2222:3333:4444:5555::7777:8888:",
- "conditions": []
- },
- {
- "address": "1111:2222:3333:4444:5555::7777::",
- "conditions": []
- },
- {
- "address": "1111:2222:3333:4444:5555::8888:",
- "conditions": []
- },
- {
- "address": "1111:2222:3333:4444:5555:::",
- "conditions": []
- },
- {
- "address": "1111:2222:3333:4444:5555:::1.2.3.4",
- "conditions": []
- },
- {
- "address": "1111:2222:3333:4444:5555:::7777:8888",
- "conditions": []
- },
- {
- "address": "1111:2222:3333:4444::5555:",
- "conditions": []
- },
- {
- "address": "1111:2222:3333:4444::6666:7777:8888:",
- "conditions": []
- },
- {
- "address": "1111:2222:3333:4444::6666:7777::",
- "conditions": []
- },
- {
- "address": "1111:2222:3333:4444::6666::8888",
- "conditions": []
- },
- {
- "address": "1111:2222:3333:4444::7777:8888:",
- "conditions": []
- },
- {
- "address": "1111:2222:3333:4444::8888:",
- "conditions": []
- },
- {
- "address": "1111:2222:3333:4444:::",
- "conditions": []
- },
- {
- "address": "1111:2222:3333:4444:::6666:1.2.3.4",
- "conditions": []
- },
- {
- "address": "1111:2222:3333:4444:::6666:7777:8888",
- "conditions": []
- },
- {
- "address": "1111:2222:3333::5555:",
- "conditions": []
- },
- {
- "address": "1111:2222:3333::5555:6666:7777:8888:",
- "conditions": []
- },
- {
- "address": "1111:2222:3333::5555:6666:7777::",
- "conditions": []
- },
- {
- "address": "1111:2222:3333::5555:6666::8888",
- "conditions": []
- },
- {
- "address": "1111:2222:3333::5555::1.2.3.4",
- "conditions": []
- },
- {
- "address": "1111:2222:3333::5555::7777:8888",
- "conditions": []
- },
- {
- "address": "1111:2222:3333::6666:7777:8888:",
- "conditions": []
- },
- {
- "address": "1111:2222:3333::7777:8888:",
- "conditions": []
- },
- {
- "address": "1111:2222:3333::8888:",
- "conditions": []
- },
- {
- "address": "1111:2222:3333:::",
- "conditions": []
- },
- {
- "address": "1111:2222:3333:::5555:6666:1.2.3.4",
- "conditions": []
- },
- {
- "address": "1111:2222:3333:::5555:6666:7777:8888",
- "conditions": []
- },
- {
- "address": "1111:2222::4444:5555:6666:7777:8888:",
- "conditions": []
- },
- {
- "address": "1111:2222::4444:5555:6666:7777::",
- "conditions": []
- },
- {
- "address": "1111:2222::4444:5555:6666::8888",
- "conditions": []
- },
- {
- "address": "1111:2222::4444:5555::1.2.3.4",
- "conditions": []
- },
- {
- "address": "1111:2222::4444:5555::7777:8888",
- "conditions": []
- },
- {
- "address": "1111:2222::4444::6666:1.2.3.4",
- "conditions": []
- },
- {
- "address": "1111:2222::4444::6666:7777:8888",
- "conditions": []
- },
- {
- "address": "1111:2222::5555:",
- "conditions": []
- },
- {
- "address": "1111:2222::5555:6666:7777:8888:",
- "conditions": []
- },
- {
- "address": "1111:2222::6666:7777:8888:",
- "conditions": []
- },
- {
- "address": "1111:2222::7777:8888:",
- "conditions": []
- },
- {
- "address": "1111:2222::8888:",
- "conditions": []
- },
- {
- "address": "1111:2222:::",
- "conditions": []
- },
- {
- "address": "1111:2222:::4444:5555:6666:1.2.3.4",
- "conditions": []
- },
- {
- "address": "1111:2222:::4444:5555:6666:7777:8888",
- "conditions": []
- },
- {
- "address": "1111::3333:4444:5555:6666:7777:8888:",
- "conditions": []
- },
- {
- "address": "1111::3333:4444:5555:6666:7777::",
- "conditions": []
- },
- {
- "address": "1111::3333:4444:5555:6666::8888",
- "conditions": []
- },
- {
- "address": "1111::3333:4444:5555::1.2.3.4",
- "conditions": []
- },
- {
- "address": "1111::3333:4444:5555::7777:8888",
- "conditions": []
- },
- {
- "address": "1111::3333:4444::6666:1.2.3.4",
- "conditions": []
- },
- {
- "address": "1111::3333:4444::6666:7777:8888",
- "conditions": []
- },
- {
- "address": "1111::3333::5555:6666:1.2.3.4",
- "conditions": []
- },
- {
- "address": "1111::3333::5555:6666:7777:8888",
- "conditions": []
- },
- {
- "address": "1111::4444:5555:6666:7777:8888:",
- "conditions": []
- },
- {
- "address": "1111::5555:",
- "conditions": []
- },
- {
- "address": "1111::5555:6666:7777:8888:",
- "conditions": []
- },
- {
- "address": "1111::6666:7777:8888:",
- "conditions": []
- },
- {
- "address": "1111::7777:8888:",
- "conditions": []
- },
- {
- "address": "1111::8888:",
- "conditions": []
- },
- {
- "address": "1111:::",
- "conditions": []
- },
- {
- "address": "1111:::3333:4444:5555:6666:1.2.3.4",
- "conditions": []
- },
- {
- "address": "1111:::3333:4444:5555:6666:7777:8888",
- "conditions": []
- },
- {
- "address": "123",
- "conditions": []
- },
- {
- "address": "12345::6:7:8",
- "conditions": []
- },
- {
- "address": "124.15.6.89/60",
- "conditions": []
- },
- {
- "address": "1:2:3:4:5:6:7:8:9",
- "conditions": []
- },
- {
- "address": "1:2:3::4:5:6:7:8:9",
- "conditions": []
- },
- {
- "address": "1:2:3::4:5::7:8",
- "conditions": []
- },
- {
- "address": "1::1.2.256.4",
- "conditions": []
- },
- {
- "address": "1::1.2.3.256",
- "conditions": []
- },
- {
- "address": "1::1.2.3.300",
- "conditions": []
- },
- {
- "address": "1::1.2.3.900",
- "conditions": []
- },
- {
- "address": "1::1.2.300.4",
- "conditions": []
- },
- {
- "address": "1::1.2.900.4",
- "conditions": []
- },
- {
- "address": "1::1.256.3.4",
- "conditions": []
- },
- {
- "address": "1::1.300.3.4",
- "conditions": []
- },
- {
- "address": "1::1.900.3.4",
- "conditions": []
- },
- {
- "address": "1::256.2.3.4",
- "conditions": []
- },
- {
- "address": "1::260.2.3.4",
- "conditions": []
- },
- {
- "address": "1::2::3",
- "conditions": []
- },
- {
- "address": "1::300.2.3.4",
- "conditions": []
- },
- {
- "address": "1::300.300.300.300",
- "conditions": []
- },
- {
- "address": "1::3000.30.30.30",
- "conditions": []
- },
- {
- "address": "1::400.2.3.4",
- "conditions": []
- },
- {
- "address": "1::5:1.2.256.4",
- "conditions": []
- },
- {
- "address": "1::5:1.2.3.256",
- "conditions": []
- },
- {
- "address": "1::5:1.2.3.300",
- "conditions": []
- },
- {
- "address": "1::5:1.2.3.900",
- "conditions": []
- },
- {
- "address": "1::5:1.2.300.4",
- "conditions": []
- },
- {
- "address": "1::5:1.2.900.4",
- "conditions": []
- },
- {
- "address": "1::5:1.256.3.4",
- "conditions": []
- },
- {
- "address": "1::5:1.300.3.4",
- "conditions": []
- },
- {
- "address": "1::5:1.900.3.4",
- "conditions": []
- },
- {
- "address": "1::5:256.2.3.4",
- "conditions": []
- },
- {
- "address": "1::5:260.2.3.4",
- "conditions": []
- },
- {
- "address": "1::5:300.2.3.4",
- "conditions": []
- },
- {
- "address": "1::5:300.300.300.300",
- "conditions": []
- },
- {
- "address": "1::5:3000.30.30.30",
- "conditions": []
- },
- {
- "address": "1::5:400.2.3.4",
- "conditions": []
- },
- {
- "address": "1::5:900.2.3.4",
- "conditions": []
- },
- {
- "address": "1::900.2.3.4",
- "conditions": []
- },
- {
- "address": "1:::3:4:5",
- "conditions": []
- },
- {
- "address": "2001:0000:1234: 0000:0000:C1C0:ABCD:0876",
- "conditions": []
- },
- {
- "address": "2001:0000:1234:0000:00001:C1C0:ABCD:0876",
- "conditions": []
- },
- {
- "address": "2001:0000:1234:0000:0000:C1C0:ABCD:0876 0",
- "conditions": []
- },
- {
- "address": "2001:1:1:1:1:1:255Z255X255Y255",
- "conditions": []
- },
- {
- "address": "2001::FFD3::57ab",
- "conditions": []
- },
- {
- "address": "2001:DB8:0:0:8:800:200C:417A:221",
- "conditions": []
- },
- {
- "address": "2001:db8:85a3::8a2e:37023:7334",
- "conditions": []
- },
- {
- "address": "2001:db8:85a3::8a2e:370k:7334",
- "conditions": []
- },
- {
- "address": "3ffe:0b00:0000:0001:0000:0000:000a",
- "conditions": []
- },
- {
- "address": "3ffe:b00::1::a",
- "conditions": []
- },
- {
- "address": ":",
- "conditions": []
- },
- {
- "address": ":1.2.3.4",
- "conditions": []
- },
- {
- "address": ":1111:2222:3333:4444:5555:6666:1.2.3.4",
- "conditions": []
- },
- {
- "address": ":1111:2222:3333:4444:5555:6666:7777:8888",
- "conditions": []
- },
- {
- "address": ":1111:2222:3333:4444:5555:6666:7777::",
- "conditions": []
- },
- {
- "address": ":1111:2222:3333:4444:5555:6666::",
- "conditions": []
- },
- {
- "address": ":1111:2222:3333:4444:5555:6666::8888",
- "conditions": []
- },
- {
- "address": ":1111:2222:3333:4444:5555::",
- "conditions": []
- },
- {
- "address": ":1111:2222:3333:4444:5555::1.2.3.4",
- "conditions": []
- },
- {
- "address": ":1111:2222:3333:4444:5555::7777:8888",
- "conditions": []
- },
- {
- "address": ":1111:2222:3333:4444:5555::8888",
- "conditions": []
- },
- {
- "address": ":1111:2222:3333:4444::",
- "conditions": []
- },
- {
- "address": ":1111:2222:3333:4444::1.2.3.4",
- "conditions": []
- },
- {
- "address": ":1111:2222:3333:4444::5555",
- "conditions": []
- },
- {
- "address": ":1111:2222:3333:4444::6666:1.2.3.4",
- "conditions": []
- },
- {
- "address": ":1111:2222:3333:4444::6666:7777:8888",
- "conditions": []
- },
- {
- "address": ":1111:2222:3333:4444::7777:8888",
- "conditions": []
- },
- {
- "address": ":1111:2222:3333:4444::8888",
- "conditions": []
- },
- {
- "address": ":1111:2222:3333::",
- "conditions": []
- },
- {
- "address": ":1111:2222:3333::1.2.3.4",
- "conditions": []
- },
- {
- "address": ":1111:2222:3333::5555",
- "conditions": []
- },
- {
- "address": ":1111:2222:3333::5555:6666:1.2.3.4",
- "conditions": []
- },
- {
- "address": ":1111:2222:3333::5555:6666:7777:8888",
- "conditions": []
- },
- {
- "address": ":1111:2222:3333::6666:1.2.3.4",
- "conditions": []
- },
- {
- "address": ":1111:2222:3333::6666:7777:8888",
- "conditions": []
- },
- {
- "address": ":1111:2222:3333::7777:8888",
- "conditions": []
- },
- {
- "address": ":1111:2222:3333::8888",
- "conditions": []
- },
- {
- "address": ":1111:2222::",
- "conditions": []
- },
- {
- "address": ":1111:2222::1.2.3.4",
- "conditions": []
- },
- {
- "address": ":1111:2222::4444:5555:6666:1.2.3.4",
- "conditions": []
- },
- {
- "address": ":1111:2222::4444:5555:6666:7777:8888",
- "conditions": []
- },
- {
- "address": ":1111:2222::5555",
- "conditions": []
- },
- {
- "address": ":1111:2222::5555:6666:1.2.3.4",
- "conditions": []
- },
- {
- "address": ":1111:2222::5555:6666:7777:8888",
- "conditions": []
- },
- {
- "address": ":1111:2222::6666:1.2.3.4",
- "conditions": []
- },
- {
- "address": ":1111:2222::6666:7777:8888",
- "conditions": []
- },
- {
- "address": ":1111:2222::7777:8888",
- "conditions": []
- },
- {
- "address": ":1111:2222::8888",
- "conditions": []
- },
- {
- "address": ":1111::",
- "conditions": []
- },
- {
- "address": ":1111::1.2.3.4",
- "conditions": []
- },
- {
- "address": ":1111::3333:4444:5555:6666:1.2.3.4",
- "conditions": []
- },
- {
- "address": ":1111::3333:4444:5555:6666:7777:8888",
- "conditions": []
- },
- {
- "address": ":1111::4444:5555:6666:1.2.3.4",
- "conditions": []
- },
- {
- "address": ":1111::4444:5555:6666:7777:8888",
- "conditions": []
- },
- {
- "address": ":1111::5555",
- "conditions": []
- },
- {
- "address": ":1111::5555:6666:1.2.3.4",
- "conditions": []
- },
- {
- "address": ":1111::5555:6666:7777:8888",
- "conditions": []
- },
- {
- "address": ":1111::6666:1.2.3.4",
- "conditions": []
- },
- {
- "address": ":1111::6666:7777:8888",
- "conditions": []
- },
- {
- "address": ":1111::7777:8888",
- "conditions": []
- },
- {
- "address": ":1111::8888",
- "conditions": []
- },
- {
- "address": ":2222:3333:4444:5555:6666:1.2.3.4",
- "conditions": []
- },
- {
- "address": ":2222:3333:4444:5555:6666:7777:8888",
- "conditions": []
- },
- {
- "address": ":3333:4444:5555:6666:1.2.3.4",
- "conditions": []
- },
- {
- "address": ":3333:4444:5555:6666:7777:8888",
- "conditions": []
- },
- {
- "address": ":4444:5555:6666:1.2.3.4",
- "conditions": []
- },
- {
- "address": ":4444:5555:6666:7777:8888",
- "conditions": []
- },
- {
- "address": ":5555:6666:1.2.3.4",
- "conditions": []
- },
- {
- "address": ":5555:6666:7777:8888",
- "conditions": []
- },
- {
- "address": ":6666:1.2.3.4",
- "conditions": []
- },
- {
- "address": ":6666:7777:8888",
- "conditions": []
- },
- {
- "address": ":7777:8888",
- "conditions": []
- },
- {
- "address": ":8888",
- "conditions": []
- },
- {
- "address": "::-1",
- "conditions": []
- },
- {
- "address": "::.",
- "conditions": []
- },
- {
- "address": "::..",
- "conditions": []
- },
- {
- "address": "::...",
- "conditions": []
- },
- {
- "address": "::...4",
- "conditions": []
- },
- {
- "address": "::..3.",
- "conditions": []
- },
- {
- "address": "::..3.4",
- "conditions": []
- },
- {
- "address": "::.2..",
- "conditions": []
- },
- {
- "address": "::.2.3.",
- "conditions": []
- },
- {
- "address": "::.2.3.4",
- "conditions": []
- },
- {
- "address": "::1...",
- "conditions": []
- },
- {
- "address": "::1.2..",
- "conditions": []
- },
- {
- "address": "::1.2.256.4",
- "conditions": []
- },
- {
- "address": "::1.2.3.",
- "conditions": []
- },
- {
- "address": "::1.2.3.256",
- "conditions": []
- },
- {
- "address": "::1.2.3.300",
- "conditions": []
- },
- {
- "address": "::1.2.3.900",
- "conditions": []
- },
- {
- "address": "::1.2.300.4",
- "conditions": []
- },
- {
- "address": "::1.2.900.4",
- "conditions": []
- },
- {
- "address": "::1.256.3.4",
- "conditions": []
- },
- {
- "address": "::1.300.3.4",
- "conditions": []
- },
- {
- "address": "::1.900.3.4",
- "conditions": []
- },
- {
- "address": "::1111:2222:3333:4444:5555:6666::",
- "conditions": []
- },
- {
- "address": "::2222:3333:4444:5555:6666:7777:1.2.3.4",
- "conditions": []
- },
- {
- "address": "::2222:3333:4444:5555:6666:7777:8888:",
- "conditions": []
- },
- {
- "address": "::2222:3333:4444:5555:6666:7777:8888:9999",
- "conditions": []
- },
- {
- "address": "::2222:3333:4444:5555:7777:8888::",
- "conditions": []
- },
- {
- "address": "::2222:3333:4444:5555:7777::8888",
- "conditions": []
- },
- {
- "address": "::2222:3333:4444:5555::1.2.3.4",
- "conditions": []
- },
- {
- "address": "::2222:3333:4444:5555::7777:8888",
- "conditions": []
- },
- {
- "address": "::2222:3333:4444::6666:1.2.3.4",
- "conditions": []
- },
- {
- "address": "::2222:3333:4444::6666:7777:8888",
- "conditions": []
- },
- {
- "address": "::2222:3333::5555:6666:1.2.3.4",
- "conditions": []
- },
- {
- "address": "::2222:3333::5555:6666:7777:8888",
- "conditions": []
- },
- {
- "address": "::2222::4444:5555:6666:1.2.3.4",
- "conditions": []
- },
- {
- "address": "::2222::4444:5555:6666:7777:8888",
- "conditions": []
- },
- {
- "address": "::256.2.3.4",
- "conditions": []
- },
- {
- "address": "::260.2.3.4",
- "conditions": []
- },
- {
- "address": "::300.2.3.4",
- "conditions": []
- },
- {
- "address": "::300.300.300.300",
- "conditions": []
- },
- {
- "address": "::3000.30.30.30",
- "conditions": []
- },
- {
- "address": "::3333:4444:5555:6666:7777:8888:",
- "conditions": []
- },
- {
- "address": "::400.2.3.4",
- "conditions": []
- },
- {
- "address": "::4444:5555:6666:7777:8888:",
- "conditions": []
- },
- {
- "address": "::5555:",
- "conditions": []
- },
- {
- "address": "::5555:6666:7777:8888:",
- "conditions": []
- },
- {
- "address": "::6666:7777:8888:",
- "conditions": []
- },
- {
- "address": "::7777:8888:",
- "conditions": []
- },
- {
- "address": "::8888:",
- "conditions": []
- },
- {
- "address": "::900.2.3.4",
- "conditions": []
- },
- {
- "address": ":::",
- "conditions": []
- },
- {
- "address": ":::1.2.3.4",
- "conditions": []
- },
- {
- "address": ":::2222:3333:4444:5555:6666:1.2.3.4",
- "conditions": []
- },
- {
- "address": ":::2222:3333:4444:5555:6666:7777:8888",
- "conditions": []
- },
- {
- "address": ":::3333:4444:5555:6666:7777:8888",
- "conditions": []
- },
- {
- "address": ":::4444:5555:6666:1.2.3.4",
- "conditions": []
- },
- {
- "address": ":::4444:5555:6666:7777:8888",
- "conditions": []
- },
- {
- "address": ":::5555",
- "conditions": []
- },
- {
- "address": ":::5555:6666:1.2.3.4",
- "conditions": []
- },
- {
- "address": ":::5555:6666:7777:8888",
- "conditions": []
- },
- {
- "address": ":::6666:1.2.3.4",
- "conditions": []
- },
- {
- "address": ":::6666:7777:8888",
- "conditions": []
- },
- {
- "address": ":::7777:8888",
- "conditions": []
- },
- {
- "address": ":::8888",
- "conditions": []
- },
- {
- "address": "::ffff:192x168.1.26",
- "conditions": []
- },
- {
- "address": "::ffff:2.3.4",
- "conditions": []
- },
- {
- "address": "::ffff:257.1.2.3",
- "conditions": []
- },
- {
- "address": "FF01::101::2",
- "conditions": []
- },
- {
- "address": "FF02:0000:0000:0000:0000:0000:0000:0000:0001",
- "conditions": []
- },
- {
- "address": "XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:1.2.3.4",
- "conditions": []
- },
- {
- "address": "XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX",
- "conditions": []
- },
- {
- "address": "a::b::c",
- "conditions": []
- },
- {
- "address": "a::g",
- "conditions": []
- },
- {
- "address": "a:a:a:a:a:a:a:a:a",
- "conditions": []
- },
- {
- "address": "a:aaaaa::",
- "conditions": []
- },
- {
- "address": "a:b",
- "conditions": []
- },
- {
- "address": "a:b:c:d:e:f:g:0",
- "conditions": []
- },
- {
- "address": "fe80:0000:0000:0000:0204:61ff:254.157.241.086",
- "conditions": []
- },
- {
- "address": "ffff:",
- "conditions": []
- },
- {
- "address": "ffff::ffff::ffff",
- "conditions": []
- },
- {
- "address": "ffgg:ffff:ffff:ffff:ffff:ffff:ffff:ffff",
- "conditions": []
- },
- {
- "address": "ldkfj",
- "conditions": []
- },
- {
- "address": "::/129",
- "conditions": []
- },
- {
- "address": "1000:://32",
- "conditions": []
- },
- {
- "address": "::/",
- "conditions": []
- }
-]
diff --git a/node_modules/ipv6/test/data/valid-ipv4-addresses.json b/node_modules/ipv6/test/data/valid-ipv4-addresses.json
deleted file mode 100644
index b2bf8a1..0000000
--- a/node_modules/ipv6/test/data/valid-ipv4-addresses.json
+++ /dev/null
@@ -1,22 +0,0 @@
-[
- {
- "address": "001.002.003.004",
- "conditions": ["incorrect-ipv4"]
- },
- {
- "address": "127.0.0.1",
- "conditions": ["correct-ipv4"]
- },
- {
- "address": "127.0.0.1/02",
- "conditions": ["incorrect-ipv4"]
- },
- {
- "address": "127.0.0.1/32",
- "conditions": ["correct-ipv4"]
- },
- {
- "address": "255.255.255.255/32",
- "conditions": ["correct-ipv4"]
- }
-]
diff --git a/node_modules/ipv6/test/data/valid-ipv6-addresses.json b/node_modules/ipv6/test/data/valid-ipv6-addresses.json
deleted file mode 100644
index ec0cade..0000000
--- a/node_modules/ipv6/test/data/valid-ipv6-addresses.json
+++ /dev/null
@@ -1,766 +0,0 @@
-[
- {
- "address": "0000:0000:0000:0000:0000:0000:0000:0000/128",
- "conditions": ["incorrect", "canonical", "has-subnet"]
- },
- {
- "address": "0000:0000:0000:0000:0000:0000:0000:0000",
- "conditions": ["incorrect", "canonical"]
- },
- {
- "address": "0000:0000:0000:0000:0000:0000:0000:0001",
- "conditions": ["incorrect", "canonical"]
- },
- {
- "address": "0:0:0:0:0:0:0:0",
- "conditions": ["incorrect"]
- },
- {
- "address": "0:0:0:0:0:0:0:1",
- "conditions": ["incorrect"]
- },
- {
- "address": "0:0:0:0:0:0:0::",
- "conditions": ["incorrect"]
- },
- {
- "address": "0:0:0:0:0:0:13.1.68.3",
- "conditions": ["incorrect", "v4-in-v6"]
- },
- {
- "address": "0:0:0:0:0:0::",
- "conditions": ["incorrect"]
- },
- {
- "address": "0:0:0:0:0::",
- "conditions": ["incorrect"]
- },
- {
- "address": "0:0:0:0:0:FFFF:129.144.52.38",
- "conditions": ["incorrect", "v4-in-v6"]
- },
- {
- "address": "0:0:0:0:1:0:0:0",
- "conditions": ["incorrect"]
- },
- {
- "address": "0:0:0:0::",
- "conditions": ["incorrect"]
- },
- {
- "address": "0:0:0::",
- "conditions": ["incorrect"]
- },
- {
- "address": "0:0::",
- "conditions": ["incorrect"]
- },
- {
- "address": "0:1:2:3:4:5:6:7/001",
- "conditions": ["incorrect", "has-subnet"]
- },
- {
- "address": "0:1:2:3:4:5:6:7/128",
- "conditions": ["correct", "has-subnet"]
- },
- {
- "address": "0:1:2:3:4:5:6:7",
- "conditions": ["correct"]
- },
- {
- "address": "0::",
- "conditions": ["incorrect"]
- },
- {
- "address": "0:a:b:c:d:e:f::",
- "conditions": ["incorrect"]
- },
- {
- "address": "1080:0:0:0:8:800:200c:417a",
- "conditions": ["incorrect"]
- },
- {
- "address": "1080::8:800:200c:417a",
- "conditions": ["correct"]
- },
- {
- "address": "1111:2222:3333:4444:5555:6666:123.123.123.123",
- "conditions": ["v4-in-v6"]
- },
- {
- "address": "1111:2222:3333:4444:5555:6666:7777:8888",
- "conditions": ["correct"]
- },
- {
- "address": "1111:2222:3333:4444:5555:6666:7777::",
- "conditions": ["incorrect"]
- },
- {
- "address": "1111:2222:3333:4444:5555:6666::",
- "conditions": ["correct"]
- },
- {
- "address": "1111:2222:3333:4444:5555:6666::8888",
- "conditions": ["incorrect"]
- },
- {
- "address": "1111:2222:3333:4444:5555::",
- "conditions": ["correct"]
- },
- {
- "address": "1111:2222:3333:4444:5555::123.123.123.123",
- "conditions": ["v4-in-v6"]
- },
- {
- "address": "1111:2222:3333:4444:5555::7777:8888",
- "conditions": ["incorrect"]
- },
- {
- "address": "1111:2222:3333:4444:5555::8888",
- "conditions": ["correct"]
- },
- {
- "address": "1111:2222:3333:4444::",
- "conditions": ["correct"]
- },
- {
- "address": "1111:2222:3333:4444::123.123.123.123",
- "conditions": ["v4-in-v6"]
- },
- {
- "address": "1111:2222:3333:4444::6666:123.123.123.123",
- "conditions": ["v4-in-v6"]
- },
- {
- "address": "1111:2222:3333:4444::6666:7777:8888",
- "conditions": ["incorrect"]
- },
- {
- "address": "1111:2222:3333:4444::7777:8888",
- "conditions": ["correct"]
- },
- {
- "address": "1111:2222:3333:4444::8888",
- "conditions": ["correct"]
- },
- {
- "address": "1111:2222:3333::",
- "conditions": ["correct"]
- },
- {
- "address": "1111:2222:3333::123.123.123.123",
- "conditions": ["v4-in-v6"]
- },
- {
- "address": "1111:2222:3333::5555:6666:123.123.123.123",
- "conditions": ["v4-in-v6"]
- },
- {
- "address": "1111:2222:3333::5555:6666:7777:8888",
- "conditions": ["incorrect"]
- },
- {
- "address": "1111:2222:3333::6666:123.123.123.123",
- "conditions": ["v4-in-v6"]
- },
- {
- "address": "1111:2222:3333::6666:7777:8888",
- "conditions": ["correct"]
- },
- {
- "address": "1111:2222:3333::7777:8888",
- "conditions": ["correct"]
- },
- {
- "address": "1111:2222:3333::8888",
- "conditions": ["correct"]
- },
- {
- "address": "1111:2222::",
- "conditions": ["correct"]
- },
- {
- "address": "1111:2222::123.123.123.123",
- "conditions": ["v4-in-v6"]
- },
- {
- "address": "1111:2222::4444:5555:6666:123.123.123.123",
- "conditions": ["v4-in-v6"]
- },
- {
- "address": "1111:2222::4444:5555:6666:7777:8888",
- "conditions": ["incorrect"]
- },
- {
- "address": "1111:2222::5555:6666:123.123.123.123",
- "conditions": ["v4-in-v6"]
- },
- {
- "address": "1111:2222::5555:6666:7777:8888",
- "conditions": ["correct"]
- },
- {
- "address": "1111:2222::6666:123.123.123.123",
- "conditions": ["v4-in-v6"]
- },
- {
- "address": "1111:2222::6666:7777:8888",
- "conditions": ["correct"]
- },
- {
- "address": "1111:2222::7777:8888",
- "conditions": ["correct"]
- },
- {
- "address": "1111:2222::8888",
- "conditions": ["correct"]
- },
- {
- "address": "1111::",
- "conditions": ["correct"]
- },
- {
- "address": "1111::123.123.123.123",
- "conditions": ["v4-in-v6"]
- },
- {
- "address": "1111::3333:4444:5555:6666:123.123.123.123",
- "conditions": ["v4-in-v6"]
- },
- {
- "address": "1111::3333:4444:5555:6666:7777:8888",
- "conditions": ["incorrect"]
- },
- {
- "address": "1111::4444:5555:6666:123.123.123.123",
- "conditions": ["v4-in-v6"]
- },
- {
- "address": "1111::4444:5555:6666:7777:8888",
- "conditions": ["correct"]
- },
- {
- "address": "1111::5555:6666:123.123.123.123",
- "conditions": ["v4-in-v6"]
- },
- {
- "address": "1111::5555:6666:7777:8888",
- "conditions": ["correct"]
- },
- {
- "address": "1111::6666:123.123.123.123",
- "conditions": ["v4-in-v6"]
- },
- {
- "address": "1111::6666:7777:8888",
- "conditions": ["correct"]
- },
- {
- "address": "1111::7777:8888",
- "conditions": ["correct"]
- },
- {
- "address": "1111::8888",
- "conditions": ["correct"]
- },
- {
- "address": "1:2:3:4:5:6:1.2.3.4",
- "conditions": ["v4-in-v6"]
- },
- {
- "address": "1:2:3:4:5:6:7:8",
- "conditions": ["correct"]
- },
- {
- "address": "1:2:3:4:5:6::",
- "conditions": ["correct"]
- },
- {
- "address": "1:2:3:4:5:6::8",
- "conditions": ["incorrect"]
- },
- {
- "address": "1:2:3:4:5::",
- "conditions": ["correct"]
- },
- {
- "address": "1:2:3:4:5::1.2.3.4",
- "conditions": ["v4-in-v6"]
- },
- {
- "address": "1:2:3:4:5::7:8",
- "conditions": ["incorrect"]
- },
- {
- "address": "1:2:3:4:5::8",
- "conditions": ["correct"]
- },
- {
- "address": "1:2:3:4::",
- "conditions": ["correct"]
- },
- {
- "address": "1:2:3:4::1.2.3.4",
- "conditions": ["v4-in-v6"]
- },
- {
- "address": "1:2:3:4::5:1.2.3.4",
- "conditions": ["v4-in-v6"]
- },
- {
- "address": "1:2:3:4::7:8",
- "conditions": ["correct"]
- },
- {
- "address": "1:2:3:4::8",
- "conditions": ["correct"]
- },
- {
- "address": "1:2:3::",
- "conditions": ["correct"]
- },
- {
- "address": "1:2:3::1.2.3.4",
- "conditions": ["v4-in-v6"]
- },
- {
- "address": "1:2:3::5:1.2.3.4",
- "conditions": ["v4-in-v6"]
- },
- {
- "address": "1:2:3::7:8",
- "conditions": ["correct"]
- },
- {
- "address": "1:2:3::8",
- "conditions": ["correct"]
- },
- {
- "address": "1:2::",
- "conditions": ["correct"]
- },
- {
- "address": "1:2::1.2.3.4",
- "conditions": ["v4-in-v6"]
- },
- {
- "address": "1:2::5:1.2.3.4",
- "conditions": ["v4-in-v6"]
- },
- {
- "address": "1:2::7:8",
- "conditions": ["correct"]
- },
- {
- "address": "1:2::8",
- "conditions": ["correct"]
- },
- {
- "address": "1::",
- "conditions": ["correct"]
- },
- {
- "address": "1::1.2.3.4",
- "conditions": ["v4-in-v6"]
- },
- {
- "address": "1::2:3",
- "conditions": ["correct"]
- },
- {
- "address": "1::2:3:4",
- "conditions": ["correct"]
- },
- {
- "address": "1::2:3:4:5",
- "conditions": ["correct"]
- },
- {
- "address": "1::2:3:4:5:6",
- "conditions": ["correct"]
- },
- {
- "address": "1::2:3:4:5:6:7",
- "conditions": ["incorrect"]
- },
- {
- "address": "1::5:1.2.3.4",
- "conditions": ["v4-in-v6"]
- },
- {
- "address": "1::5:11.22.33.44",
- "conditions": ["v4-in-v6"]
- },
- {
- "address": "1::7:8",
- "conditions": ["correct"]
- },
- {
- "address": "1::8",
- "conditions": ["correct"]
- },
- {
- "address": "2001:0000:1234:0000:0000:C1C0:ABCD:0876",
- "conditions": ["incorrect"]
- },
- {
- "address": "2001:0000:4136:e378:8000:63bf:3fff:fdd2",
- "conditions": ["canonical"]
- },
- {
- "address": "2001:0DB8:0000:CD30:0000:0000:0000:0000/60",
- "conditions": ["incorrect", "has-subnet"]
- },
- {
- "address": "2001:0DB8:0:CD30::/60",
- "conditions": ["incorrect", "has-subnet"]
- },
- {
- "address": "2001:0DB8::CD30:0:0:0:0/60",
- "conditions": ["incorrect", "has-subnet"]
- },
- {
- "address": "2001:0db8:0000:0000:0000:0000:1428:57ab",
- "conditions": []
- },
- {
- "address": "2001:0db8:0000:0000:0000::1428:57ab",
- "conditions": []
- },
- {
- "address": "2001:0db8:0:0:0:0:1428:57ab",
- "conditions": []
- },
- {
- "address": "2001:0db8:0:0::1428:57ab",
- "conditions": []
- },
- {
- "address": "2001:0db8:1234:0000:0000:0000:0000:0000",
- "conditions": []
- },
- {
- "address": "2001:0db8:1234::",
- "conditions": []
- },
- {
- "address": "2001:0db8:1234:ffff:ffff:ffff:ffff:ffff",
- "conditions": []
- },
- {
- "address": "2001:0db8:85a3:0000:0000:8a2e:0370:7334",
- "conditions": []
- },
- {
- "address": "2001:0db8::1428:57ab",
- "conditions": []
- },
- {
- "address": "2001::CE49:7601:2CAD:DFFF:7C94:FFFE",
- "conditions": ["incorrect"]
- },
- {
- "address": "2001::CE49:7601:E866:EFFF:62C3:FFFE",
- "conditions": ["incorrect"]
- },
- {
- "address": "2001:DB8:0:0:8:800:200C:417A",
- "conditions": ["incorrect"]
- },
- {
- "address": "2001:DB8::8:800:200C:417A",
- "conditions": ["incorrect"]
- },
- {
- "address": "2001:db8:85a3:0:0:8a2e:370:7334",
- "conditions": ["incorrect"]
- },
- {
- "address": "2001:db8:85a3::8a2e:370:7334",
- "conditions": ["correct"]
- },
- {
- "address": "2001:db8::",
- "conditions": ["correct"]
- },
- {
- "address": "2001:db8::1428:57ab",
- "conditions": ["correct"]
- },
- {
- "address": "2001:db8:a::123",
- "conditions": ["correct"]
- },
- {
- "address": "2002::",
- "conditions": ["correct"]
- },
- {
- "address": "2608::3:5",
- "conditions": ["correct"]
- },
- {
- "address": "2608:af09:30:0:0:0:0:134",
- "conditions": []
- },
- {
- "address": "2608:af09:30::102a:7b91:c239:baff",
- "conditions": []
- },
- {
- "address": "2::10",
- "conditions": ["correct"]
- },
- {
- "address": "3ffe:0b00:0000:0000:0001:0000:0000:000a",
- "conditions": ["canonical"]
- },
- {
- "address": "7:6:5:4:3:2:1:0",
- "conditions": ["correct"]
- },
- {
- "address": "::",
- "conditions": ["correct"]
- },
- {
- "address": "::/128",
- "conditions": ["correct", "has-subnet"]
- },
- {
- "address": "::0",
- "conditions": []
- },
- {
- "address": "::0:0",
- "conditions": []
- },
- {
- "address": "::0:0:0",
- "conditions": []
- },
- {
- "address": "::0:0:0:0",
- "conditions": []
- },
- {
- "address": "::0:0:0:0:0",
- "conditions": []
- },
- {
- "address": "::0:0:0:0:0:0",
- "conditions": []
- },
- {
- "address": "::0:0:0:0:0:0:0",
- "conditions": []
- },
- {
- "address": "::0:a:b:c:d:e:f",
- "conditions": []
- },
- {
- "address": "::1",
- "conditions": []
- },
- {
- "address": "::1/128",
- "conditions": ["correct", "has-subnet"]
- },
- {
- "address": "::123.123.123.123",
- "conditions": ["v4-in-v6"]
- },
- {
- "address": "::13.1.68.3",
- "conditions": ["v4-in-v6"]
- },
- {
- "address": "::2222:3333:4444:5555:6666:123.123.123.123",
- "conditions": ["v4-in-v6"]
- },
- {
- "address": "::2222:3333:4444:5555:6666:7777:8888",
- "conditions": []
- },
- {
- "address": "::2:3",
- "conditions": []
- },
- {
- "address": "::2:3:4",
- "conditions": []
- },
- {
- "address": "::2:3:4:5",
- "conditions": []
- },
- {
- "address": "::2:3:4:5:6",
- "conditions": []
- },
- {
- "address": "::2:3:4:5:6:7",
- "conditions": []
- },
- {
- "address": "::2:3:4:5:6:7:8",
- "conditions": []
- },
- {
- "address": "::3333:4444:5555:6666:7777:8888",
- "conditions": []
- },
- {
- "address": "::4444:5555:6666:123.123.123.123",
- "conditions": ["v4-in-v6"]
- },
- {
- "address": "::4444:5555:6666:7777:8888",
- "conditions": []
- },
- {
- "address": "::5555:6666:123.123.123.123",
- "conditions": ["v4-in-v6"]
- },
- {
- "address": "::5555:6666:7777:8888",
- "conditions": []
- },
- {
- "address": "::6666:123.123.123.123",
- "conditions": ["v4-in-v6"]
- },
- {
- "address": "::6666:7777:8888",
- "conditions": []
- },
- {
- "address": "::7777:8888",
- "conditions": []
- },
- {
- "address": "::8",
- "conditions": []
- },
- {
- "address": "::8888",
- "conditions": []
- },
- {
- "address": "::FFFF:129.144.52.38",
- "conditions": ["v4-in-v6"]
- },
- {
- "address": "::ffff:0:0",
- "conditions": []
- },
- {
- "address": "::ffff:0c22:384e",
- "conditions": []
- },
- {
- "address": "::ffff:12.34.56.78",
- "conditions": ["v4-in-v6"]
- },
- {
- "address": "::ffff:192.0.2.128",
- "conditions": ["v4-in-v6"]
- },
- {
- "address": "::ffff:192.168.1.1",
- "conditions": ["v4-in-v6"]
- },
- {
- "address": "::ffff:192.168.1.26",
- "conditions": ["v4-in-v6"]
- },
- {
- "address": "::ffff:c000:280",
- "conditions": []
- },
- {
- "address": "FE80::/10",
- "conditions": ["incorrect", "has-subnet"]
- },
- {
- "address": "FEC0::/10",
- "conditions": ["incorrect", "has-subnet"]
- },
- {
- "address": "FF00::/8",
- "conditions": ["incorrect", "has-subnet"]
- },
- {
- "address": "FF01:0:0:0:0:0:0:101",
- "conditions": ["incorrect"]
- },
- {
- "address": "FF01::101",
- "conditions": ["incorrect"]
- },
- {
- "address": "FF02:0000:0000:0000:0000:0000:0000:0001",
- "conditions": ["incorrect"]
- },
- {
- "address": "a:b:c:d:e:f:0::",
- "conditions": ["incorrect"]
- },
- {
- "address": "fe80:0000:0000:0000:0204:61ff:fe9d:f156",
- "conditions": ["canonical"]
- },
- {
- "address": "fe80:0:0:0:204:61ff:254.157.241.86",
- "conditions": ["v4-in-v6"]
- },
- {
- "address": "fe80:0:0:0:204:61ff:fe9d:f156",
- "conditions": ["incorrect"]
- },
- {
- "address": "fe80::",
- "conditions": ["correct"]
- },
- {
- "address": "fe80::1",
- "conditions": ["correct"]
- },
- {
- "address": "fe80::204:61ff:254.157.241.86",
- "conditions": ["v4-in-v6"]
- },
- {
- "address": "fe80::204:61ff:fe9d:f156",
- "conditions": []
- },
- {
- "address": "fe80::217:f2ff:254.7.237.98",
- "conditions": ["v4-in-v6"]
- },
- {
- "address": "fe80::217:f2ff:fe07:ed62",
- "conditions": ["correct"]
- },
- {
- "address": "fedc:ba98:7654:3210:fedc:ba98:7654:3210",
- "conditions": ["correct", "canonical"]
- },
- {
- "address": "ff02::1",
- "conditions": ["correct"]
- },
- {
- "address": "ffff::",
- "conditions": ["correct"]
- },
- {
- "address": "ffff::3:5",
- "conditions": ["correct"]
- },
- {
- "address": "ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff",
- "conditions": ["correct", "canonical"]
- }
-]
diff --git a/node_modules/ipv6/test/functionality-v4-test.js b/node_modules/ipv6/test/functionality-v4-test.js
deleted file mode 100644
index 2a84740..0000000
--- a/node_modules/ipv6/test/functionality-v4-test.js
+++ /dev/null
@@ -1,175 +0,0 @@
-var sprintf = require('sprintf').sprintf;
-var should = require('chai').should();
-
-var v4 = require('../ipv6').v4;
-
-// A convenience function to convert a list of IPv4 address notations
-// to v4.Address instances
-function notationsToAddresseses(notations) {
- var addresses = [];
-
- notations.forEach(function (notation) {
- addresses.push(new v4.Address(notation));
- });
-
- return addresses;
-}
-
-describe('v4', function () {
- describe('A correct address', function () {
- var topic = new v4.Address('127.0.0.1');
-
- it('validates as correct', function () {
- topic.isCorrect().should.equal(true);
-
- should.equal(topic.correctForm(), '127.0.0.1');
- });
- });
-
- describe('An address with a subnet', function () {
- var topic = new v4.Address('127.0.0.1/16');
-
- it('is contained by an identical address with an identical subnet',
- function () {
- var same = new v4.Address('127.0.0.1/16');
-
- topic.isInSubnet(same).should.equal(true);
- });
- });
-
- describe('A small subnet', function () {
- var topic = new v4.Address('127.0.0.1/16');
-
- it('is contained by larger subnets', function () {
- for (var i = 15; i > 0; i--) {
- var larger = new v4.Address(sprintf('127.0.0.1/%d', i));
-
- topic.isInSubnet(larger).should.equal(true);
- }
- });
- });
-
- describe('A large subnet', function () {
- var topic = new v4.Address('127.0.0.1/8');
-
- it('is not contained by smaller subnets', function () {
- for (var i = 9; i <= 32; i++) {
- var smaller = new v4.Address(sprintf('127.0.0.1/%d', i));
-
- topic.isInSubnet(smaller).should.equal(false);
- }
- });
- });
-
- describe('An integer v4 address', function () {
- var topic = new v4.Address.fromInteger(432432423);
-
- it('validates', function () {
- topic.isValid().should.equal(true);
- });
-
- it('parses correctly', function () {
- topic.address.should.equal('25.198.101.39');
-
- topic.subnet.should.equal('/32');
- topic.subnetMask.should.equal(32);
- });
-
- it('should match an address from its hex representation', function () {
- var hex = v4.Address.fromHex('19c66527');
-
- hex.address.should.equal('25.198.101.39');
-
- hex.subnet.should.equal('/32');
- hex.subnetMask.should.equal(32);
- });
- });
-
- describe('An address with a subnet', function () {
- var topic = new v4.Address('127.0.0.1/16');
-
- it('validates', function () {
- topic.isValid().should.equal(true);
- });
-
- it('parses the subnet', function () {
- should.equal(topic.subnet, '/16');
- });
-
- it('is in its own subnet', function () {
- topic.isInSubnet(new v4.Address('127.0.0.1/16')).should.equal(true);
- });
-
- it('is not in another subnet', function () {
- topic.isInSubnet(new v4.Address('192.168.0.1/16')).should.equal(false);
- });
- });
-
- describe('Creating an address from a BigInteger', function () {
- var topic = v4.Address.fromBigInteger(2130706433);
-
- it('should parse correctly', function () {
- topic.isValid().should.equal(true);
- topic.correctForm().should.equal('127.0.0.1');
- });
- });
-
- describe('Converting an address to a BigInteger', function () {
- var topic = new v4.Address('127.0.0.1');
-
- it('should convert properly', function () {
- topic.bigInteger().intValue().should.equal(2130706433);
- });
- });
-
- describe('Creating an address from hex', function () {
- var topic = v4.Address.fromHex('7f:00:00:01');
-
- it('should parse correctly', function () {
- topic.isValid().should.equal(true);
- topic.correctForm().should.equal('127.0.0.1');
- });
- });
-
- describe('Converting an address to hex', function () {
- var topic = new v4.Address('127.0.0.1');
-
- it('should convert correctly', function () {
- topic.toHex().should.equal('7f:00:00:01');
- });
- });
-
- describe('Converting an address to an array', function () {
- var topic = new v4.Address('127.0.0.1');
-
- it('should convert correctly', function () {
- var a = topic.toArray();
-
- a.should.be.an.instanceOf(Array).and.have.lengthOf(4);
-
- a[0].should.equal(127);
- a[1].should.equal(0);
- a[2].should.equal(0);
- a[3].should.equal(1);
- });
- });
-
- describe('A different notation of the same address', function () {
- var addresses = notationsToAddresseses([
- "127.0.0.1/32",
- "127.0.0.1/032",
- "127.000.000.001/032",
- "127.000.000.001/32",
- "127.0.0.1",
- "127.000.000.001",
- "127.000.0.1"
- ]);
-
- it('is parsed to the same result', function () {
- addresses.forEach(function (topic) {
- should.equal(topic.correctForm(), '127.0.0.1');
- should.equal(topic.subnetMask, 32);
- });
- });
- });
-});
diff --git a/node_modules/ipv6/test/functionality-v6-test.js b/node_modules/ipv6/test/functionality-v6-test.js
deleted file mode 100644
index fd5f95a..0000000
--- a/node_modules/ipv6/test/functionality-v6-test.js
+++ /dev/null
@@ -1,257 +0,0 @@
-var sprintf = require('sprintf').sprintf;
-var chai = require('chai');
-var should = chai.should();
-var expect = chai.expect;
-
-var v6 = require('../ipv6').v6;
-
-// A convenience function to convert a list of IPv6 address notations
-// to v6.Address instances
-function notationsToAddresseses(notations) {
- var addresses = [];
-
- notations.forEach(function (notation) {
- addresses.push(new v6.Address(notation));
- });
-
- return addresses;
-}
-
-describe('v6', function () {
- describe('A correct address', function () {
- var topic = new v6.Address('a::b');
-
- it('contains no uppercase letters', function () {
- /[A-Z]/.test(topic.address).should.equal(false);
- });
-
- it('validates as correct', function () {
- topic.isCorrect().should.equal(true);
-
- should.equal(topic.correctForm(), 'a::b');
- });
- });
-
- describe('An address with a subnet', function () {
- var topic = new v6.Address('ffff::/64');
-
- it('is contained by an identical address with an identical subnet',
- function () {
- var same = new v6.Address('ffff::/64');
-
- topic.isInSubnet(same).should.equal(true);
- });
- });
-
- describe('Small subnets', function () {
- var topic = new v6.Address('ffff::/64');
-
- it('is contained by larger subnets', function () {
- for (var i = 63; i > 0; i--) {
- var larger = new v6.Address(sprintf('ffff::/%d', i));
-
- topic.isInSubnet(larger).should.equal(true);
- }
- });
- });
-
- describe('Large subnets', function () {
- var topic = new v6.Address('ffff::/8');
-
- it('is not contained by smaller subnets', function () {
- for (var i = 9; i <= 128; i++) {
- var smaller = new v6.Address(sprintf('ffff::/%d', i));
-
- topic.isInSubnet(smaller).should.equal(false);
- }
- });
- });
-
- describe('A canonical address', function () {
- var topic = new v6.Address('000a:0000:0000:0000:0000:0000:0000:000b');
-
- it('is 39 characters long', function () {
- should.equal(topic.address.length, 39);
- });
-
- it('validates as canonical', function () {
- topic.isCanonical().should.equal(true);
-
- should.equal(topic.canonicalForm(),
- '000a:0000:0000:0000:0000:0000:0000:000b');
- });
- });
-
- describe('A v4-in-v6 address', function () {
- var topic = new v6.Address('::192.168.0.1');
-
- it('validates', function () {
- topic.isValid().should.equal(true);
- });
-
- it('is v4', function () {
- topic.is4().should.equal(true);
- });
- });
-
- describe('An address with a subnet', function () {
- var topic = new v6.Address('a:b::/48');
-
- it('validates', function () {
- topic.isValid().should.equal(true);
- });
-
- it('parses the subnet', function () {
- should.equal(topic.subnet, '/48');
- });
-
- it('is in its own subnet', function () {
- topic.isInSubnet(new v6.Address('a:b::/48')).should.equal(true);
- });
-
- it('is not in another subnet', function () {
- topic.isInSubnet(new v6.Address('a:c::/48')).should.equal(false);
- });
- });
-
- describe('An address with a zone', function () {
- var topic = new v6.Address('a::b%abcdefg');
-
- it('validates', function () {
- topic.isValid().should.equal(true);
- });
-
- it('parses the zone', function () {
- should.equal(topic.zone, '%abcdefg');
- });
- });
-
- describe('A teredo address', function () {
- var topic = new v6.Address('2001:0000:ce49:7601:e866:efff:62c3:fffe');
-
- it('validates as Teredo', function () {
- topic.isTeredo().should.equal(true);
- });
-
- it('contains valid Teredo information', function () {
- var teredo = topic.teredo();
-
- should.equal(teredo.prefix, '2001:0000');
- should.equal(teredo.server4, '206.73.118.1');
- should.equal(teredo.flags, '1110100001100110');
- should.equal(teredo.udpPort, '4096');
- should.equal(teredo.client4, '157.60.0.1');
- });
- });
-
- describe('A 6to4 address', function () {
- var topic = new v6.Address('2002:ce49:7601:1:2de:adff:febe:eeef');
-
- it('validates as 6to4', function () {
- topic.is6to4().should.equal(true);
- });
-
- it('contains valid 6to4 information', function () {
- var six2four = topic.six2four();
-
- should.equal(six2four.prefix, '2002');
- should.equal(six2four.gateway, '206.73.118.1');
- });
- });
-
- describe('A different notation of the same address', function () {
- var addresses = notationsToAddresseses([
- "2001:db8:0:0:1:0:0:1/128",
- "2001:db8:0:0:1:0:0:1/128%eth0",
- "2001:db8:0:0:1:0:0:1%eth0",
- "2001:db8:0:0:1:0:0:1",
- "2001:0db8:0:0:1:0:0:1",
- "2001:db8::1:0:0:1",
- "2001:db8::0:1:0:0:1",
- "2001:0db8::1:0:0:1",
- "2001:db8:0:0:1::1",
- "2001:db8:0000:0:1::1",
- "2001:DB8:0:0:1::1"
- ]);
-
- it('is parsed to the same result', function () {
- addresses.forEach(function (topic) {
- should.equal(topic.correctForm(), '2001:db8::1:0:0:1');
- should.equal(topic.canonicalForm(),
- '2001:0db8:0000:0000:0001:0000:0000:0001');
- should.equal(topic.v4inv6(), '2001:db8::1:0:0.0.0.1');
- should.equal(topic.decimal(),
- '08193:03512:00000:00000:00001:00000:00000:00001');
- should.equal(topic.binaryZeroPad(),
- '0010000000000001000011011011100000000000000000000000000000000000' +
- '0000000000000001000000000000000000000000000000000000000000000001');
- });
- });
- });
-
- describe('Address inside a URL or inside a URL with a port', function () {
- it('should work with a host address', function () {
- var obj = v6.Address.fromURL('2001:db8::5');
-
- expect(obj.address.valid).to.equal(true);
- expect(obj.address.address).to.equal('2001:db8::5');
- expect(obj.port).to.equal(null);
- });
-
- it('should work with a basic URL', function () {
- var obj = v6.Address.fromURL('http://2001:db8::5/foo');
-
- expect(obj.address.isValid()).to.equal(true);
- expect(obj.address.address).equal('2001:db8::5');
- expect(obj.port).to.equal(null);
- });
-
- it('should work with a URL with a port', function () {
- var obj = v6.Address.fromURL('http://[2001:db8::5]:80/foo');
-
- expect(obj.address.isValid()).to.equal(true);
- expect(obj.address.address).to.equal('2001:db8::5');
- expect(obj.port).to.equal(80);
- });
-
- it('should work with a URL with a long port number', function () {
- var obj = v6.Address.fromURL('http://[2001:db8::5]:65536/foo');
-
- expect(obj.address.isValid()).to.equal(true);
- expect(obj.address.address).to.equal('2001:db8::5');
- expect(obj.port).to.equal(65536);
- });
-
- it('should work with a address with a port', function () {
- var obj = v6.Address.fromURL('[2001:db8::5]:80');
-
- expect(obj.address.isValid()).to.equal(true);
- expect(obj.address.address).to.equal('2001:db8::5');
- expect(obj.port).to.equal(80);
- });
-
- it('should work with a address with a long port', function () {
- var obj = v6.Address.fromURL('[2001:db8::5]:65536');
-
- expect(obj.address.isValid()).to.equal(true);
- expect(obj.address.address).to.equal('2001:db8::5');
- expect(obj.port).to.equal(65536);
- });
-
- it('should parse the address but fail with an invalid port', function () {
- var obj = v6.Address.fromURL('[2001:db8::5]:65537');
-
- expect(obj.address.isValid()).to.equal(true);
- expect(obj.address.address).to.equal('2001:db8::5');
- expect(obj.port).to.equal(null);
- });
-
- it('should fail with an invalid address and not return a port',
- function () {
- var obj = v6.Address.fromURL('[2001:db8:z:5]:65536');
-
- expect(obj.error).to.equal('failed to parse address with port');
- expect(obj.port).to.equal(null);
- });
- });
-});
diff --git a/node_modules/ipv6/test/unused/grep-test.txt b/node_modules/ipv6/test/unused/grep-test.txt
deleted file mode 100644
index 74cb5ef..0000000
--- a/node_modules/ipv6/test/unused/grep-test.txt
+++ /dev/null
@@ -1,17 +0,0 @@
-a::b
-a::b2
-a::b testing
-http://[a::b]:80 testing
-a::b2 testing2
-000a::000b
-b::c
-b::c2
-a:0:0:0:0:0:0:b
-2001:db8:0:0:1:0:0:1
-2001:0db8:0:0:1:0:0:1
-2001:db8::1:0:0:1
-2001:db8::0:1:0:0:1
-2001:0db8::1:0:0:1
-2001:db8:0:0:1::1
-2001:db8:0000:0:1::1
-2001:DB8:0:0:1::1
diff --git a/node_modules/ipv6/test/unused/regex-test.js b/node_modules/ipv6/test/unused/regex-test.js
deleted file mode 100644
index 879644b..0000000
--- a/node_modules/ipv6/test/unused/regex-test.js
+++ /dev/null
@@ -1,21 +0,0 @@
-var fs = require('fs'),
- sprintf = require('sprintf').sprintf;
-
-var v6 = require('../ipv6').v6,
- BigInteger = require('../lib/node/bigint');
-
-var a = new v6.Address('::');
-var b = new v6.Address('a:b:c:d::');
-
-console.log(a.regularExpressionString());
-console.log(b.regularExpressionString());
-
-var ar = new RegExp(a.regularExpressionString());
-var br = new RegExp(a.regularExpressionString());
-
-console.log(ar.test('::'));
-console.log(ar.test('0:0:0:0:0:0:0:0'));
-
-console.log(br.test('a:b:c:d::'));
-console.log(br.test('a:b:c:d:0000:0000:0000:0000'));
-console.log(br.test('a:b:c:d:0:0:0:0'));
diff --git a/package-lock.json b/package-lock.json
new file mode 100644
index 0000000..fcafc4d
--- /dev/null
+++ b/package-lock.json
@@ -0,0 +1,14 @@
+{
+ "name": "socks-v5",
+ "version": "0.0.6",
+ "lockfileVersion": 1,
+ "requires": true,
+ "dependencies": {
+ "@types/node": {
+ "version": "10.7.1",
+ "resolved": "https://registry.npmjs.org/@types/node/-/node-10.7.1.tgz",
+ "integrity": "sha512-EGoI4ylB/lPOaqXqtzAyL8HcgOuCtH2hkEaLmkueOYufsTFWBn4VCvlCDC2HW8Q+9iF+QVC3sxjDKQYjHQeZ9w==",
+ "dev": true
+ }
+ }
+}
diff --git a/package.json b/package.json
index a007dc1..71dc9b0 100644
--- a/package.json
+++ b/package.json
@@ -1,19 +1,36 @@
-{ "name": "socksv5",
- "version": "0.0.6",
- "author": "Brian White