From 09ec2f39b5c612e47077272272d9d39e2048277f Mon Sep 17 00:00:00 2001 From: Naman Sood Date: Wed, 2 Oct 2024 22:54:02 -0400 Subject: [PATCH] tailcfg: add func to check for known valid ServiceProtos (#13668) Updates tailscale/corp#23574. Signed-off-by: Naman Sood --- tailcfg/tailcfg.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tailcfg/tailcfg.go b/tailcfg/tailcfg.go index 1a8576f20..df50a8603 100644 --- a/tailcfg/tailcfg.go +++ b/tailcfg/tailcfg.go @@ -677,6 +677,16 @@ const ( PeerAPIDNS = ServiceProto("peerapi-dns-proxy") ) +// IsKnownServiceProto checks whether sp represents a known-valid value of +// ServiceProto. +func IsKnownServiceProto(sp ServiceProto) bool { + switch sp { + case TCP, UDP, PeerAPI4, PeerAPI6, PeerAPIDNS, ServiceProto("egg"): + return true + } + return false +} + // Service represents a service running on a node. type Service struct { _ structs.Incomparable