proxy

package
v0.0.0-...-f69eaad Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 1, 2020 License: GPL-3.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DBInputParserName  = "DB Input parser"
	DBOutputParserName = "DB Output parser"
)
View Source
const (
	CommandInputParserName  = "Command Input parser"
	CommandOutputParserName = "Command Output parser"
)

Variables

This section is empty.

Functions

func AddSession

func AddSession(sw Session)

func GetAliveSessions

func GetAliveSessions() []string

func HandleSessionTask

func HandleSessionTask(task model.TerminalTask)

func KillSession

func KillSession(sessionID string) bool

func RemoveDBSession

func RemoveDBSession(sw *DBSwitchSession)

func RemoveSession

func RemoveSession(sw *SwitchSession)

Types

type CmdParser

type CmdParser struct {
	// contains filtered or unexported fields
}

func NewCmdParser

func NewCmdParser(sid, name string) *CmdParser

func (*CmdParser) Close

func (cp *CmdParser) Close() error

func (*CmdParser) Parse

func (cp *CmdParser) Parse() string

Parse 解析命令或输出

func (*CmdParser) WriteData

func (cp *CmdParser) WriteData(p []byte) (int, error)

type CommandRecorder

type CommandRecorder struct {
	// contains filtered or unexported fields
}

func NewCommandRecorder

func NewCommandRecorder(sid string) (recorder *CommandRecorder)

func (*CommandRecorder) End

func (c *CommandRecorder) End()

func (*CommandRecorder) Record

func (c *CommandRecorder) Record(command *model.Command)

type CommandStorage

type CommandStorage interface {
	BulkSave(commands []*model.Command) error
	StorageType
}

func NewCommandStorage

func NewCommandStorage() CommandStorage

type DBParser

type DBParser struct {
	// contains filtered or unexported fields
}

func (*DBParser) Close

func (p *DBParser) Close()

Close 关闭parser

func (*DBParser) IsCommandForbidden

func (p *DBParser) IsCommandForbidden() (string, bool)

IsCommandForbidden 判断命令是不是在过滤规则中

func (*DBParser) ParseServerOutput

func (p *DBParser) ParseServerOutput(b []byte) []byte

ParseServerOutput 解析服务器输出

func (*DBParser) ParseStream

func (p *DBParser) ParseStream(userInChan, srvInChan <-chan []byte) (userOut, srvOut <-chan []byte)

ParseStream 解析数据流

func (*DBParser) ParseUserInput

func (p *DBParser) ParseUserInput(b []byte) []byte

ParseUserInput 解析用户的输入

func (*DBParser) SetCMDFilterRules

func (p *DBParser) SetCMDFilterRules(rules []model.SystemUserFilterRule)

SetCMDFilterRules 设置命令过滤规则

type DBProxyServer

type DBProxyServer struct {
	UserConn   UserConnection
	User       *model.User
	Database   *model.Database
	SystemUser *model.SystemUser
}

func (*DBProxyServer) Proxy

func (p *DBProxyServer) Proxy()

Proxy 代理

type DBSwitchSession

type DBSwitchSession struct {
	ID string

	DateStart string
	DateEnd   string

	MaxIdleTime time.Duration
	// contains filtered or unexported fields
}

func CreateDBSession

func CreateDBSession(p *DBProxyServer) (sw *DBSwitchSession, err error)

func (*DBSwitchSession) Bridge

func (s *DBSwitchSession) Bridge(userConn UserConnection, srvConn srvconn.ServerConnection) (err error)

Bridge 桥接两个链接

func (*DBSwitchSession) Initial

func (s *DBSwitchSession) Initial()

func (*DBSwitchSession) LoopRead

func (s *DBSwitchSession) LoopRead(done chan struct{}, read io.Reader, inChan chan<- []byte)

func (*DBSwitchSession) LoopReadFromSrv

func (s *DBSwitchSession) LoopReadFromSrv(done chan struct{}, srvConn srvconn.ServerConnection, inChan chan<- []byte)

func (*DBSwitchSession) LoopReadFromUser

func (s *DBSwitchSession) LoopReadFromUser(done chan struct{}, userConn UserConnection, inChan chan<- []byte)

func (*DBSwitchSession) MapData

func (s *DBSwitchSession) MapData() map[string]interface{}

func (*DBSwitchSession) SessionID

func (s *DBSwitchSession) SessionID() string

func (*DBSwitchSession) SetFilterRules

