dialer

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2024 License: GPL-3.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultTCPTimeout = 5 * time.Second
	DefaultUDPTimeout = DefaultTCPTimeout
)

Variables

View Source
var (
	ErrorNoIpAddress           = errors.New("no ip address")
	ErrorInvalidedNetworkStack = errors.New("invalided network stack")
)
View Source
var (
	DefaultOptions     []Option
	DefaultInterface   = atomic.NewTypedValue[string]("")
	DefaultRoutingMark = atomic.NewInt32(0)
)
View Source
var (
	IP4PEnable bool
)

Functions

func DialContext

func DialContext(ctx context.Context, network, address string, options ...Option) (net.Conn, error)

func GetIP4PEnable

func GetIP4PEnable(enableIP4PConvert bool)

func GetTcpConcurrent

func GetTcpConcurrent() bool

func ListenPacket

func ListenPacket(ctx context.Context, network, address string, rAddrPort netip.AddrPort, options ...Option) (net.PacketConn, error)

func LookupLocalAddrFromIfaceName

func LookupLocalAddrFromIfaceName(ifaceName string, network string, destination netip.Addr, port int) (net.Addr, error)

func ParseNetwork

func ParseNetwork(network string, addr netip.Addr) string

func SetTcpConcurrent

func SetTcpConcurrent(concurrent bool)

Types

type Dialer

type Dialer struct {
	Opt option
}

func NewDialer

func NewDialer(options ...Option) Dialer

func (Dialer) DialContext

func (d Dialer) DialContext(ctx context.Context, network, address string) (net.Conn, error)

func (Dialer) ListenPacket

func (d Dialer) ListenPacket(ctx context.Context, network, address string, rAddrPort netip.AddrPort) (net.PacketConn, error)

type NetDialer

type NetDialer interface {
	DialContext(ctx context.Context, network, address string) (net.Conn, error)
}

type Option

type Option func(opt *option)

func WithAddrReuse

func WithAddrReuse(reuse bool) Option

func WithFallbackBind

func WithFallbackBind(fallback bool) Option

func WithInterface

func WithInterface(name string) Option

func WithMPTCP

func WithMPTCP(mpTcp bool) Option

func WithNetDialer

func WithNetDialer(netDialer NetDialer) Option

func WithOnlySingleStack

func WithOnlySingleStack(isIPv4 bool) Option

func WithOption

func WithOption(o option) Option

func WithPreferIPv4

func WithPreferIPv4() Option

func WithPreferIPv6

func WithPreferIPv6() Option

func WithResolver

func WithResolver(r resolver.Resolver) Option

func WithRoutingMark

func WithRoutingMark(mark int) Option

func WithTFO

func WithTFO(tfo bool) Option

type SocketControl

type SocketControl func(network, address string, conn syscall.RawConn) error
var DefaultSocketHook SocketControl

Jump to

Keyboard shortcuts

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