Forward ssh2 ports into docker
This commit is contained in:
parent
45f63935cd
commit
5bceaa0d47
24 changed files with 745 additions and 117 deletions
32
internal/dis/component/ssh2/server_handler.go
Normal file
32
internal/dis/component/ssh2/server_handler.go
Normal 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
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue