public Peer dropHostName() { FreenetInetAddress newAddr = addr.dropHostname(); if (newAddr == null) return null; if (addr != newAddr) { return new Peer(newAddr, _port); } else return this; }
public InetAddress getAddress(boolean doDNSRequest, boolean allowLocal) throws LocalAddressException { InetAddress a = addr.getAddress(doDNSRequest); if (a == null) return null; if (allowLocal || IPUtil.isValidAddress(a, false)) return a; throw new LocalAddressException(); }
// FIXME same issues as with FreenetInetAddress.laxEquals/equals/strictEquals public boolean laxEquals(Object o) { if (this == o) { return true; } if (!(o instanceof Peer)) { return false; } final Peer peer = (Peer) o; if (_port != peer._port) { return false; } if (!addr.laxEquals(peer.addr)) return false; return true; }
/** Get the address:port string, but prefer numeric IPs - don't return the name. */ public String toStringPrefNumeric() { return addr.toStringPrefNumeric() + ':' + _port; }
public boolean isRealInternetAddress( boolean lookup, boolean defaultVal, boolean allowLocalAddresses) { return addr.isRealInternetAddress(lookup, defaultVal, allowLocalAddresses); }
@Override public void writeToDataOutputStream(DataOutputStream dos) throws IOException { addr.writeToDataOutputStream(dos); dos.writeInt(_port); }
@Override public String toString() { return addr.toString() + ':' + _port; }
@Override public int hashCode() { return addr.hashCode() + _port; }
/** * Get the IP address, looking up the hostname if the hostname is primary, even if it has been * looked up before. Typically called on a reconnect attempt, when the dyndns address may have * changed. */ public InetAddress getHandshakeAddress() { return addr.getHandshakeAddress(); }
/** * Get the IP address. Look it up if allowed to, but return the last value if it has ever been * looked up before; will not trigger a new lookup if it has been looked up before. */ public InetAddress getAddress(boolean doDNSRequest) { return addr.getAddress(doDNSRequest); }