Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CanonicalECS ¶ added in v1.5.5
CanonicalECS returns a canonical string form of the EDNS Client Subnet (ECS, EDNS option 8) carried by msg, suitable for partitioning cache and singleflight keys. A request with no ECS option returns "", so all ECS-less queries share one partition and behave as before.
A request that DOES carry an ECS option is never mapped to "", even at SOURCE PREFIX-LENGTH 0: the /0 query is forwarded with an ECS option, may draw different upstream data than an ECS-less query, and its answer (with the echoed option) must not be served to a client that sent no ECS — RFC 7871 §7.3.1 requires /0-cached data to remain distinguishable. The family is part of the token, so an IPv4 /0 and an IPv6 /0 stay distinct too.
The address is masked to its source prefix length so only the significant subnet bits contribute to the key: two clients in the same subnet share a partition, while different subnets (or address families) never do. The response-only SCOPE PREFIX-LENGTH is deliberately excluded — it is not part of what the client asked for.
Types ¶
type Key ¶
Key is the caching key for DNS message.
ECS partitions the cache by EDNS Client Subnet so an answer resolved for one subnet is never served to a client in a different subnet. Answer records are scoped to the network that generated them (RFC 7871 §7.3), so they must not be shared across subnets even when the question is otherwise identical.
type LRUCache ¶
type LRUCache struct {
// contains filtered or unexported fields
}
LRUCache implements Cacher interface.
func NewLRUCache ¶
NewLRUCache creates a new LRUCache instance with given size.