Forward ssh2 ports into docker

This commit is contained in:
Tom Wiesing 2022-11-11 16:06:59 +01:00
parent 45f63935cd
commit 5bceaa0d47
No known key found for this signature in database
24 changed files with 745 additions and 117 deletions

View file

@ -0,0 +1,32 @@
package ssh2
import (
"bufio"
"fmt"
"io"
"github.com/gliderlabs/ssh"
)
func (ssh2 *SSH2) setupHandler(server *ssh.Server) {
server.Handle(ssh2.handleConnection)
}
func (ssh2 *SSH2) handleConnection(session ssh.Session) {
slug, _ := getAnyPermission(session.Context())
banner := fmt.Sprintf(welcomeMessage, ssh2.Config.DefaultDomain, slug+"."+ssh2.Config.DefaultDomain)
io.WriteString(session, banner)
// wait until the user closes
buffer := bufio.NewReader(session)
for {
res, _, err := buffer.ReadRune()
if err != nil {
return
}
if res == etx || res == eot {
return
}
}
}