Skip to content

Commit 3b3cc83

Browse files
committed
dnsx/transport: avoid stopping dnscrypt transport
DNSCrypt transport lifecycle is handled by DcMulti and so stopping transports against any existing id being replaced is likely to step on the newly added transport and not the previous replaced one.
1 parent f37d7f1 commit 3b3cc83

1 file changed

Lines changed: 18 additions & 6 deletions

File tree

intra/dnsx/transport.go

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,20 @@ func (r *resolver) Add(dt x.DNSTransport) (ok bool) {
349349

350350
caching := false
351351
switch t.Type() {
352-
case DNS53, DNSCrypt, DOH, DOT, ODOH:
352+
case DNSCrypt:
353+
// DNSCrypt transports must not be explicitly stopped here
354+
// as the stop/start for it is handled DcMulti
355+
r.Lock()
356+
r.transports[tid] = t
357+
if ct := NewCachingTransport(r.ctx, t, ttl10m); ct != nil {
358+
ctid := idstr(ct)
359+
r.transports[ctid] = ct
360+
caching = true
361+
}
362+
r.Unlock()
363+
core.Go("r.onAdd", func() { r.listener.OnDNSAdded(tid) })
364+
ok = true
365+
case DNS53, DOH, DOT, ODOH:
353366
r.Lock()
354367
// stop existing transport if different
355368
if oldt := r.transports[tid]; !core.PtrEq(t, oldt) {
@@ -375,14 +388,13 @@ func (r *resolver) Add(dt x.DNSTransport) (ok bool) {
375388
}
376389

377390
core.Go("r.onAdd", func() { r.listener.OnDNSAdded(tid) })
378-
log.I("dns: add transport %s@%s; caching? %t",
379-
t.ID(), t.GetAddr(), caching)
380-
381-
return true
391+
ok = true
382392
default:
383393
log.E("dns: unknown transport(%s) type: %s", t.ID(), t.Type())
384394
}
385-
return false
395+
log.I("dns: add transport %s@%s; caching? %t",
396+
t.ID(), t.GetAddr(), caching)
397+
return ok
386398
}
387399

388400
func (r *resolver) GetMult(id string) (x.DNSTransportMult, error) {

0 commit comments

Comments
 (0)