Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nftables improvements #3517

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
10 changes: 4 additions & 6 deletions runtime/syntax/nftables.yaml
Original file line number Diff line number Diff line change
@@ -1,25 +1,23 @@
filetype: nftables

detect:
filename: "((nftables.conf$)|(nftables.rules.d/)|(nftables.d/)|(nftables.rules$))"
filename: "(nftables\\.(conf|rules)$|nftables(\\.rules)?\\.d/)"
header: "^(#!.*/(env +)?nft( |$)|flush +ruleset)"

rules:
- type: "\\b(chain|counter|map|rule|ruleset|set|table)\\b"
- type: "\\b(ether|inet|i(cm)?p(x|(v?(4|6))?)|tcp|udp)\\b"
theredcmdcraft marked this conversation as resolved.
Show resolved Hide resolved
- special: "\\b(elements|hook|policy|priority|type|state)\\b"
- identifier: "\\b(ct|iif|iifname|meta|oif|oifname|th|dport|sport|saddr|daddr)\\b"
- identifier: "\\b(ct|iif|iifname|meta|oif|oifname|th|dport|sport|saddr|daddr|l4proto)\\b"
- statement: "\\b(accept|drop|goto|jump|log|masquerade|reject|limit|queue)\\b"
- preproc: "\\b(add|define|flush|include|delete)\\b"
- symbol.operator: "[<>.&|^!=:;,@]|[!=]|\\b(and|ge|gt|le|lt|or|xor)\\b"
- symbol.operator: "[<>.&|^:;,@]|[!=]|\\b(and|ge|gt|le|lt|or|xor)\\b"
theredcmdcraft marked this conversation as resolved.
Show resolved Hide resolved
- constant.string: '([\+\-\*/][\"]{1})(.*)([\"]{1})'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you give concrete examples for this rule? Looks like it's related to operators.
Usually a string is a region in micro's syntax definition.

- constant.string:
start: "\""
end: "\""
# Integer Constants
- constant.number: "(\\b([1-9][0-9]*|0[0-7]*|0[Xx][0-9A-Fa-f]+|0[Bb][01]+)([Uu][Ll]?[Ll]?|[Ll][Ll]?[Uu]?)?\\b)"
# Hexadecimal Floating Constants
- constant.number: "(\\b0[Xx]([0-9A-Za-z]*[.][0-9A-Za-z]+|[0-9A-Za-z]+[.][0-9A-Za-z]*)[Pp][+-]?[0-9]+[FfLl]?\\b)"
JoeKar marked this conversation as resolved.
Show resolved Hide resolved
- constant.number: "([-+]?[1-9]\\d*)"
theredcmdcraft marked this conversation as resolved.
Show resolved Hide resolved
- identifier.var: "[$@][a-zA-Z_.][a-zA-Z0-9_/.-]*"
- comment: "(^|[[:space:]])#([^{].*)?$"
- indent-char.whitespace: "[[:space:]]+$"
Expand Down
Loading