diff options
-rw-r--r-- | main.go | 38 |
1 files changed, 2 insertions, 36 deletions
diff --git a/main.go b/main.go index 2ebc6fa..a3fd2a6 100644 --- a/main.go +++ b/main.go @@ -50,48 +50,14 @@ func handleConnection(s ssh.Session) { // create two buffers, one for storing the char input (buf) // and the other for storing complete commands (commandBuffer) buf := make([]byte, 1024) - commandBuffer := make([]byte, 0) - // the current char - var char string - - // read until ENTER is pressed - for char != "\x0d" { - - // read the char inserted by the user into the buffer + for { _, readErr = s.Read(buf) - - if len(bytes.Trim(buf, "\x00")) == 0 { - buf[0] = []byte("\x108\x105")[0] - } - - // trim the char and append it to the commandBuffer - currentChar := bytes.Trim(buf, "\x00")[0] - log.Println(currentChar) - - // if <C-c> ist pressed, close the connection - if currentChar == []byte("\x03")[0] { - s.Close() - return - } - - // append the current char to the command buffer - commandBuffer = append(commandBuffer, currentChar) - - // write the char to stdout - char = string(bytes.Trim(buf, "\x00")) input := string(bytes.Trim(buf, "\x00")) + log.Println(input) io.WriteString(s, input) } - // prepare the command for execution - input := string(bytes.Trim(commandBuffer, "\x00")) - - // filter out unwanted commands - filteredInput := filter(input) - - // write the string to the commandHandler - io.WriteString(p, filteredInput) s.Close() return } |