-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path_tailscale
435 lines (381 loc) · 16.4 KB
/
_tailscale
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
#compdef Tailscale tailscale
typeset -a _help_arguments
_help_arguments=(
'(-h --help)--help[show help information]'
'(-h --help)-h[show help information]'
)
_tailscale_commands() {
local -a commands
commands=(
'up:Connect to Tailscale, logging in if needed'
'down:Disconnect from Tailscale'
'set:Change specified preferences'
'login:Log in to a Tailscale account'
'logout:Disconnect from Tailscale and expire current node key'
'switch:Switches to a different Tailscale account'
'configure:[ALPHA] Configure the host to enable more Tailscale features'
'netcheck:Print an analysis of local network conditions'
'ip:Show Tailscale IP addresses'
'status:Show state of tailscaled and its connections'
'ping:Ping a host at the Tailscale layer, see how it routed'
'nc:Connect to a port on a host, connected to stdin/stdout'
'ssh:SSH to a Tailscale machine'
'funnel:Serve content and local servers on the internet'
'serve:Serve content and local servers on your tailnet'
'version:Print Tailscale version'
'web:Run a web server for controlling Tailscale'
'file:Send or receive files'
'bugreport:Print a shareable identifier to help diagnose issues'
'cert:Get TLS certs'
'lock:Manage tailnet lock'
'licenses:Get open source license information'
'exit-node:Show machines on your tailnet configured as exit nodes'
'update:[BETA] Update Tailscale to the latest/different version'
'whois:Show the machine and user associated with a Tailscale IP (v4 or v6)'
)
_describe -t commands 'tailscale command' commands
}
_tailscale_bugreport() {
local -a extra_arguments
extra_arguments=(
'--diagnose=[run additional in-depth checks (default false)]: :(true false)'
'--record=[if true, pause and then write another bugreport (default false)]: :(true false)'
)
_arguments : \
${_help_arguments[@]} \
${extra_arguments[@]}
}
_tailscale_down() {
local -a extra_arguments
extra_arguments=(
'--accept-risk[accept risk and skip confirmation for risk types]: :(all lose-ssh)'
)
_arguments : \
${_help_arguments[@]} \
${extra_arguments[@]}
}
_tailscale_exit-node_subcmds() {
local -a subcmds
subcmds=(
'list:Show exit nodes'
''
)
_describe -t commands 'tailscale exit-node' subcmds
}
_tailscale_exit-node() {
local -a extra_arguments
extra_arguments=(
':::_tailscale_exit-node_subcmds'
)
_arguments : \
${_help_arguments[@]} \
${extra_arguments[@]}
}
_tailscale_file_subcmds() {
local -a subcmds
subcmds=(
'cp:Copy file(s) to a host'
'get:Move files out of the Tailscale file inbox'
)
_describe -t commands 'tailscale file' subcmds
}
_tailscale_file_cp_nodelist() {
_values -S ':' 'address' $(tailscale status | awk '{printf "%s[%s]: ", $1, $2}')
}
_tailscale_file_arg_conflict() {
_values 'arg_conflict' \
'skip[skip conflicting files: leave them in the taildrop inbox and print an error. get any non-conflicting files]' \
'overwrite[overwrite existing file]' \
'rename[write to a new number-suffixed filename]'
}
_tailscale_file() {
local -a extra_arguments
extra_arguments=(
'1: :_tailscale_file_subcmds'
'2: :_files'
'3: :_tailscale_file_cp_nodelist'
)
_arguments : \
${_help_arguments[@]} \
${extra_arguments[@]}
}
_tailscale_funnel_subcmds() {
local -a subcmds
subcmds=(
'status:view current proxy configuration'
'reset:reset current serve/funnel config'
)
_describe -t commands 'tailscale funnel' subcmds
_files
}
_tailscale_funnel() {
local -a extra_arguments
extra_arguments=(
'--bg=[Run the command as a background process (default false)]: :(true false)'
'--set-path[Appends the specified path to the base URL for accessing the underlying service --tcp uint]'
'--tcp[Expose a TCP forwarder to forward raw TCP packets at the specified port]'
'--tls-terminated-tcp[Expose a TCP forwarder to forward TLS-terminated TCP packets at the specified port]'
'--yes=[Update without interactive prompts (default false)]: :(true fasle)'
'1: :_tailscale_funnel_subcmds'
)
_arguments : \
${_help_arguments[@]} \
${extra_arguments[@]}
}
_tailscale_ip_nodelist() {
_values 'address' ${$(tailscale status | awk '{printf "%s ", $2}'):=""}
}
_tailscale_ip() {
local -a extra_arguments
extra_arguments=(
'--1=[only print one IP address (default false)]: :(true false)'
'--4=[only print IPv4 address (default false)]: :(true false)'
'--6=[only print IPv6 address (default false)]: :(true false)'
'1: :_tailscale_ip_nodelist'
)
_arguments : \
${_help_arguments[@]} \
${extra_arguments[@]}
}
_tailscale_licenses() {
_arguments : \
${_help_arguments[@]}
}
_tailscale_lock_subcmds() {
local -a subcmds
subcmds=(
'init:Initialize tailnet lock'
'status:Outputs the state of tailnet lock'
'add:Adds one or more trusted signing keys to tailnet lock'
'remove:Removes one or more trusted signing keys from tailnet lock'
'sign:Signs a node or pre-approved auth key'
'disable:Consumes a disablement secret to shut down tailnet lock for the tailnet'
'disablement-kdf:Computes a disablement value from a disablement secret (advanced users only)'
'log:List changes applied to tailnet lock'
'local-disable:Disables tailnet lock for this node only'
)
_describe -t commands 'tailscale lock' subcmds
}
_tailscale_lock() {
local -a extra_arguments
extra_arguments=(
'--1=[only print one IP address (default false)]: :(true false)'
'--4=[only print IPv4 address (default false)]: :(true false)'
'--6=[only print IPv6 address (default false)]: :(true false)'
'1: :_tailscale_lock_subcmds'
)
_arguments : \
${_help_arguments[@]} \
${extra_arguments[@]}
}
_tailscale_login() {
local -a extra_arguments
extra_arguments=(
'--accept-dns=[accept DNS configuration from the admin panel (default true)]: :(true false)'
'--accept-routes=[accept routes advertised by other Tailscale nodes (default true)]: :(true false)'
'--advertise-connector=[advertise this node as an app connector (default false)]: :(true false)'
'--advertise-exit-node=[offer to be an exit node for internet traffic for the tailnet (default false)]: :(true false)'
'--advertise-routes[routes to advertise to other nodes (comma-separated, e.g. "10.0.0.0/8,192.168.0.0/24") or empty string to not advertise routes]'
'--advertise-tags[comma-separated ACL tags to request; each must start with "tag:" (e.g. "tag:eng,tag:montreal,tag:ssh")]: :(tag\:)'
'--auth-key[node authorization key; if it begins with "file:", then it'\''s a path to a file containing the authkey]'
'--exit-node[Tailscale exit node (IP or base name) for internet traffic, or empty string to not use an exit node]'
'--exit-node-allow-lan-access=[Allow direct access to the local network when routing traffic via an exit node (default false)]: :(true false)'
'--hostname[hostname to use instead of the one provided by the OS]'
'--login-server[base URL of control server (default https://controlplane.tailscale.com)]: :(https\://controlplane.tailscale.com)'
'--nickname[short name for the account]'
'--operator[Unix username to allow to operate on tailscaled without sudo]'
'--qr=[show QR code for login URLs (default false)]: :(true false)'
'--shields-up=[don'\''t allow incoming connections (default false)]: :(true false)'
'--ssh=[run an SSH server, permitting access per tailnet admin'\''s declared policy (default false)]: :(true false)'
'--timeout[maximum amount of time to wait for tailscaled to enter a Running state; default (0s) blocks forever (default 0s)]: :(0)'
)
_arguments : \
${_help_arguments[@]} \
${extra_arguments[@]}
}
_tailscale_logout() {
}
_tailscale_nc() {
}
_tailscale_netcheck() {
local -a extra_arguments
extra_arguments=(
'--every[if non-zero, do an incremental report with the given frequency (default 0s)]: :(0)'
'--format[output format; empty (for human-readable), "json" or "json-line"]'
'--verbose=[verbose logs]: :(true false)'
)
_arguments : \
${_help_arguments[@]} \
${extra_arguments[@]}
}
_tailscale_file_ping_nodelist() {
_values 'address' ${$(tailscale status | awk '{printf "%s[%s] ", $1, $2}'):=""}
}
_tailscale_ping() {
local -a extra_arguments
extra_arguments=(
'--c[max number of pings to send. 0 for infinity. (default 10)]: :(0 10)'
'--icmp=[do a ICMP-level ping (through WireGuard, but not the local host OS stack) (default false)]: :(true false)'
'--size[size of the ping message (disco pings only). 0 for minimum size. (default 0)]: :(0)'
'--timeout[timeout before giving up on a ping (default 5s)]: :(5)'
'--tsmp=[do a TSMP-level ping (through WireGuard, but not either host OS stack) (default false)]: :(true false)'
'--until-direct=[stop once a direct path is established (default true)]: :(true)'
'--verbose=[verbose output (default false)]: :(true false)'
'1: :_tailscale_file_ping_nodelist'
)
_arguments : \
${_help_arguments[@]} \
${extra_arguments[@]}
}
_tailscale_serve() {
local -a extra_arguments
extra_arguments=(
'--bg=[Run the command as a background process (default false)]: :(true false)'
'--http[Expose an HTTP server at the specified port]: :(80)'
'--https[Expose an HTTPS server at the specified port (default mode)]: :(443)'
'--set-path[Appends the specified path to the base URL for accessing the underlying service]'
'--tcp[Expose a TCP forwarder to forward raw TCP packets at the specified port]: :(1080)'
'--tls-terminated-tcp[Expose a TCP forwarder to forward TLS-terminated TCP packets at the specified port]: :(1080)'
'--yes=[Update without interactive prompts (default false)]: :(true false)'
'1: :_tailscale_serve_subcmds'
)
_arguments : \
${_help_arguments[@]} \
${extra_arguments[@]}
}
_tailscale_serve_subcmds() {
local -a subcmds
subcmds=(
'reset:reset current serve/funnel config'
'status:view current proxy configuration'
)
_describe -t commands 'tailscale serve' subcmds
_files
}
_tailscale_set() {
local -a extra_arguments
extra_arguments=(
'--accept-dns=[accept DNS configuration from the admin panel]: :(true false)'
'--accept-risk[accept risk and skip confirmation for risk types]: :(all lose-ssh)'
'--accept-routes=[accept routes advertised by other Tailscale nodes]: :(true false)'
'--advertise-connector=[offer to be an app connector for domain specific internet traffic for the tailnet]: :(true false)'
'--advertise-exit-node=[offer to be an exit node for internet traffic for the tailnet]: :(true false)'
'--advertise-routes[routes to advertise to other nodes (comma-separated, e.g. "10.0.0.0/8,192.168.0.0/24") or empty string to not advertise routes]'
'--auto-update=[automatically update to the latest available version]: :(true false)'
'--exit-node[Tailscale exit node (IP or base name) for internet traffic, or empty string to not use an exit node]'
'--exit-node-allow-lan-access=[Allow direct access to the local network when routing traffic via an exit node]: :(true false)'
'--hostname[hostname to use instead of the one provided by the OS]'
'--nickname[nickname for the current account]'
'--operator[Unix username to allow to operate on tailscaled without sudo]'
'--shields-up=[don'\''t allow incoming connections]: :(true false)'
'--ssh=[run an SSH server, permitting access per tailnet admin'\''s declared policy]: :(true false)'
'--update-check=[notify about available Tailscale updates]: :(true false)'
'--webclient=[run a web interface for managing this node, served over Tailscale at port 5252]: :(true false)'
)
_arguments : \
${_help_arguments[@]} \
${extra_arguments[@]}
}
_tailscale_ssh() {
}
_tailscale_status() {
local -a extra_arguments
extra_arguments=(
'--active=[filter output to only peers with active sessions (not applicable to web mode) (default false)]: :(true false)'
'--browser=[Open a browser in web mode (default true)]: :(true false)'
'--json=[output in JSON format (WARNING: format subject to change) (default false)]: :(true false)'
'--listen[listen address for web mode; use port 0 for automatic (default 127.0.0.1:8384)]: :(0)'
'--peers=[show status of peers (default true)]: :(true false)'
'--self=[show status of local machine (default true)]: :(true false)'
'--web=[run webserver with HTML showing status (default false)]: :(true false)'
)
_arguments : \
${_help_arguments[@]} \
${extra_arguments[@]}
}
_tailscale_switch_idlist() {
_values 'idlist' ${$(tailscale switch --list | \
awk 'NR>2{print line}{line=$0} END{print line}' | \
awk '{printf "%s[%s] ", $1, $3}'):=""}
}
_tailscale_switch() {
local -a extra_arguments
extra_arguments=(
'--list[show current logged accounts list]'
'1: :_tailscale_switch_idlist'
)
_arguments : \
${_help_arguments[@]} \
${extra_arguments[@]}
}
_tailscale_up() {
local -a extra_arguments
extra_arguments=(
'--accept-dns=[accept DNS configuration from the admin panel (default true)]: :(true false)'
'--accept-risk[accept risk and skip confirmation for risk types]: :(all lose-ssh)'
'--accept-routes=[accept routes advertised by other Tailscale nodes (default true)]: :(true false)'
'--advertise-connector=[advertise this node as an app connector (default false)]: :(true false)'
'--advertise-exit-node=[offer to be an exit node for internet traffic for the tailnet (default false)]: :(true false)'
'--advertise-routes[routes to advertise to other nodes (comma-separated, e.g. "10.0.0.0/8,192.168.0.0/24") or empty string to not advertise routes]'
'--advertise-tags[comma-separated ACL tags to request; each must start with "tag:" (e.g. "tag:eng,tag:montreal,tag:ssh")]: :(tag\:)'
'--auth-key[node authorization key; if it begins with "file:", then it'\''s a path to a file containing the authkey]'
'--exit-node[Tailscale exit node (IP or base name) for internet traffic, or empty string to not use an exit node]'
'--exit-node-allow-lan-access=[Allow direct access to the local network when routing traffic via an exit node (default false)]: :(true false)'
'--force-reauth=[force reauthentication (default false)]: :(true false)'
'--hostname[hostname to use instead of the one provided by the OS]'
'--json=[output in JSON format (WARNING: format subject to change) (default false)]: :(true false)'
'--login-server[base URL of control server (default https://controlplane.tailscale.com)]: :(https\://controlplane.tailscale.com)'
'--operator[Unix username to allow to operate on tailscaled without sudo]'
'--qr=[show QR code for login URLs (default false)]: :(true false)'
'--reset=[reset unspecified settings to their default values (default false)]: :(true false)'
'--shields-up=[don'\''t allow incoming connections (default false)]: :(true false)'
'--ssh=[run an SSH server, permitting access per tailnet admin'\''s declared policy (default false)]: :(true false)'
'--timeout[maximum amount of time to wait for tailscaled to enter a Running state; default (0s) blocks forever (default 0s)]: :(0)'
)
_arguments : \
${_help_arguments[@]} \
${extra_arguments[@]}
}
_tailscale_version() {
local -a extra_arguments
extra_arguments=(
'--daemon=[also print local node'\''s daemon version (default false)]: :(true false)'
'--json=[output in JSON format (default false)]: :(true false)'
'--upstream=[fetch and print the latest upstream release version from pkgs.tailscale.com (default false)]: :(true false)'
)
_arguments : \
${_help_arguments[@]} \
${extra_arguments[@]}
}
_tailscale_web() {
local -a extra_arguments
extra_arguments=(
'--cgi=[run as CGI script (default false)]: :(true false)'
'--listen[listen address; use port 0 for automatic (default localhost:8088)]: :(localhost\:8088)'
'--prefix[URL prefix added to requests (for cgi or reverse proxies)]'
'--readonly=[run web UI in read-only mode (default false)]: :(true false)'
)
_arguments : \
${_help_arguments[@]} \
${extra_arguments[@]}
}
_tailscale_whois() {
local -a extra_arguments
extra_arguments=(
'--json=[output JSON (default false)]: :(true false)'
)
_arguments : \
${_help_arguments[@]} \
${extra_arguments[@]}
}
local curcontext="$curcontext"
_arguments : \
${_help_arguments[@]} \
'*:: :->cmds'
if ((CURRENT == 1)); then
_tailscale_commands
fi
if [[ $state == cmds ]]; then
curcontext="${curcontext%:*:*}:tailscale-$words[1]:"
_call_function ret _tailscale_$words[1]
fi