lazyufw 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Ronak Maheshwari
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,124 @@
1
+ # lazyufw ๐Ÿ›ก๏ธ
2
+
3
+ > The lazier way to manage UFW (Uncomplicated Firewall) โ€” Lazydocker-style terminal UI with active SSH lockout protection and sudoless privilege setup.
4
+
5
+ [![npm version](https://img.shields.io/npm/v/lazyufw.svg)](https://www.npmjs.com/package/lazyufw)
6
+ [![license](https://img.shields.io/npm/l/lazyufw.svg)](LICENSE)
7
+
8
+ ---
9
+
10
+ ## โœจ Features
11
+
12
+ - ๐Ÿ–ฅ๏ธ **Lazydocker-Style TUI**: Multi-panel dashboard with dedicated panels for **Status & Policies [1]**, **Rules [2]**, **Raw Output [3]**, and **Rule Inspection & Details [4]**.
13
+ - ๐Ÿš€ **Full UFW Feature Coverage**: Full support for `allow`, `deny`, `reject`, `limit`, rule insertion, rule deletion, toggling logging, enabling/disabling firewall, and factory resetting.
14
+ - โšก **Lazydocker Action Menu**: Press `x` anywhere to open the action menu and run commands instantly.
15
+ - ๐Ÿ”’ **SSH Lockout Protection**: Automatically detects active SSH sessions (`SSH_CLIENT`, `SSH_CONNECTION`, `SSH_TTY`) and listening SSH daemons. If a user attempts to disable the firewall, a high-visibility lockout warning modal pops up to prevent accidental disconnection.
16
+ - ๐Ÿ”‘ **Sudoless Setup**: One-time setup writes a safe, strictly-validated (`visudo -c -f`) drop-in rule in `/etc/sudoers.d/lazyufw-nopasswd` so you never have to type your password for UFW operations.
17
+
18
+ ---
19
+
20
+ ## ๐Ÿ“ฆ Installation
21
+
22
+ Install globally via npm:
23
+
24
+ ```bash
25
+ npm install -g lazyufw
26
+ ```
27
+
28
+ Or run instantly via `npx`:
29
+
30
+ ```bash
31
+ npx lazyufw
32
+ ```
33
+
34
+ ---
35
+
36
+ ## ๐Ÿ”‘ One-Time Sudoless Setup
37
+
38
+ To run `lazyufw` without being prompted for a `sudo` password on every firewall operation, run:
39
+
40
+ ```bash
41
+ sudo lazyufw setup
42
+ ```
43
+
44
+ This creates `/etc/sudoers.d/lazyufw-nopasswd` allowing your user to run UFW commands without password prompt.
45
+
46
+ To revoke permissions later:
47
+
48
+ ```bash
49
+ sudo lazyufw teardown
50
+ ```
51
+
52
+ ---
53
+
54
+ ## ๐Ÿš€ Usage
55
+
56
+ Launch the interactive dashboard:
57
+
58
+ ```bash
59
+ lazyufw
60
+ ```
61
+
62
+ ### CLI Commands & Flags
63
+
64
+ ```bash
65
+ lazyufw # Launch the interactive Lazydocker TUI
66
+ lazyufw status # Print verbose firewall status and exit
67
+ lazyufw setup # Configure passwordless sudoers drop-in
68
+ lazyufw teardown # Remove passwordless sudoers drop-in
69
+ lazyufw --help # Show help and keybindings
70
+ lazyufw --version # Show installed version
71
+ ```
72
+
73
+ ---
74
+
75
+ ## โŒจ๏ธ Keybindings
76
+
77
+ | Key | Description |
78
+ |---|---|
79
+ | `1` / `2` / `3` / `4` | Jump to or toggle maximize on Panel (Status / Rules / Raw / Detail) |
80
+ | `Tab` / `Shift+Tab` | Cycle focus between panels |
81
+ | `Esc` | Restore default 4-panel split layout |
82
+ | `x` | Open Lazydocker **Action Menu** |
83
+ | `a` | **Add Rule** (allow, deny, reject, limit by port & protocol) |
84
+ | `i` | **Insert Rule** at specific position (e.g. allow from IP) |
85
+ | `d` | **Delete** currently selected rule |
86
+ | `e` | **Enable** UFW firewall |
87
+ | `D` | **Disable** UFW firewall (*triggers SSH Lockout Protection*) |
88
+ | `l` | **Toggle Logging** (on / off) |
89
+ | `R` | **Reset** firewall (factory wipe custom rules) |
90
+ | `r` | **Refresh** dashboard status & rules |
91
+ | `s` | Setup passwordless sudo helper |
92
+ | `?` | Show Help cheatsheet |
93
+ | `q` / `Ctrl+C` | Quit |
94
+
95
+ ---
96
+
97
+ ## ๐Ÿ›ก๏ธ SSH Lockout Protection
98
+
99
+ Accidentally disabling the firewall on a remote VPS can sever SSH connections or expose the system. `lazyufw` protects remote administrators:
100
+
101
+ 1. When disabling the firewall (hotkey `D` or via Action Menu `x`), `lazyufw` checks whether the current session is connected via SSH or if port 22 is listening.
102
+ 2. If active SSH is detected, an **SSH Lockout Protection Warning Modal** pops up:
103
+ - Displays client IP, connection port, and TTY.
104
+ - Highlights the risk of lockout in bold red.
105
+ - Defaults focus to `[ Cancel (Keep Safe) ]`.
106
+ - Requires deliberate selection of `[ Force Disable Firewall ]` before any disable command can execute.
107
+
108
+ ---
109
+
110
+ ## ๐Ÿงช Development & Testing
111
+
112
+ ```bash
113
+ # Run tests
114
+ bun test
115
+
116
+ # Build release bundle
117
+ npm run build
118
+ ```
119
+
120
+ ---
121
+
122
+ ## ๐Ÿ“„ License
123
+
124
+ MIT ยฉ [Ronak Maheshwari](https://github.com/ronakmaheshwari)