Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@

<properties>
<version.org.slf4j>1.7.12</version.org.slf4j>
<netty.version>4.1.36.Final</netty.version>
<jackson.version>2.6.1</jackson.version>
<netty.version>4.1.81.Final</netty.version>
<jackson.version>2.7.4</jackson.version>
<jansi.version>2.4.0</jansi.version>
<junit.version>4.12</junit.version>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.aesh.terminal.telnet.util;
package org.aesh.terminal.utils;

import java.util.concurrent.CompletableFuture;
import java.util.function.Consumer;
Expand Down
Binary file modified terminal-ssh/hostkey.ser
Binary file not shown.
32 changes: 29 additions & 3 deletions terminal-ssh/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@
<properties>
<javaModuleName>org.aesh.terminal.ssh</javaModuleName>
<version.org.slf4j>1.7.12</version.org.slf4j>
<mina-core.version>2.2.4</mina-core.version>
<jsch.version>0.1.54</jsch.version>
<sshd-core.version>2.14.0</sshd-core.version>
</properties>

<developers>
Expand All @@ -72,6 +75,11 @@
<artifactId>netty-common</artifactId>
<version>${netty.version}</version>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-common</artifactId>
<version>${netty.version}</version>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-transport</artifactId>
Expand All @@ -93,7 +101,7 @@
<dependency>
<groupId>org.apache.sshd</groupId>
<artifactId>sshd-core</artifactId>
<version>1.0.0</version>
<version>${sshd-core.version}</version>
<optional>true</optional>
<exclusions>
<exclusion>
Expand All @@ -102,6 +110,18 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.sshd</groupId>
<artifactId>sshd-netty</artifactId>
<version>${sshd-core.version}</version>
<optional>true</optional>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</exclusion>
</exclusions>
</dependency>

<dependency>
<groupId>org.aesh</groupId>
Expand All @@ -127,15 +147,21 @@
<dependency>
<groupId>com.jcraft</groupId>
<artifactId>jsch</artifactId>
<version>0.1.54</version>
<version>${jsch.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.mina</groupId>
<artifactId>mina-core</artifactId>
<version>2.1.10</version>
<version>${mina-core.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.aesh</groupId>
<artifactId>readline</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>

</dependencies>

Expand Down
47 changes: 25 additions & 22 deletions terminal-ssh/src/main/java/org/aesh/terminal/ssh/TtyCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,16 @@
import org.apache.sshd.common.io.IoInputStream;
import org.apache.sshd.common.io.IoOutputStream;
import org.apache.sshd.common.io.IoWriteFuture;
import org.apache.sshd.common.io.WritePendingException;
import org.apache.sshd.common.util.buffer.ByteArrayBuffer;
import org.apache.sshd.server.AsyncCommand;
import org.apache.sshd.server.ChannelSessionAware;
import org.apache.sshd.server.command.AsyncCommand;
import org.apache.sshd.server.channel.ChannelSessionAware;
import org.apache.sshd.server.Environment;
import org.apache.sshd.server.ExitCallback;
import org.apache.sshd.server.channel.ChannelDataReceiver;
import org.apache.sshd.server.channel.ChannelSession;

import java.io.EOFException;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
Expand Down Expand Up @@ -120,21 +122,22 @@ public void setIoInputStream(IoInputStream in) {

@Override
public void setIoOutputStream(IoOutputStream out) {
this.ioOut = out;
this.out = (byte[] bytes) -> {
if(writeFuture == null)
writeFuture = out.write(new ByteArrayBuffer(bytes));
else if(writeFuture.isWritten())
writeFuture = out.write(new ByteArrayBuffer(bytes));
else {
try {
writeFuture.await();
writeFuture = out.write(new ByteArrayBuffer(bytes));
} catch (IOException e) {
e.printStackTrace();
}
}
};
this.ioOut = out;
this.out = bytes -> {
ByteArrayBuffer byteArrayBuffer = new ByteArrayBuffer(bytes);
// the loop is only needed if we catch a WritePendingException, to retry the write and clear the buffer
while (byteArrayBuffer.available() > 0) {
try {
IoWriteFuture ioWriteFuture = out.writeBuffer(byteArrayBuffer);
// await the write so that we do not lose bytes
ioWriteFuture.verify(1, TimeUnit.SECONDS);
} catch (WritePendingException | EOFException ignored) {
// WritePendingException is only cought if the verify() method timeouts
} catch (IOException e) {
throw new RuntimeException(e);
}
}
};
}

@Override
Expand All @@ -148,15 +151,15 @@ public void setExitCallback(ExitCallback callback) {
}

@Override
public void start(final Environment env) throws IOException {
public void start(ChannelSession channelSession, Environment env) throws IOException {
String lcctype = env.getEnv().get("LC_CTYPE");
if (lcctype != null) {
charset = parseCharset(lcctype);
}
if (charset == null) {
charset = defaultCharset;
}
env.addSignalListener(signal -> updateSize(env), EnumSet.of(org.apache.sshd.server.Signal.WINCH));
env.addSignalListener((ch, signal) -> updateSize(env), EnumSet.of(org.apache.sshd.server.Signal.WINCH));
updateSize(env);

// Event handling
Expand Down Expand Up @@ -205,7 +208,7 @@ public void updateSize(Environment env) {

@Override
public void close() throws IOException {
close(0);
close(0);
}

private void close(int exit) throws IOException {
Expand All @@ -223,8 +226,8 @@ private void close(int exit) throws IOException {
}

@Override
public void destroy() {
// Test this
public void destroy(ChannelSession channelSession) throws Exception {
// Test this
}

protected void execute(Runnable task) {
Expand Down

This file was deleted.

Loading