Skip to content

Instantly share code, notes, and snippets.

@DazWilkin
Created December 2, 2020 19:51
Show Gist options
  • Save DazWilkin/6bfbf1f28d0780d16673a437e7fd55f5 to your computer and use it in GitHub Desktop.
Save DazWilkin/6bfbf1f28d0780d16673a437e7fd55f5 to your computer and use it in GitHub Desktop.
// DNS (!) permitted name parts
// It's permitted to use hyphens but these must occur at most once (!) between alphanumeric
name = { ASCII_ALPHANUMERIC ~ ( ( ASCII_ALPHANUMERIC ~ HYPHEN ~ ASCII_ALPHANUMERIC ) | ASCII_ALPHANUMERIC )* }
full_name = { "name=\"" ~ name ~ "\"" }
domain = { ASCII_ALPHA_LOWER+ }
full_domain = { "domain=\"" ~ domain ~ "\"" }
// It may be redundant to define these as constants!?
tcp = { "tcp" }
udp = { "udp" }
sctp = { "sctp" }
// Kubernetes (my destination) only permits these protocols
protocol = { tcp | udp | sctp }
full_protocol = { "_" ~ protocol }
stype = { ASCII_ALPHA_LOWER+ }
full_stype = { "_" ~ stype }
// For example `_http._tcp`, `_rust._udp`
kind = { full_stype ~ "." ~ full_protocol }
full_kind = { "kind=\"" ~ kind ~ "\"" }
// Although numberic, wrapping in quotes to help delimit
// Otherwise `123456` is matched as `12345` and the `6` is swallowed silently
port = { ASCII_DIGIT{1,5} }
full_port = { "port=\"" ~ port ~ "\"" }
term = { full_kind | full_domain | full_name | full_port }
// Permits repetition but doesn't eliminate duplication
filter = { term ~ ( SPACE_SEPARATOR* ~ term )* }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment