@@ -807,6 +807,18 @@ func (r *resolver) determineTransport(id string) Transport {
807807 }
808808 } else if isPlus (id ) {
809809 id0 = Plus // replace a plus transport with its mult equivalent
810+ } else if isAnyBlockFree (id ) && canUseDefaultDNS (BlockFree ) {
811+ // use Preferred when BlockFree is not available. BlockFree is only
812+ // added for RDNS endpoints; for other transports, the same transport
813+ // acts as "BlockFree" provided DNSOpts.NOBLOCK is set to true.
814+ id0 = BlockFree
815+ // may technically "leak" DNS queries when Split DNS is true
816+ // and an app's queries are forced through Preferred
817+ id1 = Preferred
818+ if strings .HasPrefix (id , CT ) {
819+ id0 = CT + id0
820+ id1 = CT + id1
821+ }
810822 } else {
811823 id0 = id
812824 }
@@ -1126,6 +1138,7 @@ func (r *resolver) preferencesFrom(qname string, qtyp uint16, s *x.DNSOpts, chos
11261138 log .W ("dns: pref: no tids for %s" , qname )
11271139 // no-op
11281140 } else {
1141+ // TODO: fallback on all id1s
11291142 id1 = r .chooseOne (x ... )
11301143 id2 = r .chooseOne (xx ... ) // mostly, just 0 or 1 secondary
11311144 }
@@ -1175,6 +1188,12 @@ func (r *resolver) preferencesFrom(qname string, qtyp uint16, s *x.DNSOpts, chos
11751188 id1 = Local
11761189 id2 = ""
11771190 }
1191+ if isAnyBlockFree (id1 , id2 ) {
1192+ if s .NOBLOCK != true {
1193+ log .W ("dns: pref: tr for %s; override NOBLOCK" , id1 , id2 , qname )
1194+ s .NOBLOCK = true
1195+ }
1196+ }
11781197
11791198 if len (s .PIDCSV ) > 0 {
11801199 pidcsv = overrideProxyIfNeeded (s .PIDCSV , id1 , id2 )
@@ -1363,6 +1382,7 @@ func canUseDefaultDNS(id string) bool {
13631382 return false
13641383}
13651384
1385+ // Also accounts for prefixes such as CT+ID
13661386func isTransportID (match string , ids ... string ) bool {
13671387 return slices .Contains (ids , match )
13681388}
@@ -1371,6 +1391,10 @@ func isAnyBlockAll(ids ...string) bool {
13711391 return isTransportID (BlockAll , ids ... )
13721392}
13731393
1394+ func isAnyBlockFree (ids ... string ) bool {
1395+ return isTransportID (BlockFree , ids ... )
1396+ }
1397+
13741398func isAnyFixed (ids ... string ) bool {
13751399 return isTransportID (Fixed , ids ... )
13761400}
0 commit comments