transport

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2022 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ResolvePreferenceDefault = ResolvePreference(iota)
	ResolvePreferenceIPv4
	ResolvePreferenceIPv6
	ResolvePreferenceIPv4OrIPv6
	ResolvePreferenceIPv6OrIPv4

	ResolveTimeout = 8 * time.Second
)

Variables

View Source
var DefaultClientTransport = &ClientTransport{
	Dialer: &net.Dialer{
		Timeout: 8 * time.Second,
	},
	ResolvePreference: ResolvePreferenceDefault,
}
View Source
var DefaultServerTransport = &ServerTransport{
	Dialer: &net.Dialer{
		Timeout: 8 * time.Second,
	},
	ResolvePreference: ResolvePreferenceDefault,
}

Functions

This section is empty.

Types

type AddrEx

type AddrEx struct {
	Domain string
	IPAddr *net.IPAddr
	Port   int
}

AddrEx is like net.TCPAddr or net.UDPAddr, but with additional domain information for SOCKS5. At least one of Domain and IPAddr must be non-empty.

func (*AddrEx) String

func (a *AddrEx) String() string

type ClientTransport

type ClientTransport struct {
	Dialer            *net.Dialer
	ResolvePreference ResolvePreference
}

func (*ClientTransport) DialTCP

func (ct *ClientTransport) DialTCP(raddr *net.TCPAddr) (*net.TCPConn, error)

func (*ClientTransport) ListenUDP

func (ct *ClientTransport) ListenUDP() (*net.UDPConn, error)

func (*ClientTransport) ResolveIPAddr

func (ct *ClientTransport) ResolveIPAddr(address string) (*net.IPAddr, error)

type ResolvePreference

type ResolvePreference int

func ResolvePreferenceFromString

func ResolvePreferenceFromString(preference string) (ResolvePreference, error)

type SOCKS5Client

type SOCKS5Client struct {
	ServerTCPAddr *net.TCPAddr
	Username      string
	Password      string
	NegTimeout    time.Duration
}

func NewSOCKS5Client

func NewSOCKS5Client(serverAddr string, username string, password string, negTimeout time.Duration) (*SOCKS5Client, error)

func (*SOCKS5Client) DialTCP

func (c *SOCKS5Client) DialTCP(raddr *AddrEx) (*net.TCPConn, error)

func (*SOCKS5Client) ListenUDP

func (c *SOCKS5Client) ListenUDP() (STPacketConn, error)

type STPacketConn added in v1.2.2

type STPacketConn interface {
	ReadFrom([]byte) (int, *net.UDPAddr, error)
	WriteTo([]byte, *AddrEx) (int, error)
	Close() error
}

type ServerTransport

type ServerTransport struct {
	Dialer            *net.Dialer
	SOCKS5Client      *SOCKS5Client
	ResolvePreference ResolvePreference
	LocalUDPAddr      *net.UDPAddr
	LocalUDPIntf      *net.Interface
}

func (*ServerTransport) DialTCP

func (st *ServerTransport) DialTCP(raddr *AddrEx) (*net.TCPConn, error)

func (*ServerTransport) ListenUDP

func (st *ServerTransport) ListenUDP() (STPacketConn, error)

func (*ServerTransport) ProxyEnabled added in v1.2.2

func (st *ServerTransport) ProxyEnabled() bool

func (*ServerTransport) ResolveIPAddr

func (st *ServerTransport) ResolveIPAddr(address string) (*net.IPAddr, bool, error)

Directories

Path Synopsis
udp

Jump to

Keyboard shortcuts

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