protocol

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2022 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInstructionMissDot   = errors.New("instruction without dot")
	ErrInstructionMissComma = errors.New("instruction without comma")
	ErrInstructionBadDigit  = errors.New("instruction with bad digit")
	ErrInstructionBadRune   = errors.New("instruction with bad rune")
)

Possible errors returned by the ParseInstruction function

View Source
var ErrNotConnected = errors.New("not connected")

Functions

This section is empty.

Types

type InetSocketTunnel

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

Simple tunnel implementation over TCP sockets. This allows to connect directly to guacd, without the need of any middleware

func NewInetSocketTunnel

func NewInetSocketTunnel(address string) (*InetSocketTunnel, error)

func (*InetSocketTunnel) Connect

func (t *InetSocketTunnel) Connect(data string) error

func (*InetSocketTunnel) Disconnect

func (t *InetSocketTunnel) Disconnect()

func (*InetSocketTunnel) ReceiveInstruction

func (t *InetSocketTunnel) ReceiveInstruction() (*Instruction, error)

TODO Implement timeout

func (*InetSocketTunnel) SendInstruction

func (t *InetSocketTunnel) SendInstruction(ins ...*Instruction) error

type Instruction

type Instruction struct {
	Opcode string
	Args   []string
}

func NewInstruction

func NewInstruction(opcode string, args ...string) *Instruction

func ParseInstruction

func ParseInstruction(raw []byte) (ins *Instruction, err error)

ParseInstruction parses an instruction: 1.a,2.bc,3.def,10.abcdefghij; Copied from Occamy project: https://github.com/changkun/occamy/blob/master/protocol/instruction.go#L38

func (*Instruction) String

func (i *Instruction) String() string

type InstructionIO

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

InstructionIO ...

func NewInstructionIO

func NewInstructionIO(sock io.ReadWriteCloser) *InstructionIO

NewInstructionIO ...

func (*InstructionIO) Close

func (io *InstructionIO) Close() error

Close closes the InstructionIO

func (*InstructionIO) Read

func (io *InstructionIO) Read() (*Instruction, error)

Read reads and parses the instruction from io input

func (*InstructionIO) ReadRaw

func (io *InstructionIO) ReadRaw() ([]byte, error)

ReadRaw reads raw data from io input

func (*InstructionIO) Write

func (io *InstructionIO) Write(ins *Instruction) (int, error)

Write writes and decodes an instruction to io output

func (*InstructionIO) WriteRaw

func (io *InstructionIO) WriteRaw(buf []byte) (n int, err error)

WriteRaw writes raw buffer into io output

type Tunnel

type Tunnel interface {
	// Connect to the tunnel with the given optional data. This data is
	// typically used for authentication. The format of data accepted is
	// up to the tunnel implementation.
	Connect(data string) error

	// Disconnect from the tunnel.
	Disconnect()

	// Send the given message through the tunnel to the service on the other
	// side. All messages are guaranteed to be received in the order sent.
	SendInstruction(ins ...*Instruction) error

	// Receive a instruction from the service on the other side. This is a
	// blocking call
	ReceiveInstruction() (*Instruction, error)
}

type TunnelState

type TunnelState int
const (
	TunnelClosed TunnelState = iota
	TunnelOpen
)

All possible tunnel states.

Jump to

Keyboard shortcuts

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