feat: protocol-level filtering in ACL rules#91
Merged
Conversation
Map ACLRule.Proto ('tcp', 'udp', 'icmp', '*') to IP protocol numbers
in the packet filter pipeline:
- Add IPProto []int field to control.FilterRule
- Add protoToIPProto() mapping: tcp→6, udp→17, icmp→1+58
- Wire Proto into buildFilterRules() when constructing filter rules
- Carry IPProto through convertFilterRules() to tailcfg.FilterRule
- meshnet's MatchesFromFilterRules already handles IPProto correctly
The acl-policy.json schema already defined the 'proto' field; this
change makes the engine actually enforce it.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #64
Summary
protofield (tcp,udp,icmp,*) to IP protocol numbers in the packet filter pipelineacl-policy.jsonschema already defined theprotofield butbuildFilterRules()was ignoring it — this change makes the engine actually enforce itChanges
internal/control/types.goIPProto []intfield toFilterRuleinternal/control/dwnclient.goprotoToIPProto()mapping function; wireProtointobuildFilterRules()internal/engine/convert.goIPProtothroughconvertFilterRules()→tailcfg.FilterRule.IPProtointernal/control/control_test.goprotoToIPProto()andbuildFilterRuleswith protocol filteringinternal/engine/convert_test.goconvertFilterRulescarryingIPPrototo tailcfgProtocol mapping
prototcp[6]udp[17]icmp[1, 58]*or emptynilHow it works
buildFilterRules()callsprotoToIPProto(rule.Proto)for each ACL rule[]intis stored inFilterRule.IPProtoconvertFilterRules()copiesIPProtototailcfg.FilterRule.IPProtoMatchesFromFilterRules()already handlesIPProto— it filters the protocol list to validipproto.Protovalues and usesdefaultProtos(TCP, UDP, ICMPv4, ICMPv6) when nilVerification
go build ./...— zero errorsgo vet ./...— zero warningsgo test ./... -count=1 -race— all tests pass, no data races