diff options
Diffstat (limited to 'src/com')
7 files changed, 59 insertions, 9 deletions
diff --git a/src/com/isode/stroke/filetransfer/SOCKS5BytestreamServerManager.java b/src/com/isode/stroke/filetransfer/SOCKS5BytestreamServerManager.java index 729193a..590ee60 100644 --- a/src/com/isode/stroke/filetransfer/SOCKS5BytestreamServerManager.java +++ b/src/com/isode/stroke/filetransfer/SOCKS5BytestreamServerManager.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012-2015 Isode Limited. + * Copyright (c) 2012-2016 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -176,7 +176,7 @@ public class SOCKS5BytestreamServerManager { int port; for (port = LISTEN_PORTS_BEGIN; port < LISTEN_PORTS_END; ++port) { logger_.fine("Trying to start server on port " + port + "\n"); - connectionServer = connectionServerFactory.createConnectionServer(new HostAddress("0.0.0.0"), port); + connectionServer = connectionServerFactory.createConnectionServer(new HostAddress("::"), port); ConnectionServer.Error error = connectionServer.tryStart(); if (error == null) { break; diff --git a/src/com/isode/stroke/network/Connection.java b/src/com/isode/stroke/network/Connection.java index b0e4799..ad01553 100644 --- a/src/com/isode/stroke/network/Connection.java +++ b/src/com/isode/stroke/network/Connection.java @@ -4,7 +4,7 @@ * See Documentation/Licenses/GPLv3.txt for more information. */ /* - * Copyright (c) 2010, Isode Limited, London, England. + * Copyright (c) 2010-2016, Isode Limited, London, England. * All rights reserved. */ package com.isode.stroke.network; @@ -33,6 +33,7 @@ public abstract class Connection { public abstract void write(SafeByteArray data); public abstract HostAddressPort getLocalAddress(); + public abstract HostAddressPort getRemoteAddress(); public final Signal1<Boolean /*error*/> onConnectFinished = new Signal1<Boolean>(); public final Signal1<Error> onDisconnected = new Signal1<Error>(); public final Signal1<SafeByteArray> onDataRead = new Signal1<SafeByteArray>(); diff --git a/src/com/isode/stroke/network/DummyConnection.java b/src/com/isode/stroke/network/DummyConnection.java index 51018ef..7cc302b 100644 --- a/src/com/isode/stroke/network/DummyConnection.java +++ b/src/com/isode/stroke/network/DummyConnection.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010 Isode Limited. + * Copyright (c) 2010-2016 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -58,8 +58,14 @@ public class DummyConnection extends Connection implements EventOwner { return localAddress; } - public Signal1<SafeByteArray> onDataSent = new Signal1<SafeByteArray>(); + @Override + public HostAddressPort getRemoteAddress() { + return remoteAddress; + } - public EventLoop eventLoop; - public HostAddressPort localAddress; + public Signal1<SafeByteArray> onDataSent = new Signal1<SafeByteArray>(); + + public EventLoop eventLoop; + public HostAddressPort localAddress = new HostAddressPort(); + public HostAddressPort remoteAddress = new HostAddressPort(); }
\ No newline at end of file diff --git a/src/com/isode/stroke/network/FakeConnection.java b/src/com/isode/stroke/network/FakeConnection.java index ebcf239..1ce5c7b 100644 --- a/src/com/isode/stroke/network/FakeConnection.java +++ b/src/com/isode/stroke/network/FakeConnection.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2014 Isode Limited. + * Copyright (c) 2010-2016 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -15,6 +15,7 @@ import com.isode.stroke.eventloop.EventOwner; import com.isode.stroke.eventloop.EventLoop; import com.isode.stroke.eventloop.Event; import com.isode.stroke.base.SafeByteArray; + import java.util.Vector; public class FakeConnection extends Connection { @@ -40,6 +41,11 @@ public class FakeConnection extends Connection { public HostAddressPort getLocalAddress() { return new HostAddressPort(); } + + @Override + public HostAddressPort getRemoteAddress() { + return new HostAddressPort(); + } public void setError(final Error e) { error = e; diff --git a/src/com/isode/stroke/network/JavaConnection.java b/src/com/isode/stroke/network/JavaConnection.java index 29e3633..745655f 100644 --- a/src/com/isode/stroke/network/JavaConnection.java +++ b/src/com/isode/stroke/network/JavaConnection.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2015, Isode Limited, London, England. + * Copyright (c) 2010-2016, Isode Limited, London, England. * All rights reserved. */ package com.isode.stroke.network; @@ -7,8 +7,10 @@ package com.isode.stroke.network; import java.io.IOException; import java.net.InetSocketAddress; import java.net.Socket; +import java.net.SocketAddress; import java.nio.ByteBuffer; import java.nio.channels.CancelledKeyException; +import java.nio.channels.ClosedChannelException; import java.nio.channels.ClosedSelectorException; import java.nio.channels.SelectionKey; import java.nio.channels.Selector; @@ -515,6 +517,31 @@ public class JavaConnection extends Connection implements EventOwner { } @Override + public HostAddressPort getRemoteAddress() { + if (socketChannel_ == null) { + return null; + } + SocketAddress remoteAddress; + try { + remoteAddress = socketChannel_.getRemoteAddress(); + } catch (ClosedChannelException e) { + return null; + } catch (IOException e) { + return null; + } + if (!(remoteAddress instanceof InetSocketAddress)) { + // SocketChannel.getRemoteAddress should return a + // InetSocketAddress if it is bound to an IP Socket + // Address so return null if it does not + return null; + } + InetSocketAddress remoteInetAddress = (InetSocketAddress) remoteAddress; + return new HostAddressPort( + new HostAddress(remoteInetAddress.getAddress()), + remoteInetAddress.getPort()); + } + + @Override public String toString() { return "JavaConnection " + diff --git a/src/com/isode/stroke/network/ProxiedConnection.java b/src/com/isode/stroke/network/ProxiedConnection.java index 6f4c044..5eac083 100644 --- a/src/com/isode/stroke/network/ProxiedConnection.java +++ b/src/com/isode/stroke/network/ProxiedConnection.java @@ -87,6 +87,11 @@ public abstract class ProxiedConnection extends Connection { public HostAddressPort getLocalAddress() { return connection_.getLocalAddress(); } + + @Override + public HostAddressPort getRemoteAddress() { + return connection_.getRemoteAddress(); + } private void handleConnectFinished(Connection connection) { cancelConnector(); diff --git a/src/com/isode/stroke/network/TLSConnection.java b/src/com/isode/stroke/network/TLSConnection.java index d64f88b..4e7f304 100644 --- a/src/com/isode/stroke/network/TLSConnection.java +++ b/src/com/isode/stroke/network/TLSConnection.java @@ -124,6 +124,11 @@ public class TLSConnection extends Connection { return connection.getLocalAddress(); } + @Override + public HostAddressPort getRemoteAddress() { + return connection.getRemoteAddress(); + } + public TLSContext getContext() { return context; } |