@highstate/library 0.9.16 → 0.9.19
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/dist/highstate.library.msgpack +0 -0
- package/dist/index.js +3548 -2985
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
- package/src/common/access-point.ts +105 -0
- package/src/common/files.ts +137 -0
- package/src/common/index.ts +3 -0
- package/src/common/server.ts +231 -0
- package/src/databases/index.ts +4 -0
- package/src/databases/mariadb.ts +37 -0
- package/src/databases/mongodb.ts +37 -0
- package/src/databases/postgresql.ts +37 -0
- package/src/databases/shared.ts +61 -0
- package/src/distributions/ubuntu.ts +13 -11
- package/src/dns.ts +116 -18
- package/src/git.ts +14 -10
- package/src/impl-ref.ts +26 -0
- package/src/index.ts +14 -15
- package/src/k3s.ts +14 -12
- package/src/k8s/apps/code-server.ts +48 -0
- package/src/k8s/apps/gitea.ts +25 -0
- package/src/k8s/apps/grocy.ts +39 -0
- package/src/k8s/apps/hubble.ts +30 -0
- package/src/{apps → k8s/apps}/index.ts +16 -13
- package/src/k8s/apps/kubernetes-dashboard.ts +28 -0
- package/src/k8s/apps/mariadb.ts +83 -0
- package/src/k8s/apps/maybe.ts +39 -0
- package/src/k8s/apps/mongodb.ts +84 -0
- package/src/k8s/apps/postgresql.ts +86 -0
- package/src/k8s/apps/shared.ts +149 -0
- package/src/k8s/apps/syncthing.ts +72 -0
- package/src/k8s/apps/traefik.ts +40 -0
- package/src/k8s/apps/vaultwarden.ts +31 -0
- package/src/k8s/apps/workload.ts +214 -0
- package/src/k8s/apps/zitadel.ts +26 -0
- package/src/k8s/cert-manager.ts +80 -0
- package/src/k8s/cilium.ts +64 -0
- package/src/k8s/gateway.ts +70 -0
- package/src/k8s/index.ts +9 -0
- package/src/{obfuscators → k8s/obfuscators}/phantun.ts +14 -10
- package/src/{obfuscators → k8s/obfuscators}/shared.ts +17 -11
- package/src/k8s/resources.ts +111 -0
- package/src/k8s/service.ts +65 -0
- package/src/k8s/shared.ts +343 -0
- package/src/k8s/workload.ts +77 -0
- package/src/network.ts +249 -63
- package/src/nixos.ts +38 -77
- package/src/proxmox.ts +203 -96
- package/src/restic.ts +28 -19
- package/src/sops.ts +19 -8
- package/src/ssh.ts +122 -24
- package/src/talos.ts +21 -19
- package/src/third-party/cloudflare.ts +59 -0
- package/src/third-party/index.ts +3 -0
- package/src/{mullvad.ts → third-party/mullvad.ts} +11 -9
- package/src/third-party/timeweb.ts +99 -0
- package/src/utils.ts +27 -6
- package/src/wireguard.ts +249 -115
- package/src/apps/code-server.ts +0 -34
- package/src/apps/deployment.ts +0 -60
- package/src/apps/dns.ts +0 -107
- package/src/apps/gitea.ts +0 -18
- package/src/apps/grocy.ts +0 -20
- package/src/apps/hubble.ts +0 -20
- package/src/apps/kubernetes-dashboard.ts +0 -19
- package/src/apps/mariadb.ts +0 -81
- package/src/apps/maybe.ts +0 -25
- package/src/apps/mongodb.ts +0 -81
- package/src/apps/network.ts +0 -55
- package/src/apps/postgresql.ts +0 -81
- package/src/apps/shared.ts +0 -290
- package/src/apps/syncthing.ts +0 -54
- package/src/apps/test.ts +0 -19
- package/src/apps/traefik.ts +0 -36
- package/src/apps/vaultwarden.ts +0 -23
- package/src/apps/zitadel.ts +0 -21
- package/src/cloudflare.ts +0 -26
- package/src/common.ts +0 -200
- package/src/files.ts +0 -146
- package/src/k8s.ts +0 -638
- package/src/timeweb.ts +0 -75
- package/src/{obfuscators → k8s/obfuscators}/index.ts +1 -1
package/src/wireguard.ts
CHANGED
@@ -1,35 +1,64 @@
|
|
1
|
-
import { defineEntity, defineUnit,
|
1
|
+
import { defineEntity, defineUnit, z } from "@highstate/contract"
|
2
2
|
import { omit } from "remeda"
|
3
|
-
import {
|
3
|
+
import { serverEntity } from "./common/server"
|
4
|
+
import { exposableWorkloadEntity, networkInterfaceEntity } from "./k8s"
|
4
5
|
import { l3EndpointEntity, l4EndpointEntity } from "./network"
|
6
|
+
import { clusterEntity } from "./k8s"
|
5
7
|
import { arrayPatchModeSchema } from "./utils"
|
6
8
|
|
7
|
-
export const backendSchema =
|
9
|
+
export const backendSchema = z.enum(["wireguard", "amneziawg"])
|
8
10
|
|
9
|
-
export type Backend =
|
11
|
+
export type Backend = z.infer<typeof backendSchema>
|
10
12
|
|
13
|
+
const networkArgs = {
|
14
|
+
/**
|
15
|
+
* The backend to use for the WireGuard network.
|
16
|
+
*
|
17
|
+
* Possible values are:
|
18
|
+
* - `wireguard` - the default backend;
|
19
|
+
* - `amneziawg` - the censorship-resistant fork of WireGuard.
|
20
|
+
*/
|
21
|
+
backend: backendSchema.default("wireguard"),
|
22
|
+
|
23
|
+
/**
|
24
|
+
* Whether to enable IPv4 support in the network.
|
25
|
+
*
|
26
|
+
* By default, IPv4 support is enabled.
|
27
|
+
*/
|
28
|
+
ipv4: z.boolean().default(true),
|
29
|
+
|
30
|
+
/**
|
31
|
+
* Whether to enable IPv6 support in the network.
|
32
|
+
*
|
33
|
+
* By default, IPv6 support is disabled.
|
34
|
+
*/
|
35
|
+
ipv6: z.boolean().default(false),
|
36
|
+
}
|
37
|
+
|
38
|
+
/**
|
39
|
+
* The entity representing the WireGuard network configuration.
|
40
|
+
*
|
41
|
+
* It holds shared configuration for WireGuard identities, peers, and nodes.
|
42
|
+
*/
|
11
43
|
export const networkEntity = defineEntity({
|
12
|
-
type: "wireguard.network",
|
44
|
+
type: "wireguard.network.v1",
|
13
45
|
|
14
|
-
schema:
|
15
|
-
backend: backendSchema,
|
16
|
-
ipv6: Type.Boolean(),
|
17
|
-
}),
|
46
|
+
schema: z.object(networkArgs),
|
18
47
|
})
|
19
48
|
|
20
|
-
export const nodeExposePolicySchema =
|
49
|
+
export const nodeExposePolicySchema = z.enum(["always", "when-has-endpoint", "never"])
|
21
50
|
|
22
51
|
export const peerEntity = defineEntity({
|
23
|
-
type: "wireguard.peer",
|
52
|
+
type: "wireguard.peer.v1",
|
24
53
|
|
25
|
-
schema:
|
26
|
-
name:
|
27
|
-
network:
|
28
|
-
publicKey:
|
29
|
-
address:
|
30
|
-
allowedIps:
|
31
|
-
endpoints:
|
32
|
-
allowedEndpoints:
|
54
|
+
schema: z.object({
|
55
|
+
name: z.string(),
|
56
|
+
network: networkEntity.schema.optional(),
|
57
|
+
publicKey: z.string(),
|
58
|
+
address: z.string().optional(),
|
59
|
+
allowedIps: z.string().array(),
|
60
|
+
endpoints: l4EndpointEntity.schema.array(),
|
61
|
+
allowedEndpoints: z.union([l3EndpointEntity.schema, l4EndpointEntity.schema]).array(),
|
33
62
|
|
34
63
|
/**
|
35
64
|
* The pre-shared key of the WireGuard peer.
|
@@ -38,18 +67,18 @@ export const peerEntity = defineEntity({
|
|
38
67
|
*
|
39
68
|
* Will be ignored if both peers have `presharedKeyPart` set.
|
40
69
|
*/
|
41
|
-
presharedKey:
|
70
|
+
presharedKey: z.string().optional(),
|
42
71
|
|
43
72
|
/**
|
44
73
|
* The pre-shared key part of the WireGuard peer.
|
45
74
|
*
|
46
75
|
* If both peers have `presharedKeyPart` set, their `presharedKey` will be calculated as XOR of the two parts.
|
47
76
|
*/
|
48
|
-
presharedKeyPart:
|
77
|
+
presharedKeyPart: z.string().optional(),
|
49
78
|
|
50
|
-
excludedIps:
|
51
|
-
dns:
|
52
|
-
listenPort:
|
79
|
+
excludedIps: z.string().array(),
|
80
|
+
dns: z.string().array(),
|
81
|
+
listenPort: z.number().optional(),
|
53
82
|
}),
|
54
83
|
|
55
84
|
meta: {
|
@@ -58,11 +87,11 @@ export const peerEntity = defineEntity({
|
|
58
87
|
})
|
59
88
|
|
60
89
|
export const identityEntity = defineEntity({
|
61
|
-
type: "wireguard.identity",
|
90
|
+
type: "wireguard.identity.v1",
|
62
91
|
|
63
|
-
schema:
|
92
|
+
schema: z.object({
|
64
93
|
peer: peerEntity.schema,
|
65
|
-
privateKey:
|
94
|
+
privateKey: z.string(),
|
66
95
|
}),
|
67
96
|
|
68
97
|
meta: {
|
@@ -70,45 +99,26 @@ export const identityEntity = defineEntity({
|
|
70
99
|
},
|
71
100
|
})
|
72
101
|
|
73
|
-
export type Network =
|
74
|
-
export type Identity =
|
75
|
-
export type Peer =
|
76
|
-
export type NodeExposePolicy =
|
102
|
+
export type Network = z.infer<typeof networkEntity.schema>
|
103
|
+
export type Identity = z.infer<typeof identityEntity.schema>
|
104
|
+
export type Peer = z.infer<typeof peerEntity.schema>
|
105
|
+
export type NodeExposePolicy = z.infer<typeof nodeExposePolicySchema>
|
77
106
|
|
78
107
|
/**
|
79
|
-
*
|
108
|
+
* Holds the shared configuration for WireGuard identities, peers, and nodes.
|
80
109
|
*/
|
81
110
|
export const network = defineUnit({
|
82
|
-
type: "wireguard.network",
|
83
|
-
|
84
|
-
args: {
|
85
|
-
/**
|
86
|
-
* The backend to use for the WireGuard network.
|
87
|
-
*
|
88
|
-
* Possible values are:
|
89
|
-
* 1. `wireguard` - The default backend.
|
90
|
-
* 2. `amneziawg` - The censorship-resistant fork of WireGuard.
|
91
|
-
*
|
92
|
-
* By default, the `wireguard` backend is used.
|
93
|
-
*/
|
94
|
-
backend: Type.Default(backendSchema, "wireguard"),
|
111
|
+
type: "wireguard.network.v1",
|
95
112
|
|
96
|
-
|
97
|
-
* The option to enable IPv6 support in the network.
|
98
|
-
*
|
99
|
-
* By default, IPv6 support is disabled.
|
100
|
-
*/
|
101
|
-
ipv6: Type.Default(Type.Boolean(), false),
|
102
|
-
},
|
113
|
+
args: networkArgs,
|
103
114
|
|
104
115
|
outputs: {
|
105
116
|
network: networkEntity,
|
106
117
|
},
|
107
118
|
|
108
119
|
meta: {
|
109
|
-
|
110
|
-
|
111
|
-
primaryIconColor: "#88171a",
|
120
|
+
icon: "simple-icons:wireguard",
|
121
|
+
iconColor: "#88171a",
|
112
122
|
secondaryIcon: "mdi:local-area-network-connect",
|
113
123
|
category: "VPN",
|
114
124
|
},
|
@@ -125,32 +135,32 @@ const sharedPeerArgs = {
|
|
125
135
|
*
|
126
136
|
* If not provided, the peer will be named after the unit.
|
127
137
|
*/
|
128
|
-
peerName:
|
138
|
+
peerName: z.string().optional(),
|
129
139
|
|
130
140
|
/**
|
131
141
|
* The address of the WireGuard interface.
|
132
142
|
*
|
133
143
|
* The address may be any IPv4 or IPv6 address. CIDR notation is also supported.
|
134
144
|
*/
|
135
|
-
address:
|
145
|
+
address: z.string().optional(),
|
136
146
|
|
137
147
|
/**
|
138
148
|
* The convenience option to set `allowedIps` to `0.0.0.0/0, ::/0`.
|
139
149
|
*
|
140
150
|
* Will be merged with the `allowedIps` if provided.
|
141
151
|
*/
|
142
|
-
exitNode:
|
152
|
+
exitNode: z.boolean().default(false),
|
143
153
|
|
144
154
|
/**
|
145
155
|
* The list of IP ranges to exclude from the tunnel.
|
146
156
|
*
|
147
157
|
* Implementation notes:
|
148
158
|
*
|
149
|
-
* -
|
150
|
-
* -
|
151
|
-
* -
|
159
|
+
* - this list will not be used to generate the allowed IPs for the peer;
|
160
|
+
* - instead, the node will setup extra direct routes to these IPs via default gateway;
|
161
|
+
* - this allows to use `0.0.0.0/0, ::/0` in the `allowedIps` (and corresponding fwmark magic) and still have some IPs excluded from the tunnel.
|
152
162
|
*/
|
153
|
-
excludedIps:
|
163
|
+
excludedIps: z.string().array().default([]),
|
154
164
|
|
155
165
|
/**
|
156
166
|
* The convenience option to exclude private IPs from the tunnel.
|
@@ -168,38 +178,38 @@ const sharedPeerArgs = {
|
|
168
178
|
*
|
169
179
|
* Will be merged with `excludedIps` if provided.
|
170
180
|
*/
|
171
|
-
excludePrivateIps:
|
181
|
+
excludePrivateIps: z.boolean().default(false),
|
172
182
|
|
173
183
|
/**
|
174
184
|
* The endpoints of the WireGuard peer.
|
175
185
|
*/
|
176
|
-
endpoints:
|
186
|
+
endpoints: z.string().array().default([]),
|
177
187
|
|
178
188
|
/**
|
179
189
|
* The allowed endpoints of the WireGuard peer.
|
180
190
|
*
|
181
191
|
* The non `hostname` endpoints will be added to the `allowedIps` of the peer.
|
182
192
|
*/
|
183
|
-
allowedEndpoints:
|
193
|
+
allowedEndpoints: z.string().array().default([]),
|
184
194
|
|
185
195
|
/**
|
186
196
|
* The DNS servers that should be used by the interface connected to the WireGuard peer.
|
187
197
|
*
|
188
198
|
* If multiple peers define DNS servers, the node will merge them into a single list (but this is discouraged).
|
189
199
|
*/
|
190
|
-
dns:
|
200
|
+
dns: z.string().array().default([]),
|
191
201
|
|
192
202
|
/**
|
193
203
|
* The convenience option to include the DNS servers to the allowed IPs.
|
194
204
|
*
|
195
205
|
* By default, is `true`.
|
196
206
|
*/
|
197
|
-
includeDns:
|
207
|
+
includeDns: z.boolean().default(true),
|
198
208
|
|
199
209
|
/**
|
200
210
|
* The port to listen on.
|
201
211
|
*/
|
202
|
-
listenPort:
|
212
|
+
listenPort: z.number().optional(),
|
203
213
|
}
|
204
214
|
|
205
215
|
const sharedPeerInputs = {
|
@@ -272,10 +282,24 @@ const sharedPeerOutputs = {
|
|
272
282
|
},
|
273
283
|
} as const
|
274
284
|
|
275
|
-
export type SharedPeerArgs =
|
285
|
+
export type SharedPeerArgs = {
|
286
|
+
peerName?: string
|
287
|
+
address?: string
|
288
|
+
exitNode: boolean
|
289
|
+
excludedIps: string[]
|
290
|
+
excludePrivateIps: boolean
|
291
|
+
endpoints: string[]
|
292
|
+
allowedEndpoints: string[]
|
293
|
+
dns: string[]
|
294
|
+
includeDns: boolean
|
295
|
+
listenPort?: number
|
296
|
+
}
|
276
297
|
|
298
|
+
/**
|
299
|
+
* The WireGuard peer with the public key.
|
300
|
+
*/
|
277
301
|
export const peer = defineUnit({
|
278
|
-
type: "wireguard.peer",
|
302
|
+
type: "wireguard.peer.v1",
|
279
303
|
|
280
304
|
args: {
|
281
305
|
...sharedPeerArgs,
|
@@ -283,23 +307,22 @@ export const peer = defineUnit({
|
|
283
307
|
/**
|
284
308
|
* The public key of the WireGuard peer.
|
285
309
|
*/
|
286
|
-
publicKey:
|
310
|
+
publicKey: z.string(),
|
287
311
|
},
|
288
312
|
|
289
313
|
secrets: {
|
290
314
|
/**
|
291
315
|
* The pre-shared key which should be used for the peer.
|
292
316
|
*/
|
293
|
-
presharedKey:
|
317
|
+
presharedKey: z.string().optional(),
|
294
318
|
},
|
295
319
|
|
296
320
|
inputs: sharedPeerInputs,
|
297
321
|
outputs: sharedPeerOutputs,
|
298
322
|
|
299
323
|
meta: {
|
300
|
-
|
301
|
-
|
302
|
-
primaryIconColor: "#88171a",
|
324
|
+
icon: "simple-icons:wireguard",
|
325
|
+
iconColor: "#88171a",
|
303
326
|
secondaryIcon: "mdi:badge-account-horizontal",
|
304
327
|
category: "VPN",
|
305
328
|
},
|
@@ -310,14 +333,17 @@ export const peer = defineUnit({
|
|
310
333
|
},
|
311
334
|
})
|
312
335
|
|
336
|
+
/**
|
337
|
+
* Patches some properties of the WireGuard peer.
|
338
|
+
*/
|
313
339
|
export const peerPatch = defineUnit({
|
314
|
-
type: "wireguard.peer-patch",
|
340
|
+
type: "wireguard.peer-patch.v1",
|
315
341
|
|
316
342
|
args: {
|
317
343
|
/**
|
318
344
|
* The endpoints of the WireGuard peer.
|
319
345
|
*/
|
320
|
-
endpoints:
|
346
|
+
endpoints: z.string().array().default([]),
|
321
347
|
|
322
348
|
/**
|
323
349
|
* The mode to use for patching the endpoints.
|
@@ -325,14 +351,14 @@ export const peerPatch = defineUnit({
|
|
325
351
|
* - `prepend`: prepend the new endpoints to the existing ones (default);
|
326
352
|
* - `replace`: replace the existing endpoints with the new ones.
|
327
353
|
*/
|
328
|
-
endpointsPatchMode:
|
354
|
+
endpointsPatchMode: arrayPatchModeSchema.default("prepend"),
|
329
355
|
|
330
356
|
/**
|
331
357
|
* The allowed endpoints of the WireGuard peer.
|
332
358
|
*
|
333
359
|
* The non `hostname` endpoints will be added to the `allowedIps` of the peer.
|
334
360
|
*/
|
335
|
-
allowedEndpoints:
|
361
|
+
allowedEndpoints: z.string().array().default([]),
|
336
362
|
|
337
363
|
/**
|
338
364
|
* The mode to use for patching the allowed endpoints.
|
@@ -340,7 +366,7 @@ export const peerPatch = defineUnit({
|
|
340
366
|
* - `prepend`: prepend the new endpoints to the existing ones (default);
|
341
367
|
* - `replace`: replace the existing endpoints with the new ones.
|
342
368
|
*/
|
343
|
-
allowedEndpointsPatchMode:
|
369
|
+
allowedEndpointsPatchMode: arrayPatchModeSchema.default("prepend"),
|
344
370
|
|
345
371
|
...omit(sharedPeerArgs, ["endpoints", "allowedEndpoints"]),
|
346
372
|
},
|
@@ -361,10 +387,9 @@ export const peerPatch = defineUnit({
|
|
361
387
|
},
|
362
388
|
|
363
389
|
meta: {
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
primaryIconColor: "#88171a",
|
390
|
+
title: "WireGuard Peer Patch",
|
391
|
+
icon: "simple-icons:wireguard",
|
392
|
+
iconColor: "#88171a",
|
368
393
|
secondaryIcon: "mdi:badge-account-horizontal",
|
369
394
|
category: "VPN",
|
370
395
|
},
|
@@ -375,8 +400,11 @@ export const peerPatch = defineUnit({
|
|
375
400
|
},
|
376
401
|
})
|
377
402
|
|
403
|
+
/**
|
404
|
+
* The WireGuard identity with the public key.
|
405
|
+
*/
|
378
406
|
export const identity = defineUnit({
|
379
|
-
type: "wireguard.identity",
|
407
|
+
type: "wireguard.identity.v1",
|
380
408
|
|
381
409
|
args: {
|
382
410
|
...sharedPeerArgs,
|
@@ -386,7 +414,7 @@ export const identity = defineUnit({
|
|
386
414
|
*
|
387
415
|
* Used by the implementation of the identity and to calculate the endpoint of the peer.
|
388
416
|
*/
|
389
|
-
listenPort:
|
417
|
+
listenPort: z.number().optional(),
|
390
418
|
|
391
419
|
/**
|
392
420
|
* The endpoint of the WireGuard peer.
|
@@ -395,7 +423,7 @@ export const identity = defineUnit({
|
|
395
423
|
*
|
396
424
|
* Will take priority over all calculated endpoints and `l4Endpoint` input.
|
397
425
|
*/
|
398
|
-
endpoints:
|
426
|
+
endpoints: z.string().array().default([]),
|
399
427
|
},
|
400
428
|
|
401
429
|
secrets: {
|
@@ -404,14 +432,14 @@ export const identity = defineUnit({
|
|
404
432
|
*
|
405
433
|
* If not provided, the key will be generated automatically.
|
406
434
|
*/
|
407
|
-
privateKey:
|
435
|
+
privateKey: z.string().optional(),
|
408
436
|
|
409
437
|
/**
|
410
438
|
* The part of the pre-shared of the WireGuard identity.
|
411
439
|
*
|
412
440
|
* Will be generated automatically if not provided.
|
413
441
|
*/
|
414
|
-
presharedKeyPart:
|
442
|
+
presharedKeyPart: z.string().optional(),
|
415
443
|
},
|
416
444
|
|
417
445
|
inputs: sharedPeerInputs,
|
@@ -422,9 +450,8 @@ export const identity = defineUnit({
|
|
422
450
|
},
|
423
451
|
|
424
452
|
meta: {
|
425
|
-
|
426
|
-
|
427
|
-
primaryIconColor: "#88171a",
|
453
|
+
icon: "simple-icons:wireguard",
|
454
|
+
iconColor: "#88171a",
|
428
455
|
secondaryIcon: "mdi:account",
|
429
456
|
category: "VPN",
|
430
457
|
},
|
@@ -435,8 +462,11 @@ export const identity = defineUnit({
|
|
435
462
|
},
|
436
463
|
})
|
437
464
|
|
438
|
-
|
439
|
-
|
465
|
+
/**
|
466
|
+
* The WireGuard node deployed in the Kubernetes cluster.
|
467
|
+
*/
|
468
|
+
export const nodeK8s = defineUnit({
|
469
|
+
type: "wireguard.node.k8s.v1",
|
440
470
|
|
441
471
|
args: {
|
442
472
|
/**
|
@@ -444,12 +474,12 @@ export const node = defineUnit({
|
|
444
474
|
*
|
445
475
|
* By default, the name is `wg-${identity.name}`.
|
446
476
|
*/
|
447
|
-
appName:
|
477
|
+
appName: z.string().optional(),
|
448
478
|
|
449
479
|
/**
|
450
480
|
* Whether to expose the WireGuard node to the outside world.
|
451
481
|
*/
|
452
|
-
external:
|
482
|
+
external: z.boolean().default(false),
|
453
483
|
|
454
484
|
/**
|
455
485
|
* The policy to use for exposing the WireGuard node.
|
@@ -460,14 +490,14 @@ export const node = defineUnit({
|
|
460
490
|
*
|
461
491
|
* * By default, the `when-has-endpoint` policy is used.
|
462
492
|
*/
|
463
|
-
exposePolicy:
|
493
|
+
exposePolicy: nodeExposePolicySchema.default("when-has-endpoint"),
|
464
494
|
|
465
495
|
/**
|
466
496
|
* The extra specification of the container which runs the WireGuard node.
|
467
497
|
*
|
468
498
|
* Will override any overlapping fields.
|
469
499
|
*/
|
470
|
-
containerSpec:
|
500
|
+
containerSpec: z.record(z.string(), z.unknown()).optional(),
|
471
501
|
|
472
502
|
/**
|
473
503
|
* List of CIDR blocks that should be blocked from forwarding through this WireGuard node.
|
@@ -477,7 +507,7 @@ export const node = defineUnit({
|
|
477
507
|
*
|
478
508
|
* Useful for peer isolation where you want to prevent cross-peer communication.
|
479
509
|
*/
|
480
|
-
forwardRestrictedIps:
|
510
|
+
forwardRestrictedIps: z.string().array().default([]),
|
481
511
|
},
|
482
512
|
|
483
513
|
inputs: {
|
@@ -490,7 +520,7 @@ export const node = defineUnit({
|
|
490
520
|
},
|
491
521
|
|
492
522
|
interface: {
|
493
|
-
entity:
|
523
|
+
entity: networkInterfaceEntity,
|
494
524
|
required: false,
|
495
525
|
},
|
496
526
|
|
@@ -503,10 +533,110 @@ export const node = defineUnit({
|
|
503
533
|
|
504
534
|
outputs: {
|
505
535
|
interface: {
|
506
|
-
entity:
|
536
|
+
entity: networkInterfaceEntity,
|
537
|
+
required: false,
|
538
|
+
},
|
539
|
+
|
540
|
+
peer: {
|
541
|
+
entity: peerEntity,
|
542
|
+
required: false,
|
543
|
+
},
|
544
|
+
|
545
|
+
endpoints: {
|
546
|
+
entity: l4EndpointEntity,
|
547
|
+
required: false,
|
548
|
+
multiple: true,
|
549
|
+
},
|
550
|
+
},
|
551
|
+
|
552
|
+
meta: {
|
553
|
+
title: "WireGuard Kubernetes Node",
|
554
|
+
icon: "simple-icons:wireguard",
|
555
|
+
iconColor: "#88171a",
|
556
|
+
secondaryIcon: "devicon:kubernetes",
|
557
|
+
category: "VPN",
|
558
|
+
},
|
559
|
+
|
560
|
+
source: {
|
561
|
+
package: "@highstate/wireguard",
|
562
|
+
path: "node.k8s",
|
563
|
+
},
|
564
|
+
})
|
565
|
+
|
566
|
+
/**
|
567
|
+
* The WireGuard node deployed on a server using wg-quick systemd service.
|
568
|
+
*/
|
569
|
+
export const node = defineUnit({
|
570
|
+
type: "wireguard.node.v1",
|
571
|
+
|
572
|
+
args: {
|
573
|
+
/**
|
574
|
+
* The name of the WireGuard interface.
|
575
|
+
*
|
576
|
+
* By default, the name is `wg-${identity.name}` (truncated to 15 characters).
|
577
|
+
*/
|
578
|
+
interfaceName: z.string().optional(),
|
579
|
+
|
580
|
+
/**
|
581
|
+
* The name of the default interface for excluded routes.
|
582
|
+
*
|
583
|
+
* This is used to route excluded IPs through the default interface instead of the WireGuard tunnel.
|
584
|
+
*/
|
585
|
+
defaultInterface: z.string().default("eth0"),
|
586
|
+
|
587
|
+
/**
|
588
|
+
* List of CIDR blocks that should be blocked from forwarding through this WireGuard node.
|
589
|
+
*
|
590
|
+
* This prevents other peers from reaching these destination CIDRs while still allowing
|
591
|
+
* the peers in those CIDRs to access the internet and other allowed endpoints.
|
592
|
+
*
|
593
|
+
* Useful for peer isolation where you want to prevent cross-peer communication.
|
594
|
+
*/
|
595
|
+
forwardRestrictedIps: z.string().array().default([]),
|
596
|
+
|
597
|
+
/**
|
598
|
+
* Whether to enable IP masquerading (NAT) for outgoing traffic.
|
599
|
+
*
|
600
|
+
* By default, IP masquerading is enabled.
|
601
|
+
*/
|
602
|
+
enableMasquerade: z.boolean().default(true),
|
603
|
+
|
604
|
+
/**
|
605
|
+
* Script to run before bringing up the interface.
|
606
|
+
*/
|
607
|
+
preUpScript: z.string().optional().meta({ language: "shell" }),
|
608
|
+
|
609
|
+
/**
|
610
|
+
* Script to run after bringing up the interface.
|
611
|
+
*/
|
612
|
+
postUpScript: z.string().optional().meta({ language: "shell" }),
|
613
|
+
|
614
|
+
/**
|
615
|
+
* Script to run before bringing down the interface.
|
616
|
+
*/
|
617
|
+
preDownScript: z.string().optional().meta({ language: "shell" }),
|
618
|
+
|
619
|
+
/**
|
620
|
+
* Script to run after bringing down the interface.
|
621
|
+
*/
|
622
|
+
postDownScript: z.string().optional().meta({ language: "shell" }),
|
623
|
+
},
|
624
|
+
|
625
|
+
inputs: {
|
626
|
+
identity: identityEntity,
|
627
|
+
server: {
|
628
|
+
entity: serverEntity,
|
629
|
+
required: true,
|
630
|
+
},
|
631
|
+
|
632
|
+
peers: {
|
633
|
+
entity: peerEntity,
|
634
|
+
multiple: true,
|
507
635
|
required: false,
|
508
636
|
},
|
637
|
+
},
|
509
638
|
|
639
|
+
outputs: {
|
510
640
|
peer: {
|
511
641
|
entity: peerEntity,
|
512
642
|
required: false,
|
@@ -520,9 +650,9 @@ export const node = defineUnit({
|
|
520
650
|
},
|
521
651
|
|
522
652
|
meta: {
|
523
|
-
|
524
|
-
|
525
|
-
|
653
|
+
title: "WireGuard Server Node",
|
654
|
+
icon: "simple-icons:wireguard",
|
655
|
+
iconColor: "#88171a",
|
526
656
|
secondaryIcon: "mdi:server",
|
527
657
|
category: "VPN",
|
528
658
|
},
|
@@ -533,8 +663,11 @@ export const node = defineUnit({
|
|
533
663
|
},
|
534
664
|
})
|
535
665
|
|
666
|
+
/**
|
667
|
+
* Just the WireGuard configuration for the identity and peers.
|
668
|
+
*/
|
536
669
|
export const config = defineUnit({
|
537
|
-
type: "wireguard.config",
|
670
|
+
type: "wireguard.config.v1",
|
538
671
|
|
539
672
|
args: {
|
540
673
|
/**
|
@@ -542,7 +675,7 @@ export const config = defineUnit({
|
|
542
675
|
*
|
543
676
|
* If not provided, the config will not respect `excludedIps`.
|
544
677
|
*/
|
545
|
-
defaultInterface:
|
678
|
+
defaultInterface: z.string().optional(),
|
546
679
|
},
|
547
680
|
|
548
681
|
inputs: {
|
@@ -555,10 +688,9 @@ export const config = defineUnit({
|
|
555
688
|
},
|
556
689
|
|
557
690
|
meta: {
|
558
|
-
|
559
|
-
|
560
|
-
|
561
|
-
primaryIconColor: "#88171a",
|
691
|
+
title: "WireGuard Config",
|
692
|
+
icon: "simple-icons:wireguard",
|
693
|
+
iconColor: "#88171a",
|
562
694
|
secondaryIcon: "mdi:settings",
|
563
695
|
category: "VPN",
|
564
696
|
},
|
@@ -569,8 +701,11 @@ export const config = defineUnit({
|
|
569
701
|
},
|
570
702
|
})
|
571
703
|
|
704
|
+
/**
|
705
|
+
* The WireGuard configuration bundle for the identity and peers.
|
706
|
+
*/
|
572
707
|
export const configBundle = defineUnit({
|
573
|
-
type: "wireguard.config-bundle",
|
708
|
+
type: "wireguard.config-bundle.v1",
|
574
709
|
|
575
710
|
inputs: {
|
576
711
|
identity: identityEntity,
|
@@ -586,10 +721,9 @@ export const configBundle = defineUnit({
|
|
586
721
|
},
|
587
722
|
|
588
723
|
meta: {
|
589
|
-
|
590
|
-
|
591
|
-
|
592
|
-
primaryIconColor: "#88171a",
|
724
|
+
title: "WireGuard Config Bundle",
|
725
|
+
icon: "simple-icons:wireguard",
|
726
|
+
iconColor: "#88171a",
|
593
727
|
secondaryIcon: "mdi:folder-settings-variant",
|
594
728
|
category: "VPN",
|
595
729
|
},
|