dialers

package
v0.0.0-...-b33dbb8 Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2026 License: MPL-2.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CachedAddrs

func CachedAddrs(hostOrIP string) []netip.Addr

CachedAddrs returns addresses for hostOrIP from cache. Use Resolve() to bypass cache.

func Clear

func Clear()

func Confirm

func Confirm(hostOrIP string, addr netip.Addr) bool

func Confirm2

func Confirm2(hostOrIP string, addr string) bool

func Confirm3

func Confirm3(hostOrIP string, addr net.Addr) bool

Confirm3 marks addr as preferred for hostOrIP

func Confirmed

func Confirmed(hostOrIP string) (zz netip.Addr)

func Dial

func Dial(d *protect.RDial, network, addr string) (net.Conn, error)

Dial dials into addr using the provided dialer and returns a net.Conn, which is guaranteed to be either net.UDPConn or net.TCPConn

func DialAny

func DialAny(ds []protect.RDialer, laddr, raddr net.Addr) (*retrier, error)

func DialBind

func DialBind(d *protect.RDial, network, local, remote string) (net.Conn, error)

func DialBindWithTls

func DialBindWithTls(d protect.RDialer, cfg *tls.Config, network, local, remote string) (net.Conn, error)

DialWithTls dials into addr using the provided dialer and returns a tls.Conn

func DialWithSplitRetry

func DialWithSplitRetry(d *protect.RDial, laddr, raddr *net.TCPAddr) (*retrier, error)

DialWithSplitRetry returns a TCP connection that transparently retries by splitting the initial upstream segment if the socket closes without receiving a reply. Like net.Conn, it is intended for two-threaded use, with one thread calling Read and CloseRead, and another calling Write, ReadFrom, and CloseWrite. `dialer` will be used to establish the connection. `addr` is the destination.

func DialWithTls

func DialWithTls(d protect.RDialer, cfg *tls.Config, network, addr string) (net.Conn, error)

DialWithTls dials into addr using the provided dialer and returns a tls.Conn

func Disconfirm

func Disconfirm(hostOrIP string, addr netip.Addr) bool

Disconfirm unmarks addr as preferred for hostOrIP

func Disconfirm2

func Disconfirm2(hostOrIP string, addr string) bool

Disconfirm2 unmarks addr as preferred for hostOrIP

func Disconfirm3

func Disconfirm3(hostOrIP string, addr net.Addr) bool

Disconfirm3 unmarks addr as preferred for hostOrIP

func ECH

func ECH(hostname string) ([]byte, error)

ECH returns the ECH config, if any, for the given hostname. The query is resolved using IPMapper's default resolver.

func For

func For(hostOrIP string) []netip.Addr

For returns addresses for hostOrIP from cache, resolving them if missing. Underlying cache relies on Disconfirm() to remove unreachable IP addrs; if not called, these entries may go stale. Use Resolve to bypass cache. Use CachedAddrs() to only ever return from cache. hostOrIP may be host:port, or ip:port, or host, or ip.

func ForUrl

func ForUrl(s string) []netip.Addr

ForUrl is like For but for a url string s. It extracts the hostname from s and returns corresponding addrs from cache; or, resolving it, if empty.

func IPChanges

func IPChanges() *core.Flow[string]

func IPProtos

func IPProtos(ippro string) (diff bool)

p must be one of settings.IP4, settings.IP6, or settings.IP46

func Listen

func Listen(d *protect.RDial, network, local string) (net.Listener, error)

Listen listens on for TCP connections on the local address using d.

func ListenPacket

func ListenPacket(d *protect.RDial, network, local string) (net.PacketConn, error)

ListenPacket listens on for UDP connections on the local address using d. Returned net.Conn is guaranteed to be a *net.UDPConn.

func Mapper

func Mapper(m ipmap.IPMapper)

Mapper is a hostname to IP (a/aaaa) resolver for the network engine; may be nil.

func New

func New(hostOrIP string, ipps []string) (*ipmap.IPSet, bool)

New re-seeds hostOrIP with a new set of ips. hostOrIP may be host:port, or ip:port, or host, or ip. ipps may be ip or ip:port. It makes no attempt to resolve hostOrIP. see also: For and NewProtected.

func NewProtected

func NewProtected(hostOrIP string, ipps []string) (*ipmap.IPSet, bool)

hostOrIP may be host:port, or ip:port, or host, or ip. It makes no attempt to resolve hostOrIP, and returns a non-nil ipset.

func Probe

func Probe(d *protect.RDial, network, local string) (net.PacketConn, error)

Probe sends and accepts ICMP packets on local addr using d over a net.PacketConn.

func ProxyDial

func ProxyDial(d proxy.Dialer, network, addr string) (net.Conn, error)

ProxyDial tries to connect to addr using d

func ProxyDials

func ProxyDials(dd []proxy.Dialer, network, addr string) (c net.Conn, errs error)

ProxyDials tries to connect to addr using each dialer in dd

func Ptr

func Ptr(ip netip.Addr) []string

Ptr returns hostnames from the ipmap cache, given an IP address.

func Query

func Query(m ipmap.IPMapper, msg *dns.Msg, tids ...string) (*dns.Msg, error)

Query is like QueryFor but with uid set to protect.MyUid. m is the IPMapper implementation to query with, never nil.

func QueryFor

func QueryFor(m ipmap.IPMapper, msg *dns.Msg, uid string, tids ...string) (*dns.Msg, error)

QueryFor forward a DNS request for tid (if set) attributed to uid, or to transport chosen for uid, which may be core.UNKNOWN_UID_STR. QueryFor allows specifying both uid and tids. QueryFor, unlike ResolveFor is not just for A/AAAA records but for any record type. It bypasses the cache and returns the answer from tid or from transport designated for uid. m is the IPMapper implementation to query with, never nil.

func Resolve

func Resolve(hostname string, tids ...string) (addrs []netip.Addr, err error)

Resolve is like ResolveFor but with uid = protect.MyUid. See: For to get cached addrs and if missing, then resolve, and CachedAddrs to only get cached addrs.

func ResolveFor

func ResolveFor(m ipmap.IPMapper, nom string, uid string, tids ...string) ([]netip.Addr, error)

ResolveFor resolves nom to IPs, bypassing cache, using transport designated for given uid. If resolution fails, entries from the cache are returned, if any.

func SampleHosts

func SampleHosts(n uint8, ipver string) []string

SampleHosts returns a slice of random hosts, of size n, for the given ipver. ipver is one of "v4", "v6", or "" (for both).

func SampleIPs

func SampleIPs(n uint8, ipver string) []netip.Addr

SampleIPs returns a slice of random IPs, of size n, for the given ipver. ipver is one of "v4", "v6", or "" (for both).

func SplitDial

func SplitDial(d *protect.RDial, network, addr string) (net.Conn, error)

SplitDial dials into addr splitting the first segment to two if the first connection is unsuccessful, using settings.DialStrategy. Returns a net.Conn, which may not be net.UDPConn or net.TCPConn.

func SplitDialBind

func SplitDialBind(d *protect.RDial, network, local, remote string) (net.Conn, error)

func TlsDial

func TlsDial(d *tls.Dialer, network, addr string) (net.Conn, error)

func Use4

func Use4() bool

func Use6

func Use6() bool

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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