Skip to content

Commit 3a48afc

Browse files
committed
dnsx: assign block-target where approp
1 parent 6af6923 commit 3a48afc

File tree

5 files changed

+14
-8
lines changed

5 files changed

+14
-8
lines changed

intra/dnsx/alg.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1011,10 +1011,11 @@ func (t *dnsgateway) querySecondary(t2 Transport, uid, network string, msg *dns.
10111011
log.V("alg: querySecondary: skip; sec transport %s; nores? %t, err? %v", idstr(t2), r == nil, err)
10121012
result.smm.Msg = errNotEnoughAnswers.Error()
10131013
return
1014-
} else if a, blocklistnames := t.rdns.blockA( /*may be nil*/ t2, nil, msg, r, result.smm.Blocklists); a != nil {
1014+
} else if a, blockedtarget, blocklistnames := t.rdns.blockA( /*may be nil*/ t2, nil, msg, r, result.smm.Blocklists); a != nil {
10151015
// if "a" is not nil, then the r is blocked
10161016
if len(blocklistnames) > 0 {
10171017
result.smm.Blocklists = blocklistnames
1018+
result.smm.BlockedTarget = blockedtarget
10181019
}
10191020
// when rdns.blockA blocks, A/AAAA must be 0.0.0.0/::
10201021
// and HTTPS/SVCB is an empty answer section
@@ -1028,6 +1029,7 @@ func (t *dnsgateway) querySecondary(t2 Transport, uid, network string, msg *dns.
10281029
} else {
10291030
if len(blocklistnames) > 0 {
10301031
result.smm.Blocklists = blocklistnames
1032+
result.smm.BlockedTarget = blockedtarget
10311033
}
10321034
if xdns.AQuadAUnspecified(r) {
10331035
// A/AAAA must be 0.0.0.0/::, set UpstreamBlocks to true
@@ -1200,6 +1202,7 @@ func (t *dnsgateway) q(t1, t2 Transport, preset []netip.Addr, network, uid strin
12001202

12011203
// inform kt of secondary blocklists, if any
12021204
smm.Blocklists = secres.smm.Blocklists
1205+
smm.BlockedTarget = secres.smm.BlockedTarget
12031206
smm.UpstreamBlocks = secres.smm.UpstreamBlocks || smm.UpstreamBlocks
12041207

12051208
if smm.UpstreamBlocks || len(secres.smm.Msg) > 0 {
@@ -2261,9 +2264,10 @@ func withPresetSummary(smm *x.DNSSummary, reqSent, fixed bool) {
22612264
smm.Server = "127.5.3.9"
22622265
}
22632266
smm.Server = PrefixFor(id) + smm.Server
2264-
smm.Blocklists = "" // blocklists are not honoured
2265-
smm.PID = "" // no relay is used
2266-
smm.RPID = "" // no hops either
2267+
smm.Blocklists = "" // blocklists are not honoured
2268+
smm.BlockedTarget = "" // no targets are blocked
2269+
smm.PID = "" // no relay is used
2270+
smm.RPID = "" // no hops either
22672271
}
22682272

22692273
func idstr(t Transport) string {

intra/dnsx/cacher.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -608,6 +608,7 @@ func fillSummary(s *x.DNSSummary, out *x.DNSSummary) {
608608
out.RTtl = s.RTtl
609609
out.Status = s.Status
610610
out.Blocklists = s.Blocklists
611+
out.BlockedTarget = s.BlockedTarget
611612
out.Msg = s.Msg
612613
out.UpstreamBlocks = s.UpstreamBlocks
613614
}

intra/dnsx/rethinkdns.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ type RDNS interface {
8484
x.RDNS
8585
OnDeviceBlock() bool // Mode
8686
blockQuery(*dns.Msg) (string, error)
87-
blockAnswer(*dns.Msg) (string, error)
87+
blockAnswer(*dns.Msg) (string, string, error)
8888
}
8989

9090
type rethinkdns struct {
@@ -297,8 +297,8 @@ func (r *rethinkdns) keyToNames(list []string) (v []string) {
297297
return
298298
}
299299

300-
func (r *rethinkdns) blockQuery(*dns.Msg) (b string, err error) { err = errRemote; return }
301-
func (r *rethinkdns) blockAnswer(*dns.Msg) (b string, err error) { err = errRemote; return }
300+
func (r *rethinkdns) blockQuery(*dns.Msg) (b string, err error) { err = errRemote; return }
301+
func (r *rethinkdns) blockAnswer(*dns.Msg) (t, b string, err error) { err = errRemote; return }
302302

303303
func (r *rethinkdnslocal) blockQuery(msg *dns.Msg) (blocklists string, err error) {
304304
if len(msg.Question) <= 0 {

intra/dnsx/wall.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ func (r *resolver) blockA(t, t2 Transport, q, ans *dns.Msg, blocklistStamp strin
175175
if settings.Debug {
176176
log.V("wall: no local blockerA; letting through %s", qname)
177177
}
178-
return nil, ""
178+
return
179179
}
180180

181181
if !b.OnDeviceBlock() {

intra/doh/doh.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -816,6 +816,7 @@ func (t *transport) Query(network string, q *dns.Msg, smm *x.DNSSummary) (r *dns
816816
smm.RTtl = xdns.RTtl(r)
817817
smm.Status = status
818818
smm.Region = region
819+
// TODO: smm.BlockedTarget
819820
smm.Blocklists = blocklists
820821
if t.typ == dnsx.ODOH && len(t.odohproxyname) > 0 {
821822
smm.PID = t.odohproxyname // odoh proxy

0 commit comments

Comments
 (0)