fix: panic due to nil pointer when disconnecting a session
Some checks failed
Docker Build and Push / build-and-push (push) Has been cancelled
Some checks failed
Docker Build and Push / build-and-push (push) Has been cancelled
This commit is contained in:
@ -18,7 +18,7 @@ import (
|
||||
"golang.org/x/crypto/ssh"
|
||||
)
|
||||
|
||||
type SessionStatus string
|
||||
type Status string
|
||||
|
||||
var forbiddenSlug = []string{
|
||||
"ping",
|
||||
@ -191,7 +191,7 @@ func (s *SSHSession) handleTCPIPForward(req *ssh.Request) {
|
||||
unassign, success := portUtil.Manager.GetUnassignedPort()
|
||||
portToBind = unassign
|
||||
if !success {
|
||||
s.Interaction.SendMessage(fmt.Sprintf("No available port\r\n", portToBind))
|
||||
s.Interaction.SendMessage("No available port\r\n")
|
||||
err := req.Reply(false, nil)
|
||||
if err != nil {
|
||||
log.Println("Failed to reply to request:", err)
|
||||
@ -338,19 +338,8 @@ func (s *SSHSession) acceptTCPConnections() {
|
||||
log.Printf("Failed to open forwarded-tcpip channel: %v", err)
|
||||
return
|
||||
}
|
||||
defer func(channel ssh.Channel) {
|
||||
err := channel.Close()
|
||||
if err != nil {
|
||||
log.Println("Failed to close connection:", err)
|
||||
}
|
||||
}(channel)
|
||||
|
||||
go func() {
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
log.Printf("Panic in request handler: %v", r)
|
||||
}
|
||||
}()
|
||||
for req := range reqs {
|
||||
err := req.Reply(false, nil)
|
||||
if err != nil {
|
||||
|
||||
@ -10,9 +10,9 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
INITIALIZING SessionStatus = "INITIALIZING"
|
||||
RUNNING SessionStatus = "RUNNING"
|
||||
SETUP SessionStatus = "SETUP"
|
||||
INITIALIZING Status = "INITIALIZING"
|
||||
RUNNING Status = "RUNNING"
|
||||
SETUP Status = "SETUP"
|
||||
)
|
||||
|
||||
type TunnelType string
|
||||
@ -58,7 +58,7 @@ type Session interface {
|
||||
}
|
||||
|
||||
type Lifecycle struct {
|
||||
Status SessionStatus
|
||||
Status Status
|
||||
}
|
||||
|
||||
type Forwarder struct {
|
||||
|
||||
Reference in New Issue
Block a user