V1.0.4 Handle backspace

master
Ng Yat Yan 1 month ago
parent 2af24c044e
commit 9417a7b022

@ -16,7 +16,7 @@
</RollingFile> </RollingFile>
</Appenders> </Appenders>
<Loggers> <Loggers>
<Root level="info"> <Root level="debug">
<AppenderRef ref="LogToConsole" /> <AppenderRef ref="LogToConsole" />
</Root> </Root>
</Loggers> </Loggers>

@ -1,7 +1,7 @@
prompt=$ prompt=root@localhost$
5BAABD7C4581F90088133C0E945302C2=\t0\t0\t0 - 5BAABD7C4581F90088133C0E945302C2=\t0\t0\t0 -
uname=Linux uname=Linux
9DD46246144D353C914D7572AEDF8EA6=Linux mail.vidconnect.cyou 4.15.0-70-generic #79-Ubuntu SMP Tue Nov 12 10:36:10 UTC 2019 aarch64 aarch64 aarch64 GNU/Linux 9DD46246144D353C914D7572AEDF8EA6=Linux localhost 4.15.0-70-generic #79-Ubuntu SMP Tue Nov 12 10:36:10 UTC 2019 aarch64 aarch64 aarch64 GNU/Linux
whoami=appadmin whoami=root
4DE8A3B5E72E54D9D2A70BD43CB5EA9E=Model:\t\t0 4DE8A3B5E72E54D9D2A70BD43CB5EA9E=Model:\t\t0
99EFF9F4022855955653078ECB2B4CE4=1.9G 99EFF9F4022855955653078ECB2B4CE4=1.9G

@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>com.example.sshd</groupId> <groupId>com.example.sshd</groupId>
<artifactId>echo-sshd-server</artifactId> <artifactId>echo-sshd-server</artifactId>
<version>1.0.3</version> <version>1.0.4</version>
<name>ECHO SSH SERVER</name> <name>ECHO SSH SERVER</name>
<description>Learning Apache Mina SSHD library</description> <description>Learning Apache Mina SSHD library</description>
<parent> <parent>

@ -100,7 +100,7 @@ public class EchoShellFactory implements Factory<Command> {
@Override @Override
public void run() { public void run() {
String prompt = repliesProperties.getProperty("prompt","$ "); String prompt = repliesProperties.getProperty("prompt", "$ ");
try { try {
out.write(prompt.getBytes()); out.write(prompt.getBytes());
out.flush(); out.flush();
@ -116,8 +116,16 @@ public class EchoShellFactory implements Factory<Command> {
} }
command = ""; command = "";
} else { } else {
out.write(s); logger.trace("input character: {}", s);
command += (char) s; if (s == 127) {
if (command.length() > 0) {
command = command.substring(0, command.length() - 1);
out.write(s);
}
} else if (s >= 32 && s < 127) {
command += (char) s;
out.write(s);
}
} }
out.flush(); out.flush();
} }

Loading…
Cancel
Save