Repository navigation
0.6.0: quoted previews; --open prefilled add form (#26) - #27
Merged
Merged
Conversation
A preview with a comment such as 'headscale control (tailnet)' was shown unquoted, so pasting it into a shell failed on the parenthesis even though the rule itself was written correctly. tui-kit v0.4.3 renders every preview with runner.Join, one shell-quoted word per argv element. The UI tests now expect the quoted preview; the nftables builder tests compare the raw nft words instead, since they pin nft syntax, not shell quoting. The iptables backend no longer limits a comment to one word: that limit only existed because the preview could not show a space. Double quotes and backslashes are still refused, because the staged batch and the save carry the comment through iptables-restore. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01MbCfX3T8khyd9hsrN5kMo3
Another tool that has just found a port closed (tui-tailscale's readiness check, tui-tailscale#32) can now hand the ports over: tui-firewall --open 19443/tcp,41641/udp --comment 'headscale control (tailnet)' The UI opens the add-rule form filled in to allow each port in turn, still previewed and confirmed; esc or n moves on to the next port. The values are validated at start. The target group is the ufw rule list, the firewalld default zone, the inet tui input chain on nftables (the forms wait until the chains exist on an empty ruleset), and the filter INPUT chain of each iptables family. TestPreviewPastesAsTheSameArgv feeds every backend's preview to sh and checks that it reads back as the argv that runs. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01MbCfX3T8khyd9hsrN5kMo3
Document --open and the quoted previews, render the install snippet for 0.6.0, mark the manifest beta explicitly, and re-render every screenshot with tui-kit v0.4.3 (box borders fixed) plus a new one of the prefilled --open form. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01MbCfX3T8khyd9hsrN5kMo3
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #26. Entry point for tui-tools/tui-tailscale#32.
Release notes (0.6.0)
Every command preview is now shell-quoted (tui-kit v0.4.3): a rule whose comment carries a space or a parenthesis previews as
ufw allow 19443/tcp comment 'headscale control (tailnet)', and the line pasted into a shell runs the same argv. On iptables a comment is no longer limited to one word. A new--open <port>/<proto>[,<port>/<proto>...]flag, with an optional--comment <text>, starts the UI in the add-rule form prefilled to allow each port in turn, one form and one confirm per port, still previewed; it is the hand-off target for another tool that has just found a port closed. Every screenshot is re-rendered with the kit's fixed box borders.What changed
go get -u ./...only moved the kit). The UI tests expect the quoted previews; the nftables builder tests compare the raw nft words, since they pin nft syntax rather than shell quoting.runner.Fake.Outputsis not used anywhere in this repo, so no fake needed rekeying."and\, which go through iptables-restore in the staged batch and the save.--open/--comment(cmd/tui-firewall/open.go):tcporudp, no duplicates, the flag may be repeated; the comment is one line of at most 128 characters.--commentwithout--open, and--openwith--checkor--report, are refused.--checkitself is unchanged.escskips a port,ndeclines it, and the next form follows after whatever closed the last one (yes, no, a staged change, a failed command).--commentis not used); nftablesinet tui / input, else the first input-hooked chain, and on an empty ruleset the forms wait until the chains are created withx; iptables filterINPUTof each family (v4 then v6 for each port).--demosupports it (every demo backend).TestPreviewPastesAsTheSameArgvbuilds a rule on each of the four backends with a comment containing spaces, parentheses,',$and backticks (a rich rule with quotes for firewalld), feeds the preview tosh, and checks that the words match the argv the runner executes. There are also UI flow tests per backend and a restore round-trip test for the spaced iptables comment.--opensection, install snippet rendered for 0.6.0,"stability": "beta"explicit intool.json, newtui-firewall-open.png, and all PNGs re-rendered with kit v0.4.3.Lab evidence (podman, driving the TUI in tmux)
tui-firewall --sudo '' --open 19443/tcp,41641/udp --comment 'headscale control (tailnet)', Enter +yper form:$ ufw allow 19443/tcp comment 'headscale control (tailnet)'and the same for41641/udp.ufw statusshows both rules, v4 and v6,# headscale control (tailnet).--checkreads all four with the comment. Pasting the preview into bash givesSkipping adding existing rule, so it is the same argv.firewall-cmd --zone=public --add-port=19443/tcp+--permanent.firewall-cmd --list-portsand--permanent --list-portsboth show19443/tcp 41641/udp, and--checkreads both inpublic.xcreatesinet tuiand its chains, with the quoted previewnft add chain inet tui input '{' type filter hook input priority 0 ';' policy accept ';' '}'. Then the forms open with previewsnft add rule inet tui input tcp dport 19443 counter accept comment '"headscale control (tailnet)"'.nft list chain inet tui inputshows both rules with the comment, the pasted preview adds an identical rule, and--checkreads both.REJECT: four forms (v4 and v6 per port), for exampleiptables -I INPUT 3 -p tcp -m tcp --dport 19443 -m comment --comment 'headscale control (tailnet)' -j ACCEPT, inserted before the REJECT.iptables -Sandip6tables -Sshow them with the comment, the pasted preview works, and--checkreads all four.iptables-restoreaccepts a staged-style line with"staged (it's) fine".make check(fmt, vet, exec boundary, golangci-lint 0 issues, tests) andmake manifestpass.🤖 Generated with Claude Code
https://claude.ai/code/session_01MbCfX3T8khyd9hsrN5kMo3