micro icon indicating copy to clipboard operation
micro copied to clipboard

Added Syntax Highlighting for nftables-firewall config file

Open theredcmdcraft opened this issue 1 year ago • 12 comments

Created nftables syntax highlighting

theredcmdcraft avatar May 30 '24 21:05 theredcmdcraft

Sorry, I do not know much about nftables syntax and syntax highlighting so I cannot review much. There is nothing else I can properly suggest but the header pattern is still at least not changed.

niten94 avatar Jun 09 '24 14:06 niten94

Oh sorry, i didn`t see the "suggested change". I thought it had already been changed.

theredcmdcraft avatar Jun 09 '24 14:06 theredcmdcraft

Sorry, I do not know much about nftables syntax and syntax highlighting so I cannot review much. There is nothing else I can properly suggest but the header pattern is still at least not changed.

Can someone else check the code? Or can you merge it simply?

theredcmdcraft avatar Jun 23 '24 21:06 theredcmdcraft

Can someone else check the code? Or can you merge it simply?

I cannot merge pull requests but I tried reviewing again. I do not know much about syntax highlighting so I think it is better if another person reviews a bit. I think not adding all expressions and merging may be fine for now.

I looked at nft(8) manpage as a reference but I think reading it may be confusing when not looking at the wiki first.

niten94 avatar Jun 24 '24 13:06 niten94

It may look weird if groups in IPv6 addresses with hex digits are not highlighted but integers can be highlighted using this rule:

    - constant.number: "\\b([1-9][0-9]*|0[0-7]*|0[Xx][0-9A-Fa-f]+)\\b"

There is a lot of expressions in nftables but the keywords suggested are usually used so it may be fine highlighting them only for now.

i think we must not check everything at the first time. there is also a tool called nft. with the command nft -c -f <path to file> you can check the nftables syntax before you restart the service. this will prompt you if there is an error in your config file.

theredcmdcraft avatar Jun 24 '24 20:06 theredcmdcraft

A git client will have to be used, but can you please squash the commits into one and amend on the latest commit after editing the file?

niten94 avatar Jul 02 '24 09:07 niten94

A git client will have to be used, but can you please squash the commits into one and amend on the latest commit after editing the file?

Oh sorry i didn`t used a git client. I have accepted your suggestions. I saw your message little bit to late.

theredcmdcraft avatar Jul 12 '24 18:07 theredcmdcraft

I am sorry that I did not respond early weeks ago too. I think the file is fine now, but I do not know if the pull request will be merged if the commits are not squashed.

niten94 avatar Jul 12 '24 19:07 niten94

I am sorry that I did not respond early weeks ago too. I think the file is fine now, but I do not know if the pull request will be merged if the commits are not squashed.

I don't know if i can Squash the commits.

theredcmdcraft avatar Jul 12 '24 19:07 theredcmdcraft

It is late here (3 AM) so I cannot assist much but something like these can be done:

sudo apt install git openssh-client
ssh-keygen -t ed25519 -f ~/.ssh/id_github

# open https://github.com/settings/keys in browser
# copy ~/.ssh/id_github.pub (not id_github) content and add key

exec ssh-agent bash
ssh-add ~/.ssh/id_github
git clone ssh://[email protected]/theredcmdcraft/micro.git
# reset to commit before first commit in this pull request
git reset --soft dfd3df5~1
# write commit message then save
# message can be just something like "Add nftables syntax highlighting"
git commit
git push -u origin master

There are still other pages about squashing you can read but this is what I would do.

niten94 avatar Jul 12 '24 19:07 niten94

It is late here (3 AM) so I cannot assist much but something like these can be done:

sudo apt install git openssh-client
ssh-keygen -t ed25519 -f ~/.ssh/id_github

# open https://github.com/settings/keys in browser
# copy ~/.ssh/id_github.pub (not id_github) content and add key

exec ssh-agent bash
ssh-add ~/.ssh/id_github
git clone ssh://[email protected]/theredcmdcraft/micro.git
# reset to commit before first commit in this pull request
git reset --soft dfd3df5~1
# write commit message then save
# message can be just something like "Add nftables syntax highlighting"
git commit
git push -u origin master

There are still other pages about squashing you can read but this is what I would do.

I tried my best. Please have a look if this is correct. I hope you`re fine now.

theredcmdcraft avatar Aug 08 '24 21:08 theredcmdcraft

I am really sorry, it was not a good idea replying at 3 AM and I did not include --force in git push. I tested this with your branch on a private repository, but please try running these if possible:

exec ssh-agent bash
ssh-add ~/.ssh/id_github

# reset to first commit in pull request
git reset --soft dfd3df52
# save only
git commit --amend --date=now
git push --force -u origin master

niten94 avatar Aug 10 '24 14:08 niten94

I am really sorry, it was not a good idea replying at 3 AM and I did not include --force in git push. I tested this with your branch on a private repository, but please try running these if possible:

exec ssh-agent bash
ssh-add ~/.ssh/id_github

# reset to first commit in pull request
git reset --soft dfd3df52
# save only
git commit --amend --date=now
git push --force -u origin master

Sorry for the realy late reply. In last weeks there was a lot of stuff that i had to do. So hopefully now it sould be correctly squashed.

theredcmdcraft avatar Sep 08 '24 13:09 theredcmdcraft

Do you can merge it?

theredcmdcraft avatar Oct 05 '24 11:10 theredcmdcraft