Documentation
¶
Index ¶
- func FetchECHConfigs(ctx context.Context, hostname string) ([]byte, error)
- func FetchECHConfigsBase64(ctx context.Context, hostname string) (string, error)
- type Cache
- func (c *Cache) Cleanup()
- func (c *Cache) Clear()
- func (c *Cache) Invalidate(host string)
- func (c *Cache) PreferIPv4() bool
- func (c *Cache) Resolve(ctx context.Context, host string) ([]net.IP, error)
- func (c *Cache) ResolveAllSorted(ctx context.Context, host string) ([]net.IP, error)
- func (c *Cache) ResolveIPv6First(ctx context.Context, host string) (ipv6 []net.IP, ipv4 []net.IP, err error)
- func (c *Cache) ResolveOne(ctx context.Context, host string) (net.IP, error)
- func (c *Cache) SetPreferIPv4(prefer bool)
- func (c *Cache) SetTTL(ttl time.Duration)
- func (c *Cache) StartCleanup(ctx context.Context, interval time.Duration)
- func (c *Cache) Stats() (total int, expired int)
- type ECHEntry
- type Entry
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FetchECHConfigs ¶ added in v1.0.1
FetchECHConfigs fetches ECH configs from DNS HTTPS records for the given hostname. Returns nil if no ECH configs are available (this is not an error).
Types ¶
type Cache ¶
type Cache struct {
// contains filtered or unexported fields
}
Cache provides TTL-aware DNS caching
func (*Cache) Invalidate ¶
Invalidate removes a hostname from the cache
func (*Cache) PreferIPv4 ¶ added in v1.0.1
PreferIPv4 returns whether IPv4 is preferred over IPv6
func (*Cache) Resolve ¶
Resolve looks up the IP addresses for a hostname Returns cached result if available and not expired
func (*Cache) ResolveAllSorted ¶
ResolveAllSorted returns all IPs sorted for Happy Eyeballs (RFC 8305) By default IPv6 addresses first, interleaved with IPv4 If PreferIPv4 is set, IPv4 addresses come first
func (*Cache) ResolveIPv6First ¶
func (c *Cache) ResolveIPv6First(ctx context.Context, host string) (ipv6 []net.IP, ipv4 []net.IP, err error)
ResolveIPv6First returns IPv6 addresses first, then IPv4 addresses This is for strict IPv6 preference - try all IPv6 before falling back to IPv4
func (*Cache) ResolveOne ¶
ResolveOne returns a single IP address for the hostname By default prefers IPv6 over IPv4 (modern browser behavior) If PreferIPv4 is set, prefers IPv4 instead
func (*Cache) SetPreferIPv4 ¶ added in v1.0.1
SetPreferIPv4 sets whether to prefer IPv4 addresses over IPv6
func (*Cache) StartCleanup ¶
StartCleanup starts a background goroutine that periodically cleans up expired entries