operate

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2022 License: GPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DispatcherMap = &sync.Map{}

Functions

func PeekWormhole

func PeekWormhole(br *bufio.Reader, conn net.Conn) (bool, error)

Types

type ConnectOp

type ConnectOp struct {
	*ReqBase
	// contains filtered or unexported fields
}

func NewConnectOP

func NewConnectOP(name string) *ConnectOp

func (*ConnectOp) Decode

func (c *ConnectOp) Decode(buf *bufio.Reader) error

func (*ConnectOp) Encode

func (c *ConnectOp) Encode(buf *bytes.Buffer) error

func (*ConnectOp) Execute

func (c *ConnectOp) Execute(ctx context.Context) error

type DialOP

type DialOP struct {
	*ReqBase

	*codec2.Address
	// contains filtered or unexported fields
}

func NewDialOP

func NewDialOP(name string, address *codec2.Address) *DialOP

func (*DialOP) Decode

func (d *DialOP) Decode(buf *bufio.Reader) error

func (*DialOP) Encode

func (d *DialOP) Encode(buf *bytes.Buffer) error

func (*DialOP) Execute

func (d *DialOP) Execute(ctx context.Context) error

type Dispatcher

type Dispatcher struct {
	Name string
	Key  string

	ExchangeMap *sync.Map
	ProxyMap    *sync.Map
	Wormhole    *Wormhole
	Channel     chan Operate
	// contains filtered or unexported fields
}

Dispatcher struct

func GetCliDispatcher

func GetCliDispatcher(name string) *Dispatcher

func GetSerDispatcher

func GetSerDispatcher(name string) *Dispatcher

func NewCliDispatcher

func NewCliDispatcher(wormhole *Wormhole, name string) *Dispatcher

func NewSerDispatcher

func NewSerDispatcher(wormhole *Wormhole, name string) *Dispatcher

func (*Dispatcher) Connect

func (d *Dispatcher) Connect() error

func (*Dispatcher) DeleteExchange

func (d *Dispatcher) DeleteExchange(name string)

func (*Dispatcher) Dispatch

func (d *Dispatcher) Dispatch(ctx context.Context) error

func (*Dispatcher) LoadExchange

func (d *Dispatcher) LoadExchange(name string) (ExchangeCtl, bool)

func (*Dispatcher) LoadReq

func (d *Dispatcher) LoadReq(reqId uint32) (ReqOperate, bool)

func (*Dispatcher) Read

func (d *Dispatcher) Read() error

func (*Dispatcher) Run

func (d *Dispatcher) Run() error

func (*Dispatcher) Send

func (d *Dispatcher) Send(o Operate)

func (*Dispatcher) SendAndWait

func (d *Dispatcher) SendAndWait(req ReqOperate) *RespOP

type ExchangeCtl

type ExchangeCtl interface {
	Write(b []byte) error
	Close()
	SendInvalid()
}

type ExchangeCtlStu

type ExchangeCtlStu struct {
	Name string

	Raw net.Conn
	// contains filtered or unexported fields
}

func NewExchangeCtl

func NewExchangeCtl(name string, d *Dispatcher, raw net.Conn) *ExchangeCtlStu

func (*ExchangeCtlStu) Close

func (c *ExchangeCtlStu) Close()

func (*ExchangeCtlStu) Read

func (c *ExchangeCtlStu) Read() error

func (*ExchangeCtlStu) SendInvalid

func (c *ExchangeCtlStu) SendInvalid()

func (*ExchangeCtlStu) Write

func (c *ExchangeCtlStu) Write(b []byte) error

type ExchangeOP

type ExchangeOP struct {
	*ReqBase
	// contains filtered or unexported fields
}

func NewExchangeOP

func NewExchangeOP(name string, data []byte) *ExchangeOP

func (*ExchangeOP) Decode

func (e *ExchangeOP) Decode(buf *bufio.Reader) error

func (*ExchangeOP) Encode

func (e *ExchangeOP) Encode(buf *bytes.Buffer) error

func (*ExchangeOP) Execute

func (e *ExchangeOP) Execute(ctx context.Context) error

type OpenProxy

type OpenProxy struct {
	*ReqBase
	ShipName   string
	RemoteAddr string
	LocalAddr  string
}

func NewOpenProxyOP

func NewOpenProxyOP(shipName, remoteAddr, localAddr string) *OpenProxy

func (*OpenProxy) Decode

func (o *OpenProxy) Decode(buf *bufio.Reader) error

func (*OpenProxy) Encode

func (o *OpenProxy) Encode(buf *bytes.Buffer) error

func (*OpenProxy) Execute

func (o *OpenProxy) Execute(ctx context.Context) error

type Operate

type Operate interface {
	Encode(buf *bytes.Buffer) error

	Decode(buf *bufio.Reader) error

	Execute(ctx context.Context) error
}

Operate interface more

type ProxyCtl

type ProxyCtl struct {
	ShipName   string
	RemoteAddr string
	LocalAddr  string
	// contains filtered or unexported fields
}

func NewProxyCtl

func NewProxyCtl(dispatcher *Dispatcher, shipName, remoteAddr, localAddr string) *ProxyCtl

func (*ProxyCtl) Run

func (p *ProxyCtl) Run() error

func (*ProxyCtl) Stop

func (p *ProxyCtl) Stop()

type ReqBase

type ReqBase struct {
	Type
	// contains filtered or unexported fields
}

ReqBase struct

func NewReqBase

func NewReqBase(t Type) *ReqBase

func (*ReqBase) Decode

func (rb *ReqBase) Decode(r io.Reader) error

func (*ReqBase) Encode

func (rb *ReqBase) Encode() ([]byte, error)

func (*ReqBase) GetReqBase

func (rb *ReqBase) GetReqBase() *ReqBase

func (*ReqBase) RespCall

func (rb *ReqBase) RespCall() func(req *ReqBase, resp *RespOP)

func (ReqBase) WaitResp

func (rb ReqBase) WaitResp() *RespOP

type ReqOperate

type ReqOperate interface {
	Operate

	GetReqBase() *ReqBase

	RespCall() func(req *ReqBase, resp *RespOP)

	WaitResp() *RespOP
}

type RespOP

type RespOP struct {
	Type
	Status Status
	ReqId  uint32
	Len    uint32
	Body   []byte
}

RespOP struct

func NewRespOP

func NewRespOP(s Status, reqId uint32, msg string) *RespOP

func (*RespOP) Decode

func (r *RespOP) Decode(buf *bufio.Reader) error

func (*RespOP) Encode

func (r *RespOP) Encode(buf *bytes.Buffer) error

func (*RespOP) Execute

func (r *RespOP) Execute(ctx context.Context) error

func (*RespOP) GetRespStatus

func (r *RespOP) GetRespStatus() Status

type RespOperate

type RespOperate interface {
	Operate

	GetRespStatus() Status
}

type Status

type Status int

Status resp

const (
	SuccessStatus Status = iota
	FailStatus
)

type Type

type Type byte

Type struct

const (
	ConnectType Type = iota
	RespType
	DialType
	ExchangeType
	OpenProxyType
)

type Wormhole

type Wormhole struct {
	Hash string
	Br   *bufio.Reader
	Rwc  net.Conn
}

func (*Wormhole) Decode

func (w *Wormhole) Decode(r io.Reader) error

func (*Wormhole) Encode

func (w *Wormhole) Encode() ([]byte, error)

Jump to

Keyboard shortcuts

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