@@ -26,6 +26,7 @@ func TestFilterNameResolutionQuery(t *testing.T) { //nolint:maintidx
2626 NoRelayIPv4Configured bool
2727 NoRelayIPv6Configured bool
2828 SpoofingTemporarilyDisabled bool
29+ SpoofResponseName string
2930
3031 Host string
3132 QueryType uint16 // defaults to A
@@ -350,6 +351,38 @@ func TestFilterNameResolutionQuery(t *testing.T) { //nolint:maintidx
350351 SpoofingTemporarilyDisabled : true ,
351352 ShouldRespond : false ,
352353 },
354+ {
355+ TestName : "ignore mDNS when response name spoofing is active" ,
356+ Host : "foo" ,
357+ From : someIP ,
358+ SpoofResponseName : "test" ,
359+ HandlerType : HandlerTypeMDNS ,
360+ ShouldRespond : false ,
361+ },
362+ {
363+ TestName : "ignore NetBIOS when response name spoofing is active" ,
364+ Host : "foo" ,
365+ From : someIP ,
366+ SpoofResponseName : "test" ,
367+ HandlerType : HandlerTypeNetBIOS ,
368+ ShouldRespond : false ,
369+ },
370+ {
371+ TestName : "do not ignore DNS when response name spoofing is active" ,
372+ Host : "foo" ,
373+ From : someIP ,
374+ SpoofResponseName : "test" ,
375+ HandlerType : HandlerTypeDNS ,
376+ ShouldRespond : true ,
377+ },
378+ {
379+ TestName : "do not ignore LLMNR when response name spoofing is active" ,
380+ Host : "foo" ,
381+ From : someIP ,
382+ SpoofResponseName : "test" ,
383+ HandlerType : HandlerTypeLLMNR ,
384+ ShouldRespond : true ,
385+ },
353386 }
354387
355388 hostMatcherLookupFunction = func (host string , _ time.Duration ) ([]net.IP , error ) {
@@ -385,6 +418,7 @@ func TestFilterNameResolutionQuery(t *testing.T) { //nolint:maintidx
385418 DryWithDHCPv6Mode : testCase .DryWithDHCPv6Mode ,
386419 SpoofTypes : types ,
387420 SOAHostname : "test" ,
421+ SpoofResponseName : testCase .SpoofResponseName ,
388422 spoofingTemporarilyDisabled : testCase .SpoofingTemporarilyDisabled ,
389423 }
390424
@@ -407,7 +441,8 @@ func TestFilterNameResolutionQuery(t *testing.T) { //nolint:maintidx
407441 }
408442
409443 shouldRespond , _ := shouldRespondToNameResolutionQuery (cfg ,
410- normalizedName (testCase .Host , handlerType ), testCase .QueryType , testCase .From , testCase .FromHostnames )
444+ normalizedName (testCase .Host , handlerType ),
445+ testCase .QueryType , testCase .From , testCase .FromHostnames , testCase .HandlerType )
411446 if shouldRespond != testCase .ShouldRespond {
412447 t .Errorf ("shouldRespondToNameResolutionQuery returned %v instead of %v" ,
413448 shouldRespond , testCase .ShouldRespond )
0 commit comments