Остання активність 1 month ago

nuno ревизій цього gist 1 month ago. До ревизії

1 file changed, 292 insertions

helps.sh(файл створено)

@@ -0,0 +1,292 @@
1 + function wgctl::help() {
2 + cat <<EOF
3 + $(log::section "wgctl — WireGuard Management" 2>/dev/null || printf "\n wgctl — WireGuard Management\n")
4 +
5 + Usage: wgctl <command> [options]
6 +
7 + Client Commands:
8 + add, new Add a new client
9 + remove, rm Remove a client
10 + rename, mv Rename a client
11 + list, ls List all clients
12 + inspect Show detailed client info
13 + config Show client config
14 + qr Show QR code for a client
15 +
16 + Access Control:
17 + block, ban Block a client entirely
18 + unblock, unban Restore client access
19 + rule Manage firewall rules (list, show, add, assign...)
20 +
21 + Organization:
22 + group Manage peer groups (list, show, block, watch...)
23 +
24 + Monitoring:
25 + watch Live monitor of WireGuard activity
26 + logs Show activity and firewall logs
27 + audit Verify firewall rules are correctly applied
28 + fw Inspect firewall rules
29 +
30 + Service:
31 + service Manage WireGuard service (start/stop/restart/status)
32 + restart Restart WireGuard
33 + shell Start interactive wgctl shell
34 +
35 + Development:
36 + test Run the wgctl test suite
37 +
38 + Common examples:
39 + wgctl add --name nuno --type phone
40 + wgctl add --name visitor --type guest --subtype phone --group family
41 + wgctl list --blocked
42 + wgctl list --group family
43 + wgctl block --name phone-nuno
44 + wgctl inspect --name phone-nuno
45 + wgctl rule assign --name admin --peer laptop-nuno
46 + wgctl group block --name family
47 + wgctl logs --follow
48 + wgctl audit
49 +
50 + Run 'wgctl <command> --help' for command-specific help.
51 + EOF
52 + }
53 +
54 + function cmd::logs::help() {
55 + cat <<EOF
56 + Usage: wgctl logs [subcommand] [options]
57 +
58 + Show or manage WireGuard and firewall activity logs.
59 +
60 + Subcommands:
61 + show (default) Show activity logs
62 + remove, rm Remove log entries
63 +
64 + Options for show:
65 + --name <name> Filter by client name
66 + --type <type> Filter by device type
67 + --limit <n> Max results per source (default: 50)
68 + --fw Show only firewall drops
69 + --wg Show only WireGuard events
70 + --follow, -f Follow logs in real time
71 +
72 + Options for remove:
73 + --name <name> Remove entries for specific peer
74 + --all Remove all log entries
75 + --fw Remove only firewall events
76 + --wg Remove only WireGuard events
77 + --before <days> Remove entries older than N days
78 + --force Skip confirmation
79 +
80 + Examples:
81 + wgctl logs
82 + wgctl logs --name phone-nuno
83 + wgctl logs --fw --limit 100
84 + wgctl logs --follow
85 + wgctl logs remove --name phone-nuno
86 + wgctl logs remove --all --force
87 + wgctl logs remove --before 7
88 + wgctl logs remove --fw --before 1
89 + EOF
90 + }
91 +
92 + function cmd::rule::help() {
93 + cat <<EOF
94 + Usage: wgctl rule <subcommand> [options]
95 +
96 + Manage firewall rules for peers.
97 +
98 + Subcommands:
99 + list, ls List all rules
100 + show Show rule details
101 + inspect Show full inheritance tree
102 + add, new, create Create a new rule
103 + update, edit Update a rule and re-apply to all peers
104 + remove, rm, del Remove a rule
105 + assign Assign a rule to a peer
106 + unassign Remove rule from a peer
107 + migrate Apply default rules to all unassigned peers
108 + reapply Re-apply a rule to all assigned peers
109 +
110 + Options for list:
111 + --base Show base rules section
112 + --no-base Hide base rules section (default shows them)
113 + --group <name> Filter by group name
114 + --tree Show full inheritance tree inline
115 +
116 + Options for add/update:
117 + --name <name> Rule name
118 + --desc <description> Human readable description
119 + --group <group> Display group (e.g. vm-rules, user-rules)
120 + --extends <rule,...> Inherit from base rules (add only)
121 + --add-extends <rule,...> Add base rules (update only)
122 + --remove-extends <rule,...> Remove base rules (update only)
123 + --allow-ip <ip/cidr> Allow IP or subnet (repeatable)
124 + --allow-port <ip:port:proto> Allow specific port (repeatable)
125 + --block-ip <ip/cidr> Block IP or subnet (repeatable)
126 + --block-port <ip:port:proto> Block specific port (repeatable)
127 + --dns-redirect Force DNS through Pi-hole
128 + --remove-allow-ip <ip> Remove allow IP entry
129 + --remove-allow-port <entry> Remove allow port entry
130 + --remove-block-ip <ip> Remove block IP entry
131 + --remove-block-port <entry> Remove block port entry
132 +
133 + Options for inspect:
134 + --name <name> Rule name
135 + --peers Show assigned peers
136 + --resolved Show resolved/merged rule entries
137 +
138 + Options for assign/unassign:
139 + --name <rule> Rule name
140 + --peer <peer> Peer name
141 + --type <type> Peer device type (optional)
142 +
143 + Examples:
144 + wgctl rule list
145 + wgctl rule list --base
146 + wgctl rule list --group vm-rules
147 + wgctl rule list --tree
148 + wgctl rule show --name guest
149 + wgctl rule inspect --name moonlight-02
150 + wgctl rule inspect --name moonlight-02 --resolved --peers
151 + wgctl rule add --name dev-01 --desc "Dev VM" --group vm-rules --extends no-lan
152 + wgctl rule update --name dev-01 --add-extends no-nginx
153 + wgctl rule update --name dev-01 --remove-extends no-nginx
154 + wgctl rule update --name dev-01 --group infra-rules
155 + wgctl rule assign --name dev-01 --peer laptop-nuno
156 + wgctl rule unassign --peer laptop-nuno
157 + EOF
158 + }
159 +
160 + function cmd::inspect::help() {
161 + cat <<EOF
162 + Usage: wgctl inspect --name <name> [--type <type>]
163 + wgctl inspect <full-name>
164 +
165 + Show detailed information for a single client.
166 +
167 + Options:
168 + --name <name> Client name
169 + --type <type> Device type (optional, combines with --name)
170 + --config Show raw client config
171 + --qr Show QR code
172 +
173 + Examples:
174 + wgctl inspect --name phone-nuno
175 + wgctl inspect --name nuno --type phone
176 + wgctl inspect --name phone-nuno --config
177 + wgctl inspect --name phone-nuno --qr
178 + EOF
179 + }
180 +
181 + function cmd::group::help() {
182 + cat <<EOF
183 + Usage: wgctl group <subcommand> [options]
184 +
185 + Manage peer groups.
186 +
187 + Subcommands:
188 + list, ls List all groups
189 + show Show group details and members
190 + add, new, create Create a new group
191 + remove, rm, del Remove a group definition
192 + rename Rename a group
193 + peer add Add a peer to a group
194 + peer remove, peer rm Remove a peer from a group
195 + rm-peers Remove all peers from WireGuard server
196 + block Block all peers in group
197 + unblock Unblock all peers in group
198 + rule assign Assign a rule to all peers in group
199 + audit Audit all peers in group
200 + logs Show logs for all peers in group
201 + watch Live monitor for all peers in group
202 +
203 + Options:
204 + --name <name> Group name
205 + --desc <description> Group description
206 + --peer <peer> Peer name
207 + --type <type> Peer device type (for peer resolution)
208 + --rule <rule> Rule name (for rule assign)
209 + --new-name <name> New name (for rename)
210 + --force Skip confirmation prompts
211 +
212 + Examples:
213 + wgctl group add --name family --desc "Family devices"
214 + wgctl group peer add --name family --peer phone-nuno
215 + wgctl group block --name family
216 + wgctl group rule assign --name family --rule user
217 + wgctl group audit --name family
218 + EOF
219 + }
220 +
221 + function cmd::audit::help() {
222 + cat <<EOF
223 + Usage: wgctl audit [options]
224 +
225 + Verify WireGuard and firewall state matches expected configuration.
226 +
227 + Options:
228 + --fix Attempt to fix detected issues
229 + --peer <name> Audit specific peer only
230 + --type <type> Audit peers of specific type only
231 +
232 + Examples:
233 + wgctl audit
234 + wgctl audit --peer phone-nuno
235 + wgctl audit --fix
236 + EOF
237 + }
238 +
239 + function cmd::fw::help() {
240 + cat <<EOF
241 + Usage: wgctl fw [subcommand] [options]
242 +
243 + Inspect and manage firewall rules.
244 +
245 + Subcommands:
246 + list Show FORWARD chain rules (default)
247 + nat Show NAT/PREROUTING rules
248 + flush-nat Flush NAT rules for a subnet
249 + count Show rule counts by type
250 +
251 + Options for list:
252 + --peer <name> Filter by peer name
253 + --rule <rule> Filter by rule name (shows all peers with that rule)
254 + --no-nflog Hide NFLOG rules
255 + --no-accept Hide ACCEPT rules
256 + --no-drop Hide DROP rules
257 +
258 + Examples:
259 + wgctl fw list
260 + wgctl fw list --peer phone-nuno
261 + wgctl fw list --rule guest
262 + wgctl fw list --no-nflog
263 + wgctl fw nat
264 + wgctl fw count
265 + wgctl fw flush-nat --subnet 10.1.103.0/24
266 + EOF
267 + }
268 +
269 + function cmd::watch::help() {
270 + cat <<EOF
271 + Usage: wgctl watch [options]
272 +
273 + Live monitor of WireGuard activity.
274 + Shows handshakes from active clients and connection attempts from blocked clients.
275 +
276 + Options:
277 + --type <type> Filter by device type
278 + --name <name> Filter by client name
279 + --peers <list> Filter by comma-separated peer names (used by group watch)
280 + --allowed Show only allowed client handshakes
281 + --restricted Show only restricted client events
282 + --blocked Show only blocked client attempts
283 +
284 + Examples:
285 + wgctl watch
286 + wgctl watch --blocked
287 + wgctl watch --allowed
288 + wgctl watch --type phone
289 + wgctl watch --name phone-nuno
290 + EOF
291 + }
292 +
Новіше Пізніше