plugin

package
v0.39.3 Latest Latest
Warning

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

Go to latest
Published: May 14, 2022 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	APIVersion = "0.1.0"

	OpLogin       = "Login"
	OpNewProxy    = "NewProxy"
	OpPing        = "Ping"
	OpNewWorkConn = "NewWorkConn"
	OpNewUserConn = "NewUserConn"
)

Variables

This section is empty.

Functions

func GetReqidFromContext

func GetReqidFromContext(ctx context.Context) string

func NewReqidContext

func NewReqidContext(ctx context.Context, reqid string) context.Context

Types

type HTTPPluginOptions

type HTTPPluginOptions struct {
	Name      string   `ini:"name"`
	Addr      string   `ini:"addr"`
	Path      string   `ini:"path"`
	Ops       []string `ini:"ops"`
	TLSVerify bool     `ini:"tls_verify"`
}

type LoginContent

type LoginContent struct {
	msg.Login

	ClientAddress string `json:"client_address,omitempty"`
}

type Manager

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

func NewManager

func NewManager() *Manager

func (*Manager) Login

func (m *Manager) Login(content *LoginContent) (*LoginContent, error)

func (*Manager) NewProxy

func (m *Manager) NewProxy(content *NewProxyContent) (*NewProxyContent, error)

func (*Manager) NewUserConn

func (m *Manager) NewUserConn(content *NewUserConnContent) (*NewUserConnContent, error)

func (*Manager) NewWorkConn

func (m *Manager) NewWorkConn(content *NewWorkConnContent) (*NewWorkConnContent, error)

func (*Manager) Ping

func (m *Manager) Ping(content *PingContent) (*PingContent, error)

func (*Manager) Register

func (m *Manager) Register(p Plugin)

type NewProxyContent

type NewProxyContent struct {
	User UserInfo `json:"user"`
	msg.NewProxy
}

type NewUserConnContent

type NewUserConnContent struct {
	User       UserInfo `json:"user"`
	ProxyName  string   `json:"proxy_name"`
	ProxyType  string   `json:"proxy_type"`
	RemoteAddr string   `json:"remote_addr"`
}

type NewWorkConnContent

type NewWorkConnContent struct {
	User UserInfo `json:"user"`
	msg.NewWorkConn
}

type PingContent

type PingContent struct {
	User UserInfo `json:"user"`
	msg.Ping
}

type Plugin

type Plugin interface {
	Name() string
	IsSupport(op string) bool
	Handle(ctx context.Context, op string, content interface{}) (res *Response, retContent interface{}, err error)
}

func NewHTTPPluginOptions

func NewHTTPPluginOptions(options HTTPPluginOptions) Plugin

type Request

type Request struct {
	Version string      `json:"version"`
	Op      string      `json:"op"`
	Content interface{} `json:"content"`
}

type Response

type Response struct {
	Reject       bool        `json:"reject"`
	RejectReason string      `json:"reject_reason"`
	Unchange     bool        `json:"unchange"`
	Content      interface{} `json:"content"`
}

type UserInfo

type UserInfo struct {
	User  string            `json:"user"`
	Metas map[string]string `json:"metas"`
	RunID string            `json:"run_id"`
}

Jump to

Keyboard shortcuts

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