diff options
author | Brian Hinz <bphinz@users.sourceforge.net> | 2012-04-26 00:03:16 +0000 |
---|---|---|
committer | Brian Hinz <bphinz@users.sourceforge.net> | 2012-04-26 00:03:16 +0000 |
commit | 9dd057bb0f981c65a372ee4346bc0bb034d01d24 (patch) | |
tree | 262f0fb65cddce79712a710eb6cb3e7c6b5241f1 /java/com | |
parent | 5be8fa01edeb1e09a60cedcc400f48cea97f497b (diff) | |
download | tigervnc-9dd057bb0f981c65a372ee4346bc0bb034d01d24.tar.gz tigervnc-9dd057bb0f981c65a372ee4346bc0bb034d01d24.zip |
Fix Socket methods for querying the socket endpoints. Fix the address displayed in the info dialog for redirected connections.
git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@4902 3789f03b-4d11-0410-bbf8-ca57d06f2519
Diffstat (limited to 'java/com')
-rw-r--r-- | java/com/tigervnc/network/Socket.java | 1 | ||||
-rw-r--r-- | java/com/tigervnc/network/TcpSocket.java | 15 | ||||
-rw-r--r-- | java/com/tigervnc/vncviewer/CConn.java | 2 |
3 files changed, 13 insertions, 5 deletions
diff --git a/java/com/tigervnc/network/Socket.java b/java/com/tigervnc/network/Socket.java index bc0af5cb..0fadad4a 100644 --- a/java/com/tigervnc/network/Socket.java +++ b/java/com/tigervnc/network/Socket.java @@ -51,6 +51,7 @@ abstract public class Socket { // information about the remote end of the socket abstract public String getPeerAddress(); // a string e.g. "192.168.0.1" + abstract public String getPeerName(); abstract public int getPeerPort(); abstract public String getPeerEndpoint(); // <address>::<port> diff --git a/java/com/tigervnc/network/TcpSocket.java b/java/com/tigervnc/network/TcpSocket.java index 9672fe5e..c4c1a8cf 100644 --- a/java/com/tigervnc/network/TcpSocket.java +++ b/java/com/tigervnc/network/TcpSocket.java @@ -118,15 +118,22 @@ public class TcpSocket extends Socket { } public String getPeerAddress() { - SocketAddress peer = ((SocketDescriptor)getFd()).socket().getRemoteSocketAddress(); + InetAddress peer = ((SocketDescriptor)getFd()).socket().getInetAddress(); if (peer != null) - return peer.toString(); + return peer.getHostAddress(); + return ""; + } + + public String getPeerName() { + InetAddress peer = ((SocketDescriptor)getFd()).socket().getInetAddress(); + if (peer != null) + return peer.getHostName(); return ""; } public int getPeerPort() { - SocketAddress address = ((SocketDescriptor)getFd()).socket().getRemoteSocketAddress(); - return ((InetSocketAddress)address).getPort(); + int port = ((SocketDescriptor)getFd()).socket().getPort(); + return port; } public String getPeerEndpoint() { diff --git a/java/com/tigervnc/vncviewer/CConn.java b/java/com/tigervnc/vncviewer/CConn.java index 714dff04..8c950178 100644 --- a/java/com/tigervnc/vncviewer/CConn.java +++ b/java/com/tigervnc/vncviewer/CConn.java @@ -821,7 +821,7 @@ public class CConn extends CConnection void showInfo() { JOptionPane.showMessageDialog(viewport, "Desktop name: "+cp.name()+"\n" - +"Host: "+serverHost+":"+serverPort+"\n" + +"Host: "+sock.getPeerName()+":"+sock.getPeerPort()+"\n" +"Size: "+cp.width+"x"+cp.height+"\n" +"Pixel format: "+desktop.getPF().print()+"\n" +"(server default "+serverPF.print()+")\n" |