Port syntax
About 307 words
specht-labs.de/cilium-ports, specht-labs.de/cilium-metrics-ports and a rule entity's ports write ports the same way. specht-labs.de/tailnet-ports is read with the same parser.
[<protocol>:]<port>
[<protocol>:]<from>-<to>
[<protocol>:]*| Entry | Protocol | Ports | Renders to |
|---|---|---|---|
443 | any | 443 | {port: "443", protocol: ANY} |
tcp:443 | TCP | 443 | {port: "443", protocol: TCP} |
udp:53 | UDP | 53 | {port: "53", protocol: UDP} |
sctp:3868 | SCTP | 3868 | {port: "3868", protocol: SCTP} |
tcp:8000-8100 | TCP | 8000 to 8100 | {port: "8000", endPort: 8100, protocol: TCP} |
udp:* | UDP | every port | {port: "0", protocol: UDP} |
* | any | every port | no toPorts |
- Protocols are
tcp,udp,sctpandany, in lowercase. Without one, the entry is for any protocol. - A port is 1 to 65535. In a range, the first port is at most the second.
- Named ports (
http) aren't supported. - Entries in an annotation are separated by commas; in a rule's
ports, each list item is one entry.
A malformed entry in an annotation makes the whole annotation an error, and the plugin treats it as unset. In a rule entity, the catalog module refuses the entity.
Merging
When several flows reach the same peer in the same direction, they become one rule, and their ports are merged:
- an entry that another one covers is dropped:
tcp:443when there's443,tcp:8000-8010when there'stcp:8000-8100; of two equal entries, the first is kept; - a flow without ports, or with
*, covers everything: the merged rule has notoPorts; tcp:*andudp:*cover their protocol only, and stay entries of their own;- the rest is sorted by first port, then protocol.
In code
@spechtlabs/backstage-plugin-cilium-common exports parsePort(entry) (a PortRange or undefined), formatPort(range), portCovers(outer, inner) and mergePorts(sets).
