headscale/hscontrol/policy/v2
Kristoffer Dalby e4e209f919 policy/v2: canonicalize Protocol form during unmarshal
Tailscale accepts both named ("tcp") and numeric IANA ("6") protocol
forms wherever a Protocol value is allowed. Headscale stored whichever
form the user wrote, leaving downstream code with two equivalents to
handle separately. validateProtocolPortCompatibility only recognised
the named constants and rejected the numeric form, so a policy with
`proto: "6", dst: ["host:443"]` was rejected at parse time even though
SaaS accepts it.

Resolve the disagreement by normalising to the named form during
Protocol.UnmarshalJSON. Every downstream consumer now sees one form
regardless of what the user wrote, so layered guards like
`|| protocol == "6"` in the validator are unnecessary.

Updates #1803
2026-05-12 11:54:54 +01:00
..
testdata policy/v2: add policytester captures recorded from Tailscale SaaS 2026-05-12 11:54:54 +01:00
compiled.go policy/v2: surface autogroup:internet via grants on exit nodes 2026-04-30 19:22:45 +01:00
filter.go policy: surface exit nodes via autogroup:internet (#3212) 2026-04-29 11:24:33 +01:00
filter_test.go policy/v2: surface autogroup:internet via grants on exit nodes 2026-04-30 19:22:45 +01:00
issue_3212_test.go policy: surface exit nodes via autogroup:internet (#3212) 2026-04-29 11:24:33 +01:00
issue_3233_test.go policy/v2: surface autogroup:internet via grants on exit nodes 2026-04-30 19:22:45 +01:00
main_test.go all: fix test flakiness and improve test infrastructure 2026-03-14 02:52:28 -07:00
policy.go policy/v2: evaluate the tests block on user-initiated writes 2026-05-12 11:54:54 +01:00
policy_test.go policy/matcher: include CapGrant.Dsts in match destinations 2026-05-11 14:55:06 +01:00
policytester_compat_test.go policy/v2: canonicalize Protocol form during unmarshal 2026-05-12 11:54:54 +01:00
tailscale_acl_data_compat_test.go all: rephrase prose to fit codebase voice 2026-04-29 16:22:19 +01:00
tailscale_grants_compat_test.go all: rephrase prose to fit codebase voice 2026-04-29 16:22:19 +01:00
tailscale_routes_data_compat_test.go all: rephrase prose to fit codebase voice 2026-04-29 16:22:19 +01:00
tailscale_ssh_data_compat_test.go testdata: drop unused uppercase SSH-*.hujson fixtures 2026-05-05 11:59:01 +01:00
test.go policy/v2: add policytester compat test runner 2026-05-12 11:54:54 +01:00
test_test.go policy/v2: validate tests block at parse boundary 2026-05-12 11:54:54 +01:00
types.go policy/v2: canonicalize Protocol form during unmarshal 2026-05-12 11:54:54 +01:00
types_test.go policy/v2: canonicalize Protocol form during unmarshal 2026-05-12 11:54:54 +01:00
utils.go policy/v2: exclude exit routes from ReduceFilterRules 2026-04-01 14:10:42 +01:00
utils_test.go policy/v2: exclude exit routes from ReduceFilterRules 2026-04-01 14:10:42 +01:00