You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mina.apache.org by lg...@apache.org on 2018/02/07 07:58:29 UTC
[1/5] mina-sshd git commit: [SSHD-795] IOException (Broken pipe) on a
socket local forwarding channel causes SSH client-server connection down
Repository: mina-sshd
Updated Branches:
refs/heads/master 0cb36d988 -> a04eaf4fa
[SSHD-795] IOException (Broken pipe) on a socket local forwarding channel causes SSH client-server connection down
Project: http://git-wip-us.apache.org/repos/asf/mina-sshd/repo
Commit: http://git-wip-us.apache.org/repos/asf/mina-sshd/commit/a04eaf4f
Tree: http://git-wip-us.apache.org/repos/asf/mina-sshd/tree/a04eaf4f
Diff: http://git-wip-us.apache.org/repos/asf/mina-sshd/diff/a04eaf4f
Branch: refs/heads/master
Commit: a04eaf4fac94846a6703d1d38f50308381138419
Parents: 09dec8a
Author: Goldstein Lyor <ly...@c-b4.com>
Authored: Sun Feb 4 16:38:36 2018 +0200
Committer: Goldstein Lyor <ly...@c-b4.com>
Committed: Wed Feb 7 09:41:25 2018 +0200
----------------------------------------------------------------------
.../keyverifier/StaticServerKeyVerifier.java | 1 -
.../sshd/server/forward/TcpipServerChannel.java | 18 +++++++++++-------
2 files changed, 11 insertions(+), 8 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/a04eaf4f/sshd-core/src/main/java/org/apache/sshd/client/keyverifier/StaticServerKeyVerifier.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/client/keyverifier/StaticServerKeyVerifier.java b/sshd-core/src/main/java/org/apache/sshd/client/keyverifier/StaticServerKeyVerifier.java
index 60262bf..55ef4d9 100644
--- a/sshd-core/src/main/java/org/apache/sshd/client/keyverifier/StaticServerKeyVerifier.java
+++ b/sshd-core/src/main/java/org/apache/sshd/client/keyverifier/StaticServerKeyVerifier.java
@@ -66,5 +66,4 @@ public abstract class StaticServerKeyVerifier extends AbstractLoggingBean implem
remoteAddress, (serverKey == null) ? null : serverKey.getAlgorithm(), KeyUtils.getFingerPrint(serverKey));
}
}
-
}
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/a04eaf4f/sshd-core/src/main/java/org/apache/sshd/server/forward/TcpipServerChannel.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/server/forward/TcpipServerChannel.java b/sshd-core/src/main/java/org/apache/sshd/server/forward/TcpipServerChannel.java
index 8e1c268..da33d51 100644
--- a/sshd-core/src/main/java/org/apache/sshd/server/forward/TcpipServerChannel.java
+++ b/sshd-core/src/main/java/org/apache/sshd/server/forward/TcpipServerChannel.java
@@ -331,24 +331,28 @@ public class TcpipServerChannel extends AbstractServerChannel {
}
protected void handleWriteDataFailure(byte cmd, byte[] data, int off, int len, Throwable t) {
- Session session = getSession();
- if (log.isDebugEnabled()) {
+ boolean debugEnabled = log.isDebugEnabled();
+ if (debugEnabled) {
log.debug("handleWriteDataFailure({})[{}] failed ({}) to write len={}: {}",
this, SshConstants.getCommandMessageName(cmd & 0xFF),
t.getClass().getSimpleName(), len, t.getMessage());
}
if (log.isTraceEnabled()) {
- log.trace("doWriteData(" + this + ")[" + SshConstants.getCommandMessageName(cmd & 0xFF) + "]"
+ log.trace("handleWriteDataFailure(" + this + ")[" + SshConstants.getCommandMessageName(cmd & 0xFF) + "]"
+ " len=" + len + " write failure details", t);
}
if (ioSession.isOpen()) {
- session.exceptionCaught(t);
+ // SSHD-795 IOException (Broken pipe) on a socket local forwarding channel causes SSH client-server connection down
+ if (debugEnabled) {
+ log.debug("handleWriteDataFailure({})[{}] closing session={}",
+ this, SshConstants.getCommandMessageName(cmd & 0xFF), ioSession);
+ }
+ close(false);
} else {
- // In case remote entity has closed the socket (the ioSession), data coming from
- // the SSH channel should be simply discarded
- if (log.isDebugEnabled()) {
+ // In case remote entity has closed the socket (the ioSession), data coming from the SSH channel should be simply discarded
+ if (debugEnabled) {
log.debug("Ignoring writeDataFailure {} because ioSession {} is already closing ", t, ioSession);
}
}
[2/5] mina-sshd git commit: [SSHD-801] Close TcpipServerChannel
gracefully if exception signalled and IOSession is open
Posted by lg...@apache.org.
[SSHD-801] Close TcpipServerChannel gracefully if exception signalled and IOSession is open
Project: http://git-wip-us.apache.org/repos/asf/mina-sshd/repo
Commit: http://git-wip-us.apache.org/repos/asf/mina-sshd/commit/e077dae6
Tree: http://git-wip-us.apache.org/repos/asf/mina-sshd/tree/e077dae6
Diff: http://git-wip-us.apache.org/repos/asf/mina-sshd/diff/e077dae6
Branch: refs/heads/master
Commit: e077dae67546443a66aa4b101f88de3face5b872
Parents: 17331a8
Author: Goldstein Lyor <ly...@c-b4.com>
Authored: Sun Feb 4 16:21:18 2018 +0200
Committer: Goldstein Lyor <ly...@c-b4.com>
Committed: Wed Feb 7 09:41:25 2018 +0200
----------------------------------------------------------------------
.../apache/sshd/server/forward/TcpipServerChannel.java | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/e077dae6/sshd-core/src/main/java/org/apache/sshd/server/forward/TcpipServerChannel.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/server/forward/TcpipServerChannel.java b/sshd-core/src/main/java/org/apache/sshd/server/forward/TcpipServerChannel.java
index b333170..2c16478 100644
--- a/sshd-core/src/main/java/org/apache/sshd/server/forward/TcpipServerChannel.java
+++ b/sshd-core/src/main/java/org/apache/sshd/server/forward/TcpipServerChannel.java
@@ -158,8 +158,8 @@ public class TcpipServerChannel extends AbstractServerChannel {
// TODO: revisit for better threading. Use async io ?
out = new ChannelOutputStream(this, getRemoteWindow(), log, SshConstants.SSH_MSG_CHANNEL_DATA, true);
IoHandler handler = new IoHandler() {
- @SuppressWarnings("synthetic-access")
@Override
+ @SuppressWarnings("synthetic-access")
public void messageReceived(IoSession session, Readable message) throws Exception {
if (isClosing()) {
if (log.isDebugEnabled()) {
@@ -184,8 +184,14 @@ public class TcpipServerChannel extends AbstractServerChannel {
}
@Override
+ @SuppressWarnings("synthetic-access")
public void exceptionCaught(IoSession session, Throwable cause) throws Exception {
- close(true);
+ boolean immediately = !session.isOpen();
+ if (log.isDebugEnabled()) {
+ log.debug("exceptionCaught({}) signal close immediately={} due to {}[{}]",
+ TcpipServerChannel.this, immediately, cause.getClass().getSimpleName(), cause.getMessage());
+ }
+ close(immediately);
}
};
[4/5] mina-sshd git commit: [SSHD-799] Send
SSH_MSG_CHANNEL_OPEN_FAILURE if failed to open port forwarding connection
Posted by lg...@apache.org.
[SSHD-799] Send SSH_MSG_CHANNEL_OPEN_FAILURE if failed to open port forwarding connection
Project: http://git-wip-us.apache.org/repos/asf/mina-sshd/repo
Commit: http://git-wip-us.apache.org/repos/asf/mina-sshd/commit/09dec8af
Tree: http://git-wip-us.apache.org/repos/asf/mina-sshd/tree/09dec8af
Diff: http://git-wip-us.apache.org/repos/asf/mina-sshd/diff/09dec8af
Branch: refs/heads/master
Commit: 09dec8af44e8081b42f85453ea87ce26d27c0ded
Parents: e077dae
Author: Goldstein Lyor <ly...@c-b4.com>
Authored: Sun Feb 4 16:31:56 2018 +0200
Committer: Goldstein Lyor <ly...@c-b4.com>
Committed: Wed Feb 7 09:41:25 2018 +0200
----------------------------------------------------------------------
.../helpers/AbstractConnectionService.java | 13 +++++++-----
.../sshd/server/forward/TcpipServerChannel.java | 21 ++++++++++++--------
2 files changed, 21 insertions(+), 13 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/09dec8af/sshd-core/src/main/java/org/apache/sshd/common/session/helpers/AbstractConnectionService.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/session/helpers/AbstractConnectionService.java b/sshd-core/src/main/java/org/apache/sshd/common/session/helpers/AbstractConnectionService.java
index 262ba9d..68bf8db 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/session/helpers/AbstractConnectionService.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/session/helpers/AbstractConnectionService.java
@@ -639,19 +639,22 @@ public abstract class AbstractConnectionService<S extends AbstractSession>
buf.putInt(window.getPacketSize());
session.writePacket(buf);
} else {
+ int reasonCode = 0;
+ String message = "Generic error while opening channel: " + channelId;
Throwable exception = future.getException();
if (exception != null) {
- String message = exception.getMessage();
- int reasonCode = 0;
if (exception instanceof SshChannelOpenException) {
reasonCode = ((SshChannelOpenException) exception).getReasonCode();
} else {
message = exception.getClass().getSimpleName() + " while opening channel: " + message;
}
-
- Buffer buf = session.createBuffer(SshConstants.SSH_MSG_CHANNEL_OPEN_FAILURE, message.length() + Long.SIZE);
- sendChannelOpenFailure(buf, sender, reasonCode, message, "");
+ } else {
+ log.warn("operationComplete({}) no exception on closed future={}",
+ AbstractConnectionService.this, future);
}
+
+ Buffer buf = session.createBuffer(SshConstants.SSH_MSG_CHANNEL_OPEN_FAILURE, message.length() + Long.SIZE);
+ sendChannelOpenFailure(buf, sender, reasonCode, message, "");
}
} catch (IOException e) {
if (log.isDebugEnabled()) {
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/09dec8af/sshd-core/src/main/java/org/apache/sshd/server/forward/TcpipServerChannel.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/server/forward/TcpipServerChannel.java b/sshd-core/src/main/java/org/apache/sshd/server/forward/TcpipServerChannel.java
index 2c16478..8e1c268 100644
--- a/sshd-core/src/main/java/org/apache/sshd/server/forward/TcpipServerChannel.java
+++ b/sshd-core/src/main/java/org/apache/sshd/server/forward/TcpipServerChannel.java
@@ -142,8 +142,11 @@ public class TcpipServerChannel extends AbstractServerChannel {
if (log.isDebugEnabled()) {
log.debug("doInit(" + this + ")[" + type + "][haveFilter=" + (filter != null) + "] filtered out " + address);
}
- super.close(true);
- f.setException(new SshChannelOpenException(getId(), SshConstants.SSH_OPEN_ADMINISTRATIVELY_PROHIBITED, "Connection denied"));
+ try {
+ f.setException(new SshChannelOpenException(getId(), SshConstants.SSH_OPEN_ADMINISTRATIVELY_PROHIBITED, "Connection denied"));
+ } finally {
+ super.close(true);
+ }
return f;
}
} catch (Error e) {
@@ -244,12 +247,14 @@ public class TcpipServerChannel extends AbstractServerChannel {
protected void handleChannelOpenFailure(OpenFuture f, Throwable problem) {
signalChannelOpenFailure(problem);
notifyStateChanged(problem.getClass().getSimpleName());
- close(true);
-
- if (problem instanceof ConnectException) {
- f.setException(new SshChannelOpenException(getId(), SshConstants.SSH_OPEN_CONNECT_FAILED, problem.getMessage(), problem));
- } else {
- f.setException(problem);
+ try {
+ if (problem instanceof ConnectException) {
+ f.setException(new SshChannelOpenException(getId(), SshConstants.SSH_OPEN_CONNECT_FAILED, problem.getMessage(), problem));
+ } else {
+ f.setException(problem);
+ }
+ } finally {
+ close(true);
}
}
[5/5] mina-sshd git commit: [SSHD-801] Expose channel type
information via public methods
Posted by lg...@apache.org.
[SSHD-801] Expose channel type information via public methods
Project: http://git-wip-us.apache.org/repos/asf/mina-sshd/repo
Commit: http://git-wip-us.apache.org/repos/asf/mina-sshd/commit/17331a8f
Tree: http://git-wip-us.apache.org/repos/asf/mina-sshd/tree/17331a8f
Diff: http://git-wip-us.apache.org/repos/asf/mina-sshd/diff/17331a8f
Branch: refs/heads/master
Commit: 17331a8fc5efe91b2918ad97beded8dcbd7a116c
Parents: ad35d53
Author: Goldstein Lyor <ly...@c-b4.com>
Authored: Sun Feb 4 09:37:54 2018 +0200
Committer: Goldstein Lyor <ly...@c-b4.com>
Committed: Wed Feb 7 09:41:25 2018 +0200
----------------------------------------------------------------------
.../client/channel/AbstractClientChannel.java | 11 ++++-
.../sshd/client/channel/ChannelDirectTcpip.java | 3 +-
.../sshd/client/channel/ClientChannel.java | 5 +++
.../common/forward/DefaultForwardingFilter.java | 2 +-
.../sshd/common/forward/TcpipClientChannel.java | 47 +++++++++++++++-----
.../sshd/server/forward/TcpipServerChannel.java | 27 ++++++-----
.../sshd/server/x11/ChannelForwardedX11.java | 3 +-
7 files changed, 71 insertions(+), 27 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/17331a8f/sshd-core/src/main/java/org/apache/sshd/client/channel/AbstractClientChannel.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/client/channel/AbstractClientChannel.java b/sshd-core/src/main/java/org/apache/sshd/client/channel/AbstractClientChannel.java
index 437a87a..59a3d73 100644
--- a/sshd-core/src/main/java/org/apache/sshd/client/channel/AbstractClientChannel.java
+++ b/sshd-core/src/main/java/org/apache/sshd/client/channel/AbstractClientChannel.java
@@ -62,7 +62,6 @@ import org.apache.sshd.common.util.io.IoUtils;
public abstract class AbstractClientChannel extends AbstractChannel implements ClientChannel {
protected final AtomicBoolean opened = new AtomicBoolean();
- protected final String type;
protected Streaming streaming;
@@ -83,13 +82,15 @@ public abstract class AbstractClientChannel extends AbstractChannel implements C
protected String openFailureLang;
protected OpenFuture openFuture;
+ private final String channelType;
+
protected AbstractClientChannel(String type) {
this(type, Collections.emptyList());
}
protected AbstractClientChannel(String type, Collection<? extends RequestHandler<Channel>> handlers) {
super(true, handlers);
- this.type = ValidateUtils.checkNotNullAndNotEmpty(type, "No channel type specified");
+ this.channelType = ValidateUtils.checkNotNullAndNotEmpty(type, "No channel type specified");
this.streaming = Streaming.Sync;
addChannelSignalRequestHandlers(event -> {
@@ -106,6 +107,11 @@ public abstract class AbstractClientChannel extends AbstractChannel implements C
}
@Override
+ public String getChannelType() {
+ return channelType;
+ }
+
+ @Override
public Streaming getStreaming() {
return streaming;
}
@@ -299,6 +305,7 @@ public abstract class AbstractClientChannel extends AbstractChannel implements C
}
openFuture = new DefaultOpenFuture(this.toString(), lock);
+ String type = getChannelType();
if (log.isDebugEnabled()) {
log.debug("open({}) Send SSH_MSG_CHANNEL_OPEN - type={}", this, type);
}
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/17331a8f/sshd-core/src/main/java/org/apache/sshd/client/channel/ChannelDirectTcpip.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/client/channel/ChannelDirectTcpip.java b/sshd-core/src/main/java/org/apache/sshd/client/channel/ChannelDirectTcpip.java
index 4ecfbf4..b37cef0 100644
--- a/sshd-core/src/main/java/org/apache/sshd/client/channel/ChannelDirectTcpip.java
+++ b/sshd-core/src/main/java/org/apache/sshd/client/channel/ChannelDirectTcpip.java
@@ -79,8 +79,9 @@ public class ChannelDirectTcpip extends AbstractClientChannel {
String remoteName = remote.getHostName();
String localName = local.getHostName();
Window wLocal = getLocalWindow();
+ String type = getChannelType();
Buffer buffer = session.createBuffer(SshConstants.SSH_MSG_CHANNEL_OPEN,
- type.length() + remoteName.length() + localName.length() + Long.SIZE);
+ type.length() + remoteName.length() + localName.length() + Long.SIZE);
buffer.putString(type);
buffer.putInt(getId());
buffer.putInt(wLocal.getSize());
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/17331a8f/sshd-core/src/main/java/org/apache/sshd/client/channel/ClientChannel.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/client/channel/ClientChannel.java b/sshd-core/src/main/java/org/apache/sshd/client/channel/ClientChannel.java
index 6da4a4f..286baeb 100644
--- a/sshd-core/src/main/java/org/apache/sshd/client/channel/ClientChannel.java
+++ b/sshd-core/src/main/java/org/apache/sshd/client/channel/ClientChannel.java
@@ -45,6 +45,11 @@ public interface ClientChannel extends Channel {
Sync
}
+ /**
+ * @return The type of channel reported when it was created
+ */
+ String getChannelType();
+
Streaming getStreaming();
void setStreaming(Streaming streaming);
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/17331a8f/sshd-core/src/main/java/org/apache/sshd/common/forward/DefaultForwardingFilter.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/forward/DefaultForwardingFilter.java b/sshd-core/src/main/java/org/apache/sshd/common/forward/DefaultForwardingFilter.java
index 1017f64..a6f46fa 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/forward/DefaultForwardingFilter.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/forward/DefaultForwardingFilter.java
@@ -934,7 +934,7 @@ public class DefaultForwardingFilter
log.debug("sessionCreated({}) remote={}", session, remote);
}
- final TcpipClientChannel channel;
+ TcpipClientChannel channel;
if (remote != null) {
channel = new TcpipClientChannel(TcpipClientChannel.Type.Direct, session, remote);
} else {
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/17331a8f/sshd-core/src/main/java/org/apache/sshd/common/forward/TcpipClientChannel.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/forward/TcpipClientChannel.java b/sshd-core/src/main/java/org/apache/sshd/common/forward/TcpipClientChannel.java
index f55dca1..9c19a9d 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/forward/TcpipClientChannel.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/forward/TcpipClientChannel.java
@@ -21,11 +21,16 @@ package org.apache.sshd.common.forward;
import java.io.IOException;
import java.net.InetAddress;
import java.net.InetSocketAddress;
+import java.util.Collections;
+import java.util.EnumSet;
+import java.util.Objects;
+import java.util.Set;
import org.apache.sshd.client.channel.AbstractClientChannel;
import org.apache.sshd.client.future.DefaultOpenFuture;
import org.apache.sshd.client.future.OpenFuture;
import org.apache.sshd.common.Closeable;
+import org.apache.sshd.common.NamedResource;
import org.apache.sshd.common.SshConstants;
import org.apache.sshd.common.SshException;
import org.apache.sshd.common.channel.ChannelOutputStream;
@@ -43,13 +48,27 @@ import org.apache.sshd.common.util.net.SshdSocketAddress;
* @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
*/
public class TcpipClientChannel extends AbstractClientChannel {
-
/**
- * Type of channel being created
+ * Type of channel being created. The type's {@link #getName()}
+ * method returns the SSH request type
*/
- public enum Type {
- Direct,
- Forwarded
+ public enum Type implements NamedResource {
+ Direct("direct-tcpip"),
+ Forwarded("forwarded-tcpip");
+
+ public static final Set<Type> VALUES =
+ Collections.unmodifiableSet(EnumSet.allOf(Type.class));
+
+ private final String channelType;
+
+ Type(String channelType) {
+ this.channelType = channelType;
+ }
+
+ @Override
+ public String getName() {
+ return channelType;
+ }
}
private final Type typeEnum;
@@ -57,9 +76,9 @@ public class TcpipClientChannel extends AbstractClientChannel {
private final SshdSocketAddress remote;
public TcpipClientChannel(Type type, IoSession serverSession, SshdSocketAddress remote) {
- super(type == Type.Direct ? "direct-tcpip" : "forwarded-tcpip");
+ super(Objects.requireNonNull(type, "No type specified").getName());
this.typeEnum = type;
- this.serverSession = serverSession;
+ this.serverSession = Objects.requireNonNull(serverSession, "No server session provided");
this.remote = remote;
}
@@ -67,11 +86,16 @@ public class TcpipClientChannel extends AbstractClientChannel {
return openFuture;
}
+ public Type getTcpipChannelType() {
+ return typeEnum;
+ }
+
@Override
public synchronized OpenFuture open() throws IOException {
InetSocketAddress src;
InetSocketAddress dst;
- switch (typeEnum) {
+ Type openType = getTcpipChannelType();
+ switch (openType) {
case Direct:
src = (InetSocketAddress) serverSession.getRemoteAddress();
dst = this.remote.toInetSocketAddress();
@@ -81,7 +105,7 @@ public class TcpipClientChannel extends AbstractClientChannel {
dst = (InetSocketAddress) serverSession.getLocalAddress();
break;
default:
- throw new SshException("Unknown client channel type: " + typeEnum);
+ throw new SshException("Unknown client channel type: " + openType);
}
if (closeFuture.isClosed()) {
@@ -99,8 +123,9 @@ public class TcpipClientChannel extends AbstractClientChannel {
InetAddress dstAddress = dst.getAddress();
String dstHost = dstAddress.getHostAddress();
Window wLocal = getLocalWindow();
+ String type = getChannelType();
Buffer buffer = session.createBuffer(SshConstants.SSH_MSG_CHANNEL_OPEN,
- type.length() + srcHost.length() + dstHost.length() + Long.SIZE);
+ type.length() + srcHost.length() + dstHost.length() + Long.SIZE);
buffer.putString(type);
buffer.putInt(getId());
buffer.putInt(wLocal.getSize());
@@ -139,6 +164,6 @@ public class TcpipClientChannel extends AbstractClientChannel {
@Override
protected void doWriteExtendedData(byte[] data, int off, long len) throws IOException {
- throw new UnsupportedOperationException(type + "Tcpip channel does not support extended data");
+ throw new UnsupportedOperationException(getChannelType() + "Tcpip channel does not support extended data");
}
}
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/17331a8f/sshd-core/src/main/java/org/apache/sshd/server/forward/TcpipServerChannel.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/server/forward/TcpipServerChannel.java b/sshd-core/src/main/java/org/apache/sshd/server/forward/TcpipServerChannel.java
index 8b8d201..b333170 100644
--- a/sshd-core/src/main/java/org/apache/sshd/server/forward/TcpipServerChannel.java
+++ b/sshd-core/src/main/java/org/apache/sshd/server/forward/TcpipServerChannel.java
@@ -39,6 +39,7 @@ import org.apache.sshd.common.future.CloseFuture;
import org.apache.sshd.common.io.IoConnectFuture;
import org.apache.sshd.common.io.IoConnector;
import org.apache.sshd.common.io.IoHandler;
+import org.apache.sshd.common.io.IoServiceFactory;
import org.apache.sshd.common.io.IoSession;
import org.apache.sshd.common.session.Session;
import org.apache.sshd.common.util.GenericUtils;
@@ -50,6 +51,7 @@ import org.apache.sshd.common.util.net.SshdSocketAddress;
import org.apache.sshd.common.util.threads.ExecutorServiceCarrier;
import org.apache.sshd.common.util.threads.ThreadUtils;
import org.apache.sshd.server.channel.AbstractServerChannel;
+import org.apache.sshd.server.forward.TcpForwardingFilter.Type;
/**
* TODO Add javadoc
@@ -98,10 +100,10 @@ public class TcpipServerChannel extends AbstractServerChannel {
private OutputStream out;
public TcpipServerChannel(ForwardingFilter.Type type) {
- this.type = type;
+ this.type = Objects.requireNonNull(type, "No channel type specified");
}
- public final ForwardingFilter.Type getChannelType() {
+ public ForwardingFilter.Type getTcpipChannelType() {
return type;
}
@@ -116,16 +118,19 @@ public class TcpipServerChannel extends AbstractServerChannel {
this, hostToConnect, portToConnect, originatorIpAddress, originatorPort);
}
- final SshdSocketAddress address;
+ SshdSocketAddress address;
+ Type channelType = getTcpipChannelType();
switch (type) {
case Direct:
address = new SshdSocketAddress(hostToConnect, portToConnect);
break;
- case Forwarded:
- address = service.getForwardingFilter().getForwardedPort(portToConnect);
+ case Forwarded: {
+ org.apache.sshd.common.forward.ForwardingFilter ff = service.getForwardingFilter();
+ address = ff.getForwardedPort(portToConnect);
break;
+ }
default:
- throw new IllegalStateException("Unknown server channel type: " + type);
+ throw new IllegalStateException("Unknown server channel type: " + channelType);
}
Session session = getSession();
@@ -133,7 +138,7 @@ public class TcpipServerChannel extends AbstractServerChannel {
TcpForwardingFilter filter = manager.getTcpForwardingFilter();
OpenFuture f = new DefaultOpenFuture(this, this);
try {
- if ((address == null) || (filter == null) || (!filter.canConnect(type, address, session))) {
+ if ((address == null) || (filter == null) || (!filter.canConnect(channelType, address, session))) {
if (log.isDebugEnabled()) {
log.debug("doInit(" + this + ")[" + type + "][haveFilter=" + (filter != null) + "] filtered out " + address);
}
@@ -143,7 +148,7 @@ public class TcpipServerChannel extends AbstractServerChannel {
}
} catch (Error e) {
log.warn("doInit({})[{}] failed ({}) to consult forwarding filter: {}",
- session, type, e.getClass().getSimpleName(), e.getMessage());
+ session, channelType, e.getClass().getSimpleName(), e.getMessage());
if (log.isDebugEnabled()) {
log.debug("doInit(" + this + ")[" + type + "] filter consultation failure details", e);
}
@@ -184,7 +189,8 @@ public class TcpipServerChannel extends AbstractServerChannel {
}
};
- connector = manager.getIoServiceFactory().createConnector(handler);
+ IoServiceFactory ioServiceFactory = manager.getIoServiceFactory();
+ connector = ioServiceFactory.createConnector(handler);
IoConnectFuture future = connector.connect(address.toInetSocketAddress());
future.addListener(future1 -> handleChannelConnectResult(f, future1));
return f;
@@ -239,7 +245,6 @@ public class TcpipServerChannel extends AbstractServerChannel {
} else {
f.setException(problem);
}
-
}
@Override
@@ -296,7 +301,7 @@ public class TcpipServerChannel extends AbstractServerChannel {
@Override
protected void doWriteExtendedData(byte[] data, int off, long len) throws IOException {
- throw new UnsupportedOperationException(type + "Tcpip channel does not support extended data");
+ throw new UnsupportedOperationException(getTcpipChannelType() + "Tcpip channel does not support extended data");
}
protected void handleWriteDataSuccess(byte cmd, byte[] data, int off, int len) {
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/17331a8f/sshd-core/src/main/java/org/apache/sshd/server/x11/ChannelForwardedX11.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/server/x11/ChannelForwardedX11.java b/sshd-core/src/main/java/org/apache/sshd/server/x11/ChannelForwardedX11.java
index 42c3c38..8865854 100644
--- a/sshd-core/src/main/java/org/apache/sshd/server/x11/ChannelForwardedX11.java
+++ b/sshd-core/src/main/java/org/apache/sshd/server/x11/ChannelForwardedX11.java
@@ -63,8 +63,9 @@ public class ChannelForwardedX11 extends AbstractClientChannel {
InetAddress remoteAddress = remote.getAddress();
String remoteHost = remoteAddress.getHostAddress();
Window wLocal = getLocalWindow();
+ String type = getChannelType();
Buffer buffer = session.createBuffer(SshConstants.SSH_MSG_CHANNEL_OPEN,
- remoteHost.length() + type.length() + Integer.SIZE);
+ remoteHost.length() + type.length() + Integer.SIZE);
buffer.putString(type);
buffer.putInt(getId());
buffer.putInt(wLocal.getSize());
[3/5] mina-sshd git commit: Fix checkstyle issues for SSHD-802
Posted by lg...@apache.org.
Fix checkstyle issues for SSHD-802
Project: http://git-wip-us.apache.org/repos/asf/mina-sshd/repo
Commit: http://git-wip-us.apache.org/repos/asf/mina-sshd/commit/ad35d53f
Tree: http://git-wip-us.apache.org/repos/asf/mina-sshd/tree/ad35d53f
Diff: http://git-wip-us.apache.org/repos/asf/mina-sshd/diff/ad35d53f
Branch: refs/heads/master
Commit: ad35d53f391d2d89572695fb4457d1b97252cba3
Parents: 0cb36d9
Author: Lyor Goldstein <ly...@gmail.com>
Authored: Tue Feb 6 22:02:21 2018 +0200
Committer: Goldstein Lyor <ly...@c-b4.com>
Committed: Wed Feb 7 09:41:25 2018 +0200
----------------------------------------------------------------------
.../sshd/common/file/root/RootedFileSystemProvider.java | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/ad35d53f/sshd-core/src/main/java/org/apache/sshd/common/file/root/RootedFileSystemProvider.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/file/root/RootedFileSystemProvider.java b/sshd-core/src/main/java/org/apache/sshd/common/file/root/RootedFileSystemProvider.java
index 1866346..8765f47 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/file/root/RootedFileSystemProvider.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/file/root/RootedFileSystemProvider.java
@@ -44,8 +44,8 @@ import java.nio.file.attribute.BasicFileAttributes;
import java.nio.file.attribute.FileAttribute;
import java.nio.file.attribute.FileAttributeView;
import java.nio.file.spi.FileSystemProvider;
-import java.util.Iterator;
import java.util.HashMap;
+import java.util.Iterator;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
@@ -175,8 +175,9 @@ public class RootedFileSystemProvider extends FileSystemProvider {
}
@Override
- public AsynchronousFileChannel newAsynchronousFileChannel(Path path, Set<? extends OpenOption> options,
- ExecutorService executor, FileAttribute<?>... attrs) throws IOException {
+ public AsynchronousFileChannel newAsynchronousFileChannel(
+ Path path, Set<? extends OpenOption> options, ExecutorService executor, FileAttribute<?>... attrs)
+ throws IOException {
Path r = unroot(path);
FileSystemProvider p = provider(r);
return p.newAsynchronousFileChannel(r, options, executor, attrs);
@@ -202,6 +203,7 @@ public class RootedFileSystemProvider extends FileSystemProvider {
public Iterator<Path> iterator() {
return root(rfs, ds.iterator());
}
+
@Override
public void close() throws IOException {
ds.close();
@@ -215,6 +217,7 @@ public class RootedFileSystemProvider extends FileSystemProvider {
public boolean hasNext() {
return iter.hasNext();
}
+
@Override
public Path next() {
return root(rfs, iter.next());