@@ -49,6 +49,7 @@ type Handler struct {
4949 server net.Destination
5050 timeout time.Duration
5151 nonIPQuery string
52+ blockTypes []int32
5253}
5354
5455func (h * Handler ) Init (config * Config , dnsClient dns.Client , policyManager policy.Manager ) error {
@@ -63,6 +64,7 @@ func (h *Handler) Init(config *Config, dnsClient dns.Client, policyManager polic
6364 h .server = config .Server .AsDestination ()
6465 }
6566 h .nonIPQuery = config .Non_IPQuery
67+ h .blockTypes = config .BlockTypes
6668 return nil
6769}
6870
@@ -84,12 +86,12 @@ func parseIPQuery(b []byte) (r bool, domain string, id uint16, qType dnsmessage.
8486 errors .LogInfoInner (context .Background (), err , "question" )
8587 return
8688 }
89+ domain = q .Name .String ()
8790 qType = q .Type
8891 if qType != dnsmessage .TypeA && qType != dnsmessage .TypeAAAA {
8992 return
9093 }
9194
92- domain = q .Name .String ()
9395 r = true
9496 return
9597}
@@ -181,10 +183,18 @@ func (h *Handler) Process(ctx context.Context, link *transport.Link, d internet.
181183
182184 if ! h .isOwnLink (ctx ) {
183185 isIPQuery , domain , id , qType := parseIPQuery (b .Bytes ())
186+ if len (h .blockTypes ) > 0 {
187+ for _ , blocktype := range h .blockTypes {
188+ if blocktype == int32 (qType ) {
189+ errors .LogInfo (ctx , "blocked type " , qType , " query for domain " , domain )
190+ return nil
191+ }
192+ }
193+ }
184194 if isIPQuery {
185195 go h .handleIPQuery (id , qType , domain , writer )
186196 }
187- if isIPQuery || h .nonIPQuery == "drop" || qType == 65 {
197+ if isIPQuery || h .nonIPQuery == "drop" {
188198 b .Release ()
189199 continue
190200 }
0 commit comments