protected void handleClosePacketWriteFailure(Channel channel, boolean immediately, Throwable t) { if (log.isDebugEnabled()) { log.debug("handleClosePacketWriteFailure({})[immediately={}] failed ({}) to write SSH_MSG_CHANNEL_CLOSE on channel: {}", this, immediately, t.getClass().getSimpleName(), t.getMessage()); } if (log.isTraceEnabled()) { log.trace("handleClosePacketWriteFailure(" + channel + ") SSH_MSG_CHANNEL_CLOSE failure details", t); } channel.close(true); }
/** * Attempts to use the channel attribute, if not found then tries the session * * @param <T> The generic attribute type * @param channel The {@link Channel} - ignored if {@code null} * @param key The attribute key - never {@code null} * @return Associated value - {@code null} if not found * @see #getSession() * @see Session#resolveAttribute(Session, AttributeKey) */ static <T> T resolveAttribute(Channel channel, AttributeKey<T> key) { Objects.requireNonNull(key, "No key"); if (channel == null) { return null; } T value = channel.getAttribute(key); return (value != null) ? value : Session.resolveAttribute(channel.getSession(), key); } }
/** * Remove this channel from the list of managed channels * * @param channel the channel */ @Override public void unregisterChannel(Channel channel) { int channelId = channel.getId(); Channel result = channels.remove(channelId); if (log.isDebugEnabled()) { log.debug("unregisterChannel({}) result={}", channel, result); } }
protected void newBuffer(int size) { Channel channel = getChannel(); Session session = channel.getSession(); buffer = session.createBuffer(cmd, size <= 0 ? 12 : 12 + size); buffer.putInt(channel.getRecipient()); if (cmd == SshConstants.SSH_MSG_CHANNEL_EXTENDED_DATA) { buffer.putInt(SshConstants.SSH_EXTENDED_DATA_STDERR); } buffer.putInt(0); bufferLength = 0; }
Window clientLocal = channel.getLocalWindow(); Window clientRemote = channel.getRemoteWindow(); Window serverLocal = serverChannel.getLocalWindow(); Window serverRemote = serverChannel.getRemoteWindow();
if (total > 0) { Channel channel = getChannel(); Window remoteWindow = channel.getRemoteWindow(); long length = Math.min(Math.min(remoteWindow.getSize(), total), remoteWindow.getPacketSize()); if (log.isTraceEnabled()) { Session s = channel.getSession(); Buffer buf = s.createBuffer(cmd, (int) length + 12); buf.putInt(channel.getRecipient()); if (cmd == SshConstants.SSH_MSG_CHANNEL_EXTENDED_DATA) { buf.putInt(SshConstants.SSH_EXTENDED_DATA_STDERR);
Channel channel = getChannel(); try { Window wLocal = channel.getLocalWindow(); wLocal.consumeAndCheck(nbRead); } catch (IOException e) { Session session = channel.getSession(); session.exceptionCaught(e);
OpenFuture openFuture = channel.open(sender, rwsize, rmpsize, buffer); openFuture.addListener(future -> { try { if (future.isOpened()) { Window window = channel.getLocalWindow(); if (debugEnabled) { log.debug("operationComplete({}) send SSH_MSG_CHANNEL_OPEN_CONFIRMATION recipient={}, sender={}, window-size={}, packet-size={}",
final long maxTimeoutValue = idleTimeoutValue + disconnectTimeoutValue + TimeUnit.SECONDS.toMillis(3L); final long maxWaitNanos = TimeUnit.MILLISECONDS.toNanos(maxTimeoutValue); Window wRemote = channel.getRemoteWindow(); for (long totalNanoTime = 0L; wRemote.getSize() > 0;) { long nanoStart = System.nanoTime();
long timeout = channel.getLongProperty(FactoryManager.CHANNEL_CLOSE_TIMEOUT, FactoryManager.DEFAULT_CHANNEL_CLOSE_TIMEOUT); s.writePacket(buffer, timeout, TimeUnit.MILLISECONDS).addListener(future -> { if (future.isWritten()) { log.trace("close(" + channel + ")[immediately=" + immediately + "] packet write failure details", e); channel.close(true);
Channel channel = getChannel(); if (!isOpen()) { throw new SshChannelClosedException(channel.getId(), "write(" + this + ") len=" + l + " - channel already closed"); Session session = channel.getSession(); boolean debugEnabled = log.isDebugEnabled(); boolean traceEnabled = log.isTraceEnabled();
/** * Process incoming data on a channel * * @param buffer the buffer containing the data * @throws IOException if an error occurs */ public void channelData(Buffer buffer) throws IOException { Channel channel = getChannel(SshConstants.SSH_MSG_CHANNEL_DATA, buffer); if (channel == null) { return; // debug breakpoint } channel.handleData(buffer); }
/** * Close a channel due to a close packet received * * @param buffer the buffer containing the packet * @throws IOException if an error occurs */ public void channelClose(Buffer buffer) throws IOException { Channel channel = getChannel(SshConstants.SSH_MSG_CHANNEL_CLOSE, buffer); if (channel == null) { return; // debug breakpoint } channel.handleClose(); }
Window clientLocal = channel.getLocalWindow(); Window clientRemote = channel.getRemoteWindow(); Window serverLocal = serverChannel.getLocalWindow(); Window serverRemote = serverChannel.getRemoteWindow();
if (total > 0) { Channel channel = getChannel(); Window remoteWindow = channel.getRemoteWindow(); long length = Math.min(Math.min(remoteWindow.getSize(), total), remoteWindow.getPacketSize()); if (log.isTraceEnabled()) { Session s = channel.getSession(); Buffer buf = s.createBuffer(cmd, (int) length + 12); buf.putInt(channel.getRecipient()); if (cmd == SshConstants.SSH_MSG_CHANNEL_EXTENDED_DATA) { buf.putInt(SshConstants.SSH_EXTENDED_DATA_STDERR);
Channel channel = getChannel(); try { Window wLocal = channel.getLocalWindow(); wLocal.consumeAndCheck(nbRead); } catch (IOException e) { Session session = channel.getSession(); session.exceptionCaught(e);
OpenFuture openFuture = channel.open(sender, rwsize, rmpsize, buffer); openFuture.addListener(future -> { try { if (future.isOpened()) { Window window = channel.getLocalWindow(); if (debugEnabled) { log.debug("operationComplete({}) send SSH_MSG_CHANNEL_OPEN_CONFIRMATION recipient={}, sender={}, window-size={}, packet-size={}",
final long maxTimeoutValue = idleTimeoutValue + disconnectTimeoutValue + TimeUnit.SECONDS.toMillis(3L); final long maxWaitNanos = TimeUnit.MILLISECONDS.toNanos(maxTimeoutValue); Window wRemote = channel.getRemoteWindow(); for (long totalNanoTime = 0L; wRemote.getSize() > 0;) { long nanoStart = System.nanoTime();
protected void newBuffer(int size) { Channel channel = getChannel(); Session session = channel.getSession(); buffer = session.createBuffer(cmd, size <= 0 ? 12 : 12 + size); buffer.putInt(channel.getRecipient()); if (cmd == SshConstants.SSH_MSG_CHANNEL_EXTENDED_DATA) { buffer.putInt(SshConstants.SSH_EXTENDED_DATA_STDERR); } buffer.putInt(0); bufferLength = 0; }
long timeout = channel.getLongProperty( FactoryManager.CHANNEL_CLOSE_TIMEOUT, FactoryManager.DEFAULT_CHANNEL_CLOSE_TIMEOUT); s.writePacket(buffer, timeout, TimeUnit.MILLISECONDS).addListener(future -> { log.trace("close(" + channel + ")[immediately=" + immediately + "] packet write failure details", e); channel.close(true);