Changements dans les modules (nouvelle version Express, mysql, ..)
This commit is contained in:
80
node_modules/ipaddr.js/README.md
generated
vendored
80
node_modules/ipaddr.js/README.md
generated
vendored
@@ -15,10 +15,6 @@ and convert between IPv4 and IPv4-mapped IPv6 addresses.
|
||||
|
||||
`npm install ipaddr.js`
|
||||
|
||||
or
|
||||
|
||||
`bower install ipaddr.js`
|
||||
|
||||
## API
|
||||
|
||||
ipaddr.js defines one object in the global scope: `ipaddr`. In CommonJS,
|
||||
@@ -43,7 +39,7 @@ or throws an `Error` if the passed string is not a valid representation of an
|
||||
IP address.
|
||||
|
||||
The `ipaddr.process` method works just like the `ipaddr.parse` one, but it
|
||||
automatically converts IPv4-mapped IPv6 addresses to their IPv4 counterparts
|
||||
automatically converts IPv4-mapped IPv6 addresses to their IPv4 couterparts
|
||||
before returning. It is useful when you have a Node.js instance listening
|
||||
on an IPv6 socket, and the `net.ivp6.bindv6only` sysctl parameter (or its
|
||||
equivalent on non-Linux OS) is set to 0. In this case, you can accept IPv4
|
||||
@@ -97,7 +93,8 @@ in the source: [IPv6 ranges] and [IPv4 ranges]. Some common ones include `"unica
|
||||
(the default one) and `"reserved"`.
|
||||
|
||||
You can match against your own range list by using
|
||||
`ipaddr.subnetMatch(address, rangeList, defaultName)` method. It can work with a mix of IPv6 or IPv4 addresses, and accepts a name-to-subnet map as the range list. For example:
|
||||
`ipaddr.subnetMatch(address, rangeList, defaultName)` method. It can work with both
|
||||
IPv6 and IPv4 addresses, and accepts a name-to-subnet map as the range list. For example:
|
||||
|
||||
```js
|
||||
var rangeList = {
|
||||
@@ -107,7 +104,7 @@ var rangeList = {
|
||||
[ ipaddr.parse('2001:5c0::'), 32 ] // freenet6
|
||||
]
|
||||
};
|
||||
ipaddr.subnetMatch(ipaddr.parse('2001:470:8:66::1'), rangeList, 'unknown'); // => "tunnelProviders"
|
||||
ipaddr.subnetMatch(ipaddr.parse('2001:470:8:66::1'), rangeList, 'unknown'); // => "he.net"
|
||||
```
|
||||
|
||||
The addresses can be converted to their byte representation with `toByteArray()`.
|
||||
@@ -125,8 +122,6 @@ have the same interface for both protocols, and are similar to global methods.
|
||||
`ipaddr.IPvX.isValid(string)` can be used to check if the string is a valid address
|
||||
for particular protocol, and `ipaddr.IPvX.parse(string)` is the error-throwing parser.
|
||||
|
||||
`ipaddr.IPvX.isValid(string)` uses the same format for parsing as the POSIX `inet_ntoa` function, which accepts unusual formats like `0xc0.168.1.1` or `0x10000000`. The function `ipaddr.IPv4.isValidFourPartDecimal(string)` validates the IPv4 address and also ensures that it is written in four-part decimal format.
|
||||
|
||||
[IPv6 ranges]: https://github.com/whitequark/ipaddr.js/blob/master/src/ipaddr.coffee#L186
|
||||
[IPv4 ranges]: https://github.com/whitequark/ipaddr.js/blob/master/src/ipaddr.coffee#L71
|
||||
|
||||
@@ -154,13 +149,6 @@ var addr = ipaddr.parse("2001:db8:10::1234:DEAD");
|
||||
addr.parts // => [0x2001, 0xdb8, 0x10, 0, 0, 0, 0x1234, 0xdead]
|
||||
```
|
||||
|
||||
A IPv6 zone index can be accessed via `addr.zoneId`:
|
||||
|
||||
```js
|
||||
var addr = ipaddr.parse("2001:db8::%eth0");
|
||||
addr.zoneId // => 'eth0'
|
||||
```
|
||||
|
||||
#### IPv4 properties
|
||||
|
||||
`toIPv4MappedAddress()` will return a corresponding IPv4-mapped IPv6 address.
|
||||
@@ -171,63 +159,3 @@ To access the underlying representation of the address, use `addr.octets`.
|
||||
var addr = ipaddr.parse("192.168.1.1");
|
||||
addr.octets // => [192, 168, 1, 1]
|
||||
```
|
||||
|
||||
`prefixLengthFromSubnetMask()` will return a CIDR prefix length for a valid IPv4 netmask or
|
||||
null if the netmask is not valid.
|
||||
|
||||
```js
|
||||
ipaddr.IPv4.parse('255.255.255.240').prefixLengthFromSubnetMask() == 28
|
||||
ipaddr.IPv4.parse('255.192.164.0').prefixLengthFromSubnetMask() == null
|
||||
```
|
||||
|
||||
`subnetMaskFromPrefixLength()` will return an IPv4 netmask for a valid CIDR prefix length.
|
||||
|
||||
```js
|
||||
ipaddr.IPv4.subnetMaskFromPrefixLength(24) == "255.255.255.0"
|
||||
ipaddr.IPv4.subnetMaskFromPrefixLength(29) == "255.255.255.248"
|
||||
```
|
||||
|
||||
`broadcastAddressFromCIDR()` will return the broadcast address for a given IPv4 interface and netmask in CIDR notation.
|
||||
```js
|
||||
ipaddr.IPv4.broadcastAddressFromCIDR("172.0.0.1/24") == "172.0.0.255"
|
||||
```
|
||||
`networkAddressFromCIDR()` will return the network address for a given IPv4 interface and netmask in CIDR notation.
|
||||
```js
|
||||
ipaddr.IPv4.networkAddressFromCIDR("172.0.0.1/24") == "172.0.0.0"
|
||||
```
|
||||
|
||||
#### Conversion
|
||||
|
||||
IPv4 and IPv6 can be converted bidirectionally to and from network byte order (MSB) byte arrays.
|
||||
|
||||
The `fromByteArray()` method will take an array and create an appropriate IPv4 or IPv6 object
|
||||
if the input satisfies the requirements. For IPv4 it has to be an array of four 8-bit values,
|
||||
while for IPv6 it has to be an array of sixteen 8-bit values.
|
||||
|
||||
For example:
|
||||
```js
|
||||
var addr = ipaddr.fromByteArray([0x7f, 0, 0, 1]);
|
||||
addr.toString(); // => "127.0.0.1"
|
||||
```
|
||||
|
||||
or
|
||||
|
||||
```js
|
||||
var addr = ipaddr.fromByteArray([0x20, 1, 0xd, 0xb8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1])
|
||||
addr.toString(); // => "2001:db8::1"
|
||||
```
|
||||
|
||||
Both objects also offer a `toByteArray()` method, which returns an array in network byte order (MSB).
|
||||
|
||||
For example:
|
||||
```js
|
||||
var addr = ipaddr.parse("127.0.0.1");
|
||||
addr.toByteArray(); // => [0x7f, 0, 0, 1]
|
||||
```
|
||||
|
||||
or
|
||||
|
||||
```js
|
||||
var addr = ipaddr.parse("2001:db8::1");
|
||||
addr.toByteArray(); // => [0x20, 1, 0xd, 0xb8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user