fix: using close channel when attempting to close session
All checks were successful
Docker Build and Push / build-and-push (push) Successful in 3m35s
All checks were successful
Docker Build and Push / build-and-push (push) Successful in 3m35s
This commit is contained in:
@ -2,6 +2,7 @@ package session
|
||||
|
||||
import (
|
||||
"golang.org/x/crypto/ssh"
|
||||
"net"
|
||||
)
|
||||
|
||||
type TunnelType string
|
||||
@ -13,19 +14,38 @@ const (
|
||||
UNKNOWN TunnelType = "unknown"
|
||||
)
|
||||
|
||||
func New(conn *ssh.ServerConn, sshChannel <-chan ssh.NewChannel, req <-chan *ssh.Request) *Session {
|
||||
type Session struct {
|
||||
Connection *ssh.ServerConn
|
||||
ConnChannel ssh.Channel
|
||||
Listener net.Listener
|
||||
TunnelType TunnelType
|
||||
ForwardedPort uint16
|
||||
Status SessionStatus
|
||||
Slug string
|
||||
ChannelChan chan ssh.NewChannel
|
||||
Done chan bool
|
||||
}
|
||||
|
||||
func New(conn *ssh.ServerConn, forwardingReq <-chan *ssh.Request) *Session {
|
||||
session := &Session{
|
||||
Status: SETUP,
|
||||
Slug: "",
|
||||
ConnChannel: nil,
|
||||
Connection: conn,
|
||||
TunnelType: UNKNOWN,
|
||||
ChannelChan: make(chan ssh.NewChannel),
|
||||
Done: make(chan bool),
|
||||
}
|
||||
|
||||
go func() {
|
||||
for newChannel := range sshChannel {
|
||||
go session.HandleSessionChannel(newChannel, req)
|
||||
for channel := range session.ChannelChan {
|
||||
ch, reqs, _ := channel.Accept()
|
||||
if session.ConnChannel == nil {
|
||||
session.ConnChannel = ch
|
||||
session.Status = RUNNING
|
||||
go session.HandleGlobalRequest(forwardingReq)
|
||||
}
|
||||
go session.HandleGlobalRequest(reqs)
|
||||
}
|
||||
}()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user