stub out pastebin

This commit is contained in:
Barak Michener 2020-09-24 21:55:26 -07:00
parent b6b58fe2b3
commit a5bef3cd30
8 changed files with 366 additions and 12 deletions

View file

@ -4,6 +4,7 @@ import (
"fmt"
"log"
"net"
"strings"
"time"
"golang.org/x/crypto/ssh"
@ -84,19 +85,18 @@ func handleChannel(newChannel ssh.NewChannel, conn *ssh.ServerConn, config *Conf
connection.Close()
exit = true
case "exec":
appname := string(req.Payload[4:]) // skip the first four bytes, which are length of string
for k, v := range config.SSHApps {
fmt.Println(k, " ", []byte(k))
fmt.Printf("%#v\n", v)
appstring := string(req.Payload[4:]) // skip the first four bytes, which are length of string
appspaced := strings.SplitN(appstring, " ", 1)
if len(appspaced) == 0 {
exit = true
break
}
fmt.Println(appname, req.Payload)
v, ok := config.SSHApps[appname]
v, ok := config.SSHApps[appspaced]
if ok {
v.HandleExec(conn, connection)
v.HandleExec(appstring, conn, connection)
} else {
log.Printf("Can't find app %s", appname)
}
connection.Close()
exit = true
default:
// Ignore things like 'pty' and 'env' variables.
@ -104,8 +104,9 @@ func handleChannel(newChannel ssh.NewChannel, conn *ssh.ServerConn, config *Conf
}
case <-time.After(5 * time.Second):
fmt.Println("connection timeout")
connection.Close()
exit = true
}
}
connection.Close()
}()
}