diff options
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" |