connector

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2022 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Note: this package is not used now, just for websocket in future!

Note: this package is not used now, just for websocket in future!

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrConnectClosed    = errors.New("connection closed")
	ErrConnectReconnect = errors.New("connection reconnecting")
)

Functions

This section is empty.

Types

type ConnectStatus

type ConnectStatus int32
const (
	ConnectOpen ConnectStatus = iota
	ConnectClosed
	ConnectReconnect
)

type HConn

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

HConn examines the liveness of the underground connection periodically, and reconnects to the remote when the underground connection is unexpectedly closed

func NewConn

func NewConn(urlStr string, header http.Header) *HConn

func (*HConn) CheckHealth

func (c *HConn) CheckHealth() bool

func (*HConn) Close

func (c *HConn) Close()

func (*HConn) ReadMessage

func (c *HConn) ReadMessage() (int, []byte, error)

func (*HConn) SetWriteDeadline

func (c *HConn) SetWriteDeadline(t time.Time) error

func (*HConn) Status

func (c *HConn) Status() ConnectStatus

func (*HConn) WriteMessage

func (c *HConn) WriteMessage(messageType int, data []byte) error

type JsonResponse

type JsonResponse struct {
	Out string `json:"output"`
	Err string `json:"output_error"`
}

type Message

type Message struct {
	Type      MessageType
	Timestamp string
	Module    Module
	Session   string
	Payload   json.RawMessage
}

func NewJsonMessage

func NewJsonMessage(data, err string) *Message

func NewMessage

func NewMessage(typ MessageType, mod Module, data []byte) *Message

func (*Message) Serialize

func (m *Message) Serialize() ([]byte, error)

type MessageBytes

type MessageBytes []byte

func (MessageBytes) Deserialize

func (mb MessageBytes) Deserialize() (Message, error)

type MessageError

type MessageError struct {
	Err error
	Msg *Message
}

type MessageType

type MessageType string
const (
	FileType    MessageType = "file"
	CommandType MessageType = "command"
	JsonType    MessageType = "json"
)

type Module

type Module string
const (
	PythonModule Module = "python"
	ShellModule  Module = "shell"
	FetchModule  Module = "fetch"
	CopyModule   Module = "copy"
)

Jump to

Keyboard shortcuts

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