@@ -20,6 +20,8 @@ import (
2020 "github.com/miekg/dns"
2121)
2222
23+ const plusSupportsCachedTransports = false
24+
2325const plusMaxTries = 6
2426
2527const ttl10s = 10 * time .Second
@@ -192,8 +194,9 @@ func (t *plus) forward(network string, q *dns.Msg, smm *x.DNSSummary, all ...Tra
192194 }
193195
194196 id := tr .ID ()
195- // todo: remove cached transport prefix? see also: Add()
196- // id, _ := strings.CutPrefix(tr.ID(), CT)
197+ if plusSupportsCachedTransports {
198+ id , _ = strings .CutPrefix (id , CT )
199+ }
197200 if _ , ok := visited [id ]; ok {
198201 continue
199202 }
@@ -264,7 +267,9 @@ func (t *plus) Add(tr x.DNSTransport) bool {
264267 return false
265268 }
266269
267- if cachedTransport (newt ) {
270+ cachingTransport := cachedTransport (newt )
271+ oldTransportStopped := false
272+ if ! plusSupportsCachedTransports && cachingTransport {
268273 log .W ("plus: add %s@%s: err no cached transports" , newt .ID (), newt .GetAddr ())
269274 return false
270275 }
@@ -274,26 +279,36 @@ func (t *plus) Add(tr x.DNSTransport) bool {
274279
275280 if oldt , ok := t .transports [tr .ID ()]; ok {
276281 if oldt == newt {
282+ log .I ("plus: add %s@%s: already present" , newt .ID (), newt .GetAddr ())
277283 return true
278284 }
279285 go oldt .Stop ()
286+ oldTransportStopped = true
280287 }
281288
282289 t .transports [tr .ID ()] = newt
290+
291+ log .I ("plus: add %s@%s; old stopped? %t, cacher? %t" ,
292+ newt .ID (), newt .GetAddr (), oldTransportStopped , cachingTransport )
283293 return true
284294}
285295
286296// Remove implements TransportMult.
287- func (t * plus ) Remove (id string ) bool {
297+ func (t * plus ) Remove (id string ) ( y bool ) {
288298 t .mu .Lock ()
289299 defer t .mu .Unlock ()
290300
291- if tr , ok := t .transports [id ]; ok {
301+ tr , ok := t .transports [id ]
302+
303+ if ok {
292304 go tr .Stop ()
293305 delete (t .transports , id )
294- return true
306+ y = true
295307 }
296- return false
308+
309+ log .I ("plus: remove: %s? %t" , id , y )
310+
311+ return
297312}
298313
299314// Get implements TransportMult.
@@ -309,12 +324,8 @@ func (t *plus) Get(id string) (x.DNSTransport, error) {
309324
310325// Refresh implements TransportMult.
311326func (t * plus ) Refresh () (string , error ) {
312- go func () {
313- for _ , tr := range t .all () { // may be 0 len
314- t .Add (tr ) // add one at a time...
315- }
316- }()
317-
327+ // no-op as dialers.Clear in transport.go already clears the cache
328+ // that holds ips <> doh hostnames mapping.
318329 return t .ID (), nil
319330}
320331
0 commit comments