codec

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2022 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Socks5Version = byte(0x05)
	NoAuth        = byte(0x00)
)

socks5 const

View Source
const (
	SuccessReply uint8 = iota
)

send reply byte

Variables

This section is empty.

Functions

func DecodeUint32 added in v0.2.0

func DecodeUint32(uintByte []byte) uint32

func DialTrojan

func DialTrojan(config *client.Config, metadata *Metadata) (outbound net.Conn, err error)

DialTrojan dial trojan remote

func EncodeUint32 added in v0.2.0

func EncodeUint32(i uint32) []byte

func PeekTrojan

func PeekTrojan(bufr *bufio.Reader, conn net.Conn) (bool, error)

PeekTrojan peek trojan protocol

func ReadByte added in v0.2.0

func ReadByte(r io.Reader) (byte, error)

func ReadUint32 added in v0.2.0

func ReadUint32(r io.Reader) (uint32, error)

Types

type Address

type Address struct {
	DomainName  string
	Port        int
	NetworkType string
	net.IP
	AddressType
}

func NewAddressFromAddr

func NewAddressFromAddr(network string, addr string) (*Address, error)

func NewAddressFromHostPort

func NewAddressFromHostPort(network string, host string, port int) *Address

func (*Address) Network

func (a *Address) Network() string

func (*Address) ReadFrom

func (a *Address) ReadFrom(r io.Reader) error

func (*Address) ResolveIP

func (a *Address) ResolveIP() (net.IP, error)

func (*Address) String

func (a *Address) String() string

func (*Address) WriteTo

func (a *Address) WriteTo(w io.Writer) error

type AddressType

type AddressType byte
const (
	IPv4       AddressType = 1
	DomainName AddressType = 3
	IPv6       AddressType = 4
)

trojan AddressType

type Codec

type Codec interface {
	Encode() ([]byte, error)
	Decode(reader io.Reader) error
}

Codec interface

type Metadata

type Metadata struct {
	*Address
	// contains filtered or unexported fields
}

Metadata struct

func (*Metadata) Network

func (r *Metadata) Network() string

Network network string

func (*Metadata) ReadFrom

func (r *Metadata) ReadFrom(rr io.Reader) error

ReadFrom metadata read byte

func (*Metadata) String

func (r *Metadata) String() string

String Address string

func (*Metadata) WriteTo

func (r *Metadata) WriteTo(w io.Writer) error

WriteTo metadata write byte

type PeekReader added in v0.2.0

type PeekReader struct {
	R *bufio.Reader
	I int
}

func (*PeekReader) Read added in v0.2.0

func (p *PeekReader) Read(b []byte) (n int, err error)

type Socks5

type Socks5 struct {
	Conn     net.Conn
	Metadata *Metadata
}

Socks5 struct

func (*Socks5) HandleHandshake

func (s *Socks5) HandleHandshake() error

HandleHandshake handshake

func (*Socks5) LSTRequest

func (s *Socks5) LSTRequest() (err error)

LSTRequest lst

func (*Socks5) SendReply

func (s *Socks5) SendReply(resp uint8) error

SendReply send reply byte

type Trojan

type Trojan struct {
	Hash     string
	Metadata *Metadata
}

Trojan struct

func (*Trojan) Decode

func (s *Trojan) Decode(reader io.Reader) error

Decode read byte trojan

func (*Trojan) Encode

func (s *Trojan) Encode() ([]byte, error)

Encode write byte trojan

Jump to

Keyboard shortcuts

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