Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AddrSet ¶
Region contains cloudflared edge addresses. The edge is partitioned into several regions for redundancy purposes.
func (AddrSet) AddrUsedBy ¶
AddrUsedBy finds the address used by the given connection in this region. Returns nil if the connection isn't using any IP.
func (AddrSet) AvailableAddrs ¶
AvailableAddrs counts how many unused addresses this region contains.
func (AddrSet) GetAnyAddress ¶
GetAnyAddress returns an arbitrary address from the region.
func (AddrSet) GetUnusedIP ¶
GetUnusedIP returns a random unused address in this region. Returns nil if all addresses are in use.
type ConfigIPVersion ¶
type ConfigIPVersion int8
ConfigIPVersion is the selection of IP versions from config
const ( Auto ConfigIPVersion = 2 IPv4Only ConfigIPVersion = 4 IPv6Only ConfigIPVersion = 6 )
func (ConfigIPVersion) String ¶
func (c ConfigIPVersion) String() string
type EdgeAddr ¶
type EdgeAddr struct { TCP *net.TCPAddr UDP *net.UDPAddr IPVersion EdgeIPVersion }
EdgeAddr is a representation of possible ways to refer an edge location.
type EdgeIPVersion ¶
type EdgeIPVersion int8
IPVersion is the IP version of an EdgeAddr
const ( V4 EdgeIPVersion = 4 V6 EdgeIPVersion = 6 )
func (EdgeIPVersion) String ¶
func (c EdgeIPVersion) String() string
String returns the enum's constant name.
type Region ¶
type Region struct {
// contains filtered or unexported fields
}
Region contains cloudflared edge addresses. The edge is partitioned into several regions for redundancy purposes.
func NewRegion ¶
func NewRegion(addrs []*EdgeAddr, overrideIPVersion ConfigIPVersion) Region
NewRegion creates a region with the given addresses, which are all unused.
func (*Region) AddrUsedBy ¶
AddrUsedBy finds the address used by the given connection in this region. Returns nil if the connection isn't using any IP.
func (Region) AssignAnyAddress ¶
AssignAnyAddress returns a random unused address in this region now assigned to the connID excluding the provided EdgeAddr. Returns nil if all addresses are in use for the region.
func (Region) AvailableAddrs ¶
AvailableAddrs counts how many unused addresses this region contains.
func (Region) GetAnyAddress ¶
GetAnyAddress returns an arbitrary address from the region.
type Regions ¶
type Regions struct {
// contains filtered or unexported fields
}
Regions stores Cloudflare edge network IPs, partitioned into two regions. This is NOT thread-safe. Users of this package should use it with a lock.
func NewNoResolve ¶
NewNoResolve doesn't resolve the edge. Instead it just uses the given addresses. You probably only need this for testing.
func ResolveEdge ¶
func ResolveEdge(log *zerolog.Logger, region string, overrideIPVersion ConfigIPVersion) (*Regions, error)
ResolveEdge resolves the Cloudflare edge, returning all regions discovered.
func StaticEdge ¶
StaticEdge creates a list of edge addresses from the list of hostnames. Mainly used for testing connectivity.
func (*Regions) AddrUsedBy ¶
AddrUsedBy finds the address used by the given connection. Returns nil if the connection isn't using an address.
func (*Regions) AvailableAddrs ¶
AvailableAddrs returns how many edge addresses aren't used.
func (*Regions) GetAnyAddress ¶
GetAnyAddress returns an arbitrary address from the larger region.
func (*Regions) GetUnusedAddr ¶
GetUnusedAddr gets an unused addr from the edge, excluding the given addr. Prefer to use addresses evenly across both regions.