-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
/
Copy pathtailscale.ts
469 lines (466 loc) · 11.3 KB
/
tailscale.ts
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
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
type HostsGeneratorOptions = {
append?: string;
};
const hostsGenerator = ({ append }: HostsGeneratorOptions = {}) => ({
script: ["tailscale", "status", "--json"],
postProcess: (output: string) =>
Object.values(JSON.parse(output)["Peer"]).map((peer) => ({
name: `${peer["DNSName"].split(".")[0]}${append ?? ""}`,
displayName: peer["HostName"],
description: peer["OS"],
})),
});
const spec: Fig.Spec = {
name: "tailscale",
subcommands: [
{
name: "up",
description: "Connect to Tailscale, logging in if needed",
options: [
{
name: "--accept-dns",
description: "Accept DNS configuration from the admin panel",
},
{
name: "--accept-routes",
description: "Accept routes advertised by other Tailscale nodes",
},
{
name: "--advertise-exit-node",
description:
"Offer to be an exit node for internet traffic for the tailnet",
},
{
name: "--advertise-routes",
description:
'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',
args: {
name: "routes",
},
},
{
name: "--advertise-tags",
description:
'Comma-separated ACL tags to request; each must start with "tag:" (e.g. "tag:eng,tag:montreal,tag:ssh")',
args: {
name: "tags",
},
},
{
name: "--auth-key",
description:
'Node authorization key; if it begins with "file:", then it\'s a path to a file containing the authkey',
args: {
name: "authkey",
},
},
{
name: "--exit-node",
description:
"Tailscale exit node (IP or base name) for internet traffic, or empty string to not use an exit node",
args: {
name: "exitnode",
},
},
{
name: "--exit-node-allow-lan-access",
description:
"Allow direct access to the local network when routing traffic via an exit node",
},
{
name: "--force-reauth",
description: "Force reauthentication",
},
{
name: "--host-routes",
description: "Install host routes to other Tailscale nodes",
},
{
name: "--hostname",
description: "Hostname to use instead of the one provided by the OS",
},
{
name: "--json",
description: "Output in JSON format",
},
{
name: "--login-server",
description: "Login server to use",
},
{
name: "--operator",
description:
"Unix username to allow to operate on tailscaled without sudo",
args: {
name: "username",
suggestions: ["$USER"],
},
},
{
name: "--qr",
description: "Show QR code for login URLs",
},
{
name: "--reset",
description: "Reset unspecified settings to their default values",
},
{
name: "--shields-up",
description: "Don't allow incoming connections",
},
{
name: "--ssh",
description:
"Run an SSH server, permitting access per tailnet admin's declared policy",
},
{
name: "--help",
description: "Show help message",
},
],
},
{
name: "down",
description: "Disconnect from Tailscale",
options: [
{
name: "--help",
description: "Show help message",
},
],
},
{
name: "logout",
description: "Disconnect from Tailscale and expire current node key",
options: [
{
name: "--help",
description: "Show help message",
},
],
},
{
name: "netcheck",
description: "Print an analysis of local network conditions",
options: [
{
name: "--every",
description:
"If non-zero, do an incremental report with the given frequency",
},
{
name: "--format",
description: "Output format",
args: {
name: "format",
suggestions: [
{
name: "json",
},
{
name: "json-line",
},
{
name: "human-readable",
insertValue: "'' ",
},
],
},
},
{
name: "--verbose",
description: "Verbose logs",
},
{
name: "--help",
description: "Show help message",
},
],
},
{
name: "ip",
description: "Show Tailscale IP addresses",
args: {
isOptional: true,
generators: hostsGenerator(),
},
options: [
{
name: "--1",
description: "Only print one IP address",
},
{
name: "--4",
description: "Only print IPv4 address",
},
{
name: "--6",
description: "Only print IPv6 address",
},
{
name: "--help",
description: "Show help message",
},
],
},
{
name: "status",
description: "Show state of tailscaled and its connections",
options: [
{
name: "--active",
description: "Filter output to only peers with active sessions",
},
{
name: "--browser",
description: "Open a browser in web mode",
},
{
name: "--json",
description: "Output in JSON format",
},
{
name: "--listen",
description:
"Listen address for web mode; use port 0 for automatic (default 127.0.0.1:8384)",
args: {
name: "address",
},
},
{
name: "--peers",
description: "Show status of peers",
},
{
name: "--self",
description: "Show status of local machine",
},
{
name: "--web",
description: "Run webserver with HTML showing status",
},
{
name: "--help",
description: "Show help message",
},
],
},
{
name: "ping",
description: "Ping a host at the Tailscale layer, see how it routed",
options: [
{
name: "--c",
description: "Max number of pings to send",
args: {
name: "count",
},
},
{
name: "--timeout",
description: "Timeout before giving up on a ping",
args: {
name: "timeout",
},
},
{
name: "--tsmp",
description:
"Do a TSMP-level ping (through IP + wireguard, but not involving host OS stack)",
},
{
name: "--until-direct",
description: "Stop once a direct path is established",
},
{
name: "--verbose",
description: "Verbose logs",
},
{
name: "--help",
description: "Show help message",
},
],
},
{
name: "nc",
description: "Connect to a port on a host, connected to stdin/stdout",
args: [
{
name: "hosname-or-ip",
},
{
name: "port",
},
],
options: [
{
name: "--help",
description: "Show help message",
},
],
},
{
name: "ssh",
description: "SSH to a Tailscale machine",
args: {
name: "[user@]<host>",
},
options: [
{
name: "--help",
description: "Show help message",
},
],
},
{
name: "version",
description: "Print Tailscale version",
options: [
{
name: "--daemon",
description: "Also print local node's daemon version",
},
{
name: "--help",
description: "Show help message",
},
],
},
{
name: "web",
description: "Run a web server for controlling Tailscale",
options: [
{
name: "--cgi",
description: "Run as CGI script",
},
{
name: "--listen",
description:
"Listen address; use port 0 for automatic (default localhost:8088)",
args: {
name: "address",
},
},
{
name: "--help",
description: "Show help message",
},
],
},
{
name: "file",
description: "Send or receive files",
subcommands: [
{
name: "cp",
description: "Copy file(s) to a host",
args: [
{
name: "file",
template: "filepaths",
},
{
name: "file or host",
isVariadic: true,
generators: [
hostsGenerator({ append: ":" }),
{
template: "filepaths",
},
],
},
],
},
{
name: "get",
description: "Move files out of the Tailscale file inbox",
args: {
name: "target-directory",
template: "folders",
},
},
],
options: [
{
name: "--help",
description: "Show help message",
},
],
},
{
name: "bugreport",
description: "Print a shareable identifier to help diagnose issues",
args: {
name: "note",
isOptional: true,
isVariadic: true,
},
options: [
{
name: "--help",
description: "Show help message",
},
],
},
{
name: "cert",
description: "Get TLS certs",
options: [
{
name: "--cert-file",
description: 'Output cert file or "-" for stdout',
args: {
name: "file",
template: "filepaths",
suggestions: [
{
name: "-",
description: "Stdout",
},
],
},
},
{
name: "--key-file",
description: 'Output cert file or "-" for stdout',
args: {
name: "file",
template: "filepaths",
suggestions: [
{
name: "-",
description: "Stdout",
},
],
},
},
{
name: "--serve-demo",
description:
"Serve on port :443 using the cert as a demo, instead of writing out the files to disk",
},
{
name: "--help",
description: "Show help message",
},
],
},
{
name: "help",
description: "Print help message",
},
],
options: [
{
name: "--socket",
description: "Path to tailscaled's unix socket",
args: {
name: "socket",
default: "/var/run/tailscaled.socket",
},
},
],
};
export default spec;