Skip to content

Commit

Permalink
support boolean value in matching
Browse files Browse the repository at this point in the history
  • Loading branch information
dmachard committed Dec 18, 2023
1 parent 85de089 commit 89262b7
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
2 changes: 2 additions & 0 deletions collectors/dnsmessage.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,8 @@ func (c *DNSMessage) ReadConfig() {
c.ReadConfigMatching(value)
}
}

// TODO check drop policy
}

func (c *DNSMessage) LoadData(matchSource string, srcKind string) (MatchSource, error) {
Expand Down
1 change: 1 addition & 0 deletions config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ pipelines:
dnsmessage:
matching:
include:
#dns.flags.qr: false
dns.opcode: 0
dns.length:
greater-than: 50
Expand Down
8 changes: 7 additions & 1 deletion dnsutils/message.go
Original file line number Diff line number Diff line change
Expand Up @@ -946,9 +946,15 @@ func (dm *DNSMessage) Matching(matching map[string]interface{}) (error, bool) {
return nil, false
}

// bool
case reflect.Bool:
if value != fieldValue.Interface().(bool) {
return nil, false
}

// other types
default:
return fmt.Errorf("unsupported type %s", reflect.Slice), false
return fmt.Errorf("unsupported type value: %s", reflectedValue.Kind()), false
}

}
Expand Down

0 comments on commit 89262b7

Please sign in to comment.