protocol

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2020 License: GPL-3.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewConn

func NewConn(c net.Conn, p Protocol, iv []byte) net.Conn

NewConn wraps a stream-oriented net.Conn with protocol decoding/encoding

func NewPacketConn

func NewPacketConn(pc net.PacketConn, p Protocol) net.PacketConn

NewPacketConn returns a net.NewPacketConn with protocol decoding/encoding

Types

type Base

type Base struct {
	IV       []byte
	Key      []byte
	TCPMss   int
	Overhead int
	Param    string
}

Base information for protocol

type Conn

type Conn struct {
	net.Conn
	Protocol
	// contains filtered or unexported fields
}

Conn represents a protocol connection

func (*Conn) Read

func (c *Conn) Read(b []byte) (int, error)

func (*Conn) Write

func (c *Conn) Write(b []byte) (int, error)

type PacketConn

type PacketConn struct {
	net.PacketConn
	Protocol
}

PacketConn represents a protocol packet connection

func (*PacketConn) ReadFrom

func (c *PacketConn) ReadFrom(b []byte) (int, net.Addr, error)

func (*PacketConn) WriteTo

func (c *PacketConn) WriteTo(b []byte, addr net.Addr) (int, error)

type Protocol

type Protocol interface {
	GetProtocolOverhead() int
	SetOverhead(int)
	Decode([]byte) ([]byte, int, error)
	Encode([]byte) ([]byte, error)
	DecodePacket([]byte) ([]byte, int, error)
	EncodePacket([]byte) ([]byte, error)
	// contains filtered or unexported methods
}

Protocol provides methods for decoding, encoding and iv setting

func PickProtocol

func PickProtocol(name string, b *Base) (Protocol, error)

PickProtocol returns a protocol of the given name

Jump to

Keyboard shortcuts

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