Constructor
new NetAddress(optionsopt)
Create a network address.
Parameters:
Name | Type | Attributes | Description | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object |
<optional> |
Properties
|
Properties:
Name | Type | Description |
---|---|---|
host |
Host | |
port |
Number | |
services |
Number | |
time |
Number |
- Source:
Members
(static, constant) DEFAULT_SERVICES :Number
Default services for unknown outbound peers.
Type:
- Number
- Source:
Methods
(static) fromHost(host, port, keyopt, networkopt, nullable) → {NetAddress}
Instantiate a network address from a host and port.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
host |
String | ||
port |
Number | ||
key |
Buffer |
<optional> |
|
network |
Network | NetworkType |
<optional> <nullable> |
- Source:
Returns:
- Type
- NetAddress
(static) fromHostname(hostname, networkopt, nullable) → {NetAddress}
Instantiate a network address from a hostname (i.e. 127.0.0.1:8333).
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
hostname |
String | ||
network |
Network | NetworkType |
<optional> <nullable> |
- Source:
Returns:
- Type
- NetAddress
(static) fromSocket(socket, networkopt, nullable) → {NetAddress}
Instantiate a network address from a socket.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
socket |
NetSocket | ||
network |
Network | NetworkType |
<optional> <nullable> |
- Source:
Returns:
- Type
- NetAddress
compare(addr) → {Number}
Compare against another network address.
Parameters:
Name | Type | Description |
---|---|---|
addr |
NetAddress |
- Source:
Returns:
- Type
- Number
equal(addr) → {Boolean}
Compare against another network address.
Parameters:
Name | Type | Description |
---|---|---|
addr |
NetAddress |
- Source:
Returns:
- Type
- Boolean
format() → {Object}
Inspect the network address.
- Source:
Returns:
- Type
- Object
fromHost(host, port, keyopt, networkopt, nullable)
Inject properties from host, port, and network.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
host |
String | ||
port |
Number | ||
key |
Buffer |
<optional> |
|
network |
Network | NetworkType |
<optional> <nullable> |
- Source:
fromHostname(hostname, networkopt, nullable)
Inject properties from hostname and network.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
hostname |
String | ||
network |
Network | NetworkType |
<optional> <nullable> |
- Source:
fromJSON(json) → {this}
Inject properties from json object.
Parameters:
Name | Type | Description |
---|---|---|
json |
Object |
- Source:
Returns:
- Type
- this
fromOptions(options)
Inject properties from options object.
Parameters:
Name | Type | Description |
---|---|---|
options |
Object |
- Source:
fromSocket(socket, networkopt, nullable)
Inject properties from socket.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
socket |
NetSocket | ||
network |
Network | NetworkType |
<optional> <nullable> |
- Source:
getGroup() → {Buffer}
Get the canonical identifier of our network group
- Source:
Returns:
- Type
- Buffer
getJSON() → {Object}
Convert net address to json-friendly object.
- Source:
Returns:
- Type
- Object
getKey(enc) → {String|Buffer}
Get key.
Parameters:
Name | Type | Description |
---|---|---|
enc |
String |
- Source:
Returns:
- Type
- String | Buffer
getReachability(dest) → {Number}
Get reachable score to destination.
Parameters:
Name | Type | Description |
---|---|---|
dest |
NetAddress |
- Source:
Returns:
- Type
- Number
getSize() → {Number}
Calculate serialization size of address.
- Source:
Returns:
- Type
- Number
hasKey() → {Boolean}
Test whether the peer has a key.
- Source:
Returns:
- Type
- Boolean
hasServices(services) → {Boolean}
Test whether required services are available.
Parameters:
Name | Type | Description |
---|---|---|
services |
Number |
- Source:
Returns:
- Type
- Boolean
isIPv4() → {Boolean}
Test whether the address is IPv4.
- Source:
Returns:
- Type
- Boolean
isIPv6() → {Boolean}
Test whether the address is IPv6.
- Source:
Returns:
- Type
- Boolean
isLocal() → {Boolean}
Test whether the host is a local address.
- Source:
Returns:
- Type
- Boolean
isNull() → {Boolean}
Test whether the host is null.
- Source:
Returns:
- Type
- Boolean
isOnion() → {Boolean}
Test whether the host is an onion address.
- Source:
Returns:
- Type
- Boolean
isRFC3964() → {Boolean}
Test whether the address is RFC3964.
- Source:
Returns:
- Type
- Boolean
isRFC4380() → {Boolean}
Test whether the address is RFC4380.
- Source:
Returns:
- Type
- Boolean
isRFC6052() → {Boolean}
Test whether the address is RFC6052.
- Source:
Returns:
- Type
- Boolean
isRFC6145() → {Boolean}
Test whether the address is RFC6145.
- Source:
Returns:
- Type
- Boolean
isRoutable() → {Boolean}
Test whether the host is routable.
- Source:
Returns:
- Type
- Boolean
isValid() → {Boolean}
Test whether the host is valid.
- Source:
Returns:
- Type
- Boolean
read(br)
Inject properties from buffer reader.
Parameters:
Name | Type | Description |
---|---|---|
br |
bio.BufferReader |
- Source:
setHost(host)
Set host.
Parameters:
Name | Type | Description |
---|---|---|
host |
String |
- Source:
setKey(key)
Set key.
Parameters:
Name | Type | Description |
---|---|---|
key |
Buffer |
- Source:
setNull()
Set null host.
- Source:
setPort(port)
Set port.
Parameters:
Name | Type | Description |
---|---|---|
port |
Number |
- Source:
write(bw) → {BufioWriter}
Write network address to a buffer writer.
Parameters:
Name | Type | Description |
---|---|---|
bw |
BufioWriter |
- Source:
Returns:
- Type
- BufioWriter