mirror of
https://github.com/Control-D-Inc/ctrld.git
synced 2026-05-27 12:52:27 +02:00
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:
committed by
Cuong Manh Le
parent
e4e655414c
commit
2d9603609f
@@ -63,7 +63,7 @@ type doqConn struct {
|
||||
mu sync.Mutex
|
||||
}
|
||||
|
||||
func newDOQConnPool(ctx context.Context, uc *UpstreamConfig, addrs []string) *doqConnPool {
|
||||
func newDOQConnPool(_ context.Context, uc *UpstreamConfig, addrs []string) *doqConnPool {
|
||||
_, port, _ := net.SplitHostPort(uc.Endpoint)
|
||||
if port == "" {
|
||||
port = "853"
|
||||
@@ -96,7 +96,7 @@ func newDOQConnPool(ctx context.Context, uc *UpstreamConfig, addrs []string) *do
|
||||
// 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
|
||||
|
||||
Reference in New Issue
Block a user