Documentation
¶
Index ¶
- Constants
- Variables
- func AddCommonSwitch(s *SwitchSession)
- func GetAliveSessions() []string
- func IsEditEnterMode(p []byte) bool
- func IsEditExitMode(p []byte) bool
- func ParseUrlHostAndPort(clusterAddr string) (host string, port int, err error)
- func RemoveCommonSwitch(s *SwitchSession)
- func ReplaceURLHostAndPort(originUrl *url.URL, ip string, port int) string
- type CmdParser
- type CommandRecorder
- type CommandStorage
- type ConnectionOption
- func ConnectApp(app *model.Application) ConnectionOption
- func ConnectAsset(asset *model.Asset) ConnectionOption
- func ConnectContainer(info *ContainerInfo) ConnectionOption
- func ConnectDomain(domain *model.Domain) ConnectionOption
- func ConnectExpired(expired int64) ConnectionOption
- func ConnectFilterRules(rules model.FilterRules) ConnectionOption
- func ConnectI18nLang(lang string) ConnectionOption
- func ConnectParams(params *ConnectionParams) ConnectionOption
- func ConnectPermission(perm *model.Permission) ConnectionOption
- func ConnectProtocolType(protocol string) ConnectionOption
- func ConnectSystemAuthInfo(info *model.SystemUserAuthInfo) ConnectionOption
- func ConnectSystemUser(systemUser *model.SystemUser) ConnectionOption
- func ConnectUser(user *model.User) ConnectionOption
- type ConnectionOptions
- type ConnectionParams
- type ContainerInfo
- type CurrentActiveUser
- type ExecutedCommand
- type Parser
- func (p *Parser) Close()
- func (p *Parser) CommandRecordChan() chan *ExecutedCommand
- func (p *Parser) IsInZmodemRecvState() bool
- func (p *Parser) IsMatchCommandRule(command string) (model.FilterRule, 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) UpdateActiveUser(msg *exchange.RoomMessage)
- type ReplayStorage
- type ReplyInfo
- type ReplyRecorder
- type Server
- func (s *Server) CheckPermissionExpired(now time.Time) bool
- func (s *Server) ConvertErrorToReadableMsg(e error) string
- func (s *Server) GenerateCommandItem(user, input, output string, riskLevel int64, createdDate time.Time) *model.Command
- func (s *Server) GetCommandRecorder() *CommandRecorder
- func (s *Server) GetFilterParser() *Parser
- func (s *Server) GetReplayRecorder() *ReplyRecorder
- func (s *Server) IsKeyboardMode() bool
- func (s *Server) Proxy()
- func (s *Server) ZmodemFileTransferEvent(zinfo *zmodem.ZFileInfo, status bool)
- type SessionInfo
- type StorageType
- type SwitchSession
- type UserConnection
Constants ¶
View Source
const ( StatusQuery = "query" StatusStart = "start" StatusNone = "none" )
View Source
const ( CtrlC = 3 CtrlD = 4 )
View Source
const ( CommandInputParserName = "Command Input parser" CommandOutputParserName = "Command Output parser" )
View Source
const ( CharCleanRightLine = '\x0B' CharCTRLC = '\x03' CharCTRLE = '\x05' CharCTRLX = '\x18' )
View Source
const ( UnAuth = "unable to authenticate" ConnectRefusedErr = "connection refused" // 无监听端口或者端口被防火墙阻断 IoTimeoutErr = "i/o timeout" NoRouteErr = "No route to host" // LoginFailed = "failed login" // telnet 连接失败 )
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 AddCommonSwitch ¶
func AddCommonSwitch(s *SwitchSession)
func GetAliveSessions ¶
func GetAliveSessions() []string
func IsEditEnterMode ¶
func IsEditExitMode ¶
func ParseUrlHostAndPort ¶
func RemoveCommonSwitch ¶
func RemoveCommonSwitch(s *SwitchSession)
Types ¶
type CmdParser ¶
type CmdParser struct {
// contains filtered or unexported fields
}
func NewCmdParser ¶
type CommandRecorder ¶
type CommandRecorder struct { SessionID string Storage CommandStorage Queue chan *model.Command Closed chan struct{} JmsService *service.JMService }
func (*CommandRecorder) End ¶
func (c *CommandRecorder) End()
func (*CommandRecorder) Record ¶
func (c *CommandRecorder) Record()
func (*CommandRecorder) RecordCommand ¶
func (c *CommandRecorder) RecordCommand(command *model.Command)
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 ConnectApp ¶
func ConnectApp(app *model.Application) ConnectionOption
func ConnectAsset ¶
func ConnectAsset(asset *model.Asset) ConnectionOption
func ConnectContainer ¶
func ConnectContainer(info *ContainerInfo) ConnectionOption
func ConnectDomain ¶
func ConnectDomain(domain *model.Domain) ConnectionOption
func ConnectExpired ¶
func ConnectExpired(expired int64) ConnectionOption
func ConnectFilterRules ¶
func ConnectFilterRules(rules model.FilterRules) ConnectionOption
func ConnectI18nLang ¶
func ConnectI18nLang(lang string) ConnectionOption
func ConnectParams ¶
func ConnectParams(params *ConnectionParams) ConnectionOption
func ConnectPermission ¶
func ConnectPermission(perm *model.Permission) ConnectionOption
func ConnectProtocolType ¶
func ConnectProtocolType(protocol string) ConnectionOption
func ConnectSystemAuthInfo ¶
func ConnectSystemAuthInfo(info *model.SystemUserAuthInfo) ConnectionOption
func ConnectSystemUser ¶
func ConnectSystemUser(systemUser *model.SystemUser) ConnectionOption
func ConnectUser ¶
func ConnectUser(user *model.User) ConnectionOption
type ConnectionOptions ¶
type ConnectionOptions struct { ProtocolType string // 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 ExecutedCommand ¶
type Parser ¶
type Parser struct {
// contains filtered or unexported fields
}
func (*Parser) CommandRecordChan ¶
func (p *Parser) CommandRecordChan() chan *ExecutedCommand
func (*Parser) IsInZmodemRecvState ¶
func (*Parser) IsMatchCommandRule ¶
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) UpdateActiveUser ¶
func (p *Parser) UpdateActiveUser(msg *exchange.RoomMessage)
type ReplayStorage ¶
type ReplayStorage interface { Upload(gZipFile, target string) error StorageType }
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 ConnectedSuccessCallback func() error ConnectedFailedCallback func(err error) error DisConnectedCallback func() error OnSessionInfo func(info *SessionInfo) // contains filtered or unexported fields }
func NewServer ¶
func NewServer(conn UserConnection, jmsService *service.JMService, opts ...ConnectionOption) (*Server, error)
func (*Server) ConvertErrorToReadableMsg ¶
func (*Server) GenerateCommandItem ¶
func (*Server) GetCommandRecorder ¶
func (s *Server) GetCommandRecorder() *CommandRecorder
func (*Server) GetFilterParser ¶
func (*Server) GetReplayRecorder ¶
func (s *Server) GetReplayRecorder() *ReplyRecorder
func (*Server) IsKeyboardMode ¶
type SessionInfo ¶
type SessionInfo struct { Session *model.Session `json:"session"` Perms *model.Permission `json:"permission"` }
type StorageType ¶
type StorageType interface {
TypeName() string
}
type SwitchSession ¶
type SwitchSession struct { ID string MaxIdleTime int KeepAliveTime int Ctx context.Context Cancel context.CancelFunc P *Server // contains filtered or unexported fields }
func GetSessionById ¶
func GetSessionById(id string) (s *SwitchSession, ok bool)
func (*SwitchSession) Bridge ¶
func (s *SwitchSession) Bridge(userConn UserConnection, srvConn srvconn.ServerConnection) (err error)
Bridge 桥接两个链接
func (*SwitchSession) SessionID ¶
func (s *SwitchSession) SessionID() string
func (*SwitchSession) Terminate ¶
func (s *SwitchSession) Terminate(username string)
Source Files
¶
Click to show internal directories.
Click to hide internal directories.