func (s *DBSwitchSession) SetFilterRules(cmdRules []model.SystemUserFilterRule)

func (*DBSwitchSession) Terminate

func (s *DBSwitchSession) Terminate()

type Parser

type Parser struct {
	// contains filtered or unexported fields
}

Parse 解析用户输入输出, 拦截过滤用户输入输出

func (*Parser) Close

func (p *Parser) Close()

Close 关闭parser

func (*Parser) IsCommandForbidden

func (p *Parser) IsCommandForbidden() (string, bool)

IsCommandForbidden 判断命令是不是在过滤规则中

func (*Parser) IsInZmodemRecvState

func (p *Parser) IsInZmodemRecvState() bool

func (*Parser) ParseServerOutput

func (p *Parser) ParseServerOutput(b []byte) []byte

ParseServerOutput 解析服务器输出

func (*Parser) ParseStream

func (p *Parser) ParseStream(userInChan, srvInChan <-chan []byte) (userOut, srvOut <-chan []byte)

ParseStream 解析数据流

func (*Parser) ParseUserInput

func (p *Parser) ParseUserInput(b []byte) []byte

ParseUserInput 解析用户的输入

func (*Parser) SetCMDFilterRules

func (p *Parser) SetCMDFilterRules(rules []model.SystemUserFilterRule)

SetCMDFilterRules 设置命令过滤规则

type ProxyServer

type ProxyServer struct {
	UserConn   UserConnection
	User       *model.User
	Asset      *model.Asset
	SystemUser *model.SystemUser
	// contains filtered or unexported fields
}

func (*ProxyServer) Proxy

func (p *ProxyServer) Proxy()

Proxy 代理

type ReplayStorage

type ReplayStorage interface {
	Upload(gZipFile, target string) error
	StorageType
}

func NewReplayStorage

func NewReplayStorage() ReplayStorage

type ReplyRecorder

type ReplyRecorder struct {
	SessionID string

	AbsGzFilePath string
	Target        string
	// contains filtered or unexported fields
}

func NewReplyRecord

func NewReplyRecord(sid string) (recorder ReplyRecorder)

func (*ReplyRecorder) End

func (r *ReplyRecorder) End()

func (*ReplyRecorder) Record

func (r *ReplyRecorder) Record(b []byte)

func (*ReplyRecorder) UploadGzipFile

func (r *ReplyRecorder) UploadGzipFile(maxRetry int)

type Session

type Session interface {
	SessionID() string
	Terminate()
}

type StorageType

type StorageType interface {
	TypeName() string
}

type SwitchSession

type SwitchSession struct {
	ID string

	DateStart string
	DateEnd   string

	MaxIdleTime time.Duration
	// contains filtered or unexported fields
}

func CreateSession

func CreateSession(p *ProxyServer) (sw *SwitchSession, err error)

func NewSwitchSession

func NewSwitchSession(p *ProxyServer) (sw *SwitchSession)

func (*SwitchSession) Bridge

func (s *SwitchSession) Bridge(userConn UserConnection, srvConn srvconn.ServerConnection) (err error)

Bridge 桥接两个链接

func (*SwitchSession) Initial

func (s *SwitchSession) Initial()

func (*SwitchSession) LoopRead

func (s *SwitchSession) LoopRead(done chan struct{}, read io.Reader, inChan chan<- []byte)

func (*SwitchSession) LoopReadFromSrv

func (s *SwitchSession) LoopReadFromSrv(done chan struct{}, srvConn srvconn.ServerConnection, inChan chan<- []byte)

func (*SwitchSession) LoopReadFromUser

func (s *SwitchSession) LoopReadFromUser(done chan struct{}, userConn UserConnection, inChan chan<- []byte)

func (*SwitchSession) MapData

func (s *SwitchSession) MapData() map[string]interface{}

func (*SwitchSession) SessionID

func (s *SwitchSession) SessionID() string

func (*SwitchSession) SetFilterRules

func (s *SwitchSession) SetFilterRules(cmdRules []model.SystemUserFilterRule)

SetFilterRules 设置命令过滤规则

func (*SwitchSession) Terminate

func (s *SwitchSession) Terminate()

type UserConnection

type UserConnection interface {
	io.ReadWriteCloser
	ID() string
	WinCh() <-chan ssh.Window
	LoginFrom() string
	RemoteAddr() string
	Pty() ssh.Pty
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL