Documentation ¶
Overview ¶
The function is used to provide the gin interface plug-in and dynamic parameter HTTP transfer
Index ¶
- Constants
- Variables
- func Admin(c *gin.Context)
- func Check(c *gin.Context)
- func DecodeBase64(in string) (string, error)
- func DecodeBase64Bytes(in string) ([]byte, error)
- func EncodeBase64(in string) string
- func GenerateRSAKey(bits int) error
- func GetIPs() (ips []string)
- func GetRandomSalt() string
- func GetRandomString(len int) string
- func Home() (string, error)
- func Index(c *gin.Context)
- func InitBoltDB() *storm.DB
- func IsPathExists(path string) bool
- func RegisterTty(router *gin.Engine, data *Tty, isLocal bool)
- func RsaDecrypt(ciphertext []byte) ([]byte, error)
- func RsaEncrypt(origData []byte) ([]byte, error)
- func ServeGin(data *Tty)
- func TlsHandler(host, port string) gin.HandlerFunc
- func Who(c *gin.Context)
- func Ws(c *gin.Context)
- type Aduit
- type ClientContext
- type Lflxp
- type Options
- type Server
- type Tty
- type Whos
- type XtermJs
Constants ¶
const ( Input = '0' Ping = '1' ResizeTerminal = '2' Heartbeat = '3' )
TODO: 标准化前端输入类型 xtermjs eventListener
const ( Output = '0' Pong = '1' SetWindowTitle = '2' SetPreferences = '3' SetReconnect = '4' )
后端控制前端
Variables ¶
var ( PrivateKey string PublicKey string )
var Static embed.FS
var Views embed.FS
Functions ¶
func Home ¶
Home returns the home directory for the executing user.
This uses an OS-specific method for discovering the home directory. An error is returned if a home directory cannot be detected.
func InitBoltDB ¶
func InitBoltDB() *storm.DB
func IsPathExists ¶
func RegisterTty ¶
isLocal 参数是用于判断是否为第三方引用,进而改变访问路径
func ServeGin ¶
func ServeGin(data *Tty)
func ServeGin(data.Host,data.Port, username, password, crtpath, keypath string, cmds []string, isdebug, isReconnect, isPermitWrite, isAudit, isXsrf, isProf, enabletls bool, MaxConnections int64) {
func TlsHandler ¶
func TlsHandler(host, port string) gin.HandlerFunc
Types ¶
type Aduit ¶
type Aduit struct { Id int64 `json:"id" storm:"id,increment"` Remoteaddr string `json:"remoteaddr"` Token string `json:"token" ` Command string `json:"command"` Pid int `json:"pid"` Status string `json:"status"` Created time.Time `json:"created"` }
TODO cgo效率太低 后期转mmap或者bbolt
type ClientContext ¶
type ClientContext struct { Xtermjs *XtermJs // 前端配置 Request *http.Request // http客户端请求 WsConn *websocket.Conn // websocket连接 Cmd *exec.Cmd // exec.Command实例 Pty *os.File // 命令行pty代理 // Cache *bytes.Buffer // 命令缓存 // CacheMutex *sync.Mutex // 缓存并发锁 WriteMutex *sync.Mutex // 并发安全 通过ws发送给客户 }
服务端内部处理对象
func (*ClientContext) ParseXsrf ¶
func (this *ClientContext) ParseXsrf(info []byte) (string, string, bool)
xsrf验证 token = xsrf + request.remoteAddr
func (*ClientContext) Receive ¶
func (this *ClientContext) Receive(quitChan chan bool)
获取用户发送命令 发送到pty进行执行
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
原本是命令端http server管理,这里后期可以改成gin server管理 单线程等待