public final class PeerAddress extends Object implements Comparable<PeerAddress>, Serializable
| Modifier and Type | Field and Description |
|---|---|
static int |
SIZE_IP_SOCKv4 |
static int |
SIZE_IP_SOCKv6 |
static int |
SIZE_IPv4 |
static int |
SIZE_IPv6 |
| Constructor and Description |
|---|
PeerAddress(byte[] me)
Creates a new peeraddress, where the byte array has to be in the rigth
format and in the rigth size.
|
PeerAddress(byte[] peerAddress,
byte[] socketAddress) |
PeerAddress(byte[] me,
int offset)
Creates a PeerAddress from a continuous byte array.
|
PeerAddress(Number160 id)
This is usually used for debugging, the address will be null and ports -1
|
PeerAddress(Number160 id,
InetAddress address,
int portTCP,
int portUDP) |
PeerAddress(Number160 id,
InetAddress address,
int portTCP,
int portUDP,
boolean forwarded,
boolean firewalledUDP,
boolean firewalledTCP)
Creates a PeerAddress
|
PeerAddress(Number160 id,
InetAddress address,
int portTCP,
int portUDP,
byte optionType) |
PeerAddress(Number160 id,
InetSocketAddress inetSocketAddress) |
PeerAddress(Number160 id,
PeerAddress parent) |
| Modifier and Type | Method and Description |
|---|---|
int |
compareTo(PeerAddress nodeAddress) |
InetSocketAddress |
createSocketTCP()
Returns the socket address.
|
InetSocketAddress |
createSocketUDP()
Returns the socket address.
|
byte |
createType() |
boolean |
equals(Object obj) |
static int |
expectedLength(int type) |
PeerAddress |
forward(InetAddress inetAddress) |
Number160 |
getID()
The id of the peer.
|
InetAddress |
getInetAddress()
Returns the address or null if no address set
|
byte[] |
getSocketAddress() |
int |
getSocketAddress(byte[] me,
int offset) |
int |
getSocketAddressSize() |
int |
hashCode() |
boolean |
isFirewalledTCP() |
static boolean |
isFirewalledTCP(int type) |
boolean |
isFirewalledUDP() |
static boolean |
isFirewalledUDP(int type) |
static boolean |
isForward(int type) |
boolean |
isForwarded() |
boolean |
isIPv6() |
static boolean |
isNet6(int type) |
PeerAddress |
notFirewalledTCP() |
PeerAddress |
notFirewalledUDP() |
int |
offset()
When deserializeg, we need to know how much we deserialized from the
constructor call.
|
PeerAddress |
ports(int portUDP,
int portTCP) |
int |
portTCP() |
int |
portUDP() |
byte[] |
toByteArray()
Serializes to a new array with the proper size
|
int |
toByteArray(byte[] me,
int offset)
Serializes to an existing array.
|
String |
toString() |
public static final int SIZE_IP_SOCKv6
public static final int SIZE_IP_SOCKv4
public static final int SIZE_IPv6
public static final int SIZE_IPv4
public PeerAddress(byte[] me)
throws UnknownHostException
me - The serialized arrayUnknownHostException - Using InetXAddress.getByAddress creates this
exception.public PeerAddress(byte[] me,
int offset)
throws UnknownHostException
me - The serialized arrayoffset - the offset, where to startUnknownHostException - Using InetXAddress.getByAddress creates this
exception.public PeerAddress(byte[] peerAddress,
byte[] socketAddress)
throws UnknownHostException
UnknownHostExceptionpublic PeerAddress(Number160 id)
id - The id of the peerpublic PeerAddress(Number160 id, InetAddress address, int portTCP, int portUDP, boolean forwarded, boolean firewalledUDP, boolean firewalledTCP)
id - The id of the peeraddress - The address of the peer, how to reach this peerportTCP - The tcp port how to reach the peerportUDP - The udp port how to reach the peerpublic PeerAddress(Number160 id, InetAddress address, int portTCP, int portUDP)
public PeerAddress(Number160 id, InetSocketAddress inetSocketAddress)
public PeerAddress(Number160 id, PeerAddress parent)
public PeerAddress(Number160 id, InetAddress address, int portTCP, int portUDP, byte optionType)
public int offset()
public byte[] toByteArray()
public int toByteArray(byte[] me,
int offset)
me - The array where the result should be storedoffset - The offset where to start to save the result in the byte
arraypublic byte[] getSocketAddress()
public int getSocketAddress(byte[] me,
int offset)
public InetAddress getInetAddress()
public InetSocketAddress createSocketTCP()
public InetSocketAddress createSocketUDP()
public Number160 getID()
public byte createType()
public static boolean isNet6(int type)
public static boolean isForward(int type)
public static boolean isFirewalledTCP(int type)
public static boolean isFirewalledUDP(int type)
public static int expectedLength(int type)
public int compareTo(PeerAddress nodeAddress)
compareTo in interface Comparable<PeerAddress>public int portTCP()
public int portUDP()
public boolean isForwarded()
public boolean isFirewalledUDP()
public boolean isFirewalledTCP()
public boolean isIPv6()
public PeerAddress notFirewalledUDP()
public PeerAddress notFirewalledTCP()
public PeerAddress forward(InetAddress inetAddress)
public PeerAddress ports(int portUDP, int portTCP)
public int getSocketAddressSize()
Copyright © 2011. All Rights Reserved.