Documentation
¶
Index ¶
- Constants
- Variables
- func DefaultEnterKeyPressHandler(p []byte) bool
- func IsEditEnterMode(p []byte) bool
- func IsEditExitMode(p []byte) bool
- func IsPasswordPrompt(ps1 string) bool
- func IsPrintable(s string) bool
- func ParseAWSURLRegion(s string) string
- func ParseEndpointRegion(s string) string
- func ParseUrlHostAndPort(clusterAddr string) (host string, port int, err error)
- func ReplaceURLHostAndPort(originUrl *url.URL, ip string, port int) string
- type CommandACLDecision
- type CommandRecorder
- type CommandRule
- type CommandStorage
- type ConnectionOption
- func ConnectContainer(info *ContainerInfo) ConnectionOption
- func ConnectI18nLang(lang string) ConnectionOption
- func ConnectParams(params *ConnectionParams) ConnectionOption
- func ConnectPasswordInputGuard(guard func() error) ConnectionOption
- func ConnectTokenAuthInfo(authInfo *model.ConnectToken) ConnectionOption
- type ConnectionOptions
- type ConnectionParams
- type Container
- type ContainerInfo
- type CurrentActiveUser
- type DatabaseConnectionInfo
- type ExecutedCommand
- type FTPFileInfo
- type FTPFileRecorder
- func (r *FTPFileRecorder) ChunkedRecord(ftpLog *model.FTPLog, readerAt io.ReaderAt, offset, totalSize int64) (err error)
- func (r *FTPFileRecorder) CreateFTPFileInfo(logData *model.FTPLog) (info *FTPFileInfo, err error)
- func (r *FTPFileRecorder) DiscardFTPFile(id string)
- func (r *FTPFileRecorder) FinishFTPFile(id string)
- func (r *FTPFileRecorder) Record(ftpLog *model.FTPLog, reader io.Reader) (err error)
- func (r *FTPFileRecorder) UploadFile(maxRetry int, ftpLogId string)
- type FTPFileStorage
- type K8sNode
- type K8sResourceTree
- type KubernetesClient
- type Namespace
- type Parser
- func (p *Parser) Close()
- func (p *Parser) CommandRecordChan() chan *ExecutedCommand
- func (p *Parser) EmitCommandEvent(cmd string, outputBuf string)
- func (p *Parser) IsInZmodemRecvState() bool
- func (p *Parser) IsMatchCommandRule(command string) (CommandRule, string, bool)
- func (p *Parser) IsNeedParse() bool
- func (p *Parser) NeedRecord() bool
- func (p *Parser) ParseServerOutput(b []byte) []byte
- func (p *Parser) ParseStream(userInChan chan *exchange.RoomMessage, srvInChan <-chan []byte) (userOut, srvOut <-chan []byte)
- func (p *Parser) ParseUserInput(b []byte) []byte
- func (p *Parser) SetUserInputFilter(filter func([]byte) []byte)
- func (p *Parser) UpdateActiveUser(msg *exchange.RoomMessage)
- type Pod
- type ReplayStorage
- type ReplyInfo
- type ReplyRecorder
- type Server
- func (s *Server) AuthorizeAgentToolCommand(command string, decision *CommandACLDecision)
- func (s *Server) CheckAgentToolExecution() error
- func (s *Server) CheckBackgroundExecution() error
- func (s *Server) CheckPermissionExpired(now time.Time) bool
- func (s *Server) CloseBackgroundRecorder()
- func (s *Server) ConvertErrorToReadableMsg(e error) string
- func (s *Server) GenerateCommandItem(user, input, output string, item *ExecutedCommand) *model.Command
- func (s *Server) GetCommandRecorder() *CommandRecorder
- func (s *Server) GetFilterParser() (*Parser, error)
- func (s *Server) GetReplayRecorder() *ReplyRecorder
- func (s *Server) IsKeyboardMode() bool
- func (s *Server) MatchCommandACL(command string) CommandACLDecision
- func (s *Server) Proxy()
- func (s *Server) RecordBackgroundCommand(command, output string, exitCode *int, decision *CommandACLDecision)
- func (s *Server) ReviewCommand(ctx context.Context, decision CommandACLDecision, command string, ...) (CommandACLDecision, error)
- func (s *Server) RevokeAgentToolCommand(command string)
- func (s *Server) SupportsBackgroundExecution() bool
- func (s *Server) ZmodemFileTransferEvent(zinfo *zmodem.ZFileInfo, status bool)
- type SessionInfo
- type Storage
- type StorageType
- type SwitchSession
- func (s *SwitchSession) Bridge(userConn UserConnection, srvConn srvconn.ServerConnection) (err error)
- func (s *SwitchSession) CheckPermissionExpired(now time.Time) bool
- func (s *SwitchSession) PauseOperation(username string)
- func (s *SwitchSession) PermBecomeExpired(code, detail string)
- func (s *SwitchSession) PermBecomeValid(code, detail string)
- func (s *SwitchSession) ResumeOperation(username string)
- func (s *SwitchSession) Terminate(username string)
- type TerminalParser
- func (s *TerminalParser) Close() error
- func (s *TerminalParser) Feed(p []byte)
- func (s *TerminalParser) FeedScreen(p []byte)
- func (s *TerminalParser) GetCursorRow() string
- func (s *TerminalParser) GetPs1() string
- func (s *TerminalParser) IsScreenAlternate() bool
- func (s *TerminalParser) ProcessOutput(p []byte)
- func (s *TerminalParser) Resize(width, height int) error
- func (s *TerminalParser) SetState(state int)
- func (s *TerminalParser) TryLastRowInput() string
- func (s *TerminalParser) TryMultipleCommands()
- func (s *TerminalParser) TryOutput() string
- func (s *TerminalParser) WriteInput(chars []byte) (string, bool)
- type UserConnection
Constants ¶
View Source
const ( StatusQuery = "query" StatusStart = "start" StatusNone = "none" )
View Source
const ( CtrlC = 3 CtrlD = 4 )
View Source
const ( ResourceNamespace = "namespace" ResourcePod = "pod" ResourceContainer = "container" )
View Source
const ( CharCleanRightLine = '\x0B' CharCTRLC = '\x03' CharCTRLE = '\x05' CharCTRLX = '\x18' )
View Source
const ( InputPreState = iota + 1 InputState InVimState OutputState )
View Source
const ( UnAuth = "unable to authenticate" ConnectRefusedErr = "connection refused" // 无监听端口或者端口被防火墙阻断 IoTimeoutErr = "i/o timeout" NoRouteErr = "No route to host" // LoginFailed = "failed login" // telnet 连接失败 )
View Source
const FtpTargetPrefix = "FTP_FILES"
Variables ¶
View Source
var ( ErrMissClient = errors.New("the protocol client has not installed") ErrUnMatchProtocol = errors.New("the protocols are not matched") ErrAPIFailed = errors.New("api failed") ErrPermission = errors.New("no permission") ErrNoAuthInfo = errors.New("no auth info") )
View Source
var ErrInvalidPort = errors.New("invalid port")
View Source
var ErrNoAvailable = errors.New("no available domain")
Functions ¶
func IsEditEnterMode ¶
func IsEditExitMode ¶
func IsPasswordPrompt ¶
func IsPrintable ¶
func ParseAWSURLRegion ¶
func ParseEndpointRegion ¶
func ParseUrlHostAndPort ¶
Types ¶
type CommandACLDecision ¶
type CommandRecorder ¶
type CommandRecorder struct {
// contains filtered or unexported fields
}
func (*CommandRecorder) End ¶
func (c *CommandRecorder) End()
func (*CommandRecorder) Record ¶
func (c *CommandRecorder) Record(command *model.Command)
type CommandRule ¶
type CommandRule struct {
Acl *model.CommandACL
Item *model.CommandFilterItem
}
type CommandStorage ¶
type CommandStorage interface {
BulkSave(commands []*model.Command) error
StorageType
}
func NewCommandStorage ¶
func NewCommandStorage(jmsService *service.JMService, conf *model.TerminalConfig) CommandStorage
type ConnectionOption ¶
type ConnectionOption func(options *ConnectionOptions)
func ConnectContainer ¶
func ConnectContainer(info *ContainerInfo) ConnectionOption
func ConnectI18nLang ¶
func ConnectI18nLang(lang string) ConnectionOption
func ConnectParams ¶
func ConnectParams(params *ConnectionParams) ConnectionOption
func ConnectPasswordInputGuard ¶
func ConnectPasswordInputGuard(guard func() error) ConnectionOption
func ConnectTokenAuthInfo ¶
func ConnectTokenAuthInfo(authInfo *model.ConnectToken) ConnectionOption
type ConnectionOptions ¶
type ConnectionOptions struct {
// contains filtered or unexported fields
}
func (*ConnectionOptions) ConnectMsg ¶
func (opts *ConnectionOptions) ConnectMsg() string
func (*ConnectionOptions) TerminalTitle ¶
func (opts *ConnectionOptions) TerminalTitle() string
type ConnectionParams ¶
type ConnectionParams struct {
DisableMySQLAutoHash bool
}
type ContainerInfo ¶
func (*ContainerInfo) K8sName ¶
func (c *ContainerInfo) K8sName(name string) string
func (*ContainerInfo) String ¶
func (c *ContainerInfo) String() string
type CurrentActiveUser ¶
type DatabaseConnectionInfo ¶
type DatabaseConnectionInfo struct {
Protocol string
PlatformType string
TenantMode string
Host string
Port int
ServerName string
Username string
Password string
Database string
UseSSL bool
PGSSLMode string
CACert string
ClientCert string
ClientKey string
AllowInvalidCert bool
Encrypt bool
DisableEncrypt bool
ClusterMode bool
AuthSource string
ConnectionOpts string
ProxyURL string
DataMaskingRules []model.DataMaskingRule
}
type ExecutedCommand ¶
type FTPFileInfo ¶
type FTPFileInfo struct {
Target string
// contains filtered or unexported fields
}
func (*FTPFileInfo) Close ¶
func (f *FTPFileInfo) Close() error
func (*FTPFileInfo) WriteFromReader ¶
func (f *FTPFileInfo) WriteFromReader(r io.Reader) error
type FTPFileRecorder ¶
type FTPFileRecorder struct {
TargetPrefix string
MaxFileSize int64
// contains filtered or unexported fields
}
func GetFTPFileRecorder ¶
func GetFTPFileRecorder(jmsService *service.JMService) *FTPFileRecorder
func NewFTPFileRecord ¶
func NewFTPFileRecord(jmsService *service.JMService, storage FTPFileStorage, maxStore int64) *FTPFileRecorder
func (*FTPFileRecorder) ChunkedRecord ¶
func (*FTPFileRecorder) CreateFTPFileInfo ¶
func (r *FTPFileRecorder) CreateFTPFileInfo(logData *model.FTPLog) (info *FTPFileInfo, err error)
func (*FTPFileRecorder) DiscardFTPFile ¶
func (r *FTPFileRecorder) DiscardFTPFile(id string)
func (*FTPFileRecorder) FinishFTPFile ¶
func (r *FTPFileRecorder) FinishFTPFile(id string)
func (*FTPFileRecorder) UploadFile ¶
func (r *FTPFileRecorder) UploadFile(maxRetry int, ftpLogId string)
type FTPFileStorage ¶
type FTPFileStorage interface {
Storage
}
func NewFTPFileStorage ¶
func NewFTPFileStorage(jmsService *service.JMService, conf *model.TerminalConfig) FTPFileStorage
type K8sResourceTree ¶
type K8sResourceTree struct {
Root *K8sNode
}
func NewTree ¶
func NewTree() *K8sResourceTree
func (*K8sResourceTree) InsertResource ¶
func (tree *K8sResourceTree) InsertResource(ns, pod, container string)
func (*K8sResourceTree) SearchNamespaces ¶
func (tree *K8sResourceTree) SearchNamespaces() []Namespace
type KubernetesClient ¶
type KubernetesClient struct {
// contains filtered or unexported fields
}
func NewKubernetesClient ¶
func NewKubernetesClient(address, namespace, token string, gateway *model.Gateway) (*KubernetesClient, error)
func (*KubernetesClient) Close ¶
func (kc *KubernetesClient) Close()
func (*KubernetesClient) GetKubeConfig ¶
func (kc *KubernetesClient) GetKubeConfig(address, namespace, token string) (string, error)
func (*KubernetesClient) GetTreeData ¶
func (kc *KubernetesClient) GetTreeData() (string, error)
func (*KubernetesClient) InitClient ¶
func (kc *KubernetesClient) InitClient(address, namespace, token string, gateway *model.Gateway) error
type Parser ¶
type Parser struct {
TerminalParser *TerminalParser
// contains filtered or unexported fields
}
func (*Parser) CommandRecordChan ¶
func (p *Parser) CommandRecordChan() chan *ExecutedCommand
func (*Parser) EmitCommandEvent ¶
func (*Parser) IsInZmodemRecvState ¶
func (*Parser) IsMatchCommandRule ¶
func (p *Parser) IsMatchCommandRule(command string) (CommandRule, string, bool)
IsMatchCommandRule 判断命令是不是在过滤规则中
func (*Parser) IsNeedParse ¶
func (*Parser) NeedRecord ¶
func (*Parser) ParseServerOutput ¶
ParseServerOutput 解析服务器输出
func (*Parser) ParseStream ¶
func (p *Parser) ParseStream(userInChan chan *exchange.RoomMessage, srvInChan <-chan []byte) (userOut, srvOut <-chan []byte)
ParseStream 解析数据流
func (*Parser) ParseUserInput ¶
ParseUserInput 解析用户的输入
func (*Parser) SetUserInputFilter ¶
func (*Parser) UpdateActiveUser ¶
func (p *Parser) UpdateActiveUser(msg *exchange.RoomMessage)
type ReplayStorage ¶
type ReplayStorage interface {
Storage
}
func NewReplayStorage ¶
func NewReplayStorage(jmsService *service.JMService, conf *model.TerminalConfig) ReplayStorage
type ReplyRecorder ¶
type ReplyRecorder struct {
SessionID string
Target string
Writer *asciinema.Writer
// contains filtered or unexported fields
}
func NewReplayRecord ¶
func NewReplayRecord(sid string, jmsService *service.JMService, storage ReplayStorage, info *ReplyInfo) (*ReplyRecorder, error)
func (*ReplyRecorder) End ¶
func (r *ReplyRecorder) End()
func (*ReplyRecorder) Record ¶
func (r *ReplyRecorder) Record(p []byte)
func (*ReplyRecorder) UploadGzipFile ¶
func (r *ReplyRecorder) UploadGzipFile(maxRetry int)
type Server ¶
type Server struct {
ID string
UserConn UserConnection
CreateSessionCallback func() error
ConnectedFailedCallback func(err error) error
DisConnectedCallback func() error
OnSessionInfo func(info *SessionInfo)
OnSSHClient func(client *srvconn.SSHClient)
OnDatabaseConnection func(info DatabaseConnectionInfo)
OnWinRMConnection func(conn *srvconn.WinRMConnection)
// SessionEndReason is available after Proxy returns.
SessionEndReason model.SessionLifecycleReasonErr
// ConnectionError retains the cause when setup fails before a session starts.
ConnectionError error
// ConnectionErrorShown reports that Proxy already wrote the cause to the terminal.
ConnectionErrorShown bool
BroadcastEvent func(event *exchange.RoomMessage)
// contains filtered or unexported fields
}
func NewServer ¶
func NewServer(conn UserConnection, jmsService *service.JMService, opts ...ConnectionOption) (*Server, error)
func (*Server) AuthorizeAgentToolCommand ¶
func (s *Server) AuthorizeAgentToolCommand( command string, decision *CommandACLDecision, )
func (*Server) CheckAgentToolExecution ¶
func (*Server) CheckBackgroundExecution ¶
func (*Server) CloseBackgroundRecorder ¶
func (s *Server) CloseBackgroundRecorder()
func (*Server) ConvertErrorToReadableMsg ¶
func (*Server) GenerateCommandItem ¶
func (s *Server) GenerateCommandItem(user, input, output string, item *ExecutedCommand) *model.Command
func (*Server) GetCommandRecorder ¶
func (s *Server) GetCommandRecorder() *CommandRecorder
func (*Server) GetFilterParser ¶
func (*Server) GetReplayRecorder ¶
func (s *Server) GetReplayRecorder() *ReplyRecorder
func (*Server) IsKeyboardMode ¶
func (*Server) MatchCommandACL ¶
func (s *Server) MatchCommandACL(command string) CommandACLDecision
func (*Server) RecordBackgroundCommand ¶
func (s *Server) RecordBackgroundCommand( command, output string, exitCode *int, decision *CommandACLDecision, )
func (*Server) ReviewCommand ¶
func (s *Server) ReviewCommand( ctx context.Context, decision CommandACLDecision, command string, onProgress func(CommandACLDecision), ) (CommandACLDecision, error)
func (*Server) RevokeAgentToolCommand ¶
func (*Server) SupportsBackgroundExecution ¶
type SessionInfo ¶
type SessionInfo struct {
Session *model.Session `json:"session"`
Perms *model.Permission `json:"permission"`
ClipboardPolicy *model.ClipboardPolicy `json:"clipboard_policy,omitempty"`
BackspaceAsCtrlH *bool `json:"backspaceAsCtrlH,omitempty"`
CtrlCAsCtrlZ bool `json:"ctrlCAsCtrlZ"`
ThemeName string `json:"themeName"`
}
type Storage ¶
type Storage interface {
Upload(gZipFile, target string) error
StorageType
}
func GetStorage ¶
func GetStorage(conf *model.TerminalConfig) Storage
type StorageType ¶
type StorageType interface {
TypeName() string
}
type SwitchSession ¶
type SwitchSession struct {
ID string
MaxIdleTime int
MaxSessionTime time.Time
// contains filtered or unexported fields
}
func (*SwitchSession) Bridge ¶
func (s *SwitchSession) Bridge(userConn UserConnection, srvConn srvconn.ServerConnection) (err error)
Bridge 桥接两个链接
func (*SwitchSession) CheckPermissionExpired ¶
func (s *SwitchSession) CheckPermissionExpired(now time.Time) bool
func (*SwitchSession) PauseOperation ¶
func (s *SwitchSession) PauseOperation(username string)
func (*SwitchSession) PermBecomeExpired ¶
func (s *SwitchSession) PermBecomeExpired(code, detail string)
func (*SwitchSession) PermBecomeValid ¶
func (s *SwitchSession) PermBecomeValid(code, detail string)
func (*SwitchSession) ResumeOperation ¶
func (s *SwitchSession) ResumeOperation(username string)
func (*SwitchSession) Terminate ¶
func (s *SwitchSession) Terminate(username string)
type TerminalParser ¶
type TerminalParser struct {
InputBuf bytes.Buffer
Ps1sStr string
Terminal *terminalparser.TerminalVT
IsEnter func(p []byte) bool
EmitCommands func(cmd, out string)
// contains filtered or unexported fields
}
func (*TerminalParser) Close ¶
func (s *TerminalParser) Close() error
func (*TerminalParser) Feed ¶
func (s *TerminalParser) Feed(p []byte)
func (*TerminalParser) FeedScreen ¶
func (s *TerminalParser) FeedScreen(p []byte)
FeedScreen only updates VT state. It is used by full-screen editors so alternate-screen transitions remain observable without parsing keystrokes or recording editor repaint data as command output.
func (*TerminalParser) GetCursorRow ¶
func (s *TerminalParser) GetCursorRow() string
func (*TerminalParser) GetPs1 ¶
func (s *TerminalParser) GetPs1() string
func (*TerminalParser) IsScreenAlternate ¶
func (s *TerminalParser) IsScreenAlternate() bool
func (*TerminalParser) ProcessOutput ¶
func (s *TerminalParser) ProcessOutput(p []byte)
ProcessOutput parses command completion after the same bytes have already been applied through FeedScreen.
func (*TerminalParser) Resize ¶
func (s *TerminalParser) Resize(width, height int) error
func (*TerminalParser) SetState ¶
func (s *TerminalParser) SetState(state int)
func (*TerminalParser) TryLastRowInput ¶
func (s *TerminalParser) TryLastRowInput() string
func (*TerminalParser) TryMultipleCommands ¶
func (s *TerminalParser) TryMultipleCommands()
func (*TerminalParser) TryOutput ¶
func (s *TerminalParser) TryOutput() string
func (*TerminalParser) WriteInput ¶
func (s *TerminalParser) WriteInput(chars []byte) (string, bool)
Source Files
¶
Click to show internal directories.
Click to hide internal directories.