Documentation ¶
Index ¶
- Constants
- Variables
- func GenMyPtyHandlerId() (string, error)
- func HandleExecShell(input *websocket_pb.WsHandleExecShellInput, conn *WsConn) (string, error)
- func HandleWsAuthorize(c *WsConn, t websocket_pb.Type, message []byte)
- func HandleWsHandleCloseShell(c *WsConn, t websocket_pb.Type, message []byte)
- func HandleWsHandleExecShell(c *WsConn, t websocket_pb.Type, message []byte)
- func HandleWsHandleExecShellMsg(c *WsConn, t websocket_pb.Type, message []byte)
- func HandleWsHandleSetLang(c *WsConn, t websocket_pb.Type, message []byte)
- func WaitForTerminal(conn *WsConn, k8sClient kubernetes.Interface, cfg *rest.Config, ...)
- type Container
- type HandleRequestFunc
- type Msger
- type MyPtyHandler
- func (t *MyPtyHandler) Close(reason string) bool
- func (t *MyPtyHandler) CloseDoneChan() bool
- func (t *MyPtyHandler) Cols() uint16
- func (t *MyPtyHandler) IsClosed() bool
- func (t *MyPtyHandler) Next() *remotecommand.TerminalSize
- func (t *MyPtyHandler) Read(p []byte) (n int, err error)
- func (t *MyPtyHandler) Recorder() *Recorder
- func (t *MyPtyHandler) ResetTerminalRowCol(reset bool)
- func (t *MyPtyHandler) Resize(size remotecommand.TerminalSize)
- func (t *MyPtyHandler) Rows() uint16
- func (t *MyPtyHandler) Send(m *websocket_pb.TerminalMessage)
- func (t *MyPtyHandler) TerminalMessageChan() chan *websocket_pb.TerminalMessage
- func (t *MyPtyHandler) Toast(p string) error
- func (t *MyPtyHandler) Write(p []byte) (n int, err error)
- type PtyHandler
- type Recorder
- type SessionMap
- type SessionMapper
- type TerminalResponse
- type WaitSocketExit
- type WebsocketManager
- type WsConn
- type WsResponse
Constants ¶
const ( ResultError = websocket_pb.ResultType_Error ResultSuccess = websocket_pb.ResultType_Success WsSetUid = websocket_pb.Type_SetUid WsInternalError = websocket_pb.Type_InternalError WsHandleExecShell = websocket_pb.Type_HandleExecShell WsHandleExecShellMsg = websocket_pb.Type_HandleExecShellMsg WsHandleCloseShell = websocket_pb.Type_HandleCloseShell WsAuthorize = websocket_pb.Type_HandleAuthorize WsHandleSetLang = websocket_pb.Type_HandleSetLang )
const ( OpStdout = "stdout" OpStdin = "stdin" OpResize = "resize" OpToast = "toast" )
Variables ¶
var ( ETX = []byte("\u0003") END_OF_TRANSMISSION = []byte("\u0004") )
var Wait = NewWaitSocketExit()
Functions ¶
func GenMyPtyHandlerId ¶
GenMyPtyHandlerId generates a random session ID string. The format is not really interesting. This ID is used to identify the session when the client opens the SockJS connection. Not the same as the SockJS session id! We can't use that as that is generated on the client side and we don't have it yet at this point.
func HandleExecShell ¶
func HandleExecShell(input *websocket_pb.WsHandleExecShellInput, conn *WsConn) (string, error)
func HandleWsAuthorize ¶
func HandleWsAuthorize(c *WsConn, t websocket_pb.Type, message []byte)
func HandleWsHandleCloseShell ¶
func HandleWsHandleCloseShell(c *WsConn, t websocket_pb.Type, message []byte)
func HandleWsHandleExecShell ¶
func HandleWsHandleExecShell(c *WsConn, t websocket_pb.Type, message []byte)
func HandleWsHandleExecShellMsg ¶
func HandleWsHandleExecShellMsg(c *WsConn, t websocket_pb.Type, message []byte)
func HandleWsHandleSetLang ¶ added in v0.0.28
func HandleWsHandleSetLang(c *WsConn, t websocket_pb.Type, message []byte)
func WaitForTerminal ¶
func WaitForTerminal(conn *WsConn, k8sClient kubernetes.Interface, cfg *rest.Config, container *Container, shell, sessionId string)
WaitForTerminal is called from apihandler.handleAttach as a goroutine Waits for the SockJS connection to be opened by the client the session to be bound in handleMyPtyHandler
Types ¶
type HandleRequestFunc ¶
type HandleRequestFunc func(c *WsConn, t websocket_pb.Type, message []byte)
type Msger ¶
type Msger interface { SendEndError(error) SendError(error) SendMsg(string) SendProtoMsg(plugins.WebsocketMessage) }
func NewMessageSender ¶
func NewMessageSender(conn *WsConn, slugName string, wsType websocket_pb.Type) Msger
type MyPtyHandler ¶
type MyPtyHandler struct { Container // contains filtered or unexported fields }
func (*MyPtyHandler) Close ¶
func (t *MyPtyHandler) Close(reason string) bool
func (*MyPtyHandler) CloseDoneChan ¶ added in v0.0.47
func (t *MyPtyHandler) CloseDoneChan() bool
func (*MyPtyHandler) Cols ¶ added in v0.0.46
func (t *MyPtyHandler) Cols() uint16
func (*MyPtyHandler) IsClosed ¶ added in v0.0.46
func (t *MyPtyHandler) IsClosed() bool
func (*MyPtyHandler) Next ¶
func (t *MyPtyHandler) Next() *remotecommand.TerminalSize
func (*MyPtyHandler) Recorder ¶ added in v0.0.46
func (t *MyPtyHandler) Recorder() *Recorder
func (*MyPtyHandler) ResetTerminalRowCol ¶ added in v0.0.46
func (t *MyPtyHandler) ResetTerminalRowCol(reset bool)
func (*MyPtyHandler) Resize ¶ added in v0.0.47
func (t *MyPtyHandler) Resize(size remotecommand.TerminalSize)
func (*MyPtyHandler) Rows ¶ added in v0.0.46
func (t *MyPtyHandler) Rows() uint16
func (*MyPtyHandler) Send ¶ added in v0.0.47
func (t *MyPtyHandler) Send(m *websocket_pb.TerminalMessage)
func (*MyPtyHandler) TerminalMessageChan ¶ added in v0.0.46
func (t *MyPtyHandler) TerminalMessageChan() chan *websocket_pb.TerminalMessage
func (*MyPtyHandler) Toast ¶
func (t *MyPtyHandler) Toast(p string) error
Toast can be used to send the user any OOB messages hterm puts these in the center of the terminal
type PtyHandler ¶
type PtyHandler interface { Recorder() *Recorder Toast(string) error Send(*websocket_pb.TerminalMessage) Resize(remotecommand.TerminalSize) ResetTerminalRowCol(bool) TerminalMessageChan() chan *websocket_pb.TerminalMessage Rows() uint16 Cols() uint16 Close(string) bool IsClosed() bool io.Reader io.Writer remotecommand.TerminalSizeQueue }
PtyHandler is what remotecommand expects from a pty
type SessionMap ¶
type SessionMap struct { Sessions map[string]PtyHandler // contains filtered or unexported fields }
SessionMap stores a map of all MyPtyHandler objects and a sessLock to avoid concurrent conflict
func (*SessionMap) Close ¶
func (sm *SessionMap) Close(sessionId string, status uint32, reason string)
Close shuts down the SockJS connection and sends the status code and reason to the client Can happen if the process exits or if there is an error starting up the process For now the status code is unused and reason is shown to the user (unless "")
func (*SessionMap) CloseAll ¶
func (sm *SessionMap) CloseAll()
func (*SessionMap) Get ¶
func (sm *SessionMap) Get(sessionId string) (PtyHandler, bool)
Get return a given terminalSession by sessionId
func (*SessionMap) Send ¶
func (sm *SessionMap) Send(m *websocket_pb.TerminalMessage)
func (*SessionMap) Set ¶
func (sm *SessionMap) Set(sessionId string, session PtyHandler)
Set store a MyPtyHandler to SessionMap
type SessionMapper ¶
type SessionMapper interface { Send(message *websocket_pb.TerminalMessage) Get(sessionId string) (PtyHandler, bool) Set(sessionId string, session PtyHandler) CloseAll() Close(sessionId string, status uint32, reason string) }
type TerminalResponse ¶
type TerminalResponse struct {
ID string `json:"id"`
}
type WaitSocketExit ¶
type WaitSocketExit struct {
// contains filtered or unexported fields
}
func NewWaitSocketExit ¶
func NewWaitSocketExit() *WaitSocketExit
func (*WaitSocketExit) Count ¶
func (w *WaitSocketExit) Count() int
func (*WaitSocketExit) Dec ¶
func (w *WaitSocketExit) Dec()
func (*WaitSocketExit) Inc ¶
func (w *WaitSocketExit) Inc()
func (*WaitSocketExit) Wait ¶
func (w *WaitSocketExit) Wait()
type WebsocketManager ¶
type WebsocketManager struct{}
func NewWebsocketManager ¶
func NewWebsocketManager() *WebsocketManager
func (*WebsocketManager) Info ¶
func (wc *WebsocketManager) Info(writer http.ResponseWriter, request *http.Request)
func (*WebsocketManager) Ws ¶
func (wc *WebsocketManager) Ws(w http.ResponseWriter, r *http.Request)
type WsConn ¶
type WsConn struct {
// contains filtered or unexported fields
}
func (*WsConn) GetShellChannel ¶
func (c *WsConn) GetShellChannel(sessionID string) (chan *websocket_pb.TerminalMessage, error)
type WsResponse ¶
type WsResponse = websocket_pb.WsMetadataResponse