@@ -484,12 +484,7 @@ func (r *resolver) LocalLookup(q []byte) ([]byte, string, error) {
484484 }
485485
486486 loopingBack := settings .Loopingback .Load ()
487- defaultIsSystemDNS := false
488- if dtr , _ := r .Get (x .StrOf (Default )); dtr != nil {
489- // todo: a better way to determine whether Default is SystemDNS
490- // Default is usually SystemDNS if it is of type DNS53
491- defaultIsSystemDNS = dtr .Type ().V () == DNS53
492- }
487+ defaultIsSystemDNS := r .isDefaultSystemDNS ()
493488
494489 // including dns64 and/or alg
495490 ans , tid , err := r .forward (q , protect .UidSelf , Default )
@@ -1352,10 +1347,10 @@ func CanUseProxy(id string) bool {
13521347 switch id {
13531348 case Goos , CT + Goos , Local , CT + Local , System , CT + System :
13541349 return false
1355- case Bootstrap , CT + Bootstrap , Default , CT + Default :
1356- return false
13571350 case Preset , CT + Preset :
13581351 return false
1352+ case Default , CT + Default , Bootstrap , CT + Bootstrap :
1353+ return canProxyDefault ()
13591354 }
13601355 return true
13611356}
@@ -1371,10 +1366,12 @@ func overrideProxyIfNeeded(pid string, ids ...string) string {
13711366 return NetExitProxy
13721367 case CT + Goos , CT + Local : // exit
13731368 return NetExitProxy
1374- case Bootstrap , Default , System , Preset : // base
1369+ case System , Preset : // base
13751370 return NetBaseProxy
1376- case CT + Bootstrap , CT + Default , CT + System , CT + Preset : // base
1371+ case CT + System , CT + Preset : // base
13771372 return NetBaseProxy
1373+ case Default , CT + Default , Bootstrap , CT + Bootstrap : // may be proxy
1374+ return proxyForDefault (pid )
13781375 }
13791376 }
13801377 return pid // as-is
@@ -1386,15 +1383,44 @@ func skipBlock(tr ...Transport) bool {
13861383 continue
13871384 }
13881385 switch idstr (t ) { // Plus/CT+Plus to skip blocks conditionally?
1389- case Default , BlockFree , Alg , Bootstrap :
1386+ case BlockFree , Alg :
13901387 return true
1391- case CT + Default , CT + BlockFree , CT + Alg , CT + Bootstrap :
1388+ case CT + BlockFree , CT + Alg :
13921389 return true
1390+ case Default , CT + Default , Bootstrap , CT + Bootstrap :
1391+ return canBlockDefault ()
13931392 }
13941393 }
13951394 return false
13961395}
13971396
1397+ func (r * resolver ) isDefaultSystemDNS () (y bool ) {
1398+ if dtr , _ := r .GetInternal (Default ); dtr != nil {
1399+ // todo: a better way to determine whether Default is SystemDNS
1400+ // Default is usually SystemDNS if it is of type DNS53
1401+ y = dtr .Type ().V () == DNS53
1402+ }
1403+ return
1404+ }
1405+
1406+ func canBlockDefault () bool {
1407+ // TODO: check for gateway.split?
1408+ return settings .Loopingback .Load ()
1409+ }
1410+
1411+ func canProxyDefault () bool {
1412+ // TODO: check for gateway.split?
1413+ // TODO: do not allow proxying when Default is mapped to Goos/System
1414+ return settings .Loopingback .Load ()
1415+ }
1416+
1417+ func proxyForDefault (pid string ) string {
1418+ if canProxyDefault () {
1419+ return pid
1420+ }
1421+ return NetBaseProxy
1422+ }
1423+
13981424func skipInternalCache (tids ... string ) bool {
13991425 return isAnyBlockAll (tids ... )
14001426}
0 commit comments