public class Peer extends java.lang.Object implements WritableToDataOutputStream
Modifier and Type | Class and Description |
---|---|
static class |
Peer.LocalAddressException |
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
VERSION |
Constructor and Description |
---|
Peer(java.io.DataInput dis) |
Peer(java.io.DataInput dis,
boolean checkHostnameOrIPSyntax) |
Peer(FreenetInetAddress addr,
int port) |
Peer(java.net.InetAddress address,
int port)
Create a Peer from an InetAddress and a port.
|
Peer(java.lang.String physical,
boolean allowUnknown)
Create a Peer from a string.
|
Peer(java.lang.String physical,
boolean allowUnknown,
boolean checkHostnameOrIPSyntax)
Create a Peer from a string.
|
Modifier and Type | Method and Description |
---|---|
Peer |
dropHostName() |
boolean |
equals(java.lang.Object o) |
java.net.InetAddress |
getAddress()
Get the IP address.
|
java.net.InetAddress |
getAddress(boolean doDNSRequest)
Get the IP address.
|
java.net.InetAddress |
getAddress(boolean doDNSRequest,
boolean allowLocal) |
FreenetInetAddress |
getFreenetAddress() |
java.net.InetAddress |
getHandshakeAddress()
Get the IP address, looking up the hostname if the hostname is primary, even if
it has been looked up before.
|
int |
getPort() |
int |
hashCode() |
boolean |
isIPv6(boolean defaultValue)
Is this peer using IPv6?
|
boolean |
isNull() |
boolean |
isRealInternetAddress(boolean lookup,
boolean defaultVal,
boolean allowLocalAddresses) |
boolean |
laxEquals(java.lang.Object o) |
boolean |
strictEquals(java.lang.Object o) |
java.lang.String |
toString() |
java.lang.String |
toStringPrefNumeric()
Get the address:port string, but prefer numeric IPs - don't return the name.
|
void |
writeToDataOutputStream(java.io.DataOutputStream dos) |
public static final java.lang.String VERSION
public Peer(java.io.DataInput dis) throws java.io.IOException
java.io.IOException
public Peer(java.io.DataInput dis, boolean checkHostnameOrIPSyntax) throws HostnameSyntaxException, java.io.IOException
HostnameSyntaxException
java.io.IOException
public Peer(java.net.InetAddress address, int port)
public Peer(java.lang.String physical, boolean allowUnknown) throws PeerParseException, java.net.UnknownHostException
physical
- The string to be parsed, in the format [ ip or domain name ]:[ port number].allowUnknown
- If true, allow construction of the Peer even if the domain name
lookup fails.PeerParseException
- If the string is not valid e.g. if it doesn't contain a
port.java.net.UnknownHostException
- If allowUnknown is not set, and a domain name which does
not exist was passed in.public Peer(java.lang.String physical, boolean allowUnknown, boolean checkHostnameOrIPSyntax) throws HostnameSyntaxException, PeerParseException, java.net.UnknownHostException
physical
- The string to be parsed, in the format [ ip or domain name ]:[ port number].allowUnknown
- If true, allow construction of the Peer even if the domain name
lookup fails.checkHostnameOrIPSyntax
- If true, validate the syntax of the given DNS hostname or IPv4
IP addressHostnameSyntaxException
- If the string is not formatted as a proper DNS hostname
or IPv4 IP addressPeerParseException
- If the string is not valid e.g. if it doesn't contain a
port.java.net.UnknownHostException
- If allowUnknown is not set, and a domain name which does
not exist was passed in.public Peer(FreenetInetAddress addr, int port)
public boolean isNull()
public boolean laxEquals(java.lang.Object o)
public boolean equals(java.lang.Object o)
equals
in class java.lang.Object
public boolean strictEquals(java.lang.Object o)
public java.net.InetAddress getAddress()
public java.net.InetAddress getAddress(boolean doDNSRequest)
public java.net.InetAddress getAddress(boolean doDNSRequest, boolean allowLocal) throws Peer.LocalAddressException
Peer.LocalAddressException
public java.net.InetAddress getHandshakeAddress()
public int hashCode()
hashCode
in class java.lang.Object
public int getPort()
public java.lang.String toString()
toString
in class java.lang.Object
public void writeToDataOutputStream(java.io.DataOutputStream dos) throws java.io.IOException
writeToDataOutputStream
in interface WritableToDataOutputStream
java.io.IOException
public FreenetInetAddress getFreenetAddress()
public boolean isRealInternetAddress(boolean lookup, boolean defaultVal, boolean allowLocalAddresses)
public java.lang.String toStringPrefNumeric()
public Peer dropHostName()
public boolean isIPv6(boolean defaultValue)