public final class PeerAddress extends Object implements Comparable<PeerAddress>, Serializable
Modifier and Type | Field and Description |
---|---|
static PeerAddress |
EMPTY_IPv4 |
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 right size.
|
PeerAddress(byte[] peerAddress,
byte[] socketAddress)
The format of the peer address can also be split.
|
PeerAddress(byte[] me,
int offset)
Creates a PeerAddress from a continuous byte array.
|
PeerAddress(Number160 id)
If you only need to know the id
|
PeerAddress(Number160 id,
byte[] me,
int offset) |
PeerAddress(Number160 id,
org.jboss.netty.buffer.ChannelBuffer channelBuffer) |
PeerAddress(Number160 id,
InetAddress address)
If you only need to know the id and InetAddress
|
PeerAddress(Number160 id,
InetAddress address,
int portTCP,
int portUDP) |
PeerAddress(Number160 id,
InetAddress address,
int portTCP,
int portUDP,
boolean firewalledUDP,
boolean firewalledTCP)
Creates a PeerAddress
|
PeerAddress(Number160 id,
InetAddress address,
int portTCP,
int portUDP,
int options) |
PeerAddress(Number160 id,
InetSocketAddress inetSocketAddress) |
PeerAddress(Number160 id,
PeerAddress parent) |
PeerAddress(Number160 id,
String address,
int portTCP,
int portUDP) |
Modifier and Type | Method and Description |
---|---|
PeerAddress |
changeAddress(InetAddress address) |
PeerAddress |
changeFirewalledTCP(boolean status) |
PeerAddress |
changeFirewalledUDP(boolean status) |
PeerAddress |
changePeerId(Number160 id2) |
PeerAddress |
changePorts(int portUDP,
int portTCP) |
int |
compareTo(PeerAddress nodeAddress) |
InetSocketAddress |
createSocketTCP()
Returns the socket address.
|
InetSocketAddress |
createSocketUDP()
Returns the socket address.
|
boolean |
equals(Object obj) |
int |
expectedLength() |
static int |
expectedLength(int options) |
static int |
expectedSocketLength(int options) |
Number160 |
getID()
The id of the peer.
|
InetAddress |
getInetAddress()
Returns the address or null if no address set
|
byte |
getOptions() |
int |
getSocketAddressSize() |
int |
hashCode() |
boolean |
isFirewalledTCP() |
static boolean |
isFirewalledTCP(int options) |
boolean |
isFirewalledUDP() |
static boolean |
isFirewalledUDP(int options) |
boolean |
isIPv4() |
boolean |
isIPv6() |
static boolean |
isNet6(int options) |
int |
offset()
When deserializing, we need to know how much we deserialized from the
constructor call.
|
int |
portTCP() |
int |
portUDP() |
int |
readBytes() |
byte[] |
toByteArray()
Serializes to a new array with the proper size
|
int |
toByteArray(byte[] me,
int offset)
Serializes to an existing array.
|
byte[] |
toByteArraySocketAddress() |
int |
toByteArraySocketAddress(byte[] me,
int offset) |
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 static final PeerAddress EMPTY_IPv4
public PeerAddress(byte[] me)
me
- The serialized arrayUnknownHostException
- Using InetXAddress.getByAddress creates this exception.public PeerAddress(byte[] me, int offset)
me
- The serialized arrayoffset
- the offset, where to startUnknownHostException
- Using InetXAddress.getByAddress creates this exception.public PeerAddress(Number160 id, org.jboss.netty.buffer.ChannelBuffer channelBuffer)
public PeerAddress(Number160 id, byte[] me, int offset)
public PeerAddress(byte[] peerAddress, byte[] socketAddress)
peerAddress
- The 160bit number for the peer IDsocketAddress
- The socket address with type port and IPUnknownHostException
public PeerAddress(Number160 id)
id
- The id of the peerpublic PeerAddress(Number160 id, InetAddress address)
id
- The id of the peeraddress
- The InetAddress of the peerpublic PeerAddress(Number160 id, InetAddress address, int portTCP, int portUDP, 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, String address, int portTCP, int portUDP) throws UnknownHostException
UnknownHostException
public PeerAddress(Number160 id, InetSocketAddress inetSocketAddress)
public PeerAddress(Number160 id, PeerAddress parent)
public PeerAddress(Number160 id, InetAddress address, int portTCP, int portUDP, int options)
public int offset()
public int readBytes()
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[] toByteArraySocketAddress()
public int toByteArraySocketAddress(byte[] me, int offset)
public InetAddress getInetAddress()
public InetSocketAddress createSocketTCP()
public InetSocketAddress createSocketUDP()
public Number160 getID()
public byte getOptions()
public static boolean isNet6(int options)
public static boolean isFirewalledTCP(int options)
public static boolean isFirewalledUDP(int options)
public static int expectedLength(int options)
public static int expectedSocketLength(int options)
public int expectedLength()
public int compareTo(PeerAddress nodeAddress)
compareTo
in interface Comparable<PeerAddress>
public int portTCP()
public int portUDP()
public boolean isFirewalledUDP()
public boolean isFirewalledTCP()
public boolean isIPv6()
public boolean isIPv4()
public PeerAddress changeFirewalledUDP(boolean status)
public PeerAddress changeFirewalledTCP(boolean status)
public PeerAddress changePorts(int portUDP, int portTCP)
public PeerAddress changeAddress(InetAddress address)
public PeerAddress changePeerId(Number160 id2)
public int getSocketAddressSize()
Copyright © 2013. All Rights Reserved.