refactor(config): consolidate transport setup and eliminate duplication

Consolidate DoH/DoH3/DoQ transport initialization into a single
SetupTransport method and introduce generic helper functions to eliminate
duplicated IP stack selection logic across transport getters.

This reduces code duplication by ~77 lines while maintaining the same
functionality.
This commit is contained in:
Cuong Manh Le
2026-01-06 18:50:13 +07:00
committed by Cuong Manh Le
parent e8d1a4604e
commit 1f4c47318e
3 changed files with 54 additions and 114 deletions
+1 -1
View File
@@ -86,7 +86,7 @@ func newDOQConnPool(uc *UpstreamConfig, addrs []string) *doqConnPool {
// Resolve performs a DNS query using a pooled QUIC connection.
func (p *doqConnPool) Resolve(ctx context.Context, msg *dns.Msg) (*dns.Msg, error) {
// Retry logic for io.EOF errors (as per original implementation)
for i := 0; i < 5; i++ {
for range 5 {
answer, err := p.doResolve(ctx, msg)
if err == io.EOF {
continue