fix: conn reader stuck when header have body
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:
37
session/forwarder.go
Normal file
37
session/forwarder.go
Normal file
@ -0,0 +1,37 @@
|
||||
package session
|
||||
|
||||
import (
|
||||
"net"
|
||||
|
||||
"golang.org/x/crypto/ssh"
|
||||
)
|
||||
|
||||
type Forwarder struct {
|
||||
Listener net.Listener
|
||||
TunnelType TunnelType
|
||||
ForwardedPort uint16
|
||||
|
||||
getSlug func() string
|
||||
setSlug func(string)
|
||||
}
|
||||
|
||||
type ForwardingController interface {
|
||||
HandleGlobalRequest(ch <-chan *ssh.Request)
|
||||
HandleTCPIPForward(req *ssh.Request)
|
||||
HandleHTTPForward(req *ssh.Request, port uint16)
|
||||
HandleTCPForward(req *ssh.Request, addr string, port uint16)
|
||||
AcceptTCPConnections()
|
||||
}
|
||||
|
||||
type ForwarderInfo interface {
|
||||
GetTunnelType() TunnelType
|
||||
GetForwardedPort() uint16
|
||||
}
|
||||
|
||||
func (f *Forwarder) GetTunnelType() TunnelType {
|
||||
return f.TunnelType
|
||||
}
|
||||
|
||||
func (f *Forwarder) GetForwardedPort() uint16 {
|
||||
return f.ForwardedPort
|
||||
}
|
||||
@ -12,6 +12,32 @@ import (
|
||||
"golang.org/x/crypto/ssh"
|
||||
)
|
||||
|
||||
type InteractionController interface {
|
||||
SendMessage(message string)
|
||||
HandleUserInput()
|
||||
HandleCommand(conn ssh.Channel, command string, inSlugEditMode *bool, editSlug *string, buf *bytes.Buffer)
|
||||
HandleSlugEditMode(conn ssh.Channel, inSlugEditMode *bool, editSlug *string, char byte, buf *bytes.Buffer)
|
||||
HandleSlugSave(conn ssh.Channel, inSlugEditMode *bool, editSlug *string, buf *bytes.Buffer)
|
||||
HandleSlugCancel(conn ssh.Channel, inSlugEditMode *bool, buf *bytes.Buffer)
|
||||
HandleSlugUpdateError()
|
||||
ShowWelcomeMessage()
|
||||
DisplaySlugEditor()
|
||||
}
|
||||
|
||||
type Interaction struct {
|
||||
CommandBuffer *bytes.Buffer
|
||||
EditMode bool
|
||||
EditSlug string
|
||||
channel ssh.Channel
|
||||
|
||||
getSlug func() string
|
||||
setSlug func(string)
|
||||
|
||||
session SessionCloser
|
||||
|
||||
forwarder ForwarderInfo
|
||||
}
|
||||
|
||||
func (i *Interaction) SendMessage(message string) {
|
||||
if i.channel != nil {
|
||||
_, err := i.channel.Write([]byte(message))
|
||||
|
||||
@ -3,7 +3,6 @@ package session
|
||||
import (
|
||||
"bytes"
|
||||
"log"
|
||||
"net"
|
||||
"sync"
|
||||
|
||||
"golang.org/x/crypto/ssh"
|
||||
@ -31,26 +30,6 @@ type SessionCloser interface {
|
||||
Close() error
|
||||
}
|
||||
|
||||
type InteractionController interface {
|
||||
SendMessage(message string)
|
||||
HandleUserInput()
|
||||
HandleCommand(conn ssh.Channel, command string, inSlugEditMode *bool, editSlug *string, buf *bytes.Buffer)
|
||||
HandleSlugEditMode(conn ssh.Channel, inSlugEditMode *bool, editSlug *string, char byte, buf *bytes.Buffer)
|
||||
HandleSlugSave(conn ssh.Channel, inSlugEditMode *bool, editSlug *string, buf *bytes.Buffer)
|
||||
HandleSlugCancel(conn ssh.Channel, inSlugEditMode *bool, buf *bytes.Buffer)
|
||||
HandleSlugUpdateError()
|
||||
ShowWelcomeMessage()
|
||||
DisplaySlugEditor()
|
||||
}
|
||||
|
||||
type ForwardingController interface {
|
||||
HandleGlobalRequest(ch <-chan *ssh.Request)
|
||||
HandleTCPIPForward(req *ssh.Request)
|
||||
HandleHTTPForward(req *ssh.Request, port uint16)
|
||||
HandleTCPForward(req *ssh.Request, addr string, port uint16)
|
||||
AcceptTCPConnections()
|
||||
}
|
||||
|
||||
type Session interface {
|
||||
SessionLifecycle
|
||||
InteractionController
|
||||
@ -61,41 +40,6 @@ type Lifecycle struct {
|
||||
Status Status
|
||||
}
|
||||
|
||||
type Forwarder struct {
|
||||
Listener net.Listener
|
||||
TunnelType TunnelType
|
||||
ForwardedPort uint16
|
||||
|
||||
getSlug func() string
|
||||
setSlug func(string)
|
||||
}
|
||||
|
||||
type ForwarderInfo interface {
|
||||
GetTunnelType() TunnelType
|
||||
GetForwardedPort() uint16
|
||||
}
|
||||
|
||||
func (f *Forwarder) GetTunnelType() TunnelType {
|
||||
return f.TunnelType
|
||||
}
|
||||
|
||||
func (f *Forwarder) GetForwardedPort() uint16 {
|
||||
return f.ForwardedPort
|
||||
}
|
||||
|
||||
type Interaction struct {
|
||||
CommandBuffer *bytes.Buffer
|
||||
EditMode bool
|
||||
EditSlug string
|
||||
channel ssh.Channel
|
||||
|
||||
getSlug func() string
|
||||
setSlug func(string)
|
||||
|
||||
session SessionCloser
|
||||
|
||||
forwarder ForwarderInfo
|
||||
}
|
||||
type SSHSession struct {
|
||||
Lifecycle *Lifecycle
|
||||
Interaction *Interaction
|
||||
|
||||
Reference in New Issue
Block a user