network

package
v0.0.0-...-851e5e8 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2024 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExponentialBackoff

func ExponentialBackoff(tries int) time.Duration

func LookupAddressWithCustomDNS

func LookupAddressWithCustomDNS(addr string, dns string, protocol string) ([]netip.Addr, error)

LookupAddressWithCustomDNS looks up address in a specified DNS server

func Ping

func Ping(addr string, count int) error

func StringsToIPs

func StringsToIPs(addresses []string) []netip.Addr

func ToRouteString

func ToRouteString(network netip.Prefix) string

Types

type DNSResolver

type DNSResolver interface {
	Resolve(domain string) ([]netip.Addr, error)
}

type Endpoint

type Endpoint struct {
	// contains filtered or unexported fields
}

Endpoint is responsible for picking the correct IP to use when connecting to the server. Sometimes, even if the server supports IPv6, it cannot be used to connect to it, due to limitations on the client.

func DefaultEndpoint

func DefaultEndpoint(resolver EndpointResolver, serverIps []netip.Addr) Endpoint

DefaultEndpoint returns appropriate endpoint to use.

func NewIPv4Endpoint

func NewIPv4Endpoint(ip netip.Addr) Endpoint

func NewIPv6Endpoint

func NewIPv6Endpoint(ips []netip.Addr) Endpoint

func NewLocalEndpoint

func NewLocalEndpoint(ips []netip.Addr) Endpoint

func (Endpoint) Network

func (e Endpoint) Network() (netip.Prefix, error)

Network returns a parsed CIDR for IP to used to connect.

type EndpointResolver

type EndpointResolver interface {
	Resolve(endpoint netip.Addr) ([]netip.Addr, error)
}

EndpointResolver check if the endpoint can be used

type PingConnectionChecker

type PingConnectionChecker struct {
	// contains filtered or unexported fields
}

PingConnectionChecker is the only resolver used by ResolverChain

func NewPingConnectionChecker

func NewPingConnectionChecker(fw firewall.Service) PingConnectionChecker

func (PingConnectionChecker) Resolve

func (c PingConnectionChecker) Resolve(endpointIP netip.Addr) ([]netip.Addr, error)

type Resolver

type Resolver struct {
	sync.Mutex
	// contains filtered or unexported fields
}

Resolver is a DNSResolver implementation wrapping each DHCP request with allowing and blocking firewall rules

func NewResolver

func NewResolver(fw firewall.Service, servers dns.Getter) *Resolver

func (*Resolver) Resolve

func (r *Resolver) Resolve(domain string) ([]netip.Addr, error)

func (*Resolver) ResolveWithNameservers

func (r *Resolver) ResolveWithNameservers(domain string, nameservers []netip.Addr, protocol string) ([]netip.Addr, error)

type ResolverChain

type ResolverChain struct {
	// contains filtered or unexported fields
}

ResolverChain tries each resolver until the first successful one. It's sole purpose is to determine whether to use IPv4 vs IPv6 endpoint.

func NewDefaultResolverChain

func NewDefaultResolverChain(fw firewall.Service) ResolverChain

func (ResolverChain) Resolve

func (c ResolverChain) Resolve(endpointIP netip.Addr) ([]netip.Addr, error)

Jump to

Keyboard shortcuts

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