Code
Hub
Workspaces
Following
Trending
Connect
MCP
copy
Create free account
hub
/
github.com/bschaatsbergen/dnsdialer
/ functions
Functions
96 in github.com/bschaatsbergen/dnsdialer
⨍
Functions
96
◇
Types & classes
23
↓ 27 callers
Method
Close
Close shuts down the pool and closes all idle connections. After Close() is called, Get() will return net.ErrClosed and Put() will close connections
connpool.go:160
↓ 22 callers
Function
New
New creates a new Dialer with the given options. Default configuration: - Strategy: Race (lowest latency) - Timeout: 2 seconds per query - Logger: n
resolver.go:99
↓ 22 callers
Function
WithResolvers
WithResolvers sets the DNS resolvers to query. Each address can be: - IP with port: "8.8.8.8:53" - IP without port: "8.8.8.8" (port 53 is assumed) -
options.go:34
↓ 22 callers
Function
WithStrategy
WithStrategy sets the resolution strategy. Available strategies: - Race: Query all servers, return first successful response (minimize latency) - Fa
options.go:59
↓ 12 callers
Method
String
String returns a string representation of the record
recordtype.go:51
↓ 12 callers
Function
recordsEqual
recordsEqual checks if two slices of DNS records are equal, treating them as multisets. This means: - Order doesn't matter: [A, B] equals [B, A] - Du
util.go:26
↓ 11 callers
Function
WithCache
WithCache enables DNS response caching with TTL-aware expiration. Caching reduces query latency for repeated lookups and load on DNS resolvers. The c
options.go:149
↓ 11 callers
Method
lookupIPs
lookupIPs extracts IP addresses from DNS records.
resolver.go:168
↓ 10 callers
Method
Get
Get retrieves a connection from the pool or creates a new one. This implements a lazy allocation strategy: connections are only created when needed,
connpool.go:71
↓ 9 callers
Method
DialContext
DialContext implements the net.Dialer.DialContext signature, making it a drop-in replacement for any Go code that accepts a custom dialer. Use with H
resolver.go:233
↓ 8 callers
Method
Debug
(msg string, fields ...Field)
resolver.go:59
↓ 7 callers
Method
Error
(msg string, err error, fields ...Field)
resolver.go:61
↓ 7 callers
Function
getSystemResolver
getSystemResolver attempts to read the system's DNS resolver from /etc/resolv.conf. Returns the first nameserver found, with :53 appended if no port i
benchmark_test.go:23
↓ 4 callers
Method
Name
Name returns the identifier of this resolver (typically the server address). Used for logging and in Compare strategy to identify which resolver retur
resolver.go:26
↓ 4 callers
Method
ResolveType
(ctx context.Context, host string, qtype RecordType, resolvers []resolver, logger Logger)
compare.go:12
↓ 4 callers
Method
ResolveType
(ctx context.Context, host string, qtype RecordType, resolvers []resolver, logger Logger)
consensus.go:13
↓ 4 callers
Method
ResolveType
(ctx context.Context, host string, qtype RecordType, resolvers []resolver, logger Logger)
strategy.go:18
↓ 3 callers
Method
ResolveType
(ctx context.Context, host string, qtype RecordType, resolvers []resolver, logger Logger)
fallback.go:12
↓ 2 callers
Method
ResolveType
(ctx context.Context, host string, qtype RecordType, resolvers []resolver, logger Logger)
race.go:13
↓ 2 callers
Function
newDNSCache
newDNSCache creates a new DNS cache with the specified size and TTL bounds. Size controls the maximum number of hostnames to cache (LRU eviction when
cache.go:50
↓ 1 callers
Method
Info
(msg string, fields ...Field)
resolver.go:60
↓ 1 callers
Method
Put
Put returns a connection to the pool for reuse, or closes it if the pool is full. Always call Put() after you're done with a connection, even if an e
connpool.go:117
↓ 1 callers
Method
ResolveType
ResolveType performs a DNS query for a specific record type. Returns records on success, or an error if the query fails.
resolver.go:22
↓ 1 callers
Function
WithTimeout
WithTimeout sets the per-query timeout. This timeout applies to individual DNS queries, not the overall Lookup() call. For strategies that query mult
options.go:80
↓ 1 callers
Method
getIPs
getIPs retrieves cached IP addresses for a hostname if they exist and haven't expired. This is the fast path for lookupIPs() and is crucial for perfor
cache.go:72
↓ 1 callers
Method
isExpired
isExpired checks if the IP cache entry has expired based on DNS TTL.
cache.go:25
↓ 1 callers
Method
lookup
lookup performs DNS resolution using the configured strategy. Always queries for A and AAAA records (IPv4 and IPv6).
resolver.go:118
↓ 1 callers
Function
newConnPool
(addr string, timeout time.Duration, size int)
connpool.go:45
↓ 1 callers
Function
newUDPResolver
(addr string, timeout time.Duration, poolSize int)
udp.go:35
↓ 1 callers
Method
setIPs
setIPs stores already-parsed IP addresses in the cache with TTL-based expiration. The TTL is passed in from the caller who has already figured out the
cache.go:101
Function
BenchmarkCGOStatus_Info
This is just a convenience bench test to report CGO status in benchmarks. If the Go compiler is invoked with CGO_ENABLED=1, cgoStatus will be "WithCGO
cgo_benchmark_test.go:20
Function
BenchmarkCGO_DNSDialer_LookupHost
(b *testing.B)
cgo_benchmark_test.go:49
Function
BenchmarkCGO_StdLib_LookupHost
(b *testing.B)
cgo_benchmark_test.go:24
Function
BenchmarkDNSDialer_DialContext_Cache_Race3
(b *testing.B)
benchmark_test.go:273
Function
BenchmarkDNSDialer_DialContext_Cache_Single_Race
(b *testing.B)
benchmark_test.go:239
Function
BenchmarkDNSDialer_DialContext_IPLiteral
(b *testing.B)
benchmark_test.go:459
Function
BenchmarkDNSDialer_DialContext_NoCache_Race3
(b *testing.B)
benchmark_test.go:257
Function
BenchmarkDNSDialer_DialContext_NoCache_Single_Race
(b *testing.B)
benchmark_test.go:222
Function
BenchmarkDNSDialer_HTTPGet_Cache_Race3
(b *testing.B)
benchmark_test.go:371
Function
BenchmarkDNSDialer_HTTPGet_Cache_Single_Race
(b *testing.B)
benchmark_test.go:326
Function
BenchmarkDNSDialer_HTTPGet_Local
(b *testing.B)
benchmark_test.go:414
Function
BenchmarkDNSDialer_HTTPGet_NoCache_Race3
(b *testing.B)
benchmark_test.go:349
Function
BenchmarkDNSDialer_HTTPGet_NoCache_Single_Race
(b *testing.B)
benchmark_test.go:304
Function
BenchmarkDNSDialer_LookupHost_Cache_Consensus2
(b *testing.B)
benchmark_test.go:186
Function
BenchmarkDNSDialer_LookupHost_Cache_Fallback2
(b *testing.B)
benchmark_test.go:169
Function
BenchmarkDNSDialer_LookupHost_Cache_Race3
(b *testing.B)
benchmark_test.go:152
Function
BenchmarkDNSDialer_LookupHost_Cache_Single_Race
(b *testing.B)
benchmark_test.go:135
Function
BenchmarkDNSDialer_LookupHost_NoCache_Consensus2
(b *testing.B)
benchmark_test.go:114
Function
BenchmarkDNSDialer_LookupHost_NoCache_Fallback2
(b *testing.B)
benchmark_test.go:98
Function
BenchmarkDNSDialer_LookupHost_NoCache_Race3
(b *testing.B)
benchmark_test.go:82
Function
BenchmarkDNSDialer_LookupHost_NoCache_Single_Race
(b *testing.B)
benchmark_test.go:66
Function
BenchmarkStdLibResolver_LookupHost
(b *testing.B)
benchmark_test.go:53
Function
BenchmarkStdLib_DialContext
(b *testing.B)
benchmark_test.go:206
Function
BenchmarkStdLib_DialContext_IPLiteral
(b *testing.B)
benchmark_test.go:443
Function
BenchmarkStdLib_HTTPGet
(b *testing.B)
benchmark_test.go:290
Function
BenchmarkStdLib_HTTPGet_Local
(b *testing.B)
benchmark_test.go:394
Method
Debug
(msg string, fields ...Field)
strategy_test.go:49
Method
Debug
(msg string, fields ...Field)
resolver.go:75
Method
Error
(msg string, err error, fields ...Field)
strategy_test.go:57
Method
Error
(msg string, err error, fields ...Field)
resolver.go:77
Method
Info
(msg string, fields ...Field)
strategy_test.go:53
Method
Info
(msg string, fields ...Field)
resolver.go:76
Method
Name
()
strategy_test.go:25
Method
Name
()
udp.go:170
Method
ResolveType
(ctx context.Context, host string, qtype RecordType)
strategy_test.go:29
Method
ResolveType
(ctx context.Context, host string, qtype RecordType)
udp.go:54
Method
String
()
strategy_test.go:40
Method
String
String returns the string representation of the record type
recordtype.go:39
Function
TestCompare_IgnoreTTLDifferences
(t *testing.T)
strategy_test.go:269
Function
TestCompare_NoDiscrepancy
(t *testing.T)
strategy_test.go:219
Function
TestCompare_NoOnDiscrepancyCallback
(t *testing.T)
strategy_test.go:294
Function
TestCompare_WithDiscrepancy
(t *testing.T)
strategy_test.go:243
Function
TestConsensus_DefaultMinAgreement
(t *testing.T)
strategy_test.go:150
Function
TestConsensus_IgnoreTTL
(t *testing.T)
strategy_test.go:133
Function
TestConsensus_MajorityAgreement_Succeeds
(t *testing.T)
strategy_test.go:115
Function
TestConsensus_MinorityAgreement_Fails
(t *testing.T)
strategy_test.go:98
Function
TestDialer_DialContext
(t *testing.T)
resolver_test.go:23
Function
TestDialer_DialContext_HTTPClient
(t *testing.T)
resolver_test.go:48
Function
TestDialer_DialContext_gRPC
(t *testing.T)
resolver_test.go:75
Function
TestFallback_AllResolversFail
(t *testing.T)
strategy_test.go:203
Function
TestFallback_FirstResolverFails
(t *testing.T)
strategy_test.go:186
Function
TestFallback_FirstResolverSucceeds
(t *testing.T)
strategy_test.go:169
Function
TestRace_AllResolversFail
(t *testing.T)
strategy_test.go:82
Function
TestRace_FirstSuccessfulResponse
(t *testing.T)
strategy_test.go:65
Function
TestRecordsEqual_DifferentDuplicateCount
(t *testing.T)
util_test.go:88
Function
TestRecordsEqual_DifferentLengths
(t *testing.T)
util_test.go:116
Function
TestRecordsEqual_DifferentOrder
(t *testing.T)
util_test.go:27
Function
TestRecordsEqual_DifferentTTL
(t *testing.T)
util_test.go:51
Function
TestRecordsEqual_DifferentValues
(t *testing.T)
util_test.go:40
Function
TestRecordsEqual_DuplicateRecords
(t *testing.T)
util_test.go:73
Function
TestRecordsEqual_EmptySlices
(t *testing.T)
util_test.go:100
Function
TestRecordsEqual_IgnoreTTL
(t *testing.T)
util_test.go:62
Function
TestRecordsEqual_OneEmpty
(t *testing.T)
util_test.go:107
Function
TestRecordsEqual_SameRecords
(t *testing.T)
util_test.go:14
Function
WithConnPoolSize
WithConnPoolSize sets the maximum number of pooled connections per resolver. Connection pooling reduces socket creation/destruction overhead. Each DN
options.go:121
Function
WithLogger
WithLogger sets a custom logger for debugging and monitoring. The logger receives structured log events about query attempts, failures, strategy deci
options.go:100