Skip to content

Commit

Permalink
linemode kinda works for GNU telnet now
Browse files Browse the repository at this point in the history
  • Loading branch information
teverett committed Jun 16, 2024
1 parent dadccf1 commit 977b53f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 11 deletions.
17 changes: 9 additions & 8 deletions src/main/java/com/khubla/telnet/nvt/NVT.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import java.io.IOException;
import java.net.Socket;
import java.util.HashMap;
import java.util.Set;

public class NVT implements Flushable, Closeable {
/**
Expand All @@ -50,6 +51,12 @@ public class NVT implements Flushable, Closeable {
@Getter
@Setter
private HashMap<String, String> environment;
/**
* RFC 1184 local chars
*/
@Getter
@Setter
private Set<LineModeIAICCommandHandlerImpl.SLCOption> slcOptions;

public NVT(Socket socket) throws IOException {
super();
Expand All @@ -62,12 +69,6 @@ public NVT(Socket socket) throws IOException {
* send config
*/
sendConfigParameters();
/*
* send GA
*/
if (!nvtOptions.isSuppressGoAhead()) {
// sendIACCommand(IACIAC.IAC_COMMAND_GA);
}
}

@Override
Expand Down Expand Up @@ -102,9 +103,9 @@ private void sendConfigParameters() throws IOException {
*/
sendIACCommand(IAC.IAC_COMMAND_WILL, EchoIAICCommandHandlerImpl.IAC_CODE_ECHO);
/*
* i don't line line mode
* we like line mode and GNU telnet does too
*/
sendIACCommand(IAC.IAC_COMMAND_DONT, LineModeIAICCommandHandlerImpl.IAC_CODE_LINEMODE);
sendIACCommand(IAC.IAC_COMMAND_DO, LineModeIAICCommandHandlerImpl.IAC_CODE_LINEMODE);
/*
* tell me your terminal type
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,17 +100,21 @@ public void process(NVT nvt, int cmd) throws IOException {
switch (cmd) {
case IAC.IAC_COMMAND_DO:
logger.info("Received IAC DO linemode");
// we don't do linemode
nvt.sendIACCommand(IAC.IAC_COMMAND_WONT, IAC_CODE_LINEMODE);
nvt.sendIACCommand(IAC.IAC_COMMAND_WILL, IAC_CODE_LINEMODE);
nvt.getNvtOptions().setLineMode(true);
break;
case IAC.IAC_COMMAND_DONT:
logger.info("Received IAC DONT linemode");
nvt.sendIACCommand(IAC.IAC_COMMAND_WONT, IAC_CODE_LINEMODE);
nvt.getNvtOptions().setLineMode(false);
break;
case IAC.IAC_COMMAND_WILL:
logger.info("Received IAC WILL linemode");
nvt.getNvtOptions().setLineMode(true);
break;
case IAC.IAC_COMMAND_WONT:
logger.info("Received IAC WONT linemode");
nvt.getNvtOptions().setLineMode(false);
break;
case IAC.IAC_COMMAND_SB:
logger.info("Received IAC SB linemode");
Expand All @@ -124,7 +128,7 @@ public void process(NVT nvt, int cmd) throws IOException {
processFORWARDMASK(nvt, sn);
break;
case SLC:
processSLC(nvt, sn);
nvt.setSlcOptions(processSLC(nvt, sn));
break;
case _EOF:
processEOF(nvt, sn);
Expand Down

0 comments on commit 977b53f

Please sign in to comment.