constant

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Jan 19, 2021 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ATypIPv4       = 1
	ATypDomainName = 3
	ATypIPv6       = 4

	TCP NetWork = iota
	UDP
)

Socks addr type

Variables

This section is empty.

Functions

This section is empty.

Types

type AdapterType

type AdapterType int

AdapterType is enum of adapter type

const (
	Shadowsocks AdapterType = iota
	ShadowsocksR
	Snell
	Socks5
	Http
	Vmess
	Trojan
)

Adapter Type

func (AdapterType) String

func (at AdapterType) String() string

type Chain

type Chain []string

func (Chain) String

func (c Chain) String() string

type Conn

type Conn interface {
	net.Conn
	Connection
}

type Connection

type Connection interface {
	Chains() Chain
	AppendToChains(adapter ProxyAdapter)
}

type Metadata

type Metadata struct {
	NetWork  NetWork `json:"network"`
	DstIP    net.IP  `json:"destinationIP"`
	DstPort  string  `json:"destinationPort"`
	AddrType int     `json:"-"`
	Host     string  `json:"host"`
}

Metadata is used to store connection address

func (*Metadata) RemoteAddress

func (m *Metadata) RemoteAddress() string

func (*Metadata) Resolved

func (m *Metadata) Resolved() bool

func (*Metadata) SourceAddress

func (m *Metadata) SourceAddress() string

func (*Metadata) String

func (m *Metadata) String() string

func (*Metadata) UDPAddr

func (m *Metadata) UDPAddr() *net.UDPAddr

func (*Metadata) Valid

func (m *Metadata) Valid() bool

type NetWork

type NetWork int

func (NetWork) MarshalJSON

func (n NetWork) MarshalJSON() ([]byte, error)

func (NetWork) String

func (n NetWork) String() string

type PacketConn

type PacketConn interface {
	net.PacketConn
	Connection
}

type Proxy

type Proxy interface {
	ProxyAdapter
	Dial(metadata *Metadata) (Conn, error)
	URLTest(ctx context.Context, URL string) (uint16, error)
}

type ProxyAdapter

type ProxyAdapter interface {
	Name() string
	Type() AdapterType
	StreamConn(c net.Conn, metadata *Metadata) (net.Conn, error)
	DialContext(ctx context.Context, metadata *Metadata) (Conn, error)
	DialUDP(metadata *Metadata) (PacketConn, error)
	SupportUDP() bool
	Addr() string
}

type ServerAdapter

type ServerAdapter interface {
	net.Conn
	Metadata() *Metadata
}

type UDPPacket

type UDPPacket interface {
	// Data get the payload of UDP Packet
	Data() []byte

	// WriteBack writes the payload with source IP/Port equals addr
	// - variable source IP/Port is important to STUN
	// - if addr is not provided, WriteBack will write out UDP packet with SourceIP/Port equals to original Target,
	//   this is important when using Fake-IP.
	WriteBack(b []byte, addr net.Addr) (n int, err error)

	// Drop call after packet is used, could recycle buffer in this function.
	Drop()

	// LocalAddr returns the source IP/Port of packet
	LocalAddr() net.Addr
}

UDPPacket contains the data of UDP packet, and offers control/info of UDP packet's source

Jump to

Keyboard shortcuts

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