@studiometa/trafic-agent 0.1.45 → 0.1.47

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.
Files changed (37) hide show
  1. package/README.md +129 -20
  2. package/dist/cli.js +49 -4
  3. package/dist/cli.js.map +1 -1
  4. package/dist/index.js +2 -2
  5. package/dist/{server-BAjHxgqh.js → server-EPU5dtPx.js} +355 -21
  6. package/dist/server-EPU5dtPx.js.map +1 -0
  7. package/dist/server.d.ts.map +1 -1
  8. package/dist/server.js +1 -1
  9. package/dist/setup/agent.d.ts +2 -0
  10. package/dist/setup/agent.d.ts.map +1 -1
  11. package/dist/setup/audit.d.ts +39 -1
  12. package/dist/setup/audit.d.ts.map +1 -1
  13. package/dist/setup/ddev.d.ts +102 -3
  14. package/dist/setup/ddev.d.ts.map +1 -1
  15. package/dist/setup/docker.d.ts +23 -0
  16. package/dist/setup/docker.d.ts.map +1 -1
  17. package/dist/setup/index.d.ts.map +1 -1
  18. package/dist/setup/migrations/0015__catchall_priority.d.ts +40 -0
  19. package/dist/setup/migrations/0015__catchall_priority.d.ts.map +1 -0
  20. package/dist/setup/migrations/0016__wildcard_dns_challenge.d.ts +63 -0
  21. package/dist/setup/migrations/0016__wildcard_dns_challenge.d.ts.map +1 -0
  22. package/dist/setup/migrations/0018__docker_address_pools.d.ts +29 -0
  23. package/dist/setup/migrations/0018__docker_address_pools.d.ts.map +1 -0
  24. package/dist/setup/migrations/index.d.ts.map +1 -1
  25. package/dist/setup/types.d.ts +11 -0
  26. package/dist/setup/types.d.ts.map +1 -1
  27. package/dist/{setup-BrMbM8w4.js → setup-4zlNJqDe.js} +373 -173
  28. package/dist/setup-4zlNJqDe.js.map +1 -0
  29. package/dist/types.d.ts +21 -0
  30. package/dist/types.d.ts.map +1 -1
  31. package/dist/utils/config.d.ts.map +1 -1
  32. package/dist/utils/tls.d.ts +10 -0
  33. package/dist/utils/tls.d.ts.map +1 -0
  34. package/package.json +1 -1
  35. package/templates/wait.html +1 -0
  36. package/dist/server-BAjHxgqh.js.map +0 -1
  37. package/dist/setup-BrMbM8w4.js.map +0 -1
