Added internal hostname reporting, documented other PeerNode methods.

git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@5834 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Michael Bayne
2009-06-22 22:05:06 +00:00
parent 55f66f01da
commit fcda0f3156
2 changed files with 34 additions and 0 deletions
@@ -523,6 +523,20 @@ public abstract class PeerManager
return (peer == null) ? null : peer.getPublicHostName();
}
/**
* Returns the internal hostname to use when connecting to the specified peer or null if the
* peer is not currently connected to this server. Peers connect to one another via their
* internal hostname. Do not publish this data to clients out on the Internets.
*/
public String getPeerInternalHostName (String nodeName)
{
if (_nodeName.equals(nodeName)) {
return _self.hostName;
}
PeerNode peer = _peers.get(nodeName);
return (peer == null) ? null : peer.getInternalHostName();
}
/**
* Returns the port on which to connect to the specified peer or -1 if the peer is not
* currently connected to this server.
@@ -86,21 +86,41 @@ public class PeerNode
_client.addClientObserver(this);
}
/**
* Returns the {@link Client} instance that manages our connection to this peer.
*/
public Client getClient ()
{
return _client;
}
/**
* Returns this peer's unique string identifier.
*/
public String getNodeName ()
{
return _record.nodeName;
}
/**
* Returns the hostname for external clients to use when connecting to this peer.
*/
public String getPublicHostName ()
{
return _record.publicHostName;
}
/**
* Returns the hostname for internal clients to use when connecting to this peer.
*/
public String getInternalHostName ()
{
return _record.hostName;
}
/**
* Returns the port on which to connect to this peer.
*/
public int getPort ()
{
return _record.port;