packet

package
v1.13.1 Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2024 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrUnsupportedIPVersion    = errors.New("ip version not supported")
	ErrUnsupportedSubProtocol  = errors.New("sub protocol not supported")
	ErrOffsetBiggerThanData    = errors.New("sub protocol offset is larger than given data")
	ErrSubProtocolDataTooSmall = errors.New("sub protocol data is too small")
	ErrPacketTooSmall          = errors.New("packet to small")
	ErrNoData                  = errors.New("no data provided")
)
View Source
var (
	ErrSOCKS5InvalidMessage     = errors.New("invalid socks5 message")
	ErrSOCKS5InvalidVersion     = errors.New("invalid version set in socks5 payload")
	ErrSOCKS5InvalidAddressType = errors.New("invalid address type")
)

Functions

This section is empty.

Types

type SOCKS5AddressType added in v1.5.0

type SOCKS5AddressType uint8
const (
	SOCKS5AddressTypeIPv4       SOCKS5AddressType = 0x01
	SOCKS5AddressTypeDomainName SOCKS5AddressType = 0x03
	SOCKS5AddressTypeIPv6       SOCKS5AddressType = 0x04
)

func (SOCKS5AddressType) String added in v1.5.0

func (a SOCKS5AddressType) String() string

type SOCKS5InitialClientRequest added in v1.5.0

type SOCKS5InitialClientRequest struct{}

func (SOCKS5InitialClientRequest) MessageType added in v1.5.0

type SOCKS5InitialServerResponse added in v1.5.0

type SOCKS5InitialServerResponse struct{}

func (SOCKS5InitialServerResponse) MessageType added in v1.5.0

type SOCKS5Message added in v1.5.0

type SOCKS5Message interface {
	MessageType() SOCKS5MessagesType
	// contains filtered or unexported methods
}

func ParseSOCKS5 added in v1.5.0

func ParseSOCKS5(data []byte) (SOCKS5Message, error)

ParseSOCKS5 tries to parses the given data based on https://datatracker.ietf.org/doc/html/rfc1928

type SOCKS5MessagesType added in v1.5.0

type SOCKS5MessagesType uint8
const (
	SOCKS5MessageUnknown SOCKS5MessagesType = iota
	SOCKS5MessageInitialClientRequest
	SOCKS5MessageInitialServerResponse

	// they request and reply message look identical on the wire
	// so hence we need to share a constant
	SOCKS5MessageRequestOrReply
)

func (SOCKS5MessagesType) String added in v1.5.0

func (m SOCKS5MessagesType) String() string

type SOCKS5RequestOrReply added in v1.5.0

type SOCKS5RequestOrReply struct {
	CmdOrReply  uint8
	AddressType SOCKS5AddressType
	Address     []byte // can either be a domain name, ipv4 or ipv6. check the address type to know how to parse it
	Port        uint16
}

func (SOCKS5RequestOrReply) MessageType added in v1.5.0

type SubProtocol

type SubProtocol byte
const (
	UnsupportedSubProtocol SubProtocol = 0
	SubProtocolTCP         SubProtocol = 0x06
	SubProtocolUDP         SubProtocol = 0x11
)

func ExtractPayload

func ExtractPayload(data []byte) ([]byte, SubProtocol, error)

ExtractPayload will try to extract the payload for a given IPv4/IPv6 packet.

func (SubProtocol) String added in v1.5.0

func (s SubProtocol) String() string

Jump to

Keyboard shortcuts

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