@@ -0,0 +1,63 @@
1
+ import { type SetupIo } from "../io.js";
2
+ import type { Migration } from "../types.js";
3
+ import type { TlsConfig } from "../../types.js";
4
+ /**
5
+ * Migration 0016: apply the wildcard DNS-01 certificate on servers that ask
6
+ * for one in their config.
7
+ *
8
+ * `tls.dns_provider` is read by `configureTraefik`, which setup runs on a
9
+ * fresh server. An existing server has the config but none of the files, so
10
+ * this writes them: the resolver in `static_config.trafic.yaml`, the default
11
+ * TLS store in `custom-global-config/0-trafic-tls.yaml`, and the provider
12
+ * credentials in `router-compose.trafic.yaml`.
13
+ *
14
+ * Why the router is removed and a project started, rather than restarted
15
+ * (the 0010 rationale, plus one more): Traefik reads its configuration from
16
+ * the ddev-global-cache volume, and DDEV only copies `~/.ddev/traefik` into
17
+ * that volume and merges `static_config.*.yaml` into `.static_config.yaml`
18
+ * when a project starts. And DDEV 1.25 reads `router-compose.*.yaml` only
19
+ * when it *recreates* the router: a running, healthy router just gets the
20
+ * Traefik config pushed (StartDdevRouter, `needsRecreation`). Seen on a live
21
+ * server — the static config was merged, the credentials never reached the
22
+ * container. Removing the router first forces the recreation; `ddev start`
23
+ * brings it back within seconds with the new environment.
24
+ *
25
+ * The container is found by its compose label, not by name: when compose
26
+ * recreates a container it renames the old one `<id>_ddev-router`, and a
27
+ * failed recreation can leave it that way. `docker restart ddev-router` then
28
+ * silently does nothing — also seen on that server.
29
+ *
30
+ * Two details this depends on:
31
+ * - Traefik's file provider keeps the FIRST `tls.stores.default` it reads in
32
+ * directory order and logs "TLS store default already configured,
33
+ * skipping" for the rest. DDEV writes an empty one in
34
+ * `default_config.yaml`, so the agent's file is named `0-trafic-tls.yaml`
35
+ * to sort ahead of it.
36
+ * - DDEV keeps `certResolver: acme-tlsChallenge` on every project router, and
37
+ * that is fine: Traefik skips a per-host ACME request once the default
38
+ * store already holds a certificate matching the host with wildcard
39
+ * semantics. So `use_letsencrypt` stays true — the ACME account email comes
40
+ * from it — and the per-host quota use stops on its own.
41
+ *
42
+ * `ddev poweroff` is deliberately not used: the server runs live previews and
43
+ * a project start is enough to regenerate the config and recreate the router.
44
+ *
45
+ * Idempotent: skipped when no DNS provider is configured, and when all three
46
+ * files are already in place.
47
+ */
48
+ export declare const migration0016WildcardDnsChallenge: Migration;
49
+ /**
50
+ * The migration body, with its effects injected so tests can drive it.
51
+ *
52
+ * `tls` defaults to the server's own config: the migration runs after setup
53
+ * wrote /etc/trafic/config.toml, so that file is the only source.
54
+ */
55
+ export declare function runWildcardMigration(io?: SetupIo, tls?: TlsConfig): void;
56
+ /**
57
+ * The ddev-router container id, whatever its current name.
58
+ *
59
+ * Compose labels survive the `<id>_ddev-router` rename a recreation leaves
60
+ * behind; the container name does not.
61
+ */
62
+ export declare function findRouterContainer(io?: SetupIo): string | undefined;
63
+ //# sourceMappingURL=0016__wildcard_dns_challenge.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"0016__wildcard_dns_challenge.d.ts","sourceRoot":"","sources":["../../../src/setup/migrations/0016__wildcard_dns_challenge.ts"],"names":[],"mappings":"AASA,OAAO,EAAU,KAAK,OAAO,EAAE,MAAM,UAAU,CAAC;AAEhD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAEhD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AACH,eAAO,MAAM,iCAAiC,EAAE,SAO/C,CAAC;AAEF;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAClC,EAAE,GAAE,OAAgB,EACpB,GAAG,GAAE,SAA4B,GAChC,IAAI,CAuCN;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,EAAE,GAAE,OAAgB,GAAG,MAAM,GAAG,SAAS,CAM5E"}
@@ -0,0 +1,29 @@
1
+ import { type SetupIo } from "../io.js";
2
+ import type { Migration } from "../types.js";
3
+ /**
4
+ * Migration 0018: give Docker enough address space for one network per
5
+ * project.
6
+ *
7
+ * `setup` wrote a daemon.json without `default-address-pools`, so Docker
8
+ * used its built-in pools: about 31 networks. Each DDEV project creates its
9
+ * own `ddev-<name>_default` network, and a server with ~30 projects failed
10
+ * to start the next one with "all predefined address pools have been fully
11
+ * subnetted". The last 16 of those built-in networks are in 192.168.x,
12
+ * outside the 172.16.0.0/12 range the firewall allows to reach the agent.
13
+ *
14
+ * `configureDocker` now writes /24 pools in 172.16.0.0/12, which covers
15
+ * fresh installs. This migration adds them to existing servers.
16
+ *
17
+ * Docker reads the pools only at start, so the daemon is restarted.
18
+ * `live-restore`, set by setup, keeps the running containers up. Existing
19
+ * networks keep their subnets; only new networks get a /24, and Docker skips
20
+ * subnets an existing network already uses.
21
+ *
22
+ * Idempotent: does nothing when the config already sets pools.
23
+ */
24
+ export declare const migration0018DockerAddressPools: Migration;
25
+ /**
26
+ * The migration body, with its effects injected so tests can drive it.
27
+ */
28
+ export declare function runDockerAddressPoolsMigration(io?: SetupIo): void;
29
+ //# sourceMappingURL=0018__docker_address_pools.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"0018__docker_address_pools.d.ts","sourceRoot":"","sources":["../../../src/setup/migrations/0018__docker_address_pools.ts"],"names":[],"mappings":"AACA,OAAO,EAAU,KAAK,OAAO,EAAE,MAAM,UAAU,CAAC;AAChD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAE7C;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,eAAO,MAAM,+BAA+B,EAAE,SAO7C,CAAC;AAEF;;GAEG;AACH,wBAAgB,8BAA8B,CAAC,EAAE,GAAE,OAAgB,GAAG,IAAI,CAIzE"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/setup/migrations/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAgBjF,iDAAiD;AACjD,eAAO,MAAM,qBAAqB,iCAAiC,CAAC;AAEpE,+CAA+C;AAC/C,eAAO,MAAM,cAAc,EAAE,SAAS,EAerC,CAAC;AAMF;;;GAGG;AACH,wBAAgB,kBAAkB,IAAI,cAAc,CAqBnD;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,cAAc,GAAG,IAAI,CAG9D;AAMD;;GAEG;AACH,wBAAgB,cAAc,IAAI,kBAAkB,EAAE,CAMrD;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,UAAQ,GAAG,IAAI,CAyBzD;AAED;;;;;;GAMG;AACH,wBAAgB,wBAAwB,IAAI,IAAI,CAU/C"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/setup/migrations/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAmBjF,iDAAiD;AACjD,eAAO,MAAM,qBAAqB,iCAAiC,CAAC;AAEpE,+CAA+C;AAC/C,eAAO,MAAM,cAAc,EAAE,SAAS,EAkBrC,CAAC;AAMF;;;GAGG;AACH,wBAAgB,kBAAkB,IAAI,cAAc,CAqBnD;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,cAAc,GAAG,IAAI,CAG9D;AAMD;;GAEG;AACH,wBAAgB,cAAc,IAAI,kBAAkB,EAAE,CAMrD;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,UAAQ,GAAG,IAAI,CAyBzD;AAED;;;;;;GAMG;AACH,wBAAgB,wBAAwB,IAAI,IAAI,CAU/C"}
@@ -31,6 +31,17 @@ export interface SetupOptions {
31
31
  tld: string;
32
32
  /** Email for Let's Encrypt certificates */
33
33
  email?: string;
34
+ /**
35
+ * DNS-01 provider name (lego), e.g. "cloudflare".
36
+ *
37
+ * Turns on the wildcard certificate: Traefik asks for `*.<tld>` once and
38
+ * serves it to every host, instead of one certificate per preview.
39
+ */
40
+ dnsProvider?: string;
41
+ /** Credentials for that provider, passed to the router container */
42
+ dnsEnv?: Record<string, string>;
43
+ /** ACME CA directory URL, kept from the config on a re-run */
44
+ caServer?: string;
34
45
  /** Skip hardening steps */
35
46
  noHardening?: boolean;
36
47
  /** Skip Docker installation (already installed) */
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/setup/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,SAAS;IACxB,oDAAoD;IACpD,EAAE,EAAE,MAAM,CAAC;IACX,mEAAmE;IACnE,WAAW,EAAE,MAAM,CAAC;IACpB,iEAAiE;IACjE,GAAG,IAAI,IAAI,CAAC;CACb;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,4CAA4C;IAC5C,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,SAAS,EAAE,SAAS,CAAC;IACrB,MAAM,EAAE,SAAS,GAAG,SAAS,CAAC;CAC/B;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,uCAAuC;IACvC,GAAG,EAAE,MAAM,CAAC;IACZ,2CAA2C;IAC3C,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,2BAA2B;IAC3B,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,mDAAmD;IACnD,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,iDAAiD;IACjD,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,oCAAoC;IACpC,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB,kFAAkF;IAClF,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB;;;OAGG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,oDAAoD;IAC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