@camstack/server 1.2.718 → 1.2.720
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/CHANGELOG.md +13 -0
- package/dist/addon-root-inventory.js +1 -1
- package/dist/agent/addon-scan.js +11 -7
- package/dist/agent/agent-addon-updates.js +1 -1
- package/dist/agent/agent-cap-dispatch-service.js +1 -1
- package/dist/agent/agent-heap-watch.js +1 -1
- package/dist/agent/agent-http.js +1 -1
- package/dist/agent/agent-hub-addon-update.js +1 -1
- package/dist/agent/agent-hub-registration.js +1 -1
- package/dist/agent/agent-infra-capabilities.js +2 -2
- package/dist/agent/agent-mesh-gate.js +1 -1
- package/dist/agent/agent-node-certificates.js +1 -1
- package/dist/agent/agent-pairing-routes.js +1 -1
- package/dist/agent/agent-pairing-store.js +1 -1
- package/dist/agent/agent-service.js +6 -2
- package/dist/agent/agent-update-service.js +3 -1
- package/dist/agent/hub-membership-client.js +1 -1
- package/dist/agent/infra-boot-guard.js +2 -2
- package/dist/agent/main.js +9 -9
- package/dist/api/addon-upload.js +1 -1
- package/dist/api/core/addon-settings.router.js +1 -1
- package/dist/api/core/agent-pairing.router.js +1 -1
- package/dist/api/core/auth-device-cert.procedures.js +1 -1
- package/dist/api/core/cap-providers.js +6 -6
- package/dist/api/core/certificates.router.js +1 -1
- package/dist/api/core/lifecycle-job-runner.js +1 -1
- package/dist/api/core/logging-settings.js +1 -1
- package/dist/api/core/logs.router.js +2 -2
- package/dist/api/core/notifications.router.js +1 -1
- package/dist/api/core/preferences.router.js +1 -1
- package/dist/api/core/repl.router.js +1 -1
- package/dist/api/cors/cors-policy.js +1 -1
- package/dist/api/mesh-membership-routes.js +1 -1
- package/dist/api/model-distributor.js +1 -1
- package/dist/api/trpc/cap-route-error-formatter.js +1 -1
- package/dist/api/trpc/cap-router-runtime.js +2 -2
- package/dist/api/trpc/core-cap-bridge.js +1 -1
- package/dist/api/trpc/device-collection-dispatch.js +1 -1
- package/dist/api/trpc/generated-cap-routers.js +1 -1
- package/dist/api/trpc/principal-authorization.js +1 -1
- package/dist/api/trpc/principal-visibility.js +1 -1
- package/dist/api/trpc/scope-access.js +1 -1
- package/dist/api/trpc/trpc.context.js +1 -1
- package/dist/api/trpc/trpc.middleware.js +1 -1
- package/dist/api/trpc/trpc.router.js +3 -3
- package/dist/auth/auth-network-policy.js +1 -1
- package/dist/auth/client-address.js +1 -1
- package/dist/auth/hub-sessions.js +1 -1
- package/dist/auth/session-lifetimes.js +1 -1
- package/dist/auth/sso-finish-deps.js +1 -1
- package/dist/boot/boot-config.js +53 -133
- package/dist/boot/platform-keychain-key.js +1 -1
- package/dist/boot/post-boot.service.js +1 -1
- package/dist/bootstrap-packages.js +3 -3
- package/dist/core/addon/addon-call-gateway.js +1 -1
- package/dist/core/addon/addon-package.service.js +140 -21
- package/dist/core/addon/addon-registry.service.js +36 -32
- package/dist/core/addon/addon-requirements.js +81 -0
- package/dist/core/addon/hub-addon-api.js +1 -1
- package/dist/core/addon/installed-addon-versions.js +82 -0
- package/dist/core/addon/package-dir-utils.js +11 -1
- package/dist/core/addon/settings-door-wiring.js +1 -1
- package/dist/core/addon-bridge/addon-bridge.service.js +3 -3
- package/dist/core/addon-pages/addon-pages.service.js +1 -1
- package/dist/core/agent/agent-desired-set.js +1 -1
- package/dist/core/agent/agent-pairing-http.js +1 -1
- package/dist/core/agent/agent-registry.service.js +41 -7
- package/dist/core/agent/cluster-node-history-store.js +1 -1
- package/dist/core/agent/delivery-requirements.js +36 -0
- package/dist/core/agent/forgotten-node-revoker.js +1 -1
- package/dist/core/agent/node-removal-hooks.js +6 -2
- package/dist/core/auth/auth.service.js +1 -1
- package/dist/core/config/config.schema.js +2 -2
- package/dist/core/config/config.service.js +1 -1
- package/dist/core/events/event-bus.service.js +1 -1
- package/dist/core/feature/feature.service.js +1 -1
- package/dist/core/lifecycle/lifecycle-state-machine.js +2 -2
- package/dist/core/logging/log-history.js +1 -1
- package/dist/core/logging/log-ring-buffer.js +2 -2
- package/dist/core/logging/logging.service.js +2 -2
- package/dist/core/logging/scoped-logger.js +2 -2
- package/dist/core/moleculer/cap-route-authority.js +2 -2
- package/dist/core/moleculer/hub-mesh-guard.js +1 -1
- package/dist/core/moleculer/moleculer.service.js +1 -1
- package/dist/core/network/network-quality.service.js +1 -1
- package/dist/core/notification/notification-wrapper.service.js +1 -1
- package/dist/core/notification/toast-wrapper.service.js +1 -1
- package/dist/core/repl/repl-engine.service.js +1 -1
- package/dist/core/server-update/server-update.service.js +3 -0
- package/dist/core/server-update/system-ensure-prebuilds.js +3 -3
- package/dist/core/server-update/system-exec-npm.js +2 -2
- package/dist/core/storage/fs-storage-backend.js +2 -2
- package/dist/core/storage/storage-location-manager.js +2 -2
- package/dist/core/storage/storage.service.js +1 -1
- package/dist/framework-nodepath.js +14 -1
- package/dist/launcher.js +23 -23
- package/dist/legacy-package-names.js +15 -0
- package/dist/main.js +2 -2
- package/dist/manual-boot.js +4 -3
- package/dist/package-inventory.js +6 -3
- package/dist/server-root/index.js +182 -30
- package/dist/single-copy-cleanup-runner.js +3 -3
- package/dist/single-copy-cleanup.js +19 -14
- package/package.json +53 -19
- package/scripts/closure-postinstall.mjs +1 -1
- package/system/assets/addon-pages-aggregator/icon.svg +5 -0
- package/system/assets/addon-widgets-aggregator/icon.svg +6 -0
- package/system/assets/alert-center/icon.svg +5 -0
- package/system/assets/autotrack/icon.svg +5 -0
- package/system/assets/backup-orchestrator/icon.svg +5 -0
- package/system/assets/calendars/icon.svg +5 -0
- package/system/assets/camera-grid/icon.svg +10 -0
- package/system/assets/composer/icon.svg +7 -0
- package/system/assets/console-logging/icon.svg +4 -0
- package/system/assets/core-blocks/icon.svg +6 -0
- package/system/assets/device-history/icon.svg +4 -0
- package/system/assets/device-manager/icon.svg +6 -0
- package/system/assets/filesystem-storage/icon.svg +6 -0
- package/system/assets/hub-forwarder/icon.svg +7 -0
- package/system/assets/keychain/icon.svg +6 -0
- package/system/assets/liveness-monitor/icon.svg +4 -0
- package/system/assets/local-auth/icon.svg +5 -0
- package/system/assets/local-network/icon.svg +7 -0
- package/system/assets/loki-logging/icon.svg +7 -0
- package/system/assets/metrics-native/icon.svg +3 -0
- package/system/assets/platform-probe/icon.svg +5 -0
- package/system/assets/record-entries/icon.svg +8 -0
- package/system/assets/remote-access-orchestrator/icon.svg +5 -0
- package/system/assets/snapshot/icon.svg +4 -0
- package/system/assets/sqlite-settings/icon.svg +5 -0
- package/system/assets/storage-orchestrator/icon.svg +8 -0
- package/system/assets/system-config/icon.svg +4 -0
- package/system/assets/winston-logging/icon.svg +6 -0
- package/system/dist/addon/addon-api-factory.d.ts +35 -0
- package/system/dist/addon-routes/addon-route-registry.d.ts +37 -0
- package/system/dist/addon-runner.js +11894 -0
- package/system/dist/addon-runner.mjs +11840 -0
- package/system/dist/addon-utils.d.ts +23 -0
- package/system/dist/addon-utils.js +27 -0
- package/system/dist/addon-utils.mjs +3 -0
- package/system/dist/agent-https-BMbnmX5u.mjs +1042 -0
- package/system/dist/agent-https-DslXCDRW.js +1289 -0
- package/system/dist/amd-accelerators-CEuPFBBK.js +36 -0
- package/system/dist/amd-accelerators-U_RsoEDd.mjs +35 -0
- package/system/dist/auth/auth-audit-log.d.ts +45 -0
- package/system/dist/auth/auth-manager.d.ts +155 -0
- package/system/dist/auth/cidr.d.ts +22 -0
- package/system/dist/auth/device-ca-store.d.ts +57 -0
- package/system/dist/auth/device-ca.d.ts +65 -0
- package/system/dist/auth/device-credential-manager.d.ts +158 -0
- package/system/dist/auth/external-identity-manager.d.ts +42 -0
- package/system/dist/auth/jwt-signing-key.d.ts +42 -0
- package/system/dist/auth/legacy-token-tables.d.ts +16 -0
- package/system/dist/auth/login-session-manager.d.ts +140 -0
- package/system/dist/auth/origin.d.ts +34 -0
- package/system/dist/auth/parse-record.d.ts +18 -0
- package/system/dist/auth/scope-matcher.d.ts +8 -0
- package/system/dist/auth/session-revocation-bus.d.ts +32 -0
- package/system/dist/auth/token-expiry.d.ts +62 -0
- package/system/dist/auth/totp-manager.d.ts +107 -0
- package/system/dist/auth/user-management-internal.d.ts +90 -0
- package/system/dist/auth/user-manager.d.ts +69 -0
- package/system/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.d.ts +57 -0
- package/system/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.js +271 -0
- package/system/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.mjs +263 -0
- package/system/dist/builtins/addon-pages-aggregator/dedupe-pages.d.ts +24 -0
- package/system/dist/builtins/addon-pages-aggregator/index.d.ts +1 -0
- package/system/dist/builtins/addon-pages-aggregator/index.js +8 -0
- package/system/dist/builtins/addon-pages-aggregator/index.mjs +2 -0
- package/system/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.d.ts +57 -0
- package/system/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.js +257 -0
- package/system/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.mjs +249 -0
- package/system/dist/builtins/addon-widgets-aggregator/index.d.ts +1 -0
- package/system/dist/builtins/addon-widgets-aggregator/index.js +8 -0
- package/system/dist/builtins/addon-widgets-aggregator/index.mjs +2 -0
- package/system/dist/builtins/alerts/alert-episode-policy.d.ts +39 -0
- package/system/dist/builtins/alerts/alert-store.d.ts +32 -0
- package/system/dist/builtins/alerts/alerts.addon.d.ts +148 -0
- package/system/dist/builtins/alerts/alerts.addon.js +1566 -0
- package/system/dist/builtins/alerts/alerts.addon.mjs +1559 -0
- package/system/dist/builtins/alerts/device-label.d.ts +8 -0
- package/system/dist/builtins/alerts/emit-alert-policy.d.ts +15 -0
- package/system/dist/builtins/alerts/index.d.ts +1 -0
- package/system/dist/builtins/alerts/index.js +4 -0
- package/system/dist/builtins/alerts/index.mjs +2 -0
- package/system/dist/builtins/alerts/migration-alerts.d.ts +13 -0
- package/system/dist/builtins/alerts/prune-policy.d.ts +44 -0
- package/system/dist/builtins/alerts/record-kinds.d.ts +15 -0
- package/system/dist/builtins/alerts/runner-alert.d.ts +58 -0
- package/system/dist/builtins/autotrack/autotrack-cameras.d.ts +125 -0
- package/system/dist/builtins/autotrack/autotrack-config.d.ts +89 -0
- package/system/dist/builtins/autotrack/autotrack-decision.d.ts +86 -0
- package/system/dist/builtins/autotrack/autotrack-loop.d.ts +95 -0
- package/system/dist/builtins/autotrack/autotrack.addon.d.ts +108 -0
- package/system/dist/builtins/autotrack/frame-error.d.ts +50 -0
- package/system/dist/builtins/autotrack/frame-measurements.d.ts +97 -0
- package/system/dist/builtins/autotrack/index.d.ts +2 -0
- package/system/dist/builtins/autotrack/index.js +1018 -0
- package/system/dist/builtins/autotrack/index.mjs +1012 -0
- package/system/dist/builtins/autotrack/ptz-mirror.d.ts +54 -0
- package/system/dist/builtins/autotrack/target-selection.d.ts +46 -0
- package/system/dist/builtins/backup-orchestrator/backup-databases.d.ts +51 -0
- package/system/dist/builtins/backup-orchestrator/backup-orchestrator.addon.d.ts +291 -0
- package/system/dist/builtins/backup-orchestrator/backup-orchestrator.addon.js +3213 -0
- package/system/dist/builtins/backup-orchestrator/backup-orchestrator.addon.mjs +3204 -0
- package/system/dist/builtins/backup-orchestrator/cron-helpers.d.ts +23 -0
- package/system/dist/builtins/backup-orchestrator/destination-policy.d.ts +91 -0
- package/system/dist/builtins/backup-orchestrator/download-helpers.d.ts +12 -0
- package/system/dist/builtins/backup-orchestrator/encryption-key-store.d.ts +49 -0
- package/system/dist/builtins/backup-orchestrator/index.d.ts +2 -0
- package/system/dist/builtins/backup-orchestrator/index.js +8 -0
- package/system/dist/builtins/backup-orchestrator/index.mjs +2 -0
- package/system/dist/builtins/backup-orchestrator/manifest-store.d.ts +134 -0
- package/system/dist/builtins/backup-orchestrator/record-kinds.d.ts +56 -0
- package/system/dist/builtins/backup-orchestrator/restore-archive.d.ts +24 -0
- package/system/dist/builtins/backup-orchestrator/run-queue.d.ts +106 -0
- package/system/dist/builtins/backup-orchestrator/schedule-store.d.ts +59 -0
- package/system/dist/builtins/backup-orchestrator/seed-marker-store.d.ts +26 -0
- package/system/dist/builtins/backup-orchestrator/staging-paths.d.ts +36 -0
- package/system/dist/builtins/backup-orchestrator/write-targets.d.ts +63 -0
- package/system/dist/builtins/calendars/calendar-color.d.ts +9 -0
- package/system/dist/builtins/calendars/calendar-prefs-store.d.ts +34 -0
- package/system/dist/builtins/calendars/calendars.addon.d.ts +19 -0
- package/system/dist/builtins/calendars/calendars.addon.js +227 -0
- package/system/dist/builtins/calendars/calendars.addon.mjs +220 -0
- package/system/dist/builtins/calendars/index.d.ts +1 -0
- package/system/dist/builtins/calendars/index.js +8 -0
- package/system/dist/builtins/calendars/index.mjs +2 -0
- package/system/dist/builtins/calendars/record-kinds.d.ts +18 -0
- package/system/dist/builtins/camera-grid/acquire-retry.d.ts +30 -0
- package/system/dist/builtins/camera-grid/addon.d.ts +205 -0
- package/system/dist/builtins/camera-grid/flv-join.d.ts +40 -0
- package/system/dist/builtins/camera-grid/grid-activity-mirror.d.ts +42 -0
- package/system/dist/builtins/camera-grid/grid-activity.d.ts +91 -0
- package/system/dist/builtins/camera-grid/grid-camera-declarations.d.ts +59 -0
- package/system/dist/builtins/camera-grid/grid-camera-device.d.ts +68 -0
- package/system/dist/builtins/camera-grid/grid-canvas-derivation.d.ts +54 -0
- package/system/dist/builtins/camera-grid/grid-canvas-seed.d.ts +112 -0
- package/system/dist/builtins/camera-grid/grid-canvas.d.ts +85 -0
- package/system/dist/builtins/camera-grid/grid-child.d.ts +32 -0
- package/system/dist/builtins/camera-grid/grid-compositor-child.d.ts +3 -0
- package/system/dist/builtins/camera-grid/grid-compositor-invocation.d.ts +47 -0
- package/system/dist/builtins/camera-grid/grid-compositor.d.ts +54 -0
- package/system/dist/builtins/camera-grid/grid-detection-mapping.d.ts +61 -0
- package/system/dist/builtins/camera-grid/grid-device-settings.d.ts +35 -0
- package/system/dist/builtins/camera-grid/grid-filter-graph.d.ts +53 -0
- package/system/dist/builtins/camera-grid/grid-frame-sample.d.ts +53 -0
- package/system/dist/builtins/camera-grid/grid-instances.d.ts +22 -0
- package/system/dist/builtins/camera-grid/grid-last-frame-store.d.ts +58 -0
- package/system/dist/builtins/camera-grid/grid-layout-native-provider.d.ts +34 -0
- package/system/dist/builtins/camera-grid/grid-plan.d.ts +34 -0
- package/system/dist/builtins/camera-grid/grid-profiles.d.ts +104 -0
- package/system/dist/builtins/camera-grid/grid-row-normalization.d.ts +10 -0
- package/system/dist/builtins/camera-grid/grid-sentry-sources.d.ts +64 -0
- package/system/dist/builtins/camera-grid/grid-snapshot.d.ts +62 -0
- package/system/dist/builtins/camera-grid/grid-stream-descriptor.d.ts +53 -0
- package/system/dist/builtins/camera-grid/grid-stream-invocation.d.ts +44 -0
- package/system/dist/builtins/camera-grid/grid-stream-relay.d.ts +35 -0
- package/system/dist/builtins/camera-grid/grid-stream-session.d.ts +143 -0
- package/system/dist/builtins/camera-grid/grid-tile-feed.d.ts +50 -0
- package/system/dist/builtins/camera-grid/grid-tile-plan.d.ts +66 -0
- package/system/dist/builtins/camera-grid/grid-wire-format.d.ts +30 -0
- package/system/dist/builtins/camera-grid/index.d.ts +45 -0
- package/system/dist/builtins/camera-grid/index.js +3994 -0
- package/system/dist/builtins/camera-grid/index.mjs +3961 -0
- package/system/dist/builtins/camera-grid/silence-analysis.d.ts +37 -0
- package/system/dist/builtins/cluster-agent/record-kinds.d.ts +49 -0
- package/system/dist/builtins/composer/actuator-dispatch.d.ts +13 -0
- package/system/dist/builtins/composer/actuator-groups.d.ts +68 -0
- package/system/dist/builtins/composer/actuator-invoke.d.ts +32 -0
- package/system/dist/builtins/composer/claim-gate.d.ts +59 -0
- package/system/dist/builtins/composer/composed-device-set.d.ts +52 -0
- package/system/dist/builtins/composer/composed-device.d.ts +57 -0
- package/system/dist/builtins/composer/composer-apply-waits.d.ts +28 -0
- package/system/dist/builtins/composer/composer-grafts.d.ts +73 -0
- package/system/dist/builtins/composer/composer-live-set.d.ts +30 -0
- package/system/dist/builtins/composer/composer-plan.d.ts +112 -0
- package/system/dist/builtins/composer/composer-runtime-factory.d.ts +30 -0
- package/system/dist/builtins/composer/composer-seeds.d.ts +28 -0
- package/system/dist/builtins/composer/composer-verdict.d.ts +33 -0
- package/system/dist/builtins/composer/composer.addon.d.ts +26 -0
- package/system/dist/builtins/composer/composer.addon.js +6229 -0
- package/system/dist/builtins/composer/composer.addon.mjs +6223 -0
- package/system/dist/builtins/composer/composer.d.ts +208 -0
- package/system/dist/builtins/composer/composition-declarations.d.ts +64 -0
- package/system/dist/builtins/composer/composition-evaluation.d.ts +53 -0
- package/system/dist/builtins/composer/composition-runtime.d.ts +203 -0
- package/system/dist/builtins/composer/composition-target.d.ts +60 -0
- package/system/dist/builtins/composer/confirmed-seed.d.ts +44 -0
- package/system/dist/builtins/composer/deadline-timer.d.ts +18 -0
- package/system/dist/builtins/composer/existing-target.d.ts +131 -0
- package/system/dist/builtins/composer/field-record.d.ts +64 -0
- package/system/dist/builtins/composer/forward-commands.d.ts +61 -0
- package/system/dist/builtins/composer/graft-host.d.ts +71 -0
- package/system/dist/builtins/composer/held-claims.d.ts +29 -0
- package/system/dist/builtins/composer/history-helpers.d.ts +67 -0
- package/system/dist/builtins/composer/index.d.ts +1 -0
- package/system/dist/builtins/composer/index.js +8 -0
- package/system/dist/builtins/composer/index.mjs +2 -0
- package/system/dist/builtins/composer/math-quantity.d.ts +20 -0
- package/system/dist/builtins/composer/own-field-reads.d.ts +30 -0
- package/system/dist/builtins/composer/owned-fields-target.d.ts +95 -0
- package/system/dist/builtins/composer/pulse-seed-resolve.d.ts +59 -0
- package/system/dist/builtins/composer/pulse-seed.d.ts +75 -0
- package/system/dist/builtins/composer/slice-assembler.d.ts +26 -0
- package/system/dist/builtins/composer/source-readings.d.ts +128 -0
- package/system/dist/builtins/composer/source-tracker.d.ts +135 -0
- package/system/dist/builtins/console-logging/console-destination.d.ts +19 -0
- package/system/dist/builtins/console-logging/console-logging.addon.d.ts +26 -0
- package/system/dist/builtins/console-logging/index.d.ts +3 -0
- package/system/dist/builtins/console-logging/index.js +108 -0
- package/system/dist/builtins/console-logging/index.mjs +99 -0
- package/system/dist/builtins/core-blocks/actions-service.d.ts +113 -0
- package/system/dist/builtins/core-blocks/actions-store.d.ts +32 -0
- package/system/dist/builtins/core-blocks/actions-wiring.d.ts +32 -0
- package/system/dist/builtins/core-blocks/block-package.d.ts +54 -0
- package/system/dist/builtins/core-blocks/block-settings-store.d.ts +93 -0
- package/system/dist/builtins/core-blocks/block-supervisor.d.ts +176 -0
- package/system/dist/builtins/core-blocks/block-type-defs.d.ts +29 -0
- package/system/dist/builtins/core-blocks/blocks-integration.d.ts +89 -0
- package/system/dist/builtins/core-blocks/compile-block.d.ts +52 -0
- package/system/dist/builtins/core-blocks/composition-api.d.ts +50 -0
- package/system/dist/builtins/core-blocks/composition-peers.d.ts +31 -0
- package/system/dist/builtins/core-blocks/composition-sources.d.ts +40 -0
- package/system/dist/builtins/core-blocks/core-block-store.d.ts +120 -0
- package/system/dist/builtins/core-blocks/core-blocks.addon.d.ts +108 -0
- package/system/dist/builtins/core-blocks/core-blocks.addon.js +6374 -0
- package/system/dist/builtins/core-blocks/core-blocks.addon.mjs +6355 -0
- package/system/dist/builtins/core-blocks/extract-settings-schema.d.ts +6 -0
- package/system/dist/builtins/core-blocks/index.d.ts +8 -0
- package/system/dist/builtins/core-blocks/index.js +21 -0
- package/system/dist/builtins/core-blocks/index.mjs +2 -0
- package/system/dist/builtins/core-blocks/lock-door-gate.d.ts +31 -0
- package/system/dist/builtins/core-blocks/lock-door-sensor.d.ts +35 -0
- package/system/dist/builtins/core-blocks/power-source-service.d.ts +70 -0
- package/system/dist/builtins/core-blocks/record-kinds.d.ts +83 -0
- package/system/dist/builtins/core-blocks/remote-call-redirect.d.ts +23 -0
- package/system/dist/builtins/core-blocks/remote-components-service.d.ts +10 -0
- package/system/dist/builtins/core-blocks/remote-service.d.ts +85 -0
- package/system/dist/builtins/core-blocks/remote-wiring.d.ts +49 -0
- package/system/dist/builtins/core-blocks/runs-api.d.ts +30 -0
- package/system/dist/builtins/core-blocks/runs-ledger.d.ts +64 -0
- package/system/dist/builtins/core-blocks/scheduler/scheduler-engine.d.ts +91 -0
- package/system/dist/builtins/core-blocks/scheduler/scheduler-holds.d.ts +54 -0
- package/system/dist/builtins/core-blocks/scheduler/scheduler-service.d.ts +76 -0
- package/system/dist/builtins/core-blocks/scheduler/scheduler-store.d.ts +23 -0
- package/system/dist/builtins/core-blocks/scheduler/scheduler-timeline.d.ts +53 -0
- package/system/dist/builtins/core-blocks/scheduler/scheduler-trace.d.ts +17 -0
- package/system/dist/builtins/core-blocks/scheduler/scheduler-types.d.ts +20 -0
- package/system/dist/builtins/core-blocks/scheduler/scheduler-wiring.d.ts +41 -0
- package/system/dist/builtins/core-blocks/templates-service.d.ts +24 -0
- package/system/dist/builtins/device-history/capture/capture-engine.d.ts +113 -0
- package/system/dist/builtins/device-history/capture/capture-filter.d.ts +37 -0
- package/system/dist/builtins/device-history/capture/device-directory.d.ts +47 -0
- package/system/dist/builtins/device-history/capture/field-path.d.ts +10 -0
- package/system/dist/builtins/device-history/capture/point-writer.d.ts +63 -0
- package/system/dist/builtins/device-history/device-history.addon.d.ts +53 -0
- package/system/dist/builtins/device-history/device-history.addon.js +2885 -0
- package/system/dist/builtins/device-history/device-history.addon.mjs +2878 -0
- package/system/dist/builtins/device-history/index.d.ts +3 -0
- package/system/dist/builtins/device-history/ingest/producer-ingest.d.ts +99 -0
- package/system/dist/builtins/device-history/query/history-query.d.ts +116 -0
- package/system/dist/builtins/device-history/query/point-shape.d.ts +31 -0
- package/system/dist/builtins/device-history/retention/departure-tracker.d.ts +33 -0
- package/system/dist/builtins/device-history/retention/orphans.d.ts +50 -0
- package/system/dist/builtins/device-history/retention/retention.d.ts +74 -0
- package/system/dist/builtins/device-history/rollup/rollup-engine.d.ts +74 -0
- package/system/dist/builtins/device-history/rollup/rollup-math.d.ts +50 -0
- package/system/dist/builtins/device-history/runtime/history-runtime.d.ts +118 -0
- package/system/dist/builtins/device-history/status/counters.d.ts +55 -0
- package/system/dist/builtins/device-history/store/history-door.d.ts +7 -0
- package/system/dist/builtins/device-history/store/history-schema.d.ts +28 -0
- package/system/dist/builtins/device-history/store/history-store.d.ts +109 -0
- package/system/dist/builtins/device-history/store/row-readers.d.ts +11 -0
- package/system/dist/builtins/device-history/store/series-registry.d.ts +64 -0
- package/system/dist/builtins/device-history/store/series-scale.d.ts +37 -0
- package/system/dist/builtins/device-history/time/bucket-time.d.ts +25 -0
- package/system/dist/builtins/device-manager/adoption-job-engine.d.ts +153 -0
- package/system/dist/builtins/device-manager/claimed-status-overlay.d.ts +45 -0
- package/system/dist/builtins/device-manager/contribution-cache.d.ts +85 -0
- package/system/dist/builtins/device-manager/day-night-config-schema.d.ts +30 -0
- package/system/dist/builtins/device-manager/device-aggregation-merge.d.ts +22 -0
- package/system/dist/builtins/device-manager/device-aggregation.d.ts +335 -0
- package/system/dist/builtins/device-manager/device-bindings-store.d.ts +278 -0
- package/system/dist/builtins/device-manager/device-config-contribution.d.ts +45 -0
- package/system/dist/builtins/device-manager/device-config-secrets.d.ts +40 -0
- package/system/dist/builtins/device-manager/device-event-propagator.d.ts +26 -0
- package/system/dist/builtins/device-manager/device-extension-linked-slot.d.ts +27 -0
- package/system/dist/builtins/device-manager/device-form-secrets.d.ts +25 -0
- package/system/dist/builtins/device-manager/device-linked-devices.d.ts +201 -0
- package/system/dist/builtins/device-manager/device-manager.addon.d.ts +234 -0
- package/system/dist/builtins/device-manager/device-manager.addon.js +11369 -0
- package/system/dist/builtins/device-manager/device-manager.addon.mjs +11358 -0
- package/system/dist/builtins/device-manager/device-meta-actions.d.ts +338 -0
- package/system/dist/builtins/device-manager/device-meta-store.d.ts +103 -0
- package/system/dist/builtins/device-manager/device-meta-types.d.ts +277 -0
- package/system/dist/builtins/device-manager/device-online-fallback.d.ts +35 -0
- package/system/dist/builtins/device-manager/device-projection.d.ts +71 -0
- package/system/dist/builtins/device-manager/device-provider-context.d.ts +126 -0
- package/system/dist/builtins/device-manager/device-queries.d.ts +67 -0
- package/system/dist/builtins/device-manager/device-removal-hooks.d.ts +92 -0
- package/system/dist/builtins/device-manager/device-row-store.d.ts +449 -0
- package/system/dist/builtins/device-manager/device-source-activation.d.ts +103 -0
- package/system/dist/builtins/device-manager/device-state-claim-views.d.ts +92 -0
- package/system/dist/builtins/device-manager/device-state-claims.d.ts +66 -0
- package/system/dist/builtins/device-manager/device-state-mirror.d.ts +267 -0
- package/system/dist/builtins/device-manager/device-sync-resolvers.d.ts +30 -0
- package/system/dist/builtins/device-manager/device-tombstone-store.d.ts +29 -0
- package/system/dist/builtins/device-manager/discovery-orchestrator.d.ts +45 -0
- package/system/dist/builtins/device-manager/field-claims-index.d.ts +96 -0
- package/system/dist/builtins/device-manager/field-ownership.d.ts +71 -0
- package/system/dist/builtins/device-manager/fleet-read-census.d.ts +104 -0
- package/system/dist/builtins/device-manager/image-settings-config-schema.d.ts +22 -0
- package/system/dist/builtins/device-manager/index.d.ts +2 -0
- package/system/dist/builtins/device-manager/index.js +8 -0
- package/system/dist/builtins/device-manager/index.mjs +2 -0
- package/system/dist/builtins/device-manager/linked-devices-manual-backfill.d.ts +27 -0
- package/system/dist/builtins/device-manager/location-alignment.d.ts +61 -0
- package/system/dist/builtins/device-manager/migrate-device.d.ts +192 -0
- package/system/dist/builtins/device-manager/migrate-guard.d.ts +78 -0
- package/system/dist/builtins/device-manager/migrate-hardware-state.d.ts +79 -0
- package/system/dist/builtins/device-manager/migrate-reload.d.ts +46 -0
- package/system/dist/builtins/device-manager/migration-refused.d.ts +23 -0
- package/system/dist/builtins/device-manager/mirror-row-writer.d.ts +222 -0
- package/system/dist/builtins/device-manager/record-kinds.d.ts +14 -0
- package/system/dist/builtins/device-manager/recording-onboard-config-schema.d.ts +65 -0
- package/system/dist/builtins/device-manager/removal-cleanup.d.ts +50 -0
- package/system/dist/builtins/device-manager/removal-fence.d.ts +58 -0
- package/system/dist/builtins/device-manager/running-flip.d.ts +11 -0
- package/system/dist/builtins/device-manager/runtime-state-persist-gate.d.ts +64 -0
- package/system/dist/builtins/device-manager/secret-config-paths.d.ts +24 -0
- package/system/dist/builtins/device-manager/stale-wrapper-activations.d.ts +59 -0
- package/system/dist/builtins/device-manager/write-lock.d.ts +17 -0
- package/system/dist/builtins/hub-forwarder/hub-forwarder-destination.d.ts +43 -0
- package/system/dist/builtins/hub-forwarder/hub-forwarder.addon.d.ts +16 -0
- package/system/dist/builtins/hub-forwarder/index.d.ts +3 -0
- package/system/dist/builtins/hub-forwarder/index.js +151 -0
- package/system/dist/builtins/hub-forwarder/index.mjs +142 -0
- package/system/dist/builtins/keychain/index.d.ts +1 -0
- package/system/dist/builtins/keychain/index.js +2059 -0
- package/system/dist/builtins/keychain/index.mjs +2052 -0
- package/system/dist/builtins/keychain/key-sources.d.ts +37 -0
- package/system/dist/builtins/keychain/keychain-crypto.d.ts +28 -0
- package/system/dist/builtins/keychain/keychain-reset-trigger.d.ts +25 -0
- package/system/dist/builtins/keychain/keychain-service.d.ts +180 -0
- package/system/dist/builtins/keychain/keychain-store.d.ts +125 -0
- package/system/dist/builtins/keychain/keychain-usage.d.ts +17 -0
- package/system/dist/builtins/keychain/keychain.addon.d.ts +36 -0
- package/system/dist/builtins/keychain/platform-key-source.d.ts +24 -0
- package/system/dist/builtins/keychain/record-kinds.d.ts +16 -0
- package/system/dist/builtins/keychain/system-held-secrets.d.ts +25 -0
- package/system/dist/builtins/liveness-monitor/index.d.ts +2 -0
- package/system/dist/builtins/liveness-monitor/index.js +6 -0
- package/system/dist/builtins/liveness-monitor/index.mjs +2 -0
- package/system/dist/builtins/liveness-monitor/liveness-checks.d.ts +85 -0
- package/system/dist/builtins/liveness-monitor/liveness-monitor.addon.d.ts +46 -0
- package/system/dist/builtins/liveness-monitor/liveness-monitor.addon.js +443 -0
- package/system/dist/builtins/liveness-monitor/liveness-monitor.addon.mjs +437 -0
- package/system/dist/builtins/liveness-monitor/liveness-reporter.d.ts +28 -0
- package/system/dist/builtins/liveness-monitor/storage-root-access.d.ts +53 -0
- package/system/dist/builtins/local-auth/admin-account-boot.d.ts +27 -0
- package/system/dist/builtins/local-auth/auth-config-reader.d.ts +39 -0
- package/system/dist/builtins/local-auth/auth-schema.d.ts +93 -0
- package/system/dist/builtins/local-auth/index.d.ts +1 -0
- package/system/dist/builtins/local-auth/index.js +4 -0
- package/system/dist/builtins/local-auth/index.mjs +2 -0
- package/system/dist/builtins/local-auth/jwt-signing-key-keeper.d.ts +30 -0
- package/system/dist/builtins/local-auth/local-auth.addon.d.ts +48 -0
- package/system/dist/builtins/local-auth/local-auth.addon.js +12418 -0
- package/system/dist/builtins/local-auth/local-auth.addon.mjs +12388 -0
- package/system/dist/builtins/local-auth/oauth-grants.d.ts +71 -0
- package/system/dist/builtins/local-auth/oauth-session-manager.d.ts +44 -0
- package/system/dist/builtins/local-auth/person-scopes.d.ts +7 -0
- package/system/dist/builtins/local-auth/preferences-record-kinds.d.ts +27 -0
- package/system/dist/builtins/local-auth/record-kinds.d.ts +137 -0
- package/system/dist/builtins/local-auth/user-preferences-store.d.ts +56 -0
- package/system/dist/builtins/local-network/address-book.d.ts +128 -0
- package/system/dist/builtins/local-network/agent-mdns.d.ts +56 -0
- package/system/dist/builtins/local-network/hub-mdns-ciao.d.ts +7 -0
- package/system/dist/builtins/local-network/hub-mdns.d.ts +58 -0
- package/system/dist/builtins/local-network/index.d.ts +1 -0
- package/system/dist/builtins/local-network/index.js +10 -0
- package/system/dist/builtins/local-network/index.mjs +2 -0
- package/system/dist/builtins/local-network/ipv6-lan.d.ts +21 -0
- package/system/dist/builtins/local-network/local-hostname.d.ts +15 -0
- package/system/dist/builtins/local-network/local-network.addon.d.ts +334 -0
- package/system/dist/builtins/local-network/local-network.addon.js +2487 -0
- package/system/dist/builtins/local-network/local-network.addon.mjs +2466 -0
- package/system/dist/builtins/local-network/scan/dns-wire.d.ts +17 -0
- package/system/dist/builtins/local-network/scan/scan-engine.d.ts +31 -0
- package/system/dist/builtins/local-network/scan/scan-io-node.d.ts +2 -0
- package/system/dist/builtins/local-network/scan/scan-io.d.ts +56 -0
- package/system/dist/builtins/local-network/scan/subnets.d.ts +57 -0
- package/system/dist/builtins/loki-logging/index.d.ts +4 -0
- package/system/dist/builtins/loki-logging/index.js +915 -0
- package/system/dist/builtins/loki-logging/index.mjs +901 -0
- package/system/dist/builtins/loki-logging/loki-destination.d.ts +142 -0
- package/system/dist/builtins/loki-logging/loki-logging.addon.d.ts +66 -0
- package/system/dist/builtins/loki-logging/loki-payload.d.ts +100 -0
- package/system/dist/builtins/loki-logging/loki-read.d.ts +51 -0
- package/system/dist/builtins/loki-logging/retire-enabled-flag.d.ts +48 -0
- package/system/dist/builtins/native-metrics/cgroup-memory.d.ts +240 -0
- package/system/dist/builtins/native-metrics/cgroup-pids.d.ts +159 -0
- package/system/dist/builtins/native-metrics/container-memory-ring.d.ts +18 -0
- package/system/dist/builtins/native-metrics/darwin-memory.d.ts +26 -0
- package/system/dist/builtins/native-metrics/gpu-probe.d.ts +18 -0
- package/system/dist/builtins/native-metrics/index.d.ts +2 -0
- package/system/dist/builtins/native-metrics/load-series-config.d.ts +83 -0
- package/system/dist/builtins/native-metrics/load-series-reader.d.ts +63 -0
- package/system/dist/builtins/native-metrics/load-series-types.d.ts +14 -0
- package/system/dist/builtins/native-metrics/native-metrics-provider.d.ts +49 -0
- package/system/dist/builtins/native-metrics/native-metrics.addon.d.ts +233 -0
- package/system/dist/builtins/native-metrics/native-metrics.addon.js +3116 -0
- package/system/dist/builtins/native-metrics/native-metrics.addon.mjs +3106 -0
- package/system/dist/builtins/native-metrics/node-load-ring.d.ts +212 -0
- package/system/dist/builtins/native-metrics/node-metrics-history-recorder.d.ts +155 -0
- package/system/dist/builtins/native-metrics/proc-process-table.d.ts +25 -0
- package/system/dist/builtins/native-metrics/process-classification.d.ts +110 -0
- package/system/dist/builtins/native-metrics/thread-cpu-sampler.d.ts +116 -0
- package/system/dist/builtins/platform-probe/accelerator-facts-probe.d.ts +24 -0
- package/system/dist/builtins/platform-probe/accelerator-reprobe.d.ts +23 -0
- package/system/dist/builtins/platform-probe/amd-accelerators.d.ts +15 -0
- package/system/dist/builtins/platform-probe/amd-npu.d.ts +35 -0
- package/system/dist/builtins/platform-probe/coral-accelerators.d.ts +87 -0
- package/system/dist/builtins/platform-probe/index.d.ts +57 -0
- package/system/dist/builtins/platform-probe/index.js +1151 -0
- package/system/dist/builtins/platform-probe/index.mjs +1140 -0
- package/system/dist/builtins/platform-probe/inference-config-resolver.d.ts +29 -0
- package/system/dist/builtins/platform-probe/intel-accelerators.d.ts +14 -0
- package/system/dist/builtins/platform-probe/intel-npu.d.ts +38 -0
- package/system/dist/builtins/platform-probe/platform-scorer.d.ts +66 -0
- package/system/dist/builtins/platform-probe/runtime-packages.d.ts +6 -0
- package/system/dist/builtins/platform-probe/windows-hardware.d.ts +77 -0
- package/system/dist/builtins/record-entries/entries-service.d.ts +42 -0
- package/system/dist/builtins/record-entries/index.d.ts +1 -0
- package/system/dist/builtins/record-entries/index.js +162 -0
- package/system/dist/builtins/record-entries/index.mjs +156 -0
- package/system/dist/builtins/record-entries/record-entries.addon.d.ts +13 -0
- package/system/dist/builtins/records-isolated.d.ts +10 -0
- package/system/dist/builtins/remote-access-orchestrator/enabled-providers-reconcile.d.ts +96 -0
- package/system/dist/builtins/remote-access-orchestrator/index.d.ts +1 -0
- package/system/dist/builtins/remote-access-orchestrator/index.js +8 -0
- package/system/dist/builtins/remote-access-orchestrator/index.mjs +2 -0
- package/system/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.d.ts +71 -0
- package/system/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.js +214 -0
- package/system/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.mjs +208 -0
- package/system/dist/builtins/shared/device-state-changed.d.ts +16 -0
- package/system/dist/builtins/shared/settle-sources.d.ts +22 -0
- package/system/dist/builtins/snapshot/index.d.ts +2 -0
- package/system/dist/builtins/snapshot/index.js +2720 -0
- package/system/dist/builtins/snapshot/index.mjs +2713 -0
- package/system/dist/builtins/snapshot/snapshot-cache.d.ts +108 -0
- package/system/dist/builtins/snapshot/snapshot-coalescing.d.ts +135 -0
- package/system/dist/builtins/snapshot/snapshot-courtesy.d.ts +68 -0
- package/system/dist/builtins/snapshot/snapshot-durable-store.d.ts +36 -0
- package/system/dist/builtins/snapshot/snapshot-fatigue.d.ts +41 -0
- package/system/dist/builtins/snapshot/snapshot-grab-pick.d.ts +20 -0
- package/system/dist/builtins/snapshot/snapshot-link-url.d.ts +66 -0
- package/system/dist/builtins/snapshot/snapshot-media-handler.d.ts +121 -0
- package/system/dist/builtins/snapshot/snapshot-resize.d.ts +75 -0
- package/system/dist/builtins/snapshot/snapshot.addon.d.ts +581 -0
- package/system/dist/builtins/sqlite-storage/analyze-stats.d.ts +83 -0
- package/system/dist/builtins/sqlite-storage/config-store.d.ts +8 -0
- package/system/dist/builtins/sqlite-storage/database-snapshot-provider.d.ts +18 -0
- package/system/dist/builtins/sqlite-storage/device-store.d.ts +23 -0
- package/system/dist/builtins/sqlite-storage/file-host-client.d.ts +75 -0
- package/system/dist/builtins/sqlite-storage/file-host-handlers.d.ts +27 -0
- package/system/dist/builtins/sqlite-storage/file-host-protocol.d.ts +167 -0
- package/system/dist/builtins/sqlite-storage/file-host-worker.d.ts +1 -0
- package/system/dist/builtins/sqlite-storage/filesystem-browse-provider.d.ts +25 -0
- package/system/dist/builtins/sqlite-storage/filesystem-storage-provider.d.ts +83 -0
- package/system/dist/builtins/sqlite-storage/filesystem-storage.addon.d.ts +33 -0
- package/system/dist/builtins/sqlite-storage/filesystem-storage.addon.js +419 -0
- package/system/dist/builtins/sqlite-storage/filesystem-storage.addon.mjs +411 -0
- package/system/dist/builtins/sqlite-storage/filter-compiler.d.ts +126 -0
- package/system/dist/builtins/sqlite-storage/index.d.ts +12 -0
- package/system/dist/builtins/sqlite-storage/index.js +82 -0
- package/system/dist/builtins/sqlite-storage/index.mjs +50 -0
- package/system/dist/builtins/sqlite-storage/integration-record-kinds.d.ts +31 -0
- package/system/dist/builtins/sqlite-storage/integration-registry.d.ts +34 -0
- package/system/dist/builtins/sqlite-storage/migrations/migration-actions.d.ts +12 -0
- package/system/dist/builtins/sqlite-storage/migrations/migration-edits.d.ts +35 -0
- package/system/dist/builtins/sqlite-storage/migrations/migration-engine.d.ts +125 -0
- package/system/dist/builtins/sqlite-storage/migrations/migration-hold.d.ts +23 -0
- package/system/dist/builtins/sqlite-storage/migrations/migration-pass.d.ts +48 -0
- package/system/dist/builtins/sqlite-storage/migrations/migration-restore-marker.d.ts +3 -0
- package/system/dist/builtins/sqlite-storage/migrations/migration-types.d.ts +151 -0
- package/system/dist/builtins/sqlite-storage/migrations/migrations-provider.d.ts +61 -0
- package/system/dist/builtins/sqlite-storage/owned-sqlite-file.d.ts +173 -0
- package/system/dist/builtins/sqlite-storage/path-guard.d.ts +11 -0
- package/system/dist/builtins/sqlite-storage/placement-errors.d.ts +60 -0
- package/system/dist/builtins/sqlite-storage/placement-router.d.ts +85 -0
- package/system/dist/builtins/sqlite-storage/prefix-range.d.ts +50 -0
- package/system/dist/builtins/sqlite-storage/query-bounds.d.ts +110 -0
- package/system/dist/builtins/sqlite-storage/query-profiler.d.ts +242 -0
- package/system/dist/builtins/sqlite-storage/records/records-catalog.d.ts +27 -0
- package/system/dist/builtins/sqlite-storage/records/records-engine-types.d.ts +48 -0
- package/system/dist/builtins/sqlite-storage/records/records-engine.d.ts +115 -0
- package/system/dist/builtins/sqlite-storage/records/records-explain.d.ts +18 -0
- package/system/dist/builtins/sqlite-storage/records/records-plan.d.ts +95 -0
- package/system/dist/builtins/sqlite-storage/records/records-probe.d.ts +33 -0
- package/system/dist/builtins/sqlite-storage/records/records-provider.d.ts +72 -0
- package/system/dist/builtins/sqlite-storage/records/records-rows.d.ts +46 -0
- package/system/dist/builtins/sqlite-storage/records/records-sql.d.ts +39 -0
- package/system/dist/builtins/sqlite-storage/retired-settings-keys.d.ts +276 -0
- package/system/dist/builtins/sqlite-storage/shm-lock-canary.d.ts +60 -0
- package/system/dist/builtins/sqlite-storage/sqlite-pragmas.d.ts +191 -0
- package/system/dist/builtins/sqlite-storage/sqlite-settings-backend.d.ts +583 -0
- package/system/dist/builtins/sqlite-storage/sqlite-settings.addon.d.ts +52 -0
- package/system/dist/builtins/sqlite-storage/sqlite-settings.addon.js +2960 -0
- package/system/dist/builtins/sqlite-storage/sqlite-settings.addon.mjs +2952 -0
- package/system/dist/builtins/sqlite-storage/sqlite-snapshot-protocol.d.ts +54 -0
- package/system/dist/builtins/sqlite-storage/sqlite-snapshot-worker.d.ts +33 -0
- package/system/dist/builtins/sqlite-storage/sqlite-snapshotter.d.ts +118 -0
- package/system/dist/builtins/sqlite-storage/stale-data/stale-data-audit.d.ts +81 -0
- package/system/dist/builtins/sqlite-storage/stale-data/stale-data-ports.d.ts +17 -0
- package/system/dist/builtins/sqlite-storage/statement-shape.d.ts +64 -0
- package/system/dist/builtins/sqlite-storage/storage-admin-provider.d.ts +33 -0
- package/system/dist/builtins/sqlite-storage/table-sizes.d.ts +95 -0
- package/system/dist/builtins/sqlite-storage/vector-index-shared.d.ts +81 -0
- package/system/dist/builtins/sqlite-storage/vector-index-vec.d.ts +143 -0
- package/system/dist/builtins/sqlite-storage/vector-provider.d.ts +30 -0
- package/system/dist/builtins/sqlite-storage/wal-checkpoint-policy.d.ts +196 -0
- package/system/dist/builtins/sqlite-storage/wal-checkpoint-worker.d.ts +1 -0
- package/system/dist/builtins/sqlite-storage/wal-checkpointer.d.ts +76 -0
- package/system/dist/builtins/sqlite-storage/wal-maintenance.d.ts +130 -0
- package/system/dist/builtins/storage-orchestrator/access-guards.d.ts +43 -0
- package/system/dist/builtins/storage-orchestrator/data-store-dispatch.d.ts +39 -0
- package/system/dist/builtins/storage-orchestrator/drain-ratchet.d.ts +104 -0
- package/system/dist/builtins/storage-orchestrator/drain-state-store.d.ts +26 -0
- package/system/dist/builtins/storage-orchestrator/hub-settings-forward.d.ts +128 -0
- package/system/dist/builtins/storage-orchestrator/index.d.ts +7 -0
- package/system/dist/builtins/storage-orchestrator/index.js +11 -0
- package/system/dist/builtins/storage-orchestrator/index.mjs +2 -0
- package/system/dist/builtins/storage-orchestrator/location-class-paths.d.ts +13 -0
- package/system/dist/builtins/storage-orchestrator/location-history-recorder.d.ts +76 -0
- package/system/dist/builtins/storage-orchestrator/location-occupancy-slice.d.ts +71 -0
- package/system/dist/builtins/storage-orchestrator/location-occupancy.d.ts +19 -0
- package/system/dist/builtins/storage-orchestrator/location-protection.d.ts +20 -0
- package/system/dist/builtins/storage-orchestrator/location-repoint-move.d.ts +57 -0
- package/system/dist/builtins/storage-orchestrator/location-repointer.d.ts +97 -0
- package/system/dist/builtins/storage-orchestrator/location-root-collision.d.ts +80 -0
- package/system/dist/builtins/storage-orchestrator/location-secrets.d.ts +114 -0
- package/system/dist/builtins/storage-orchestrator/location-store.d.ts +82 -0
- package/system/dist/builtins/storage-orchestrator/location-volume-capacity.d.ts +58 -0
- package/system/dist/builtins/storage-orchestrator/provider-discovery.d.ts +24 -0
- package/system/dist/builtins/storage-orchestrator/record-kinds.d.ts +43 -0
- package/system/dist/builtins/storage-orchestrator/storage-cleanup-coordinator.d.ts +68 -0
- package/system/dist/builtins/storage-orchestrator/storage-location-band-monitor.d.ts +77 -0
- package/system/dist/builtins/storage-orchestrator/storage-migration-coordinator.d.ts +241 -0
- package/system/dist/builtins/storage-orchestrator/storage-orchestrator.addon.d.ts +318 -0
- package/system/dist/builtins/storage-orchestrator/storage-orchestrator.addon.js +5280 -0
- package/system/dist/builtins/storage-orchestrator/storage-orchestrator.addon.mjs +5264 -0
- package/system/dist/builtins/storage-orchestrator/storage-orchestrator.service.d.ts +475 -0
- package/system/dist/builtins/storage-orchestrator/storage-pressure-manager.d.ts +115 -0
- package/system/dist/builtins/system-backup/backup-encryption.d.ts +94 -0
- package/system/dist/builtins/system-backup/system-backup.service.d.ts +308 -0
- package/system/dist/builtins/system-config/index.d.ts +2 -0
- package/system/dist/builtins/system-config/index.js +10 -0
- package/system/dist/builtins/system-config/index.mjs +2 -0
- package/system/dist/builtins/system-config/mesh-actions.d.ts +3 -0
- package/system/dist/builtins/system-config/record-kinds.d.ts +32 -0
- package/system/dist/builtins/system-config/system-config.addon.d.ts +56 -0
- package/system/dist/builtins/system-config/system-config.addon.js +89334 -0
- package/system/dist/builtins/system-config/system-config.addon.mjs +89233 -0
- package/system/dist/builtins/winston-logging/index.d.ts +3 -0
- package/system/dist/builtins/winston-logging/index.js +324 -0
- package/system/dist/builtins/winston-logging/index.mjs +313 -0
- package/system/dist/builtins/winston-logging/log-file-cursor.d.ts +12 -0
- package/system/dist/builtins/winston-logging/log-file-index-store.d.ts +11 -0
- package/system/dist/builtins/winston-logging/log-file-index.d.ts +77 -0
- package/system/dist/builtins/winston-logging/log-file-read-client.d.ts +44 -0
- package/system/dist/builtins/winston-logging/log-file-read-protocol.d.ts +41 -0
- package/system/dist/builtins/winston-logging/log-file-read-worker.d.ts +1 -0
- package/system/dist/builtins/winston-logging/log-file-reader.d.ts +51 -0
- package/system/dist/builtins/winston-logging/winston-destination.d.ts +39 -0
- package/system/dist/builtins/winston-logging/winston-logging.addon.d.ts +20 -0
- package/system/dist/chunk-CNf5ZN-e.mjs +37 -0
- package/system/dist/chunk-Cek0wNdY.js +64 -0
- package/system/dist/composition-sources-C14epb_m.js +155 -0
- package/system/dist/composition-sources-EXNuxmGQ.mjs +132 -0
- package/system/dist/constants-DIGWBiNC.mjs +20 -0
- package/system/dist/constants-M7NtSiRo.js +66 -0
- package/system/dist/coral-accelerators-BSVsBVzt.js +250 -0
- package/system/dist/coral-accelerators-DBlgWB8k.mjs +231 -0
- package/system/dist/custom-action-registry-JuMHGKEc.js +1638 -0
- package/system/dist/custom-action-registry-oHl1xltx.mjs +1482 -0
- package/system/dist/device-ca-3vmBP1i0.js +474 -0
- package/system/dist/device-ca-DZlvNBWU.mjs +367 -0
- package/system/dist/dist-DcMqHB_N.mjs +108095 -0
- package/system/dist/dist-M9yHiIY7.js +110554 -0
- package/system/dist/download/hosted-model-revisions.d.ts +10 -0
- package/system/dist/download/model-download-service.d.ts +35 -0
- package/system/dist/download/model-downloader.d.ts +156 -0
- package/system/dist/events/event-bus.d.ts +10 -0
- package/system/dist/events/system-event-bus.d.ts +14 -0
- package/system/dist/feature/feature-manager.d.ts +11 -0
- package/system/dist/file-host-worker.js +160 -0
- package/system/dist/file-host-worker.mjs +160 -0
- package/system/dist/formatter-DkYZ4LXp.mjs +162 -0
- package/system/dist/formatter-xbxeV4GD.js +167 -0
- package/system/dist/framework-resolver-hook.mjs +49 -0
- package/system/dist/http/asset-compression.d.ts +55 -0
- package/system/dist/http/authenticated-file-server.d.ts +53 -0
- package/system/dist/http/data-plane-registry.d.ts +58 -0
- package/system/dist/http/file-data-plane.d.ts +18 -0
- package/system/dist/http/lan-http-bind.d.ts +41 -0
- package/system/dist/http/reverse-proxy.d.ts +42 -0
- package/system/dist/hub-mdns-ciao-CpCKuQnK.js +1163 -0
- package/system/dist/hub-mdns-ciao-Czz2ssit.mjs +942 -0
- package/system/dist/i18n/catalog-registry.d.ts +35 -0
- package/system/dist/i18n/index.d.ts +2 -0
- package/system/dist/index.d.ts +156 -0
- package/system/dist/index.js +28736 -0
- package/system/dist/index.mjs +28065 -0
- package/system/dist/intel-accelerators-BvBjZn4j.js +16 -0
- package/system/dist/intel-accelerators-idEumqk1.mjs +15 -0
- package/system/dist/intel-npu-C8HKvRQF.mjs +27 -0
- package/system/dist/intel-npu-DYF5hO5K.js +28 -0
- package/system/dist/kernel/addon-class-resolver.d.ts +4 -0
- package/system/dist/kernel/addon-engine-manager.d.ts +22 -0
- package/system/dist/kernel/addon-health-monitor.d.ts +163 -0
- package/system/dist/kernel/addon-installer.d.ts +651 -0
- package/system/dist/kernel/addon-loader.d.ts +144 -0
- package/system/dist/kernel/addon-manifest.d.ts +128 -0
- package/system/dist/kernel/addon-refused-error.d.ts +30 -0
- package/system/dist/kernel/addon-residue.d.ts +45 -0
- package/system/dist/kernel/addon-settings-store.d.ts +43 -0
- package/system/dist/kernel/addon-version-policy.d.ts +34 -0
- package/system/dist/kernel/anon-rss.d.ts +12 -0
- package/system/dist/kernel/array-buffer-census.d.ts +118 -0
- package/system/dist/kernel/bootstrap-config.d.ts +7 -0
- package/system/dist/kernel/cap-router-builder.d.ts +180 -0
- package/system/dist/kernel/capability-handle.d.ts +46 -0
- package/system/dist/kernel/capability-registry.d.ts +621 -0
- package/system/dist/kernel/config-manager.d.ts +174 -0
- package/system/dist/kernel/config-schema.d.ts +37 -0
- package/system/dist/kernel/custom-action-registry.d.ts +32 -0
- package/system/dist/kernel/deps/addon-deps-manager.d.ts +28 -0
- package/system/dist/kernel/deps/closure-dedupe.d.ts +105 -0
- package/system/dist/kernel/deps/ensure-addon-natives.d.ts +41 -0
- package/system/dist/kernel/deps/ensure-native-prebuilds.d.ts +40 -0
- package/system/dist/kernel/deps/manifest-native-deps.d.ts +42 -0
- package/system/dist/kernel/deps/manifest-python-deps.d.ts +20 -0
- package/system/dist/kernel/deps/manifest-system-deps.d.ts +18 -0
- package/system/dist/kernel/deps/npm-command.d.ts +60 -0
- package/system/dist/kernel/deps/system-package-allowlist.d.ts +12 -0
- package/system/dist/kernel/deps/system-package-broker.d.ts +31 -0
- package/system/dist/kernel/deps/system-package-client.d.ts +9 -0
- package/system/dist/kernel/device-call-redirect.d.ts +18 -0
- package/system/dist/kernel/device-registry.d.ts +29 -0
- package/system/dist/kernel/device-settings-store.d.ts +74 -0
- package/system/dist/kernel/event-loop-stall-monitor.d.ts +41 -0
- package/system/dist/kernel/event-plane-report.d.ts +225 -0
- package/system/dist/kernel/fs-utils.d.ts +88 -0
- package/system/dist/kernel/gc-census.d.ts +161 -0
- package/system/dist/kernel/heap-spaces.d.ts +112 -0
- package/system/dist/kernel/heap-watch.d.ts +816 -0
- package/system/dist/kernel/host-externals.d.ts +12 -0
- package/system/dist/kernel/hwaccel/hwaccel-resolver.d.ts +56 -0
- package/system/dist/kernel/hwaccel/vaapi-init-probe.d.ts +29 -0
- package/system/dist/kernel/index.d.ts +116 -0
- package/system/dist/kernel/inference/inference-resolver.d.ts +22 -0
- package/system/dist/kernel/inference/local-python-runtimes.d.ts +2 -0
- package/system/dist/kernel/infra-capabilities.d.ts +13 -0
- package/system/dist/kernel/isolated-builtin-phase.d.ts +57 -0
- package/system/dist/kernel/lifecycle/job-journal.d.ts +19 -0
- package/system/dist/kernel/lifecycle/lifecycle-job-engine.d.ts +106 -0
- package/system/dist/kernel/lifecycle/staging-area.d.ts +31 -0
- package/system/dist/kernel/moleculer/accessory-prune-gate.d.ts +55 -0
- package/system/dist/kernel/moleculer/addon-context-factory.d.ts +104 -0
- package/system/dist/kernel/moleculer/addon-data-plane-facility.d.ts +19 -0
- package/system/dist/kernel/moleculer/addon-deploy-source.d.ts +16 -0
- package/system/dist/kernel/moleculer/addon-peer-bytes-facility.d.ts +25 -0
- package/system/dist/kernel/moleculer/addon-runner.d.ts +1 -0
- package/system/dist/kernel/moleculer/addon-service-factory.d.ts +50 -0
- package/system/dist/kernel/moleculer/agent-event-scope.d.ts +49 -0
- package/system/dist/kernel/moleculer/agent-ui-unlock.d.ts +67 -0
- package/system/dist/kernel/moleculer/broker-factory.d.ts +95 -0
- package/system/dist/kernel/moleculer/broker-transport-swap.d.ts +60 -0
- package/system/dist/kernel/moleculer/cap-usage-registry.d.ts +126 -0
- package/system/dist/kernel/moleculer/capabilities-access.d.ts +21 -0
- package/system/dist/kernel/moleculer/child-addon-call-dispatch.d.ts +53 -0
- package/system/dist/kernel/moleculer/child-cap-descriptors.d.ts +34 -0
- package/system/dist/kernel/moleculer/child-cap-dispatch.d.ts +59 -0
- package/system/dist/kernel/moleculer/children-batch-loader.d.ts +98 -0
- package/system/dist/kernel/moleculer/core-cap-service.d.ts +65 -0
- package/system/dist/kernel/moleculer/crash-supervisor.d.ts +50 -0
- package/system/dist/kernel/moleculer/device-cap-proxy.d.ts +70 -0
- package/system/dist/kernel/moleculer/device-event-ring.d.ts +155 -0
- package/system/dist/kernel/moleculer/event-bus-core.d.ts +198 -0
- package/system/dist/kernel/moleculer/event-bus.d.ts +106 -0
- package/system/dist/kernel/moleculer/hub-log-forwarder.d.ts +36 -0
- package/system/dist/kernel/moleculer/hub-service.d.ts +39 -0
- package/system/dist/kernel/moleculer/init-watchdog.d.ts +60 -0
- package/system/dist/kernel/moleculer/mesh-access-middleware.d.ts +42 -0
- package/system/dist/kernel/moleculer/mesh-identity.d.ts +57 -0
- package/system/dist/kernel/moleculer/mesh-mtls/constants.d.ts +17 -0
- package/system/dist/kernel/moleculer/mesh-mtls/index.d.ts +12 -0
- package/system/dist/kernel/moleculer/mesh-mtls/mesh-ca-keeper.d.ts +60 -0
- package/system/dist/kernel/moleculer/mesh-mtls/mesh-ca.d.ts +49 -0
- package/system/dist/kernel/moleculer/mesh-mtls/mesh-certificate-registry.d.ts +105 -0
- package/system/dist/kernel/moleculer/mesh-mtls/mesh-crl.d.ts +16 -0
- package/system/dist/kernel/moleculer/mesh-mtls/mesh-membership.d.ts +64 -0
- package/system/dist/kernel/moleculer/mesh-mtls/mesh-peer-transport.d.ts +47 -0
- package/system/dist/kernel/moleculer/mesh-mtls/mesh-renewal.d.ts +135 -0
- package/system/dist/kernel/moleculer/mesh-mtls/mesh-tls-enabler.d.ts +9 -0
- package/system/dist/kernel/moleculer/mesh-mtls/mesh-tls-gate.d.ts +40 -0
- package/system/dist/kernel/moleculer/mesh-mtls/pairing/agent-pairing.d.ts +214 -0
- package/system/dist/kernel/moleculer/mesh-mtls/pairing/hub-pairing.d.ts +115 -0
- package/system/dist/kernel/moleculer/mesh-mtls/pairing/index.d.ts +3 -0
- package/system/dist/kernel/moleculer/mesh-mtls/pairing/pairing-protocol.d.ts +107 -0
- package/system/dist/kernel/moleculer/mesh-mtls/tls-tcp-transporter.d.ts +242 -0
- package/system/dist/kernel/moleculer/mesh-queue-report.d.ts +51 -0
- package/system/dist/kernel/moleculer/node-registry.d.ts +146 -0
- package/system/dist/kernel/moleculer/process-context.d.ts +4 -0
- package/system/dist/kernel/moleculer/process-service.d.ts +92 -0
- package/system/dist/kernel/moleculer/provider-registry.d.ts +28 -0
- package/system/dist/kernel/moleculer/readiness-context.d.ts +67 -0
- package/system/dist/kernel/moleculer/readiness-service.d.ts +37 -0
- package/system/dist/kernel/moleculer/records-api-transport.d.ts +9 -0
- package/system/dist/kernel/moleculer/register-framework-resolver.d.ts +8 -0
- package/system/dist/kernel/moleculer/register-node-client.d.ts +49 -0
- package/system/dist/kernel/moleculer/remote-logger.d.ts +43 -0
- package/system/dist/kernel/moleculer/resilient-cap-call.d.ts +28 -0
- package/system/dist/kernel/moleculer/runner-addon-settings.d.ts +29 -0
- package/system/dist/kernel/moleculer/runner-device-settings.d.ts +39 -0
- package/system/dist/kernel/moleculer/runner-heap-flags.d.ts +228 -0
- package/system/dist/kernel/moleculer/runner-native-allocator.d.ts +107 -0
- package/system/dist/kernel/moleculer/runner-process-group.d.ts +96 -0
- package/system/dist/kernel/moleculer/runner-refusal.d.ts +27 -0
- package/system/dist/kernel/moleculer/runtime-state-load.d.ts +29 -0
- package/system/dist/kernel/moleculer/settings-read-guard.d.ts +49 -0
- package/system/dist/kernel/moleculer/stream-probe-service.d.ts +28 -0
- package/system/dist/kernel/moleculer/trpc-links.d.ts +244 -0
- package/system/dist/kernel/moleculer/typed-array-serde.d.ts +14 -0
- package/system/dist/kernel/moleculer/worker-device-restore.d.ts +10 -0
- package/system/dist/kernel/outbound-queue-watch.d.ts +94 -0
- package/system/dist/kernel/prefix-walk.d.ts +39 -0
- package/system/dist/kernel/process-cpu-census.d.ts +74 -0
- package/system/dist/kernel/provider-kind-drift.d.ts +21 -0
- package/system/dist/kernel/restart-coordinator.d.ts +90 -0
- package/system/dist/kernel/sections-store.d.ts +20 -0
- package/system/dist/kernel/settings-door-view.d.ts +41 -0
- package/system/dist/kernel/settings-read-error.d.ts +35 -0
- package/system/dist/kernel/settings-view-types.d.ts +80 -0
- package/system/dist/kernel/socket-plane-report.d.ts +268 -0
- package/system/dist/kernel/status-overlay.d.ts +38 -0
- package/system/dist/kernel/storage-location-registry.d.ts +55 -0
- package/system/dist/kernel/store-settings-view.d.ts +14 -0
- package/system/dist/kernel/system-settings-mirror.d.ts +46 -0
- package/system/dist/kernel/system-settings-policy.d.ts +28 -0
- package/system/dist/kernel/transport/cap-action-census.d.ts +218 -0
- package/system/dist/kernel/transport/cap-action-name.d.ts +100 -0
- package/system/dist/kernel/transport/cap-child-index.d.ts +49 -0
- package/system/dist/kernel/transport/cap-route-resolver.d.ts +231 -0
- package/system/dist/kernel/transport/cap-route.d.ts +168 -0
- package/system/dist/kernel/transport/cap-routing-hints.d.ts +42 -0
- package/system/dist/kernel/transport/child-cap-protocol.d.ts +307 -0
- package/system/dist/kernel/transport/claimed-get-status.d.ts +39 -0
- package/system/dist/kernel/transport/create-local-transport.d.ts +7 -0
- package/system/dist/kernel/transport/device-call-redirect.d.ts +39 -0
- package/system/dist/kernel/transport/frame-codec.d.ts +122 -0
- package/system/dist/kernel/transport/hub-cap-forward.d.ts +96 -0
- package/system/dist/kernel/transport/index.d.ts +38 -0
- package/system/dist/kernel/transport/local-child-client.d.ts +199 -0
- package/system/dist/kernel/transport/local-child-registry.d.ts +654 -0
- package/system/dist/kernel/transport/local-endpoint-path.d.ts +6 -0
- package/system/dist/kernel/transport/local-transport.d.ts +122 -0
- package/system/dist/kernel/transport/parent-unowned-call.d.ts +283 -0
- package/system/dist/kernel/transport/peer-answered-error.d.ts +21 -0
- package/system/dist/kernel/transport/socket-channel.d.ts +116 -0
- package/system/dist/kernel/transport/socket-traffic.d.ts +118 -0
- package/system/dist/kernel/transport/uds-event-bridge.d.ts +85 -0
- package/system/dist/kernel/transport/uds-event-bus.d.ts +93 -0
- package/system/dist/kernel/transport/uds-local-transport.d.ts +18 -0
- package/system/dist/kernel/transport/uds-log-ingest.d.ts +43 -0
- package/system/dist/kernel/transport/uds-logger.d.ts +44 -0
- package/system/dist/kernel/utils/ring-buffer.d.ts +15 -0
- package/system/dist/kernel/workspace-detect.d.ts +9 -0
- package/system/dist/lib-5THG9eKz.mjs +15545 -0
- package/system/dist/lib-C3U1yluo.js +7110 -0
- package/system/dist/lib-CZ3g2WTS.js +15549 -0
- package/system/dist/lib-DFZblCIu.mjs +7106 -0
- package/system/dist/lifecycle/lifecycle-state-machine.d.ts +28 -0
- package/system/dist/log-file-read-protocol-B7M3X3bT.mjs +785 -0
- package/system/dist/log-file-read-protocol-D0WcLbIV.js +817 -0
- package/system/dist/log-file-read-worker.js +64 -0
- package/system/dist/log-file-read-worker.mjs +64 -0
- package/system/dist/log-read-filter-Bi066jwU.js +134 -0
- package/system/dist/log-read-filter-D7Ev3zm-.mjs +93 -0
- package/system/dist/logging/formatter.d.ts +57 -0
- package/system/dist/logging/log-manager.d.ts +145 -0
- package/system/dist/logging/log-read-filter.d.ts +43 -0
- package/system/dist/logging/log-redactor.d.ts +30 -0
- package/system/dist/logging/log-ring-buffer.d.ts +62 -0
- package/system/dist/logging/logging-gate.d.ts +76 -0
- package/system/dist/logging/logging-gate.singleton.d.ts +16 -0
- package/system/dist/logging/partitioned-log-buffer.d.ts +169 -0
- package/system/dist/logging/scoped-logger.d.ts +17 -0
- package/system/dist/migrations/hub/index.d.ts +11 -0
- package/system/dist/ms-CgH2OFlD.mjs +120 -0
- package/system/dist/ms-LB3giGoU.js +124 -0
- package/system/dist/network/network-quality.d.ts +11 -0
- package/system/dist/notification/notification-service.d.ts +43 -0
- package/system/dist/notification/toast-service.d.ts +22 -0
- package/system/dist/pipeline/engine-manager-resolver.d.ts +15 -0
- package/system/dist/pipeline/pipeline-runner.d.ts +8 -0
- package/system/dist/pipeline/pipeline-validator.d.ts +13 -0
- package/system/dist/platform-key-source-BWlq0jjn.mjs +23 -0
- package/system/dist/platform-key-source-Di7HrlGR.js +40 -0
- package/system/dist/prefix-range-D_KueXbQ.js +27 -0
- package/system/dist/prefix-range-Dl0znowN.mjs +22 -0
- package/system/dist/prefix-walk-DAOBSyH1.mjs +88 -0
- package/system/dist/prefix-walk-Dv6MLZlM.js +99 -0
- package/system/dist/process/proc-stat.d.ts +75 -0
- package/system/dist/process/resource-monitor.d.ts +28 -0
- package/system/dist/python/python-env-manager.d.ts +12 -0
- package/system/dist/read-all-rows-CVoO1ONM.js +29 -0
- package/system/dist/read-all-rows-TaPqdWNF.mjs +25 -0
- package/system/dist/records/read-all-rows.d.ts +6 -0
- package/system/dist/repl/interfaces.d.ts +31 -0
- package/system/dist/repl/repl-engine.d.ts +8 -0
- package/system/dist/resource-monitor-Di9daRwI.mjs +96 -0
- package/system/dist/resource-monitor-mio9dSCT.js +113 -0
- package/system/dist/restore-archive-Cy7jGqiD.js +4325 -0
- package/system/dist/restore-archive-DS4nvQ43.mjs +4213 -0
- package/system/dist/retention-Dqm_EiVq.mjs +893 -0
- package/system/dist/retention-Ufa2fci-.js +1024 -0
- package/system/dist/retired-settings-keys-C8nOOr5H.js +381 -0
- package/system/dist/retired-settings-keys-u6xQA6r7.mjs +364 -0
- package/system/dist/safe-buffer-B1OjL1I9.mjs +42 -0
- package/system/dist/safe-buffer-D3aoa-7X.js +46 -0
- package/system/dist/settle-sources-Bhsy57y-.js +38 -0
- package/system/dist/settle-sources-CDtNC8ub.mjs +33 -0
- package/system/dist/snapshot-courtesy-CyFs1M3I.mjs +167 -0
- package/system/dist/snapshot-courtesy-D_C5-nC0.js +192 -0
- package/system/dist/sqlite-snapshot-protocol-2QaTouWV.mjs +34 -0
- package/system/dist/sqlite-snapshot-protocol-B9OndqZv.js +51 -0
- package/system/dist/sqlite-snapshot-worker.js +185 -0
- package/system/dist/sqlite-snapshot-worker.mjs +179 -0
- package/system/dist/src-CnAqG6EF.js +714 -0
- package/system/dist/src-hG4grMU4.mjs +709 -0
- package/system/dist/storage/fs-storage-backend.d.ts +40 -0
- package/system/dist/storage/storage-location-manager.d.ts +23 -0
- package/system/dist/storage/storage-manager.d.ts +83 -0
- package/system/dist/tls/agent-https-names.d.ts +25 -0
- package/system/dist/tls/agent-https.d.ts +111 -0
- package/system/dist/tls/boot-tls.d.ts +35 -0
- package/system/dist/tls/cert-backdate.d.ts +10 -0
- package/system/dist/tls/cert-evaluation.d.ts +41 -0
- package/system/dist/tls/cert-identity.d.ts +60 -0
- package/system/dist/tls/cert-issue.d.ts +57 -0
- package/system/dist/tls/cert-manager.d.ts +124 -0
- package/system/dist/tls/cert-name-constraints.d.ts +53 -0
- package/system/dist/tls/cert-utc-time.d.ts +1 -0
- package/system/dist/tls/https-listener.d.ts +30 -0
- package/system/dist/tls/index.d.ts +12 -0
- package/system/dist/tls/tls-actions.d.ts +49 -0
- package/system/dist/tls/tls-status.d.ts +57 -0
- package/system/dist/tls/uploaded-cert.d.ts +46 -0
- package/system/dist/wal-checkpoint-policy-BahrTtyD.mjs +186 -0
- package/system/dist/wal-checkpoint-policy-d2z2qPqx.js +233 -0
- package/system/dist/wal-checkpoint-worker.js +144 -0
- package/system/dist/wal-checkpoint-worker.mjs +143 -0
- package/system/dist/wal-maintenance-BmugbgS7.js +0 -0
- package/system/dist/wal-maintenance-Bnb2QzYG.mjs +0 -0
- package/system/dist/x509.es-BRiJgOvu.mjs +11939 -0
- package/system/dist/x509.es-WtnRNyYS.js +12076 -0
- package/system/package.json +516 -0
|
@@ -0,0 +1,2466 @@
|
|
|
1
|
+
import { Di as resolveAppConnections, Fi as resolveNotificationTapAddress, Ir as localNetworkCapability, Ji as shortHostname, Ms as EventCategory, Qa as BaseAddon, _ as CAMSTACK_APP_LINK_ORIGIN, at as HUB_MDNS_TXT_KEYS, br as isAppLinkBase, bt as NetworkTunnelStartedDataSchema, da as validateCustomAddress, di as pickAppLinkHub, it as HUB_MDNS_SERVICE_TYPE, ji as resolveHubAddressRoles, js as errMsg, wr as isDefaultAppConnectionEndpoint, yn as checkRoleAddress } from "../../dist-DcMqHB_N.mjs";
|
|
2
|
+
import { E as ensureTlsCert, I as readLanHttpState, N as applyLanHttp, _ as readTlsMode, a as storeUploadedCertificate, b as writeTlsEnabled, d as servedHttpsLeafFingerprint, h as readTlsAccessStatus, i as revertToGeneratedCertificate, j as DEFAULT_LAN_HTTP_PORT, m as readExtraSans, n as applyCertificateToListener, o as useStoredUploadedCertificate, r as regenerateCertificate, t as createCiaoPublisher, y as writeExtraSans } from "../../hub-mdns-ciao-Czz2ssit.mjs";
|
|
3
|
+
import { z } from "zod";
|
|
4
|
+
import { isIP } from "node:net";
|
|
5
|
+
import * as os$1 from "node:os";
|
|
6
|
+
import { readFileSync } from "node:fs";
|
|
7
|
+
import * as http from "node:http";
|
|
8
|
+
import { createSocket } from "node:dgram";
|
|
9
|
+
import * as https from "node:https";
|
|
10
|
+
//#region src/builtins/local-network/address-book.ts
|
|
11
|
+
/**
|
|
12
|
+
* The Network page's address book, as pure functions: custom addresses plus
|
|
13
|
+
* the role flags carried by detected and custom addresses alike.
|
|
14
|
+
*
|
|
15
|
+
* ## Storage (D734)
|
|
16
|
+
*
|
|
17
|
+
* One key per role: `appConnectionUrls` (`appConnections`, many),
|
|
18
|
+
* `notificationTapUrl` (`notificationTaps`), `publicEndpointUrl`
|
|
19
|
+
* (`publicEndpoint`) and `internalUrl` (`internal`). A single-valued role is
|
|
20
|
+
* one URL — at most one address carries it, by construction. `''` / `[]` is
|
|
21
|
+
* automatic. The custom addresses are `customAddresses` (url + label).
|
|
22
|
+
*
|
|
23
|
+
* The keys of the earlier role names (`viewerBaseUrls`, `notificationBaseUrl`,
|
|
24
|
+
* `signInBaseUrl`, `agentBaseUrl`) are not read: a value stored under one is
|
|
25
|
+
* ignored, and that role is automatic until the operator flags it again
|
|
26
|
+
* (D734 — one install, re-set by hand, no migration code).
|
|
27
|
+
*
|
|
28
|
+
* ## A flag on an address that is in no row
|
|
29
|
+
*
|
|
30
|
+
* A flagged detected address can disappear (a DHCP move) while it still wins
|
|
31
|
+
* its role. {@link normalizeAddressBook} turns every single-valued flag that
|
|
32
|
+
* names neither a detected address, a custom one nor the app link into a
|
|
33
|
+
* custom address carrying that role, on every read; the next write persists
|
|
34
|
+
* the result — so the address shows as a custom row instead of vanishing.
|
|
35
|
+
*/
|
|
36
|
+
var CustomAddressListSchema = z.array(z.object({
|
|
37
|
+
baseUrl: z.string(),
|
|
38
|
+
label: z.string()
|
|
39
|
+
}));
|
|
40
|
+
/** The label a flag promoted to a custom address is given. */
|
|
41
|
+
var PROMOTED_LABEL = {
|
|
42
|
+
notificationTaps: "Notification taps address",
|
|
43
|
+
internal: "Internal address",
|
|
44
|
+
publicEndpoint: "Public endpoint"
|
|
45
|
+
};
|
|
46
|
+
var SINGLE_ROLES = [
|
|
47
|
+
"notificationTaps",
|
|
48
|
+
"internal",
|
|
49
|
+
"publicEndpoint"
|
|
50
|
+
];
|
|
51
|
+
function flagOf(value) {
|
|
52
|
+
return value === "" ? null : value;
|
|
53
|
+
}
|
|
54
|
+
/** Parse the stored custom list; a malformed store reads as empty, never throws. */
|
|
55
|
+
function parseCustomAddresses(raw) {
|
|
56
|
+
const parsed = CustomAddressListSchema.safeParse(raw ?? []);
|
|
57
|
+
return parsed.success ? parsed.data : [];
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* The address book as it stands: stored custom addresses, plus every
|
|
61
|
+
* single-valued flag that names neither a detected address, a custom one nor
|
|
62
|
+
* the app link, promoted to a custom address (see the module doc).
|
|
63
|
+
*/
|
|
64
|
+
function normalizeAddressBook(stored, detectedUrls) {
|
|
65
|
+
const flags = {
|
|
66
|
+
appConnections: stored.appConnectionUrls,
|
|
67
|
+
notificationTaps: flagOf(stored.notificationTapUrl),
|
|
68
|
+
internal: flagOf(stored.internalUrl),
|
|
69
|
+
publicEndpoint: flagOf(stored.publicEndpointUrl)
|
|
70
|
+
};
|
|
71
|
+
const custom = [...parseCustomAddresses(stored.customAddresses)];
|
|
72
|
+
for (const role of SINGLE_ROLES) {
|
|
73
|
+
const url = flags[role];
|
|
74
|
+
if (url === null || isAppLinkBase(url) || detectedUrls.has(url)) continue;
|
|
75
|
+
if (custom.some((c) => c.baseUrl === url)) continue;
|
|
76
|
+
custom.push({
|
|
77
|
+
baseUrl: url,
|
|
78
|
+
label: PROMOTED_LABEL[role]
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
return {
|
|
82
|
+
custom,
|
|
83
|
+
flags
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
/** The stored-settings patch that persists `state`. */
|
|
87
|
+
function addressBookPatch(state) {
|
|
88
|
+
return {
|
|
89
|
+
customAddresses: state.custom,
|
|
90
|
+
appConnectionUrls: state.flags.appConnections,
|
|
91
|
+
notificationTapUrl: state.flags.notificationTaps ?? "",
|
|
92
|
+
publicEndpointUrl: state.flags.publicEndpoint ?? "",
|
|
93
|
+
internalUrl: state.flags.internal ?? ""
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
function withCustomAddress(state, entry) {
|
|
97
|
+
const custom = state.custom.some((c) => c.baseUrl === entry.baseUrl) ? state.custom.map((c) => c.baseUrl === entry.baseUrl ? entry : c) : [...state.custom, entry];
|
|
98
|
+
return {
|
|
99
|
+
...state,
|
|
100
|
+
custom
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
/** Drop a custom address and every flag it carried (those roles turn automatic). */
|
|
104
|
+
function withoutCustomAddress(state, baseUrl) {
|
|
105
|
+
const clear = (flag) => flag === baseUrl ? null : flag;
|
|
106
|
+
return {
|
|
107
|
+
custom: state.custom.filter((c) => c.baseUrl !== baseUrl),
|
|
108
|
+
flags: {
|
|
109
|
+
appConnections: state.flags.appConnections.filter((u) => u !== baseUrl),
|
|
110
|
+
notificationTaps: clear(state.flags.notificationTaps),
|
|
111
|
+
internal: clear(state.flags.internal),
|
|
112
|
+
publicEndpoint: clear(state.flags.publicEndpoint)
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
/** Every role back to automatic for `role`. */
|
|
117
|
+
function withRoleAutomatic(state, role) {
|
|
118
|
+
return role === "appConnections" ? {
|
|
119
|
+
...state,
|
|
120
|
+
flags: {
|
|
121
|
+
...state.flags,
|
|
122
|
+
appConnections: []
|
|
123
|
+
}
|
|
124
|
+
} : {
|
|
125
|
+
...state,
|
|
126
|
+
flags: {
|
|
127
|
+
...state.flags,
|
|
128
|
+
[role]: null
|
|
129
|
+
}
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Flag or unflag `baseUrl` for `role`. A single-valued role flagged here moves
|
|
134
|
+
* off every other address (it is one URL); unflagging the address that carries
|
|
135
|
+
* it returns the role to automatic. The app link flagged for notification
|
|
136
|
+
* taps IS the automatic answer, stored as automatic — one representation.
|
|
137
|
+
* `appConnections` toggles inside the set; toggling while automatic starts
|
|
138
|
+
* from the automatic set (`autoApp`) so the other addresses keep racing.
|
|
139
|
+
*/
|
|
140
|
+
function withRoleFlag(state, role, baseUrl, enabled, autoApp) {
|
|
141
|
+
if (role === "appConnections") {
|
|
142
|
+
const without = (state.flags.appConnections.length === 0 ? autoApp : state.flags.appConnections).filter((u) => u !== baseUrl);
|
|
143
|
+
const appConnections = enabled ? [...without, baseUrl] : without;
|
|
144
|
+
return {
|
|
145
|
+
...state,
|
|
146
|
+
flags: {
|
|
147
|
+
...state.flags,
|
|
148
|
+
appConnections
|
|
149
|
+
}
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
if (role === "notificationTaps" && isAppLinkBase(baseUrl)) return withRoleAutomatic(state, role);
|
|
153
|
+
if (enabled) return {
|
|
154
|
+
...state,
|
|
155
|
+
flags: {
|
|
156
|
+
...state.flags,
|
|
157
|
+
[role]: baseUrl
|
|
158
|
+
}
|
|
159
|
+
};
|
|
160
|
+
return state.flags[role] === baseUrl ? withRoleAutomatic(state, role) : state;
|
|
161
|
+
}
|
|
162
|
+
/** What a row may be flagged with. */
|
|
163
|
+
function eligibleRoles(endpoint) {
|
|
164
|
+
if (endpoint.kind === "loopback") return [];
|
|
165
|
+
if (endpoint.kind === "app-link") return ["notificationTaps"];
|
|
166
|
+
return [
|
|
167
|
+
"appConnections",
|
|
168
|
+
"notificationTaps",
|
|
169
|
+
"internal",
|
|
170
|
+
"publicEndpoint"
|
|
171
|
+
];
|
|
172
|
+
}
|
|
173
|
+
/** A custom address as a palette entry (`kind: 'custom'`). */
|
|
174
|
+
function customEndpoint(entry) {
|
|
175
|
+
return {
|
|
176
|
+
label: entry.label === "" ? "Custom address" : entry.label,
|
|
177
|
+
baseUrl: entry.baseUrl,
|
|
178
|
+
kind: "custom",
|
|
179
|
+
interfaceKind: "other",
|
|
180
|
+
plausible: true,
|
|
181
|
+
plausibleReason: "",
|
|
182
|
+
priority: 200
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* The palette a client races: the detected endpoints plus the custom
|
|
187
|
+
* addresses flagged `appConnections` (a detected URL is never listed twice).
|
|
188
|
+
*/
|
|
189
|
+
function withAppConnectionCustomEndpoints(detected, state) {
|
|
190
|
+
const known = new Set(detected.map((e) => e.baseUrl));
|
|
191
|
+
const wanted = new Set(state.flags.appConnections);
|
|
192
|
+
const extra = state.custom.filter((c) => wanted.has(c.baseUrl) && !known.has(c.baseUrl)).map(customEndpoint);
|
|
193
|
+
return [...detected, ...extra];
|
|
194
|
+
}
|
|
195
|
+
/** Where a twin sorts relative to its plain-HTTP row: straight after it. */
|
|
196
|
+
var HTTPS_TWIN_PRIORITY_STEP = .5;
|
|
197
|
+
/**
|
|
198
|
+
* The HTTPS counterpart of every LAN address advertised over plain HTTP
|
|
199
|
+
* (D859): `http://<lan>:<httpPort>` gains `https://<lan>:<httpsPort>`, the hub's
|
|
200
|
+
* TLS listener, as its own row straight after it. The twin is an ordinary
|
|
201
|
+
* detected LAN row — ticked, unticked and flagged like any other, on by default
|
|
202
|
+
* (a LAN row is an automatic app connection). A phone that does not trust the
|
|
203
|
+
* hub's local CA fails that candidate in the race it already runs; one that
|
|
204
|
+
* does reaches it. Only the app-connection palette and the table carry twins:
|
|
205
|
+
* the palette `internal` and `publicEndpoint` resolve over never does, so those
|
|
206
|
+
* roles keep their answer. Rows already on https (LAN HTTP off), the public
|
|
207
|
+
* tunnel, the mesh, custom addresses and loopback have no twin.
|
|
208
|
+
*/
|
|
209
|
+
function withLanHttpsCounterparts(palette, httpsPort) {
|
|
210
|
+
const known = new Set(palette.map((e) => e.baseUrl));
|
|
211
|
+
const out = [];
|
|
212
|
+
for (const endpoint of palette) {
|
|
213
|
+
out.push(endpoint);
|
|
214
|
+
if (endpoint.kind !== "lan-ipv4" && endpoint.kind !== "lan-ipv6") continue;
|
|
215
|
+
const twin = httpsTwinOf(endpoint, httpsPort);
|
|
216
|
+
if (twin === null || known.has(twin.baseUrl)) continue;
|
|
217
|
+
known.add(twin.baseUrl);
|
|
218
|
+
out.push(twin);
|
|
219
|
+
}
|
|
220
|
+
return out;
|
|
221
|
+
}
|
|
222
|
+
function httpsTwinOf(endpoint, httpsPort) {
|
|
223
|
+
let parsed;
|
|
224
|
+
try {
|
|
225
|
+
parsed = new URL(endpoint.baseUrl);
|
|
226
|
+
} catch {
|
|
227
|
+
return null;
|
|
228
|
+
}
|
|
229
|
+
if (parsed.protocol !== "http:") return null;
|
|
230
|
+
return {
|
|
231
|
+
...endpoint,
|
|
232
|
+
label: `${endpoint.label} (HTTPS)`,
|
|
233
|
+
baseUrl: `https://${parsed.hostname}:${httpsPort}`,
|
|
234
|
+
priority: endpoint.priority + HTTPS_TWIN_PRIORITY_STEP
|
|
235
|
+
};
|
|
236
|
+
}
|
|
237
|
+
/** Every role's answer — the resolvers from `@camstack/types`, nothing else. */
|
|
238
|
+
function resolveRoles(state, appPalette, httpsPalette) {
|
|
239
|
+
return resolveHubAddressRoles(withAppConnectionCustomEndpoints(appPalette, state), httpsPalette, state.flags);
|
|
240
|
+
}
|
|
241
|
+
function flagsOn(state, baseUrl) {
|
|
242
|
+
const out = [];
|
|
243
|
+
if (state.flags.appConnections.includes(baseUrl)) out.push("appConnections");
|
|
244
|
+
for (const role of SINGLE_ROLES) if (state.flags[role] === baseUrl) out.push(role);
|
|
245
|
+
return out;
|
|
246
|
+
}
|
|
247
|
+
function inUseOn(roles, baseUrl) {
|
|
248
|
+
const out = [];
|
|
249
|
+
if (roles.appConnections.resolved.includes(baseUrl)) out.push("appConnections");
|
|
250
|
+
for (const role of SINGLE_ROLES) if (roles[role].resolved === baseUrl) out.push(role);
|
|
251
|
+
return out;
|
|
252
|
+
}
|
|
253
|
+
/** The Addresses table: app link, detected rows, then custom-only rows. */
|
|
254
|
+
function buildAddressBook(state, inputs) {
|
|
255
|
+
const roles = resolveRoles(state, inputs.rowsPalette, inputs.httpsPalette);
|
|
256
|
+
const customUrls = new Set(state.custom.map((c) => c.baseUrl));
|
|
257
|
+
const detectedUrls = new Set(inputs.rowsPalette.map((e) => e.baseUrl));
|
|
258
|
+
const row = (endpoint, detected) => ({
|
|
259
|
+
...endpoint,
|
|
260
|
+
detected,
|
|
261
|
+
custom: customUrls.has(endpoint.baseUrl),
|
|
262
|
+
flags: endpoint.kind === "app-link" ? [] : flagsOn(state, endpoint.baseUrl),
|
|
263
|
+
inUse: endpoint.kind === "app-link" ? roles.notificationTaps.resolved === "https://camstack.zentik.app" ? ["notificationTaps"] : [] : inUseOn(roles, endpoint.baseUrl),
|
|
264
|
+
eligible: eligibleRoles(endpoint)
|
|
265
|
+
});
|
|
266
|
+
return {
|
|
267
|
+
rows: [
|
|
268
|
+
row(inputs.appLink, false),
|
|
269
|
+
...inputs.rowsPalette.map((e) => row(e, true)),
|
|
270
|
+
...state.custom.filter((c) => !detectedUrls.has(c.baseUrl)).map((c) => row(customEndpoint(c), false))
|
|
271
|
+
],
|
|
272
|
+
roles,
|
|
273
|
+
appLinkHub: inputs.appLinkHub,
|
|
274
|
+
listenerOrigins: inputs.listenerOrigins
|
|
275
|
+
};
|
|
276
|
+
}
|
|
277
|
+
var ORIGIN_KINDS = new Set([
|
|
278
|
+
"lan-ipv4",
|
|
279
|
+
"lan-ipv6",
|
|
280
|
+
"public"
|
|
281
|
+
]);
|
|
282
|
+
/**
|
|
283
|
+
* Every origin a browser can really reach this hub at: the HTTPS listener's
|
|
284
|
+
* `https://<lan>:<httpsPort>` AND, while the LAN HTTP listener is on,
|
|
285
|
+
* `http://<lan>:<httpPort>`; plus the public and custom addresses. The rows
|
|
286
|
+
* show `http://` only while LAN HTTP is on (native clients skip the private
|
|
287
|
+
* certificate), so the https origin the admin UI is opened at is in no row —
|
|
288
|
+
* a sign-in return (D794) matches against this list instead of falling back
|
|
289
|
+
* to the public endpoint. Never loopback, never the app link.
|
|
290
|
+
*/
|
|
291
|
+
function buildListenerOrigins(inputs) {
|
|
292
|
+
const out = /* @__PURE__ */ new Set();
|
|
293
|
+
for (const e of [...inputs.overHttps, ...inputs.overHttp]) if (ORIGIN_KINDS.has(e.kind)) out.add(e.baseUrl);
|
|
294
|
+
for (const c of inputs.custom) out.add(c.baseUrl);
|
|
295
|
+
for (const o of inputs.localNameOrigins) out.add(o);
|
|
296
|
+
return [...out];
|
|
297
|
+
}
|
|
298
|
+
//#endregion
|
|
299
|
+
//#region src/builtins/local-network/hub-mdns.ts
|
|
300
|
+
/**
|
|
301
|
+
* Hub mDNS advertisement (D838) — how `camstack login` / `camstack discover`
|
|
302
|
+
* find a hub on the LAN.
|
|
303
|
+
*
|
|
304
|
+
* The hub publishes ONE `_camstack._tcp` service for its HTTPS endpoint. There
|
|
305
|
+
* is no mesh channel in it (D826 retired mesh UDP discovery on purpose) and
|
|
306
|
+
* nothing secret: the TXT record carries the node id, the version, the role
|
|
307
|
+
* and the address URL — finding a hub grants nothing, every client still signs
|
|
308
|
+
* in.
|
|
309
|
+
*
|
|
310
|
+
* The advertised address is NOT ranked here. It is the `internal` role of the
|
|
311
|
+
* address book (the address flagged for LAN clients, else the automatic LAN
|
|
312
|
+
* pick) — this module only reads the answer `local-network` already gives.
|
|
313
|
+
*
|
|
314
|
+
* The responder is injected so the logic is tested with a fake; the real one
|
|
315
|
+
* wraps `@homebridge/ciao`.
|
|
316
|
+
*/
|
|
317
|
+
/** The announcement for the current address, or null when nothing qualifies. */
|
|
318
|
+
function buildHubAnnouncement(inputs) {
|
|
319
|
+
if (inputs.internalUrl === null) return null;
|
|
320
|
+
let url;
|
|
321
|
+
try {
|
|
322
|
+
url = new URL(inputs.internalUrl);
|
|
323
|
+
} catch {
|
|
324
|
+
return null;
|
|
325
|
+
}
|
|
326
|
+
if (url.protocol !== "https:") return null;
|
|
327
|
+
const port = url.port === "" ? 443 : Number.parseInt(url.port, 10);
|
|
328
|
+
if (!Number.isInteger(port) || port < 1 || port > 65535) return null;
|
|
329
|
+
const host = url.hostname.replace(/^\[|\]$/g, "");
|
|
330
|
+
const txt = {
|
|
331
|
+
[HUB_MDNS_TXT_KEYS.nodeId]: inputs.nodeId,
|
|
332
|
+
[HUB_MDNS_TXT_KEYS.role]: "hub",
|
|
333
|
+
[HUB_MDNS_TXT_KEYS.url]: url.origin
|
|
334
|
+
};
|
|
335
|
+
if (inputs.version !== null) txt[HUB_MDNS_TXT_KEYS.version] = inputs.version;
|
|
336
|
+
return {
|
|
337
|
+
name: `camstack-${inputs.nodeId}`,
|
|
338
|
+
type: HUB_MDNS_SERVICE_TYPE,
|
|
339
|
+
port,
|
|
340
|
+
address: isIP(host) !== 0 ? host : null,
|
|
341
|
+
txt
|
|
342
|
+
};
|
|
343
|
+
}
|
|
344
|
+
function announcementKey(a) {
|
|
345
|
+
return JSON.stringify([
|
|
346
|
+
a.name,
|
|
347
|
+
a.type,
|
|
348
|
+
a.port,
|
|
349
|
+
a.address,
|
|
350
|
+
a.txt
|
|
351
|
+
]);
|
|
352
|
+
}
|
|
353
|
+
/**
|
|
354
|
+
* Keeps one mDNS service in step with the hub's `internal` address. `sync()`
|
|
355
|
+
* is safe to call on any change; it never throws — a failure to advertise is
|
|
356
|
+
* logged and the boot goes on.
|
|
357
|
+
*/
|
|
358
|
+
var HubMdnsAdvertiser = class {
|
|
359
|
+
options;
|
|
360
|
+
current = null;
|
|
361
|
+
running = false;
|
|
362
|
+
chain = Promise.resolve();
|
|
363
|
+
constructor(options) {
|
|
364
|
+
this.options = options;
|
|
365
|
+
}
|
|
366
|
+
async start() {
|
|
367
|
+
this.running = true;
|
|
368
|
+
await this.sync();
|
|
369
|
+
}
|
|
370
|
+
/** Re-read the address and re-announce when it changed. Serialised. */
|
|
371
|
+
sync() {
|
|
372
|
+
this.chain = this.chain.then(() => this.syncOnce());
|
|
373
|
+
return this.chain;
|
|
374
|
+
}
|
|
375
|
+
async stop() {
|
|
376
|
+
this.running = false;
|
|
377
|
+
await (this.chain = this.chain.then(() => this.withdraw()));
|
|
378
|
+
}
|
|
379
|
+
async syncOnce() {
|
|
380
|
+
if (!this.running) return;
|
|
381
|
+
const { logger } = this.options;
|
|
382
|
+
try {
|
|
383
|
+
const internalUrl = await this.options.readInternalUrl();
|
|
384
|
+
const next = buildHubAnnouncement({
|
|
385
|
+
nodeId: this.options.nodeId,
|
|
386
|
+
version: this.options.version,
|
|
387
|
+
internalUrl
|
|
388
|
+
});
|
|
389
|
+
if (next === null) {
|
|
390
|
+
if (this.current !== null) {
|
|
391
|
+
await this.withdraw();
|
|
392
|
+
logger.info("hub mDNS: no internal address, advertisement withdrawn");
|
|
393
|
+
}
|
|
394
|
+
return;
|
|
395
|
+
}
|
|
396
|
+
const key = announcementKey(next);
|
|
397
|
+
if (this.current?.key === key) return;
|
|
398
|
+
await this.withdraw();
|
|
399
|
+
const handle = await this.options.publisher.publish(next);
|
|
400
|
+
this.current = {
|
|
401
|
+
key,
|
|
402
|
+
handle
|
|
403
|
+
};
|
|
404
|
+
logger.info("hub mDNS: advertising _camstack._tcp", { meta: {
|
|
405
|
+
url: next.txt[HUB_MDNS_TXT_KEYS.url],
|
|
406
|
+
port: next.port
|
|
407
|
+
} });
|
|
408
|
+
} catch (err) {
|
|
409
|
+
logger.warn("hub mDNS: could not advertise the hub (logins still work with --server)", { meta: { error: err instanceof Error ? err.message : String(err) } });
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
async withdraw() {
|
|
413
|
+
const held = this.current;
|
|
414
|
+
this.current = null;
|
|
415
|
+
if (held === null) return;
|
|
416
|
+
try {
|
|
417
|
+
await held.handle.stop();
|
|
418
|
+
} catch (err) {
|
|
419
|
+
this.options.logger.warn("hub mDNS: withdraw failed", { meta: { error: err instanceof Error ? err.message : String(err) } });
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
};
|
|
423
|
+
/**
|
|
424
|
+
* The address a hub advertises: the `internal` role's answer, exactly as the
|
|
425
|
+
* address book resolved it. Never re-ranked here (D729, D732).
|
|
426
|
+
*/
|
|
427
|
+
function internalUrlOf(book) {
|
|
428
|
+
return book.roles.internal.resolved;
|
|
429
|
+
}
|
|
430
|
+
//#endregion
|
|
431
|
+
//#region src/builtins/local-network/ipv6-lan.ts
|
|
432
|
+
/**
|
|
433
|
+
* IPv6 helpers for LAN advertisement: prefix matching (privacy addresses
|
|
434
|
+
* rotate inside a /64), Linux `/proc/net/if_inet6` flags, and the gate
|
|
435
|
+
* that keeps temporary GUA off the connection candidate list.
|
|
436
|
+
*/
|
|
437
|
+
var IFA_F_TEMPORARY = 1;
|
|
438
|
+
var IFA_F_DEPRECATED = 32;
|
|
439
|
+
var IFA_F_TENTATIVE = 64;
|
|
440
|
+
/** First 64 bits, canonical hex groups, or null if the address is not IPv6. */
|
|
441
|
+
function ipv6Prefix64Key(address) {
|
|
442
|
+
const groups = parseIpv6Groups(address);
|
|
443
|
+
if (groups === null) return null;
|
|
444
|
+
return groups.slice(0, 4).map((g) => g.toString(16).padStart(4, "0")).join(":");
|
|
445
|
+
}
|
|
446
|
+
/** 32-char lowercase hex (same encoding as `/proc/net/if_inet6`). */
|
|
447
|
+
function ipv6ToHex32(address) {
|
|
448
|
+
const groups = parseIpv6Groups(address);
|
|
449
|
+
if (groups === null) return null;
|
|
450
|
+
return groups.map((g) => g.toString(16).padStart(4, "0")).join("");
|
|
451
|
+
}
|
|
452
|
+
/**
|
|
453
|
+
* Parse Linux `if_inet6` into hex32 → flags. Unknown / malformed lines
|
|
454
|
+
* are skipped. Keys match {@link ipv6ToHex32}.
|
|
455
|
+
*/
|
|
456
|
+
function parseProcIfInet6(text) {
|
|
457
|
+
const out = /* @__PURE__ */ new Map();
|
|
458
|
+
for (const line of text.split("\n")) {
|
|
459
|
+
const trimmed = line.trim();
|
|
460
|
+
if (trimmed === "") continue;
|
|
461
|
+
const parts = trimmed.split(/\s+/);
|
|
462
|
+
const hex = parts[0]?.toLowerCase();
|
|
463
|
+
const flagsRaw = parts[4];
|
|
464
|
+
if (!hex || hex.length !== 32 || flagsRaw === void 0) continue;
|
|
465
|
+
const flags = Number.parseInt(flagsRaw, 16);
|
|
466
|
+
if (!Number.isFinite(flags)) continue;
|
|
467
|
+
out.set(hex, flags);
|
|
468
|
+
}
|
|
469
|
+
return out;
|
|
470
|
+
}
|
|
471
|
+
/**
|
|
472
|
+
* Whether this IPv6 should be auto-seeded / advertised.
|
|
473
|
+
* `flags === undefined` means the platform did not tell us (macOS, tests
|
|
474
|
+
* without a proc snapshot) — keep every non-link-local plausible address.
|
|
475
|
+
*
|
|
476
|
+
* On Linux, drop addresses marked TEMPORARY / DEPRECATED / TENTATIVE, and
|
|
477
|
+
* `flags === 0` which is how this kernel reports RFC 4941 privacy temps
|
|
478
|
+
* (the stable GUA is PERMANENT|NODAD). Do **not** require PERMANENT —
|
|
479
|
+
* stateful DHCPv6 GUA often has only NODAD (0x02).
|
|
480
|
+
*/
|
|
481
|
+
function shouldAdvertiseIpv6(address, flags) {
|
|
482
|
+
const a = address.toLowerCase().split("%")[0] ?? address;
|
|
483
|
+
if (a === "::" || a === "::1") return false;
|
|
484
|
+
if (a.startsWith("fe80:")) return false;
|
|
485
|
+
if (a.startsWith("ff")) return false;
|
|
486
|
+
if (flags === void 0) return true;
|
|
487
|
+
if ((flags & IFA_F_TEMPORARY) !== 0) return false;
|
|
488
|
+
if ((flags & IFA_F_DEPRECATED) !== 0) return false;
|
|
489
|
+
if ((flags & IFA_F_TENTATIVE) !== 0) return false;
|
|
490
|
+
if (flags === 0) return false;
|
|
491
|
+
return true;
|
|
492
|
+
}
|
|
493
|
+
function ipv6AllowlistMatches(address, allowed) {
|
|
494
|
+
if (allowed.includes(address)) return true;
|
|
495
|
+
const key = ipv6Prefix64Key(address);
|
|
496
|
+
if (key === null) return false;
|
|
497
|
+
for (const entry of allowed) {
|
|
498
|
+
if (!entry.includes(":")) continue;
|
|
499
|
+
if (ipv6Prefix64Key(entry) === key) return true;
|
|
500
|
+
}
|
|
501
|
+
return false;
|
|
502
|
+
}
|
|
503
|
+
function parseIpv6Groups(address) {
|
|
504
|
+
const raw = address.toLowerCase().split("%")[0];
|
|
505
|
+
if (!raw || raw.includes(".")) return null;
|
|
506
|
+
const sides = raw.split("::");
|
|
507
|
+
if (sides.length > 2) return null;
|
|
508
|
+
const parsePart = (part) => {
|
|
509
|
+
if (part === void 0 || part === "") return [];
|
|
510
|
+
const groups = part.split(":");
|
|
511
|
+
const out = [];
|
|
512
|
+
for (const g of groups) {
|
|
513
|
+
if (g === "") return null;
|
|
514
|
+
if (!/^[0-9a-f]{1,4}$/.test(g)) return null;
|
|
515
|
+
out.push(Number.parseInt(g, 16));
|
|
516
|
+
}
|
|
517
|
+
return out;
|
|
518
|
+
};
|
|
519
|
+
if (sides.length === 1) {
|
|
520
|
+
const groups = parsePart(sides[0]);
|
|
521
|
+
if (groups === null || groups.length !== 8) return null;
|
|
522
|
+
return groups;
|
|
523
|
+
}
|
|
524
|
+
const left = parsePart(sides[0]);
|
|
525
|
+
const right = parsePart(sides[1]);
|
|
526
|
+
if (left === null || right === null) return null;
|
|
527
|
+
const fill = 8 - left.length - right.length;
|
|
528
|
+
if (fill < 0) return null;
|
|
529
|
+
return [
|
|
530
|
+
...left,
|
|
531
|
+
...Array(fill).fill(0),
|
|
532
|
+
...right
|
|
533
|
+
];
|
|
534
|
+
}
|
|
535
|
+
//#endregion
|
|
536
|
+
//#region src/builtins/local-network/local-hostname.ts
|
|
537
|
+
var DNS_NAME = /^(?=.{1,253}$)([a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.)*[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])$/;
|
|
538
|
+
/**
|
|
539
|
+
* Parse the operator-typed local hostname.
|
|
540
|
+
*
|
|
541
|
+
* Empty / whitespace → `null` (advertise the raw LAN IP). A DNS name is
|
|
542
|
+
* lowercased. A URL, port suffix, path, or bare IP is rejected so it cannot
|
|
543
|
+
* leak into a SAN or a candidate URL.
|
|
544
|
+
*/
|
|
545
|
+
function parseLocalHostname(raw) {
|
|
546
|
+
const trimmed = raw.trim();
|
|
547
|
+
if (trimmed === "") return {
|
|
548
|
+
ok: true,
|
|
549
|
+
value: null
|
|
550
|
+
};
|
|
551
|
+
if (/[\s/:?#]/.test(trimmed) || trimmed.includes("\\")) return {
|
|
552
|
+
ok: false,
|
|
553
|
+
error: "Enter a DNS name such as camstack.lan, without a scheme or port."
|
|
554
|
+
};
|
|
555
|
+
const lowered = trimmed.toLowerCase();
|
|
556
|
+
if (isIP(lowered) !== 0) return {
|
|
557
|
+
ok: false,
|
|
558
|
+
error: "Use the address allowlist for IPs — this field is a DNS name."
|
|
559
|
+
};
|
|
560
|
+
if (!DNS_NAME.test(lowered)) return {
|
|
561
|
+
ok: false,
|
|
562
|
+
error: "Enter a DNS name such as camstack.lan, without a scheme or port."
|
|
563
|
+
};
|
|
564
|
+
return {
|
|
565
|
+
ok: true,
|
|
566
|
+
value: lowered
|
|
567
|
+
};
|
|
568
|
+
}
|
|
569
|
+
//#endregion
|
|
570
|
+
//#region src/builtins/local-network/scan/dns-wire.ts
|
|
571
|
+
/**
|
|
572
|
+
* DNS-SD wire format for the scan engine: one PTR question per service type,
|
|
573
|
+
* and a parser that turns an answer into services (instance, host, port, TXT).
|
|
574
|
+
*/
|
|
575
|
+
/** Top bit of the question class: ask for a unicast reply (RFC 6762). */
|
|
576
|
+
var MDNS_QU_CLASS = 32769;
|
|
577
|
+
var A = 1;
|
|
578
|
+
var PTR = 12;
|
|
579
|
+
var TXT = 16;
|
|
580
|
+
var SRV = 33;
|
|
581
|
+
var SRV_FIXED = 6;
|
|
582
|
+
var MAX_NAME_HOPS = 16;
|
|
583
|
+
var MDNS_PORT = 5353;
|
|
584
|
+
var MDNS_GROUP = "224.0.0.251";
|
|
585
|
+
/** `_esphomelib._tcp` and `_esphomelib._tcp.local.` name the same service. */
|
|
586
|
+
function normalizeServiceType(serviceType) {
|
|
587
|
+
const lower = serviceType.trim().toLowerCase().replace(/\.$/, "");
|
|
588
|
+
return lower.endsWith(".local") ? lower.slice(0, -6) : lower;
|
|
589
|
+
}
|
|
590
|
+
function readName(buf, start) {
|
|
591
|
+
const labels = [];
|
|
592
|
+
let pos = start;
|
|
593
|
+
let end = start;
|
|
594
|
+
let jumped = false;
|
|
595
|
+
for (let hops = 0; hops < MAX_NAME_HOPS; hops++) {
|
|
596
|
+
if (pos < 0 || pos >= buf.length) return null;
|
|
597
|
+
const len = buf[pos] ?? 0;
|
|
598
|
+
if (len === 0) {
|
|
599
|
+
if (!jumped) end = pos + 1;
|
|
600
|
+
return {
|
|
601
|
+
name: labels.join("."),
|
|
602
|
+
end
|
|
603
|
+
};
|
|
604
|
+
}
|
|
605
|
+
if ((len & 192) === 192) {
|
|
606
|
+
if (pos + 1 >= buf.length) return null;
|
|
607
|
+
if (!jumped) end = pos + 2;
|
|
608
|
+
jumped = true;
|
|
609
|
+
pos = (len & 63) << 8 | (buf[pos + 1] ?? 0);
|
|
610
|
+
continue;
|
|
611
|
+
}
|
|
612
|
+
if ((len & 192) !== 0 || pos + 1 + len > buf.length) return null;
|
|
613
|
+
labels.push(buf.subarray(pos + 1, pos + 1 + len).toString("utf8"));
|
|
614
|
+
pos += 1 + len;
|
|
615
|
+
if (!jumped) end = pos;
|
|
616
|
+
}
|
|
617
|
+
return null;
|
|
618
|
+
}
|
|
619
|
+
function readRecords(buf, offset, count) {
|
|
620
|
+
const records = [];
|
|
621
|
+
let pos = offset;
|
|
622
|
+
for (let i = 0; i < count; i++) {
|
|
623
|
+
const name = readName(buf, pos);
|
|
624
|
+
if (name === null || name.end + 10 > buf.length) return null;
|
|
625
|
+
const type = buf.readUInt16BE(name.end);
|
|
626
|
+
const dataLength = buf.readUInt16BE(name.end + 8);
|
|
627
|
+
const dataOffset = name.end + 10;
|
|
628
|
+
if (dataOffset + dataLength > buf.length) return null;
|
|
629
|
+
records.push({
|
|
630
|
+
name: name.name,
|
|
631
|
+
type,
|
|
632
|
+
dataOffset,
|
|
633
|
+
dataLength
|
|
634
|
+
});
|
|
635
|
+
pos = dataOffset + dataLength;
|
|
636
|
+
}
|
|
637
|
+
return {
|
|
638
|
+
records,
|
|
639
|
+
next: pos
|
|
640
|
+
};
|
|
641
|
+
}
|
|
642
|
+
function parseTxt(buf, offset, length) {
|
|
643
|
+
const out = {};
|
|
644
|
+
let pos = offset;
|
|
645
|
+
const end = offset + length;
|
|
646
|
+
while (pos < end) {
|
|
647
|
+
const len = buf[pos] ?? 0;
|
|
648
|
+
pos += 1;
|
|
649
|
+
if (len === 0 || pos + len > end) break;
|
|
650
|
+
const entry = buf.subarray(pos, pos + len).toString("utf8");
|
|
651
|
+
pos += len;
|
|
652
|
+
const eq = entry.indexOf("=");
|
|
653
|
+
if (eq < 0) out[entry] = "";
|
|
654
|
+
else out[entry.slice(0, eq)] = entry.slice(eq + 1);
|
|
655
|
+
}
|
|
656
|
+
return out;
|
|
657
|
+
}
|
|
658
|
+
/** One PTR question per service type, all with the unicast-reply bit. */
|
|
659
|
+
function buildPtrQuery(serviceTypes) {
|
|
660
|
+
const header = Buffer.alloc(12);
|
|
661
|
+
header.writeUInt16BE(serviceTypes.length, 4);
|
|
662
|
+
const questions = serviceTypes.map((type) => {
|
|
663
|
+
const encoded = `${normalizeServiceType(type)}.local`.split(".").filter((part) => part.length > 0).map((l) => Buffer.concat([Buffer.from([l.length]), Buffer.from(l)]));
|
|
664
|
+
const tail = Buffer.alloc(4);
|
|
665
|
+
tail.writeUInt16BE(PTR, 0);
|
|
666
|
+
tail.writeUInt16BE(MDNS_QU_CLASS, 2);
|
|
667
|
+
return Buffer.concat([
|
|
668
|
+
...encoded,
|
|
669
|
+
Buffer.from([0]),
|
|
670
|
+
tail
|
|
671
|
+
]);
|
|
672
|
+
});
|
|
673
|
+
return Buffer.concat([header, ...questions]);
|
|
674
|
+
}
|
|
675
|
+
/** The services advertised on one mDNS message; a malformed packet yields none. */
|
|
676
|
+
function parseMdnsMessage(buf) {
|
|
677
|
+
if (buf.length < 12) return [];
|
|
678
|
+
const [questions = 0, answers = 0, authorities = 0, extra = 0] = [
|
|
679
|
+
4,
|
|
680
|
+
6,
|
|
681
|
+
8,
|
|
682
|
+
10
|
|
683
|
+
].map((o) => buf.readUInt16BE(o));
|
|
684
|
+
let pos = 12;
|
|
685
|
+
for (let i = 0; i < questions; i++) {
|
|
686
|
+
const name = readName(buf, pos);
|
|
687
|
+
if (name === null) return [];
|
|
688
|
+
pos = name.end + 4;
|
|
689
|
+
if (pos > buf.length) return [];
|
|
690
|
+
}
|
|
691
|
+
const records = [];
|
|
692
|
+
for (const count of [
|
|
693
|
+
answers,
|
|
694
|
+
authorities,
|
|
695
|
+
extra
|
|
696
|
+
]) {
|
|
697
|
+
const read = readRecords(buf, pos, count);
|
|
698
|
+
if (read === null) return [];
|
|
699
|
+
records.push(...read.records);
|
|
700
|
+
pos = read.next;
|
|
701
|
+
}
|
|
702
|
+
const ptrs = [];
|
|
703
|
+
const srv = /* @__PURE__ */ new Map();
|
|
704
|
+
const txt = /* @__PURE__ */ new Map();
|
|
705
|
+
const addresses = /* @__PURE__ */ new Map();
|
|
706
|
+
for (const rec of records) {
|
|
707
|
+
const key = rec.name.toLowerCase();
|
|
708
|
+
if (rec.type === PTR) {
|
|
709
|
+
const target = readName(buf, rec.dataOffset);
|
|
710
|
+
if (target !== null) ptrs.push({
|
|
711
|
+
serviceType: rec.name,
|
|
712
|
+
instance: target.name
|
|
713
|
+
});
|
|
714
|
+
} else if (rec.type === SRV && rec.dataLength >= SRV_FIXED) {
|
|
715
|
+
const target = readName(buf, rec.dataOffset + SRV_FIXED);
|
|
716
|
+
if (target !== null) srv.set(key, {
|
|
717
|
+
target: target.name,
|
|
718
|
+
port: buf.readUInt16BE(rec.dataOffset + 4)
|
|
719
|
+
});
|
|
720
|
+
} else if (rec.type === TXT) txt.set(key, parseTxt(buf, rec.dataOffset, rec.dataLength));
|
|
721
|
+
else if (rec.type === A && rec.dataLength === 4) addresses.set(key, `${buf[rec.dataOffset]}.${buf[rec.dataOffset + 1]}.${buf[rec.dataOffset + 2]}.${buf[rec.dataOffset + 3]}`);
|
|
722
|
+
}
|
|
723
|
+
const out = [];
|
|
724
|
+
for (const { serviceType, instance } of ptrs) {
|
|
725
|
+
const service = srv.get(instance.toLowerCase());
|
|
726
|
+
const target = service?.target ?? instance;
|
|
727
|
+
out.push({
|
|
728
|
+
serviceType: normalizeServiceType(serviceType),
|
|
729
|
+
instance,
|
|
730
|
+
address: addresses.get(target.toLowerCase()) ?? addresses.get(instance.toLowerCase()) ?? null,
|
|
731
|
+
host: target,
|
|
732
|
+
port: service?.port ?? 0,
|
|
733
|
+
txt: txt.get(instance.toLowerCase()) ?? {}
|
|
734
|
+
});
|
|
735
|
+
}
|
|
736
|
+
return out;
|
|
737
|
+
}
|
|
738
|
+
//#endregion
|
|
739
|
+
//#region src/builtins/local-network/scan/scan-io.ts
|
|
740
|
+
/** A hit carries at most this much of a response body. */
|
|
741
|
+
var MAX_HIT_BODY_BYTES = 16 * 1024;
|
|
742
|
+
//#endregion
|
|
743
|
+
//#region src/builtins/local-network/scan/subnets.ts
|
|
744
|
+
/** Total hosts one scan may visit across every subnet. */
|
|
745
|
+
var MAX_SCAN_HOSTS = 4096;
|
|
746
|
+
/** A refused subnet input: the operator typed something the engine will not sweep. */
|
|
747
|
+
var ScanSubnetError = class extends Error {
|
|
748
|
+
constructor(message) {
|
|
749
|
+
super(message);
|
|
750
|
+
this.name = "ScanSubnetError";
|
|
751
|
+
}
|
|
752
|
+
};
|
|
753
|
+
var IPV4 = /^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/;
|
|
754
|
+
function ipv4ToInt(address) {
|
|
755
|
+
const m = IPV4.exec(address.trim());
|
|
756
|
+
if (m === null) return null;
|
|
757
|
+
let out = 0;
|
|
758
|
+
for (let i = 1; i <= 4; i++) {
|
|
759
|
+
const octet = Number(m[i]);
|
|
760
|
+
if (octet > 255) return null;
|
|
761
|
+
out = out * 256 + octet;
|
|
762
|
+
}
|
|
763
|
+
return out;
|
|
764
|
+
}
|
|
765
|
+
function intToIpv4(value) {
|
|
766
|
+
return [
|
|
767
|
+
value >>> 24,
|
|
768
|
+
value >>> 16 & 255,
|
|
769
|
+
value >>> 8 & 255,
|
|
770
|
+
value & 255
|
|
771
|
+
].join(".");
|
|
772
|
+
}
|
|
773
|
+
function prefixMask(prefix) {
|
|
774
|
+
return prefix === 0 ? 0 : 4294967295 << 32 - prefix >>> 0;
|
|
775
|
+
}
|
|
776
|
+
/** Parse `a.b.c.d/p`. A bare address is a /32. Throws {@link ScanSubnetError}. */
|
|
777
|
+
function parseCidr(input) {
|
|
778
|
+
const [addr, rest, ...extra] = input.trim().split("/");
|
|
779
|
+
if (extra.length > 0 || addr === void 0) throw new ScanSubnetError(`Invalid CIDR "${input}"`);
|
|
780
|
+
const ip = ipv4ToInt(addr);
|
|
781
|
+
if (ip === null) throw new ScanSubnetError(`Invalid CIDR "${input}": not an IPv4 address`);
|
|
782
|
+
const prefix = rest === void 0 ? 32 : /^\d{1,2}$/.test(rest) ? Number(rest) : -1;
|
|
783
|
+
if (prefix < 0 || prefix > 32) throw new ScanSubnetError(`Invalid CIDR "${input}": bad prefix`);
|
|
784
|
+
if (prefix < 22) throw new ScanSubnetError(`CIDR "${input}" is wider than /22`);
|
|
785
|
+
const base = (ip & prefixMask(prefix)) >>> 0;
|
|
786
|
+
return {
|
|
787
|
+
cidr: `${intToIpv4(base)}/${prefix}`,
|
|
788
|
+
base,
|
|
789
|
+
prefix
|
|
790
|
+
};
|
|
791
|
+
}
|
|
792
|
+
/** Host addresses of a subnet, network and broadcast excluded (a /32 is its own host). */
|
|
793
|
+
function hostsOf(subnet) {
|
|
794
|
+
if (subnet.prefix === 32) return [intToIpv4(subnet.base)];
|
|
795
|
+
const size = 2 ** (32 - subnet.prefix);
|
|
796
|
+
if (subnet.prefix === 31) return [intToIpv4(subnet.base), intToIpv4(subnet.base + 1)];
|
|
797
|
+
const out = [];
|
|
798
|
+
for (let i = 1; i < size - 1; i++) out.push(intToIpv4(subnet.base + i));
|
|
799
|
+
return out;
|
|
800
|
+
}
|
|
801
|
+
/** The directed-broadcast address of a subnet. */
|
|
802
|
+
function broadcastOf(subnet) {
|
|
803
|
+
return intToIpv4(subnet.base + 2 ** (32 - subnet.prefix) - 1);
|
|
804
|
+
}
|
|
805
|
+
function containsAddress(subnet, address) {
|
|
806
|
+
const ip = ipv4ToInt(address);
|
|
807
|
+
return ip !== null && (ip & prefixMask(subnet.prefix)) >>> 0 === subnet.base;
|
|
808
|
+
}
|
|
809
|
+
function prefixOfNetmask(netmask) {
|
|
810
|
+
const mask = ipv4ToInt(netmask);
|
|
811
|
+
if (mask === null) return 24;
|
|
812
|
+
let bits = 0;
|
|
813
|
+
for (let bit = 31; bit >= 0 && (mask >>> bit & 1) === 1; bit--) bits++;
|
|
814
|
+
return bits;
|
|
815
|
+
}
|
|
816
|
+
/** A link the hub sits on and can scan: IPv4, not loopback / link-local, LAN or Wi-Fi. */
|
|
817
|
+
function isScannableLink(iface) {
|
|
818
|
+
if (iface.family !== "IPv4" || iface.internal) return false;
|
|
819
|
+
if (iface.address.startsWith("169.254.")) return false;
|
|
820
|
+
return iface.kind === "lan" || iface.kind === "wifi";
|
|
821
|
+
}
|
|
822
|
+
/** The hub's own /24 (or narrower) per scannable link. */
|
|
823
|
+
function ownLinkSubnets(interfaces) {
|
|
824
|
+
const out = /* @__PURE__ */ new Map();
|
|
825
|
+
for (const iface of interfaces) {
|
|
826
|
+
if (!isScannableLink(iface)) continue;
|
|
827
|
+
const prefix = Math.max(prefixOfNetmask(iface.netmask), 24);
|
|
828
|
+
const ip = ipv4ToInt(iface.address);
|
|
829
|
+
if (ip === null) continue;
|
|
830
|
+
const base = (ip & prefixMask(prefix)) >>> 0;
|
|
831
|
+
const subnet = {
|
|
832
|
+
cidr: `${intToIpv4(base)}/${prefix}`,
|
|
833
|
+
base,
|
|
834
|
+
prefix
|
|
835
|
+
};
|
|
836
|
+
out.set(subnet.cidr, subnet);
|
|
837
|
+
}
|
|
838
|
+
return [...out.values()];
|
|
839
|
+
}
|
|
840
|
+
/**
|
|
841
|
+
* hub /24s ∪ saved ∪ per-call. An invalid CIDR, or a union above
|
|
842
|
+
* {@link MAX_SCAN_HOSTS} hosts, throws {@link ScanSubnetError}.
|
|
843
|
+
*/
|
|
844
|
+
function resolveScanSubnets(input) {
|
|
845
|
+
const own = ownLinkSubnets(input.interfaces);
|
|
846
|
+
const ownCidrs = new Set(own.map((s) => s.cidr));
|
|
847
|
+
const extraParsed = [...input.saved, ...input.perCall].map(parseCidr);
|
|
848
|
+
const all = /* @__PURE__ */ new Map();
|
|
849
|
+
for (const s of own) all.set(s.cidr, s);
|
|
850
|
+
const extra = /* @__PURE__ */ new Map();
|
|
851
|
+
for (const s of extraParsed) {
|
|
852
|
+
if (!all.has(s.cidr)) all.set(s.cidr, s);
|
|
853
|
+
if (!ownCidrs.has(s.cidr)) extra.set(s.cidr, s);
|
|
854
|
+
}
|
|
855
|
+
const ownAddresses = new Set(input.interfaces.map((i) => i.address));
|
|
856
|
+
const hosts = /* @__PURE__ */ new Set();
|
|
857
|
+
for (const s of all.values()) {
|
|
858
|
+
for (const h of hostsOf(s)) if (!ownAddresses.has(h)) hosts.add(h);
|
|
859
|
+
if (hosts.size > 4096) throw new ScanSubnetError(`The subnets cover more than ${MAX_SCAN_HOSTS} hosts; remove or narrow one`);
|
|
860
|
+
}
|
|
861
|
+
return {
|
|
862
|
+
all: [...all.values()],
|
|
863
|
+
extra: [...extra.values()],
|
|
864
|
+
hosts: [...hosts]
|
|
865
|
+
};
|
|
866
|
+
}
|
|
867
|
+
/** Validate a list to be saved: same rules as a scan, returned canonical and deduplicated. */
|
|
868
|
+
function validateSavedSubnets(list) {
|
|
869
|
+
const parsed = list.map(parseCidr);
|
|
870
|
+
const cidrs = [...new Set(parsed.map((s) => s.cidr))];
|
|
871
|
+
resolveScanSubnets({
|
|
872
|
+
interfaces: [],
|
|
873
|
+
saved: cidrs,
|
|
874
|
+
perCall: []
|
|
875
|
+
});
|
|
876
|
+
return cidrs;
|
|
877
|
+
}
|
|
878
|
+
var SCAN_REQUEST_TIMEOUT_MS = 1200;
|
|
879
|
+
/** Wi-Fi boards drop or late-answer one multicast query: send it three times, listen to the end. */
|
|
880
|
+
var MULTICAST_RESEND_AT_MS = [1200, 2500];
|
|
881
|
+
var MULTICAST_LISTEN_MS = 4500;
|
|
882
|
+
/** Unicast DNS-SD probes to extra subnets get one retry. */
|
|
883
|
+
var UNICAST_RESEND_AT_MS = [900];
|
|
884
|
+
var UNICAST_LISTEN_MS = 2e3;
|
|
885
|
+
var WSD_GROUP = "239.255.255.250";
|
|
886
|
+
var WSD_PORT = 3702;
|
|
887
|
+
var SSDP_PORT = 1900;
|
|
888
|
+
var MAX_HEADERS_PER_HIT = 32;
|
|
889
|
+
function bucket(c, kind) {
|
|
890
|
+
const existing = c.stats.get(kind);
|
|
891
|
+
if (existing !== void 0) return existing;
|
|
892
|
+
const fresh = {
|
|
893
|
+
probed: 0,
|
|
894
|
+
hits: 0,
|
|
895
|
+
timeouts: 0
|
|
896
|
+
};
|
|
897
|
+
c.stats.set(kind, fresh);
|
|
898
|
+
return fresh;
|
|
899
|
+
}
|
|
900
|
+
function emit(c, entry, hit) {
|
|
901
|
+
c.hits.push({
|
|
902
|
+
providerId: entry.providerId,
|
|
903
|
+
hit: {
|
|
904
|
+
...hit,
|
|
905
|
+
modeIndex: entry.modeIndex
|
|
906
|
+
}
|
|
907
|
+
});
|
|
908
|
+
bucket(c, entry.mode.kind).hits += 1;
|
|
909
|
+
}
|
|
910
|
+
function isKind(mode, kind) {
|
|
911
|
+
return mode.kind === kind;
|
|
912
|
+
}
|
|
913
|
+
function entriesOf(requests, kind) {
|
|
914
|
+
const out = [];
|
|
915
|
+
for (const req of requests) req.modes.forEach((mode, modeIndex) => {
|
|
916
|
+
if (isKind(mode, kind)) out.push({
|
|
917
|
+
providerId: req.providerId,
|
|
918
|
+
modeIndex,
|
|
919
|
+
mode
|
|
920
|
+
});
|
|
921
|
+
});
|
|
922
|
+
return out;
|
|
923
|
+
}
|
|
924
|
+
/** Hosts of the subnets multicast cannot reach. */
|
|
925
|
+
function extraHostsOf(subnets) {
|
|
926
|
+
return subnets.hosts.filter((h) => subnets.extra.some((s) => containsAddress(s, h)));
|
|
927
|
+
}
|
|
928
|
+
/** Run `task` over `items` with at most `limit` in flight. */
|
|
929
|
+
async function pool(items, limit, task) {
|
|
930
|
+
let next = 0;
|
|
931
|
+
const worker = async () => {
|
|
932
|
+
for (;;) {
|
|
933
|
+
const index = next++;
|
|
934
|
+
const item = items[index];
|
|
935
|
+
if (index >= items.length || item === void 0) return;
|
|
936
|
+
await task(item);
|
|
937
|
+
}
|
|
938
|
+
};
|
|
939
|
+
await Promise.all(Array.from({ length: Math.min(limit, items.length) }, worker));
|
|
940
|
+
}
|
|
941
|
+
/** Hits per scanned CIDR, so "5 of 20 boards" is visible without a packet capture. */
|
|
942
|
+
function hitsBySubnet(subnets, hits) {
|
|
943
|
+
const out = {};
|
|
944
|
+
for (const subnet of subnets.all) out[subnet.cidr] = hits.filter((h) => containsAddress(subnet, h.hit.host)).length;
|
|
945
|
+
return out;
|
|
946
|
+
}
|
|
947
|
+
/** A resent query is answered more than once: one hit per distinct reply. */
|
|
948
|
+
function dedupeReplies(replies) {
|
|
949
|
+
const seen = /* @__PURE__ */ new Set();
|
|
950
|
+
const out = [];
|
|
951
|
+
for (const reply of replies) {
|
|
952
|
+
const key = `${reply.host}:${reply.port}:${reply.data.toString("hex")}`;
|
|
953
|
+
if (seen.has(key)) continue;
|
|
954
|
+
seen.add(key);
|
|
955
|
+
out.push(reply);
|
|
956
|
+
}
|
|
957
|
+
return out;
|
|
958
|
+
}
|
|
959
|
+
function hubLinks(interfaces) {
|
|
960
|
+
return interfaces.filter(isScannableLink);
|
|
961
|
+
}
|
|
962
|
+
function instanceLabel(instance) {
|
|
963
|
+
return instance.split("._")[0] ?? instance;
|
|
964
|
+
}
|
|
965
|
+
async function runMdns(deps, entries, subnets, c) {
|
|
966
|
+
if (entries.length === 0) return;
|
|
967
|
+
const query = buildPtrQuery([...new Set(entries.map((e) => normalizeServiceType(e.mode.serviceType)))]);
|
|
968
|
+
const replies = [];
|
|
969
|
+
const links = hubLinks(deps.interfaces());
|
|
970
|
+
for (const link of links) {
|
|
971
|
+
bucket(c, "mdns").probed += 1;
|
|
972
|
+
replies.push(...await deps.io.udpExchange({
|
|
973
|
+
payload: query,
|
|
974
|
+
targets: [{
|
|
975
|
+
host: MDNS_GROUP,
|
|
976
|
+
port: MDNS_PORT
|
|
977
|
+
}],
|
|
978
|
+
localAddress: link.address,
|
|
979
|
+
resendAtMs: MULTICAST_RESEND_AT_MS,
|
|
980
|
+
listenMs: MULTICAST_LISTEN_MS
|
|
981
|
+
}));
|
|
982
|
+
}
|
|
983
|
+
const extraHosts = extraHostsOf(subnets);
|
|
984
|
+
if (extraHosts.length > 0) {
|
|
985
|
+
bucket(c, "mdns").probed += extraHosts.length;
|
|
986
|
+
replies.push(...await deps.io.udpExchange({
|
|
987
|
+
payload: query,
|
|
988
|
+
targets: extraHosts.map((host) => ({
|
|
989
|
+
host,
|
|
990
|
+
port: MDNS_PORT
|
|
991
|
+
})),
|
|
992
|
+
resendAtMs: UNICAST_RESEND_AT_MS,
|
|
993
|
+
listenMs: UNICAST_LISTEN_MS
|
|
994
|
+
}));
|
|
995
|
+
}
|
|
996
|
+
for (const reply of dedupeReplies(replies)) for (const service of parseMdnsMessage(reply.data)) for (const entry of entries) {
|
|
997
|
+
if (normalizeServiceType(entry.mode.serviceType) !== service.serviceType) continue;
|
|
998
|
+
const label = instanceLabel(service.instance);
|
|
999
|
+
if (entry.mode.instancePattern !== void 0 && !matches(entry.mode.instancePattern, label)) continue;
|
|
1000
|
+
emit(c, entry, {
|
|
1001
|
+
host: service.address ?? reply.host,
|
|
1002
|
+
port: service.port,
|
|
1003
|
+
mdns: {
|
|
1004
|
+
instance: label,
|
|
1005
|
+
host: service.host,
|
|
1006
|
+
port: service.port,
|
|
1007
|
+
txt: service.txt
|
|
1008
|
+
}
|
|
1009
|
+
});
|
|
1010
|
+
}
|
|
1011
|
+
}
|
|
1012
|
+
function matches(pattern, text) {
|
|
1013
|
+
try {
|
|
1014
|
+
return new RegExp(pattern, "i").test(text);
|
|
1015
|
+
} catch {
|
|
1016
|
+
return false;
|
|
1017
|
+
}
|
|
1018
|
+
}
|
|
1019
|
+
function wsdProbe() {
|
|
1020
|
+
const id = `uuid:${Array.from({ length: 4 }, () => Math.random().toString(16).slice(2, 10)).join("").slice(0, 32)}`;
|
|
1021
|
+
return Buffer.from(`<?xml version="1.0" encoding="UTF-8"?><e:Envelope xmlns:e="http://www.w3.org/2003/05/soap-envelope" xmlns:w="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:d="http://schemas.xmlsoap.org/ws/2005/04/discovery"><e:Header><w:MessageID>${id}</w:MessageID><w:To>urn:schemas-xmlsoap-org:ws:2005:04:discovery</w:To><w:Action>http://schemas.xmlsoap.org/ws/2005/04/discovery/Probe</w:Action></e:Header><e:Body><d:Probe/></e:Body></e:Envelope>`);
|
|
1022
|
+
}
|
|
1023
|
+
function xmlText(xml, tag) {
|
|
1024
|
+
const out = [];
|
|
1025
|
+
const re = new RegExp(`<(?:[\\w-]+:)?${tag}[^>]*>([^<]*)</(?:[\\w-]+:)?${tag}>`, "g");
|
|
1026
|
+
for (const m of xml.matchAll(re)) {
|
|
1027
|
+
const text = m[1]?.trim();
|
|
1028
|
+
if (text !== void 0 && text.length > 0) out.push(...text.split(/\s+/));
|
|
1029
|
+
}
|
|
1030
|
+
return out;
|
|
1031
|
+
}
|
|
1032
|
+
async function exchangeEverywhere(deps, kind, payload, multicast, unicastPort, subnets, c) {
|
|
1033
|
+
const replies = [];
|
|
1034
|
+
for (const link of hubLinks(deps.interfaces())) {
|
|
1035
|
+
bucket(c, kind).probed += 1;
|
|
1036
|
+
replies.push(...await deps.io.udpExchange({
|
|
1037
|
+
payload,
|
|
1038
|
+
targets: [multicast],
|
|
1039
|
+
localAddress: link.address,
|
|
1040
|
+
resendAtMs: MULTICAST_RESEND_AT_MS,
|
|
1041
|
+
listenMs: MULTICAST_LISTEN_MS
|
|
1042
|
+
}));
|
|
1043
|
+
}
|
|
1044
|
+
const extraHosts = extraHostsOf(subnets);
|
|
1045
|
+
if (extraHosts.length > 0) {
|
|
1046
|
+
bucket(c, kind).probed += extraHosts.length;
|
|
1047
|
+
replies.push(...await deps.io.udpExchange({
|
|
1048
|
+
payload,
|
|
1049
|
+
targets: extraHosts.map((host) => ({
|
|
1050
|
+
host,
|
|
1051
|
+
port: unicastPort
|
|
1052
|
+
})),
|
|
1053
|
+
resendAtMs: UNICAST_RESEND_AT_MS,
|
|
1054
|
+
listenMs: UNICAST_LISTEN_MS
|
|
1055
|
+
}));
|
|
1056
|
+
}
|
|
1057
|
+
return dedupeReplies(replies);
|
|
1058
|
+
}
|
|
1059
|
+
async function runWsDiscovery(deps, entries, subnets, c) {
|
|
1060
|
+
if (entries.length === 0) return;
|
|
1061
|
+
const replies = await exchangeEverywhere(deps, "ws-discovery", wsdProbe(), {
|
|
1062
|
+
host: WSD_GROUP,
|
|
1063
|
+
port: WSD_PORT
|
|
1064
|
+
}, WSD_PORT, subnets, c);
|
|
1065
|
+
for (const reply of replies) {
|
|
1066
|
+
const xml = reply.data.toString("utf8");
|
|
1067
|
+
const xaddrs = xmlText(xml, "XAddrs");
|
|
1068
|
+
const types = xmlText(xml, "Types");
|
|
1069
|
+
const scopes = xmlText(xml, "Scopes");
|
|
1070
|
+
if (xaddrs.length === 0 && types.length === 0) continue;
|
|
1071
|
+
const first = xaddrs[0] === void 0 ? null : safeUrl(xaddrs[0]);
|
|
1072
|
+
for (const entry of entries) {
|
|
1073
|
+
const wanted = entry.mode.types;
|
|
1074
|
+
if (wanted !== void 0 && !wanted.some((w) => types.some((t) => t.includes(w)))) continue;
|
|
1075
|
+
emit(c, entry, {
|
|
1076
|
+
host: first?.hostname ?? reply.host,
|
|
1077
|
+
port: first === null ? reply.port : Number(first.port || (first.protocol === "https:" ? 443 : 80)),
|
|
1078
|
+
wsd: {
|
|
1079
|
+
xaddrs,
|
|
1080
|
+
types,
|
|
1081
|
+
scopes
|
|
1082
|
+
}
|
|
1083
|
+
});
|
|
1084
|
+
}
|
|
1085
|
+
}
|
|
1086
|
+
}
|
|
1087
|
+
function safeUrl(text) {
|
|
1088
|
+
try {
|
|
1089
|
+
return new URL(text);
|
|
1090
|
+
} catch {
|
|
1091
|
+
return null;
|
|
1092
|
+
}
|
|
1093
|
+
}
|
|
1094
|
+
function parseSsdp(data) {
|
|
1095
|
+
const lines = data.toString("utf8").split(/\r?\n/);
|
|
1096
|
+
const first = /^HTTP\/1\.[01]\s+(\d{3})/.exec(lines[0] ?? "");
|
|
1097
|
+
if (first === null) return null;
|
|
1098
|
+
const headers = {};
|
|
1099
|
+
for (const line of lines.slice(1)) {
|
|
1100
|
+
const colon = line.indexOf(":");
|
|
1101
|
+
if (colon <= 0) continue;
|
|
1102
|
+
if (Object.keys(headers).length >= MAX_HEADERS_PER_HIT) break;
|
|
1103
|
+
headers[line.slice(0, colon).trim().toLowerCase()] = line.slice(colon + 1).trim();
|
|
1104
|
+
}
|
|
1105
|
+
return {
|
|
1106
|
+
status: Number(first[1]),
|
|
1107
|
+
headers
|
|
1108
|
+
};
|
|
1109
|
+
}
|
|
1110
|
+
async function runSsdp(deps, entries, subnets, c) {
|
|
1111
|
+
for (const target of new Set(entries.map((e) => e.mode.searchTarget))) {
|
|
1112
|
+
const replies = await exchangeEverywhere(deps, "ssdp", Buffer.from(`M-SEARCH * HTTP/1.1\r\nHOST: ${WSD_GROUP}:${SSDP_PORT}\r\nMAN: "ssdp:discover"\r\nMX: 1\r\nST: ${target}\r\n\r\n`), {
|
|
1113
|
+
host: WSD_GROUP,
|
|
1114
|
+
port: SSDP_PORT
|
|
1115
|
+
}, SSDP_PORT, subnets, c);
|
|
1116
|
+
for (const reply of replies) {
|
|
1117
|
+
const parsed = parseSsdp(reply.data);
|
|
1118
|
+
if (parsed === null) continue;
|
|
1119
|
+
for (const entry of entries) {
|
|
1120
|
+
if (entry.mode.searchTarget !== target) continue;
|
|
1121
|
+
emit(c, entry, {
|
|
1122
|
+
host: reply.host,
|
|
1123
|
+
port: reply.port,
|
|
1124
|
+
http: {
|
|
1125
|
+
status: parsed.status,
|
|
1126
|
+
headers: parsed.headers,
|
|
1127
|
+
bodyText: ""
|
|
1128
|
+
}
|
|
1129
|
+
});
|
|
1130
|
+
}
|
|
1131
|
+
}
|
|
1132
|
+
}
|
|
1133
|
+
}
|
|
1134
|
+
async function runUdpBroadcast(deps, entries, subnets, c) {
|
|
1135
|
+
const groups = /* @__PURE__ */ new Map();
|
|
1136
|
+
for (const entry of entries) {
|
|
1137
|
+
const { port, payloadHex, listenPort } = entry.mode;
|
|
1138
|
+
const key = `${port}|${payloadHex.toLowerCase()}|${listenPort ?? ""}`;
|
|
1139
|
+
groups.set(key, [...groups.get(key) ?? [], entry]);
|
|
1140
|
+
}
|
|
1141
|
+
const links = hubLinks(deps.interfaces());
|
|
1142
|
+
for (const group of groups.values()) {
|
|
1143
|
+
const first = group[0];
|
|
1144
|
+
if (first === void 0) continue;
|
|
1145
|
+
const { port, payloadHex, listenPort } = first.mode;
|
|
1146
|
+
const payload = Buffer.from(payloadHex, "hex");
|
|
1147
|
+
const replies = [];
|
|
1148
|
+
const sends = [...subnets.all.filter((s) => !subnets.extra.some((x) => x.cidr === s.cidr)).map((s) => ({
|
|
1149
|
+
link: links.find((l) => containsAddress(s, l.address)),
|
|
1150
|
+
host: broadcastOf(s)
|
|
1151
|
+
})).map((b) => ({
|
|
1152
|
+
localAddress: b.link?.address,
|
|
1153
|
+
host: b.host
|
|
1154
|
+
})), ...subnets.extra.map((s) => ({
|
|
1155
|
+
localAddress: void 0,
|
|
1156
|
+
host: broadcastOf(s)
|
|
1157
|
+
}))];
|
|
1158
|
+
for (const send of sends) {
|
|
1159
|
+
bucket(c, "udp-broadcast").probed += 1;
|
|
1160
|
+
replies.push(...await deps.io.udpExchange({
|
|
1161
|
+
payload,
|
|
1162
|
+
targets: [{
|
|
1163
|
+
host: send.host,
|
|
1164
|
+
port
|
|
1165
|
+
}],
|
|
1166
|
+
...send.localAddress !== void 0 ? { localAddress: send.localAddress } : {},
|
|
1167
|
+
...listenPort !== void 0 ? { bindPort: listenPort } : {},
|
|
1168
|
+
broadcast: true,
|
|
1169
|
+
resendAtMs: UNICAST_RESEND_AT_MS,
|
|
1170
|
+
listenMs: UNICAST_LISTEN_MS
|
|
1171
|
+
}));
|
|
1172
|
+
}
|
|
1173
|
+
for (const reply of replies) for (const entry of group) emit(c, entry, {
|
|
1174
|
+
host: reply.host,
|
|
1175
|
+
port: reply.port,
|
|
1176
|
+
udp: { payloadHex: reply.data.toString("hex") }
|
|
1177
|
+
});
|
|
1178
|
+
}
|
|
1179
|
+
}
|
|
1180
|
+
function probeKey(m) {
|
|
1181
|
+
return [
|
|
1182
|
+
m.port,
|
|
1183
|
+
m.method,
|
|
1184
|
+
m.path,
|
|
1185
|
+
m.tls,
|
|
1186
|
+
m.contentType ?? "",
|
|
1187
|
+
m.bodyText ?? ""
|
|
1188
|
+
].join("|");
|
|
1189
|
+
}
|
|
1190
|
+
async function runHttpSweep(deps, entries, subnets, c) {
|
|
1191
|
+
if (entries.length === 0) return;
|
|
1192
|
+
const probes = /* @__PURE__ */ new Map();
|
|
1193
|
+
for (const entry of entries) {
|
|
1194
|
+
const key = probeKey(entry.mode);
|
|
1195
|
+
probes.set(key, [...probes.get(key) ?? [], entry]);
|
|
1196
|
+
}
|
|
1197
|
+
const stats = bucket(c, "http-probe");
|
|
1198
|
+
await pool(subnets.hosts, 64, async (host) => {
|
|
1199
|
+
for (const group of probes.values()) {
|
|
1200
|
+
const mode = group[0]?.mode;
|
|
1201
|
+
if (mode === void 0) continue;
|
|
1202
|
+
const request = {
|
|
1203
|
+
host,
|
|
1204
|
+
port: mode.port,
|
|
1205
|
+
path: mode.path,
|
|
1206
|
+
method: mode.method,
|
|
1207
|
+
tls: mode.tls,
|
|
1208
|
+
timeoutMs: SCAN_REQUEST_TIMEOUT_MS,
|
|
1209
|
+
...mode.bodyText !== void 0 ? { bodyText: mode.bodyText } : {},
|
|
1210
|
+
...mode.contentType !== void 0 ? { contentType: mode.contentType } : {}
|
|
1211
|
+
};
|
|
1212
|
+
stats.probed += 1;
|
|
1213
|
+
const outcome = await deps.io.httpProbe(request);
|
|
1214
|
+
if (outcome.kind === "timeout") stats.timeouts += 1;
|
|
1215
|
+
if (outcome.kind !== "response") continue;
|
|
1216
|
+
for (const entry of group) {
|
|
1217
|
+
const accept = entry.mode.acceptStatus;
|
|
1218
|
+
if (accept !== void 0 && !accept.includes(outcome.status)) continue;
|
|
1219
|
+
emit(c, entry, {
|
|
1220
|
+
host,
|
|
1221
|
+
port: mode.port,
|
|
1222
|
+
http: {
|
|
1223
|
+
status: outcome.status,
|
|
1224
|
+
headers: outcome.headers,
|
|
1225
|
+
bodyText: outcome.bodyText.slice(0, MAX_HIT_BODY_BYTES)
|
|
1226
|
+
}
|
|
1227
|
+
});
|
|
1228
|
+
}
|
|
1229
|
+
}
|
|
1230
|
+
});
|
|
1231
|
+
}
|
|
1232
|
+
/** Why a family of modes failed, without taking the others down with it. */
|
|
1233
|
+
async function guarded(c, kind, work) {
|
|
1234
|
+
try {
|
|
1235
|
+
await work();
|
|
1236
|
+
} catch (err) {
|
|
1237
|
+
c.errors.push({
|
|
1238
|
+
mode: kind,
|
|
1239
|
+
message: err instanceof Error ? err.message : String(err)
|
|
1240
|
+
});
|
|
1241
|
+
}
|
|
1242
|
+
}
|
|
1243
|
+
async function runScan(deps, input) {
|
|
1244
|
+
const startedAt = Date.now();
|
|
1245
|
+
const subnets = resolveScanSubnets({
|
|
1246
|
+
interfaces: deps.interfaces(),
|
|
1247
|
+
saved: deps.savedSubnets(),
|
|
1248
|
+
perCall: input.subnets ?? []
|
|
1249
|
+
});
|
|
1250
|
+
const c = {
|
|
1251
|
+
hits: [],
|
|
1252
|
+
errors: [],
|
|
1253
|
+
stats: /* @__PURE__ */ new Map()
|
|
1254
|
+
};
|
|
1255
|
+
await Promise.all([
|
|
1256
|
+
guarded(c, "mdns", () => runMdns(deps, entriesOf(input.requests, "mdns"), subnets, c)),
|
|
1257
|
+
guarded(c, "ws-discovery", () => runWsDiscovery(deps, entriesOf(input.requests, "ws-discovery"), subnets, c)),
|
|
1258
|
+
guarded(c, "ssdp", () => runSsdp(deps, entriesOf(input.requests, "ssdp"), subnets, c)),
|
|
1259
|
+
guarded(c, "udp-broadcast", () => runUdpBroadcast(deps, entriesOf(input.requests, "udp-broadcast"), subnets, c)),
|
|
1260
|
+
guarded(c, "http-probe", () => runHttpSweep(deps, entriesOf(input.requests, "http-probe"), subnets, c))
|
|
1261
|
+
]);
|
|
1262
|
+
const byMode = Object.fromEntries(c.stats);
|
|
1263
|
+
const stats = {
|
|
1264
|
+
hostsProbed: byMode["http-probe"] === void 0 ? 0 : subnets.hosts.length,
|
|
1265
|
+
hits: c.hits.length,
|
|
1266
|
+
timeouts: [...c.stats.values()].reduce((n, s) => n + s.timeouts, 0),
|
|
1267
|
+
byMode
|
|
1268
|
+
};
|
|
1269
|
+
deps.logger.info("local-network: scan finished", { meta: {
|
|
1270
|
+
providers: input.requests.length,
|
|
1271
|
+
subnets: subnets.all.map((s) => s.cidr),
|
|
1272
|
+
hostsProbed: stats.hostsProbed,
|
|
1273
|
+
hits: stats.hits,
|
|
1274
|
+
timeouts: stats.timeouts,
|
|
1275
|
+
errors: c.errors.length,
|
|
1276
|
+
byMode,
|
|
1277
|
+
hitsBySubnet: hitsBySubnet(subnets, c.hits),
|
|
1278
|
+
ms: Date.now() - startedAt
|
|
1279
|
+
} });
|
|
1280
|
+
return {
|
|
1281
|
+
hits: c.hits,
|
|
1282
|
+
subnetsScanned: subnets.all.map((s) => s.cidr),
|
|
1283
|
+
errors: c.errors,
|
|
1284
|
+
stats
|
|
1285
|
+
};
|
|
1286
|
+
}
|
|
1287
|
+
//#endregion
|
|
1288
|
+
//#region src/builtins/local-network/scan/scan-io-node.ts
|
|
1289
|
+
/** The real {@link ScanIo}: node `dgram`, `http` and `https`. Not unit-tested; the engine is. */
|
|
1290
|
+
function udpExchange(request) {
|
|
1291
|
+
return new Promise((resolve, reject) => {
|
|
1292
|
+
const socket = createSocket({
|
|
1293
|
+
type: "udp4",
|
|
1294
|
+
reuseAddr: true
|
|
1295
|
+
});
|
|
1296
|
+
const replies = [];
|
|
1297
|
+
let settled = false;
|
|
1298
|
+
const finish = (error) => {
|
|
1299
|
+
if (settled) return;
|
|
1300
|
+
settled = true;
|
|
1301
|
+
try {
|
|
1302
|
+
socket.close();
|
|
1303
|
+
} catch {}
|
|
1304
|
+
if (error !== null) reject(error);
|
|
1305
|
+
else resolve(replies);
|
|
1306
|
+
};
|
|
1307
|
+
socket.on("error", (err) => finish(err));
|
|
1308
|
+
socket.on("message", (data, rinfo) => {
|
|
1309
|
+
replies.push({
|
|
1310
|
+
host: rinfo.address,
|
|
1311
|
+
port: rinfo.port,
|
|
1312
|
+
data
|
|
1313
|
+
});
|
|
1314
|
+
});
|
|
1315
|
+
socket.bind(request.bindPort ?? 0, request.localAddress ?? void 0, () => {
|
|
1316
|
+
try {
|
|
1317
|
+
if (request.broadcast === true) socket.setBroadcast(true);
|
|
1318
|
+
if (request.localAddress !== void 0) socket.setMulticastInterface(request.localAddress);
|
|
1319
|
+
} catch (err) {
|
|
1320
|
+
finish(err instanceof Error ? err : new Error(String(err)));
|
|
1321
|
+
return;
|
|
1322
|
+
}
|
|
1323
|
+
const burst = () => {
|
|
1324
|
+
if (settled) return;
|
|
1325
|
+
for (const target of request.targets) socket.send(request.payload, target.port, target.host, () => {});
|
|
1326
|
+
};
|
|
1327
|
+
burst();
|
|
1328
|
+
for (const offset of request.resendAtMs ?? []) setTimeout(burst, offset);
|
|
1329
|
+
setTimeout(() => finish(null), request.listenMs);
|
|
1330
|
+
});
|
|
1331
|
+
});
|
|
1332
|
+
}
|
|
1333
|
+
function httpProbe(request) {
|
|
1334
|
+
return new Promise((resolve) => {
|
|
1335
|
+
const transport = request.tls ? https : http;
|
|
1336
|
+
let settled = false;
|
|
1337
|
+
const done = (outcome) => {
|
|
1338
|
+
if (settled) return;
|
|
1339
|
+
settled = true;
|
|
1340
|
+
resolve(outcome);
|
|
1341
|
+
};
|
|
1342
|
+
const body = request.bodyText;
|
|
1343
|
+
const req = transport.request({
|
|
1344
|
+
host: request.host,
|
|
1345
|
+
port: request.port,
|
|
1346
|
+
path: request.path,
|
|
1347
|
+
method: request.method,
|
|
1348
|
+
timeout: request.timeoutMs,
|
|
1349
|
+
...request.tls ? { rejectUnauthorized: false } : {},
|
|
1350
|
+
headers: {
|
|
1351
|
+
...request.contentType !== void 0 ? { "content-type": request.contentType } : {},
|
|
1352
|
+
...body !== void 0 ? { "content-length": Buffer.byteLength(body) } : {}
|
|
1353
|
+
}
|
|
1354
|
+
}, (res) => {
|
|
1355
|
+
const chunks = [];
|
|
1356
|
+
let size = 0;
|
|
1357
|
+
const finish = () => {
|
|
1358
|
+
const headers = {};
|
|
1359
|
+
for (const [k, v] of Object.entries(res.headers)) if (typeof v === "string") headers[k.toLowerCase()] = v;
|
|
1360
|
+
else if (Array.isArray(v)) headers[k.toLowerCase()] = v.join(", ");
|
|
1361
|
+
done({
|
|
1362
|
+
kind: "response",
|
|
1363
|
+
status: res.statusCode ?? 0,
|
|
1364
|
+
headers,
|
|
1365
|
+
bodyText: Buffer.concat(chunks).toString("utf8")
|
|
1366
|
+
});
|
|
1367
|
+
};
|
|
1368
|
+
res.on("data", (chunk) => {
|
|
1369
|
+
chunks.push(chunk.subarray(0, MAX_HIT_BODY_BYTES - size));
|
|
1370
|
+
size += chunk.length;
|
|
1371
|
+
if (size >= 16384) {
|
|
1372
|
+
finish();
|
|
1373
|
+
req.destroy();
|
|
1374
|
+
}
|
|
1375
|
+
});
|
|
1376
|
+
res.on("end", finish);
|
|
1377
|
+
res.on("error", () => done({ kind: "unreachable" }));
|
|
1378
|
+
});
|
|
1379
|
+
req.on("timeout", () => {
|
|
1380
|
+
done({ kind: "timeout" });
|
|
1381
|
+
req.destroy();
|
|
1382
|
+
});
|
|
1383
|
+
req.on("error", () => done({ kind: "unreachable" }));
|
|
1384
|
+
if (body !== void 0) req.write(body);
|
|
1385
|
+
req.end();
|
|
1386
|
+
});
|
|
1387
|
+
}
|
|
1388
|
+
var nodeScanIo = {
|
|
1389
|
+
udpExchange,
|
|
1390
|
+
httpProbe
|
|
1391
|
+
};
|
|
1392
|
+
//#endregion
|
|
1393
|
+
//#region src/builtins/local-network/local-network.addon.ts
|
|
1394
|
+
/**
|
|
1395
|
+
* local-network — hub-only system cap implementation.
|
|
1396
|
+
*
|
|
1397
|
+
* Wraps `os.networkInterfaces()` with:
|
|
1398
|
+
* - Coarse kind classification (lan/wifi/docker/vpn/loopback/other)
|
|
1399
|
+
* - Auto-select heuristic for the outbound interface
|
|
1400
|
+
* - Periodic poll (30s) + diff to emit `LocalNetworkChanged` events
|
|
1401
|
+
* so subscribers can react to DHCP renewals, VPN connect, etc.
|
|
1402
|
+
* - `getConnectionEndpoints()` — ranked URL list for SDK clients
|
|
1403
|
+
*
|
|
1404
|
+
* Does NOT poll the cloudflare-tunnel state directly; the public
|
|
1405
|
+
* tunnel hostname (if any) is provided by `network-access` consumers
|
|
1406
|
+
* via `NetworkTunnelStarted/Stopped` events on the bus, so the cap
|
|
1407
|
+
* stays free of cross-addon dependencies.
|
|
1408
|
+
*/
|
|
1409
|
+
/**
|
|
1410
|
+
* Forked `mesh-network` provider addon ids `local-network` pull-reconciles
|
|
1411
|
+
* against. `mesh-network` is a COLLECTION cap, so a hub builtin's local
|
|
1412
|
+
* registry can't enumerate forked providers — we resolve each by addonId
|
|
1413
|
+
* via `getProviderByAddon`. New mesh providers (Headscale, ZeroTier) add
|
|
1414
|
+
* their id here.
|
|
1415
|
+
*/
|
|
1416
|
+
var MESH_PROVIDER_ADDON_IDS = ["tailscale-client"];
|
|
1417
|
+
var POLL_INTERVAL_MS = 3e4;
|
|
1418
|
+
/** Drop rotated IPv6 / dead extras from the persisted allowlist. */
|
|
1419
|
+
var ALLOWLIST_RECONCILE_INTERVAL_MS = 3600 * 1e3;
|
|
1420
|
+
/**
|
|
1421
|
+
* Compiled-in boot default — mirrors `CONFIG_DEFAULTS.server.port` in
|
|
1422
|
+
* `server/backend/src/boot/boot-config.ts`. Used only when neither the live
|
|
1423
|
+
* config section, the env, nor the caller says anything.
|
|
1424
|
+
*/
|
|
1425
|
+
var DEFAULT_HUB_PORT = 4443;
|
|
1426
|
+
var LocalNetworkAddon = class extends BaseAddon {
|
|
1427
|
+
pollTimer = null;
|
|
1428
|
+
allowlistTimer = null;
|
|
1429
|
+
allowlistReconcilePending = false;
|
|
1430
|
+
lastSnapshotKey = "";
|
|
1431
|
+
/** Optional public hostname tracked from `NetworkTunnelStarted`/
|
|
1432
|
+
* `Stopped` events on the bus. */
|
|
1433
|
+
publicHostname = "";
|
|
1434
|
+
/** False for a Quick tunnel: shown in the palette, never picked automatically (D860). */
|
|
1435
|
+
publicHostnameStable = true;
|
|
1436
|
+
/**
|
|
1437
|
+
* Mesh-reachable endpoint (Tailscale MagicDNS / 100.x), learned from
|
|
1438
|
+
* the `MeshNetworkChanged` event-tail and refreshed by a pull-reconcile
|
|
1439
|
+
* before each `getConnectionEndpoints` build (events are lossy — D8).
|
|
1440
|
+
* `null` when no mesh provider is joined.
|
|
1441
|
+
*/
|
|
1442
|
+
meshEndpoint = null;
|
|
1443
|
+
mdns = null;
|
|
1444
|
+
constructor() {
|
|
1445
|
+
super({
|
|
1446
|
+
allowedAddresses: [],
|
|
1447
|
+
bootSeeded: false,
|
|
1448
|
+
notificationTapUrl: "",
|
|
1449
|
+
appConnectionUrls: [],
|
|
1450
|
+
customAddresses: [],
|
|
1451
|
+
httpEnabled: true,
|
|
1452
|
+
httpPort: DEFAULT_LAN_HTTP_PORT,
|
|
1453
|
+
tlsEnabled: true,
|
|
1454
|
+
localHostname: "",
|
|
1455
|
+
internalUrl: "",
|
|
1456
|
+
publicEndpointUrl: "",
|
|
1457
|
+
mdnsAdvertise: true,
|
|
1458
|
+
scanSubnets: []
|
|
1459
|
+
});
|
|
1460
|
+
}
|
|
1461
|
+
/**
|
|
1462
|
+
* The detected palettes, with the mesh reconciled once: `https` (what
|
|
1463
|
+
* `internal` and `publicEndpoint` resolve over, and the app link's `hub=`)
|
|
1464
|
+
* and `http` (what the app-connections race resolves over).
|
|
1465
|
+
*/
|
|
1466
|
+
async palettes() {
|
|
1467
|
+
const port = (await this.resolveAdvertisedListenPort(null)).port;
|
|
1468
|
+
await this.reconcileMeshEndpoint();
|
|
1469
|
+
const http = this.endpointsNow(false, false, "http", port);
|
|
1470
|
+
const https = this.endpointsNow(false, false, "https", port);
|
|
1471
|
+
return {
|
|
1472
|
+
http,
|
|
1473
|
+
https,
|
|
1474
|
+
httpWithTwins: withLanHttpsCounterparts(http, port),
|
|
1475
|
+
httpsWithTwins: withLanHttpsCounterparts(https, port)
|
|
1476
|
+
};
|
|
1477
|
+
}
|
|
1478
|
+
/** The stored address book, normalised against what is detected now. */
|
|
1479
|
+
addressState(detected) {
|
|
1480
|
+
return normalizeAddressBook(this.config, new Set(detected.map((e) => e.baseUrl)));
|
|
1481
|
+
}
|
|
1482
|
+
/** The role flags alone — they do not depend on what is detected. */
|
|
1483
|
+
storedFlags() {
|
|
1484
|
+
return normalizeAddressBook(this.config, /* @__PURE__ */ new Set()).flags;
|
|
1485
|
+
}
|
|
1486
|
+
/** `getAddresses`: the Addresses table and every role's answer. */
|
|
1487
|
+
async addressBook(scheme) {
|
|
1488
|
+
const { http, https, httpWithTwins, httpsWithTwins } = await this.palettes();
|
|
1489
|
+
const state = this.addressState([...httpWithTwins, ...httpsWithTwins]);
|
|
1490
|
+
const httpsPort = (await this.resolveAdvertisedListenPort(null)).port;
|
|
1491
|
+
return buildAddressBook(state, {
|
|
1492
|
+
rowsPalette: scheme === "http" ? httpWithTwins : httpsWithTwins,
|
|
1493
|
+
httpsPalette: https,
|
|
1494
|
+
appLink: appLinkEndpoint(),
|
|
1495
|
+
appLinkHub: pickAppLinkHub(https),
|
|
1496
|
+
listenerOrigins: this.listenerOriginsNow(state, http, httpsPort)
|
|
1497
|
+
});
|
|
1498
|
+
}
|
|
1499
|
+
/**
|
|
1500
|
+
* Apply one change to the address book and persist it, normalised (a flag
|
|
1501
|
+
* naming an address in no row becomes a custom address in the same write).
|
|
1502
|
+
*/
|
|
1503
|
+
async changeAddressBook(change) {
|
|
1504
|
+
const { httpWithTwins, httpsWithTwins } = await this.palettes();
|
|
1505
|
+
const detected = [...httpWithTwins, ...httpsWithTwins];
|
|
1506
|
+
const detectedUrls = new Set(detected.map((e) => e.baseUrl));
|
|
1507
|
+
const changed = change(this.addressState(detected), {
|
|
1508
|
+
detectedUrls,
|
|
1509
|
+
autoApp: [...new Set(detected.filter(isDefaultAppConnectionEndpoint).map((e) => e.baseUrl))]
|
|
1510
|
+
});
|
|
1511
|
+
const after = normalizeAddressBook({
|
|
1512
|
+
...addressBookPatch(changed),
|
|
1513
|
+
customAddresses: changed.custom
|
|
1514
|
+
}, detectedUrls);
|
|
1515
|
+
await this.updateGlobalSettings(addressBookPatch(after));
|
|
1516
|
+
await this.mdns?.sync();
|
|
1517
|
+
}
|
|
1518
|
+
/** The deprecated `getHubAddresses` shape, from the role resolvers. */
|
|
1519
|
+
async snapshotHubAddresses() {
|
|
1520
|
+
const { roles } = await this.addressBook("https");
|
|
1521
|
+
const legacy = (r) => ({
|
|
1522
|
+
override: r.flagged,
|
|
1523
|
+
resolved: r.resolved,
|
|
1524
|
+
source: r.source === "flagged" ? "override" : r.source
|
|
1525
|
+
});
|
|
1526
|
+
return {
|
|
1527
|
+
cluster: legacy(roles.internal),
|
|
1528
|
+
browser: legacy(roles.publicEndpoint)
|
|
1529
|
+
};
|
|
1530
|
+
}
|
|
1531
|
+
/**
|
|
1532
|
+
* Flag / unflag `baseUrl` for `role`, or (`baseUrl: null`) return the role
|
|
1533
|
+
* to automatic. Validated: the address must be a row (detected, custom, or
|
|
1534
|
+
* the app link for `notificationTaps`), never loopback, and
|
|
1535
|
+
* `publicEndpoint` on plain http only when accepted. A refusal stores nothing.
|
|
1536
|
+
*/
|
|
1537
|
+
async setRole(role, baseUrl, enabled, acceptInsecureHttp) {
|
|
1538
|
+
if (baseUrl === null || baseUrl.trim() === "" && role !== "appConnections") {
|
|
1539
|
+
await this.changeAddressBook((state) => withRoleAutomatic(state, role));
|
|
1540
|
+
this.ctx.logger.info("local-network: address role set to automatic", { meta: { role } });
|
|
1541
|
+
return;
|
|
1542
|
+
}
|
|
1543
|
+
let target = baseUrl.trim();
|
|
1544
|
+
if (enabled) {
|
|
1545
|
+
const check = checkRoleAddress(role, target, { acceptInsecureHttp });
|
|
1546
|
+
if (!check.ok) throw new Error(check.reason);
|
|
1547
|
+
target = check.baseUrl;
|
|
1548
|
+
}
|
|
1549
|
+
await this.changeAddressBook((state, ctx) => {
|
|
1550
|
+
const known = isAppLinkBase(target) || ctx.detectedUrls.has(target) || state.custom.some((c) => c.baseUrl === target);
|
|
1551
|
+
if (enabled && !known && role !== "notificationTaps") throw new Error(`${target} is not in the address list — add it as a custom address first.`);
|
|
1552
|
+
return withRoleFlag(state, role, target, enabled, ctx.autoApp);
|
|
1553
|
+
});
|
|
1554
|
+
this.ctx.logger.info("local-network: address role set", { meta: {
|
|
1555
|
+
role,
|
|
1556
|
+
baseUrl: target,
|
|
1557
|
+
enabled
|
|
1558
|
+
} });
|
|
1559
|
+
}
|
|
1560
|
+
async notificationEndpointSnapshot() {
|
|
1561
|
+
const resolution = resolveNotificationTapAddress(this.storedFlags());
|
|
1562
|
+
const port = (await this.resolveAdvertisedListenPort(null)).port;
|
|
1563
|
+
return {
|
|
1564
|
+
baseUrl: resolution.flagged,
|
|
1565
|
+
resolved: resolution.resolved,
|
|
1566
|
+
appLinkHub: pickAppLinkHub(await this.buildAdvertisedEndpoints(false, false, "https", port))
|
|
1567
|
+
};
|
|
1568
|
+
}
|
|
1569
|
+
async snapshotViewerEndpoints() {
|
|
1570
|
+
const resolution = resolveAppConnections(await this.buildAdvertisedEndpoints(false, false, "http", (await this.resolveAdvertisedListenPort(null)).port), this.storedFlags());
|
|
1571
|
+
return {
|
|
1572
|
+
baseUrls: resolution.flagged,
|
|
1573
|
+
resolved: resolution.resolved
|
|
1574
|
+
};
|
|
1575
|
+
}
|
|
1576
|
+
/**
|
|
1577
|
+
* Palette shown to clients: LAN IPv4, stable LAN IPv6, public, mesh, and
|
|
1578
|
+
* the custom addresses flagged `appConnections` (`kind: 'custom'`). The app
|
|
1579
|
+
* HTTP/WS race is a subset (`selectAppConnectionEndpoints`) — IPv6 stays in this
|
|
1580
|
+
* list because ICE/WebRTC gathers it regardless.
|
|
1581
|
+
*/
|
|
1582
|
+
async buildAdvertisedEndpoints(includeLoopback, ipv4Only, scheme, httpsPort) {
|
|
1583
|
+
await this.reconcileMeshEndpoint();
|
|
1584
|
+
const detected = withLanHttpsCounterparts(this.endpointsNow(includeLoopback, ipv4Only, scheme, httpsPort), httpsPort);
|
|
1585
|
+
return withAppConnectionCustomEndpoints(detected, this.addressState(detected));
|
|
1586
|
+
}
|
|
1587
|
+
/**
|
|
1588
|
+
* Where the listeners answer, whatever the rows advertise: the HTTPS
|
|
1589
|
+
* listener's origin per allowlisted LAN address, the HTTP one while it is
|
|
1590
|
+
* on (`http` is the palette that already carries those rows).
|
|
1591
|
+
*/
|
|
1592
|
+
listenerOriginsNow(state, http, httpsPort) {
|
|
1593
|
+
const httpListening = this.config.httpEnabled !== false && readLanHttpState().listening;
|
|
1594
|
+
const hostname = this.config.localHostname || null;
|
|
1595
|
+
const localNameOrigins = hostname === null ? [] : [`https://${hostname}:${httpsPort}`, ...httpListening ? [`http://${hostname}:${this.resolvedHttpPort()}`] : []];
|
|
1596
|
+
return buildListenerOrigins({
|
|
1597
|
+
overHttps: this.endpointsNow(false, false, "https", httpsPort, false),
|
|
1598
|
+
overHttp: httpListening ? http : [],
|
|
1599
|
+
custom: state.custom,
|
|
1600
|
+
localNameOrigins
|
|
1601
|
+
});
|
|
1602
|
+
}
|
|
1603
|
+
/** The DETECTED palette from the cached interface/tunnel/mesh state. */
|
|
1604
|
+
endpointsNow(includeLoopback, ipv4Only, scheme, httpsPort, advertiseLanHttp = true) {
|
|
1605
|
+
const interfaces = applyAllowlist(this.enumerate(), this.config.allowedAddresses);
|
|
1606
|
+
const httpState = readLanHttpState();
|
|
1607
|
+
return buildEndpoints(interfaces, httpsPort, includeLoopback, ipv4Only, this.publicHostname, scheme, this.meshEndpoint, advertiseLanHttp ? {
|
|
1608
|
+
enabled: this.config.httpEnabled !== false,
|
|
1609
|
+
listening: httpState.listening,
|
|
1610
|
+
httpPort: this.resolvedHttpPort(),
|
|
1611
|
+
httpsPort,
|
|
1612
|
+
localHostname: this.config.localHostname || null
|
|
1613
|
+
} : null, this.publicHostnameStable);
|
|
1614
|
+
}
|
|
1615
|
+
async onInitialize() {
|
|
1616
|
+
if (!this.config.bootSeeded) {
|
|
1617
|
+
const seed = autoSeedAllowlist(this.enumerate());
|
|
1618
|
+
await this.updateGlobalSettings({
|
|
1619
|
+
allowedAddresses: seed,
|
|
1620
|
+
bootSeeded: true
|
|
1621
|
+
});
|
|
1622
|
+
this.ctx.logger.info("local-network: first-boot auto-seed", { meta: { addresses: seed } });
|
|
1623
|
+
}
|
|
1624
|
+
await this.persistReconciledAllowlist();
|
|
1625
|
+
const provider = {
|
|
1626
|
+
list: async () => ({
|
|
1627
|
+
interfaces: this.enumerate(),
|
|
1628
|
+
probedAt: Date.now()
|
|
1629
|
+
}),
|
|
1630
|
+
getPreferred: async () => pickPreferred(applyAllowlist(this.enumerate(), this.config.allowedAddresses)),
|
|
1631
|
+
getConnectionEndpoints: async (input) => {
|
|
1632
|
+
const includeLoopback = input.includeLoopback ?? false;
|
|
1633
|
+
const scheme = input.scheme ?? "http";
|
|
1634
|
+
const localPort = await this.resolveAdvertisedListenPort(input.port ?? null);
|
|
1635
|
+
if (input.port !== void 0 && input.port !== localPort.port) this.ctx.logger.info("local-network: caller port hint overridden", { meta: {
|
|
1636
|
+
hint: input.port,
|
|
1637
|
+
advertised: localPort.port,
|
|
1638
|
+
source: localPort.source
|
|
1639
|
+
} });
|
|
1640
|
+
const endpoints = await this.buildAdvertisedEndpoints(includeLoopback, input.ipv4Only ?? false, scheme, localPort.port);
|
|
1641
|
+
return {
|
|
1642
|
+
endpoints: input.includeAppLink === true ? [appLinkEndpoint(), ...endpoints] : endpoints,
|
|
1643
|
+
localPort
|
|
1644
|
+
};
|
|
1645
|
+
},
|
|
1646
|
+
getNotificationEndpoint: async () => this.notificationEndpointSnapshot(),
|
|
1647
|
+
setNotificationEndpoint: async ({ baseUrl }) => {
|
|
1648
|
+
await this.setRole("notificationTaps", baseUrl, true, false);
|
|
1649
|
+
return this.notificationEndpointSnapshot();
|
|
1650
|
+
},
|
|
1651
|
+
getViewerEndpoints: async () => this.snapshotViewerEndpoints(),
|
|
1652
|
+
setViewerEndpoints: async ({ baseUrls }) => {
|
|
1653
|
+
const appConnections = [...new Set(baseUrls.filter((u) => u.length > 0))];
|
|
1654
|
+
await this.changeAddressBook((state) => ({
|
|
1655
|
+
...state,
|
|
1656
|
+
flags: {
|
|
1657
|
+
...state.flags,
|
|
1658
|
+
appConnections
|
|
1659
|
+
}
|
|
1660
|
+
}));
|
|
1661
|
+
this.ctx.logger.info("local-network: app connections set", { meta: {
|
|
1662
|
+
count: appConnections.length,
|
|
1663
|
+
auto: appConnections.length === 0
|
|
1664
|
+
} });
|
|
1665
|
+
return this.snapshotViewerEndpoints();
|
|
1666
|
+
},
|
|
1667
|
+
getAddresses: async (input) => this.addressBook(input?.scheme ?? "https"),
|
|
1668
|
+
addCustomAddress: async ({ baseUrl, label }) => {
|
|
1669
|
+
const check = validateCustomAddress(baseUrl);
|
|
1670
|
+
if (!check.ok) throw new Error(check.reason);
|
|
1671
|
+
const entry = {
|
|
1672
|
+
baseUrl: check.baseUrl,
|
|
1673
|
+
label: label.trim()
|
|
1674
|
+
};
|
|
1675
|
+
await this.changeAddressBook((state) => withCustomAddress(state, entry));
|
|
1676
|
+
this.ctx.logger.info("local-network: custom address added", { meta: {
|
|
1677
|
+
baseUrl: entry.baseUrl,
|
|
1678
|
+
label: entry.label
|
|
1679
|
+
} });
|
|
1680
|
+
return this.addressBook("https");
|
|
1681
|
+
},
|
|
1682
|
+
removeCustomAddress: async ({ baseUrl }) => {
|
|
1683
|
+
await this.changeAddressBook((state) => withoutCustomAddress(state, baseUrl));
|
|
1684
|
+
this.ctx.logger.info("local-network: custom address removed", { meta: { baseUrl } });
|
|
1685
|
+
return this.addressBook("https");
|
|
1686
|
+
},
|
|
1687
|
+
setAddressRole: async ({ role, baseUrl, enabled, acceptInsecureHttp }) => {
|
|
1688
|
+
await this.setRole(role, baseUrl, enabled, acceptInsecureHttp === true);
|
|
1689
|
+
return this.addressBook("https");
|
|
1690
|
+
},
|
|
1691
|
+
getHubAddresses: async () => this.snapshotHubAddresses(),
|
|
1692
|
+
getAllowedAddresses: async () => ({ addresses: this.config.allowedAddresses }),
|
|
1693
|
+
resetAllowlistToBestMatch: async () => {
|
|
1694
|
+
const seed = autoSeedAllowlist(this.enumerate());
|
|
1695
|
+
await this.updateGlobalSettings({
|
|
1696
|
+
allowedAddresses: seed,
|
|
1697
|
+
bootSeeded: true
|
|
1698
|
+
});
|
|
1699
|
+
this.ctx.logger.info("local-network: allowlist reset to auto-seed", { meta: { count: seed.length } });
|
|
1700
|
+
return { addresses: seed };
|
|
1701
|
+
},
|
|
1702
|
+
setAllowedAddresses: async ({ addresses }) => {
|
|
1703
|
+
const known = new Set(this.enumerate().map((i) => i.address));
|
|
1704
|
+
const cleaned = [...new Set(addresses)].filter((a) => known.has(a));
|
|
1705
|
+
await this.updateGlobalSettings({ allowedAddresses: cleaned });
|
|
1706
|
+
this.ctx.logger.info("local-network: allowlist updated", { meta: {
|
|
1707
|
+
count: cleaned.length,
|
|
1708
|
+
dropped: addresses.length - cleaned.length
|
|
1709
|
+
} });
|
|
1710
|
+
return { success: true };
|
|
1711
|
+
},
|
|
1712
|
+
scanNetwork: async (input) => runScan({
|
|
1713
|
+
io: nodeScanIo,
|
|
1714
|
+
interfaces: () => this.enumerate(),
|
|
1715
|
+
savedSubnets: () => this.config.scanSubnets,
|
|
1716
|
+
logger: this.ctx.logger
|
|
1717
|
+
}, input),
|
|
1718
|
+
getScanSubnets: async () => ({ subnets: [...this.config.scanSubnets] }),
|
|
1719
|
+
setScanSubnets: async ({ subnets }) => {
|
|
1720
|
+
const cleaned = [...validateSavedSubnets(subnets)];
|
|
1721
|
+
await this.updateGlobalSettings({ scanSubnets: cleaned });
|
|
1722
|
+
this.ctx.logger.info("local-network: scan subnets updated", { meta: {
|
|
1723
|
+
count: cleaned.length,
|
|
1724
|
+
subnets: cleaned
|
|
1725
|
+
} });
|
|
1726
|
+
return { subnets: cleaned };
|
|
1727
|
+
},
|
|
1728
|
+
getTlsStatus: async () => this.snapshotTls(),
|
|
1729
|
+
regenerateCertificate: async (_input) => {
|
|
1730
|
+
const extraSans = [...readExtraSans(this.tlsDataDir())];
|
|
1731
|
+
await regenerateCertificate(this.tlsDataDir(), {
|
|
1732
|
+
extraSans,
|
|
1733
|
+
...await this.caHubName()
|
|
1734
|
+
});
|
|
1735
|
+
this.putCertificateOnListener("regenerate");
|
|
1736
|
+
return this.snapshotTls();
|
|
1737
|
+
},
|
|
1738
|
+
uploadCertificate: async ({ certPem, keyPem, caPem }) => {
|
|
1739
|
+
await storeUploadedCertificate(this.tlsDataDir(), {
|
|
1740
|
+
certPem,
|
|
1741
|
+
keyPem,
|
|
1742
|
+
caPem
|
|
1743
|
+
});
|
|
1744
|
+
this.putCertificateOnListener("upload");
|
|
1745
|
+
return this.snapshotTls();
|
|
1746
|
+
},
|
|
1747
|
+
useStoredUploadedCertificate: async () => {
|
|
1748
|
+
await useStoredUploadedCertificate(this.tlsDataDir());
|
|
1749
|
+
this.putCertificateOnListener("upload");
|
|
1750
|
+
return this.snapshotTls();
|
|
1751
|
+
},
|
|
1752
|
+
downloadCa: async () => {
|
|
1753
|
+
return { pem: this.snapshotTls().caCertPem ?? "" };
|
|
1754
|
+
},
|
|
1755
|
+
revertToGeneratedCertificate: async () => {
|
|
1756
|
+
const extraSans = [...readExtraSans(this.tlsDataDir())];
|
|
1757
|
+
await revertToGeneratedCertificate(this.tlsDataDir(), {
|
|
1758
|
+
extraSans,
|
|
1759
|
+
...await this.caHubName()
|
|
1760
|
+
});
|
|
1761
|
+
this.putCertificateOnListener("revert");
|
|
1762
|
+
return this.snapshotTls();
|
|
1763
|
+
}
|
|
1764
|
+
};
|
|
1765
|
+
this.lastSnapshotKey = snapshotKey(this.enumerate());
|
|
1766
|
+
this.pollTimer = setInterval(() => this.detectChanges(), POLL_INTERVAL_MS);
|
|
1767
|
+
this.pollTimer.unref?.();
|
|
1768
|
+
this.allowlistTimer = setInterval(() => {
|
|
1769
|
+
this.persistReconciledAllowlist();
|
|
1770
|
+
}, ALLOWLIST_RECONCILE_INTERVAL_MS);
|
|
1771
|
+
this.allowlistTimer.unref?.();
|
|
1772
|
+
this.ctx.eventBus?.subscribe({ category: EventCategory.NetworkTunnelStarted }, (event) => {
|
|
1773
|
+
const parsed = NetworkTunnelStartedDataSchema.safeParse(event.data ?? {});
|
|
1774
|
+
if (parsed.success) {
|
|
1775
|
+
const data = parsed.data;
|
|
1776
|
+
try {
|
|
1777
|
+
const hostname = new URL(data.url).hostname;
|
|
1778
|
+
if (hostname && !hostname.endsWith(".placeholder") && !hostname.startsWith("pending.")) this.setPublicHostname(hostname, data.stable !== false);
|
|
1779
|
+
} catch {}
|
|
1780
|
+
}
|
|
1781
|
+
});
|
|
1782
|
+
this.ctx.eventBus?.subscribe({ category: EventCategory.NetworkTunnelStopped }, () => this.setPublicHostname(""));
|
|
1783
|
+
this.ctx.eventBus?.subscribe({ category: EventCategory.MeshNetworkChanged }, (event) => {
|
|
1784
|
+
const data = event.data ?? {};
|
|
1785
|
+
const host = typeof data.host === "string" ? data.host : "";
|
|
1786
|
+
const port = typeof data.port === "number" ? data.port : 0;
|
|
1787
|
+
this.setMeshEndpoint(host && port > 0 ? {
|
|
1788
|
+
host,
|
|
1789
|
+
port
|
|
1790
|
+
} : null);
|
|
1791
|
+
});
|
|
1792
|
+
this.ctx.logger.info("local-network initialized", { meta: { interfaceCount: this.enumerate().length } });
|
|
1793
|
+
try {
|
|
1794
|
+
await this.applyLanAccessFromSettings();
|
|
1795
|
+
} catch (err) {
|
|
1796
|
+
this.ctx.logger.warn("local-network: LAN HTTP not applied at boot", { meta: { error: err instanceof Error ? err.message : String(err) } });
|
|
1797
|
+
}
|
|
1798
|
+
await this.applyMdnsAdvertisement();
|
|
1799
|
+
return [{
|
|
1800
|
+
capability: localNetworkCapability,
|
|
1801
|
+
provider
|
|
1802
|
+
}];
|
|
1803
|
+
}
|
|
1804
|
+
globalSettingsSchema() {
|
|
1805
|
+
return this.schema({ sections: [{
|
|
1806
|
+
id: "local-access",
|
|
1807
|
+
title: "LAN HTTP",
|
|
1808
|
+
titleKey: "server:globalSettings.s_local-access.title",
|
|
1809
|
+
description: "Native apps on this Wi-Fi use http:// and skip the private certificate. The tunnel and this admin UI stay on HTTPS. Turn off once a publicly-trusted certificate covers the LAN name.",
|
|
1810
|
+
descriptionKey: "server:globalSettings.s_local-access.description",
|
|
1811
|
+
columns: 1,
|
|
1812
|
+
fields: [
|
|
1813
|
+
this.field({
|
|
1814
|
+
type: "boolean",
|
|
1815
|
+
key: "httpEnabled",
|
|
1816
|
+
label: "Enable HTTP on the LAN",
|
|
1817
|
+
labelKey: "server:globalSettings.s_local-access.httpEnabled.label",
|
|
1818
|
+
style: "switch",
|
|
1819
|
+
default: true
|
|
1820
|
+
}),
|
|
1821
|
+
this.field({
|
|
1822
|
+
type: "number",
|
|
1823
|
+
key: "httpPort",
|
|
1824
|
+
label: "HTTP port",
|
|
1825
|
+
labelKey: "server:globalSettings.s_local-access.httpPort.label",
|
|
1826
|
+
description: "Dedicated listener. Must not equal the HTTPS port (4443 by default).",
|
|
1827
|
+
descriptionKey: "server:globalSettings.s_local-access.httpPort.description",
|
|
1828
|
+
min: 1,
|
|
1829
|
+
max: 65535,
|
|
1830
|
+
step: 1,
|
|
1831
|
+
default: DEFAULT_LAN_HTTP_PORT,
|
|
1832
|
+
showWhen: {
|
|
1833
|
+
field: "httpEnabled",
|
|
1834
|
+
equals: true
|
|
1835
|
+
}
|
|
1836
|
+
}),
|
|
1837
|
+
this.field({
|
|
1838
|
+
type: "boolean",
|
|
1839
|
+
key: "tlsEnabled",
|
|
1840
|
+
label: "Serve HTTPS",
|
|
1841
|
+
labelKey: "server:globalSettings.s_local-access.tlsEnabled.label",
|
|
1842
|
+
description: "On by default. Turn off only behind a reverse proxy that terminates TLS for you: browsers refuse passkeys, the camera and the microphone over plain HTTP. Applies after the hub restarts.",
|
|
1843
|
+
descriptionKey: "server:globalSettings.s_local-access.tlsEnabled.description",
|
|
1844
|
+
style: "switch",
|
|
1845
|
+
default: true
|
|
1846
|
+
}),
|
|
1847
|
+
this.field({
|
|
1848
|
+
type: "boolean",
|
|
1849
|
+
key: "mdnsAdvertise",
|
|
1850
|
+
label: "Announce this hub on the LAN (mDNS)",
|
|
1851
|
+
labelKey: "server:globalSettings.s_local-access.mdnsAdvertise.label",
|
|
1852
|
+
description: "Lets `camstack login` find the hub without an address. Advertises only the HTTPS address, never a secret. Needs UDP 5353 multicast to reach the LAN (host networking or a dedicated container IP).",
|
|
1853
|
+
descriptionKey: "server:globalSettings.s_local-access.mdnsAdvertise.description",
|
|
1854
|
+
style: "switch",
|
|
1855
|
+
default: true
|
|
1856
|
+
}),
|
|
1857
|
+
this.field({
|
|
1858
|
+
type: "text",
|
|
1859
|
+
key: "localHostname",
|
|
1860
|
+
label: "Local hostname",
|
|
1861
|
+
labelKey: "server:globalSettings.s_local-access.localHostname.label",
|
|
1862
|
+
description: "Advertised to the viewer instead of the raw LAN IP, and added to the certificate SAN. Requires this name to resolve on the LAN (router DNS, mDNS, or a hosts file). Leave empty to keep using the IP.",
|
|
1863
|
+
descriptionKey: "server:globalSettings.s_local-access.localHostname.description",
|
|
1864
|
+
maxLength: 253,
|
|
1865
|
+
placeholder: "camstack.lan"
|
|
1866
|
+
})
|
|
1867
|
+
]
|
|
1868
|
+
}] });
|
|
1869
|
+
}
|
|
1870
|
+
async onConfigChanged() {
|
|
1871
|
+
await this.applyLanAccessFromSettings();
|
|
1872
|
+
await this.applyMdnsAdvertisement();
|
|
1873
|
+
}
|
|
1874
|
+
/**
|
|
1875
|
+
* Start, re-announce or stop the hub's mDNS service (D838). Never throws:
|
|
1876
|
+
* the advertiser logs its own failures and boot goes on.
|
|
1877
|
+
*/
|
|
1878
|
+
async applyMdnsAdvertisement() {
|
|
1879
|
+
if (this.config.mdnsAdvertise === false) {
|
|
1880
|
+
await this.mdns?.stop();
|
|
1881
|
+
return;
|
|
1882
|
+
}
|
|
1883
|
+
if (this.mdns === null) this.mdns = new HubMdnsAdvertiser({
|
|
1884
|
+
publisher: createCiaoPublisher(),
|
|
1885
|
+
logger: this.ctx.logger,
|
|
1886
|
+
nodeId: this.ctx.kernel.localNodeId ?? "hub",
|
|
1887
|
+
version: null,
|
|
1888
|
+
readInternalUrl: async () => internalUrlOf(await this.addressBook("https"))
|
|
1889
|
+
});
|
|
1890
|
+
await this.mdns.start();
|
|
1891
|
+
}
|
|
1892
|
+
async onShutdown() {
|
|
1893
|
+
await this.mdns?.stop();
|
|
1894
|
+
this.mdns = null;
|
|
1895
|
+
if (this.pollTimer) {
|
|
1896
|
+
clearInterval(this.pollTimer);
|
|
1897
|
+
this.pollTimer = null;
|
|
1898
|
+
}
|
|
1899
|
+
if (this.allowlistTimer) {
|
|
1900
|
+
clearInterval(this.allowlistTimer);
|
|
1901
|
+
this.allowlistTimer = null;
|
|
1902
|
+
}
|
|
1903
|
+
}
|
|
1904
|
+
/**
|
|
1905
|
+
* Other hub addons (e.g. cloudflare-tunnel) signal the active public
|
|
1906
|
+
* FQDN by emitting `NetworkTunnelStarted` on the bus — handled in
|
|
1907
|
+
* `onInitialize`. This setter exists for tests + future direct
|
|
1908
|
+
* callers; cleared by passing an empty string.
|
|
1909
|
+
*/
|
|
1910
|
+
setPublicHostname(hostname, stable = true) {
|
|
1911
|
+
if (this.publicHostname === hostname && this.publicHostnameStable === stable) return;
|
|
1912
|
+
this.publicHostname = hostname;
|
|
1913
|
+
this.publicHostnameStable = stable;
|
|
1914
|
+
this.ctx.logger.info("local-network: public hostname updated", { meta: {
|
|
1915
|
+
hostname: hostname || "(cleared)",
|
|
1916
|
+
stable
|
|
1917
|
+
} });
|
|
1918
|
+
}
|
|
1919
|
+
/**
|
|
1920
|
+
* Replace the cached mesh endpoint. Set from the `MeshNetworkChanged`
|
|
1921
|
+
* event-tail + the pull-reconcile; exposed for tests + future direct
|
|
1922
|
+
* callers. Pass `null` to clear (mesh left / no provider joined).
|
|
1923
|
+
*/
|
|
1924
|
+
setMeshEndpoint(endpoint) {
|
|
1925
|
+
const prev = this.meshEndpoint;
|
|
1926
|
+
if (prev?.host === endpoint?.host && prev?.port === endpoint?.port) return;
|
|
1927
|
+
this.meshEndpoint = endpoint;
|
|
1928
|
+
this.ctx.logger.info("local-network: mesh endpoint updated", { meta: {
|
|
1929
|
+
host: endpoint?.host || "(cleared)",
|
|
1930
|
+
port: endpoint?.port ?? 0
|
|
1931
|
+
} });
|
|
1932
|
+
}
|
|
1933
|
+
/**
|
|
1934
|
+
* Refresh the cached mesh endpoint from the authoritative forked
|
|
1935
|
+
* `mesh-network` provider(s). `mesh-network` is a COLLECTION cap on a
|
|
1936
|
+
* forked addon, so the hub builtin can't see it via `ctx.api` /
|
|
1937
|
+
* `getCollectionEntries` — we resolve each provider by addonId through
|
|
1938
|
+
* the hub-side `capabilityRegistry.getProviderByAddon` resolver (the
|
|
1939
|
+
* same mechanism `device-manager` uses for cross-process exporter
|
|
1940
|
+
* contributions). Best-effort: a provider that's absent / errors /
|
|
1941
|
+
* not joined simply contributes nothing.
|
|
1942
|
+
*/
|
|
1943
|
+
async reconcileMeshEndpoint() {
|
|
1944
|
+
const registry = this.ctx.kernel.capabilityRegistry;
|
|
1945
|
+
if (!registry) return;
|
|
1946
|
+
for (const addonId of MESH_PROVIDER_ADDON_IDS) {
|
|
1947
|
+
const provider = registry.getProviderByAddon("mesh-network", addonId);
|
|
1948
|
+
if (!provider) continue;
|
|
1949
|
+
try {
|
|
1950
|
+
const status = await provider.getStatus();
|
|
1951
|
+
if (!status.joined) {
|
|
1952
|
+
this.setMeshEndpoint(null);
|
|
1953
|
+
continue;
|
|
1954
|
+
}
|
|
1955
|
+
const host = status.magicDnsHostname || status.meshIp;
|
|
1956
|
+
const port = (status.endpoints.find((e) => e.id === "magicdns") ?? status.endpoints.find((e) => e.id === "mesh-ipv4"))?.port ?? 0;
|
|
1957
|
+
this.setMeshEndpoint(host && port > 0 ? {
|
|
1958
|
+
host,
|
|
1959
|
+
port
|
|
1960
|
+
} : null);
|
|
1961
|
+
return;
|
|
1962
|
+
} catch (err) {
|
|
1963
|
+
this.ctx.logger.debug("local-network: mesh reconcile skipped", { meta: {
|
|
1964
|
+
addonId,
|
|
1965
|
+
error: err instanceof Error ? err.message : String(err)
|
|
1966
|
+
} });
|
|
1967
|
+
}
|
|
1968
|
+
}
|
|
1969
|
+
}
|
|
1970
|
+
resolvedHttpPort() {
|
|
1971
|
+
const port = this.config.httpPort;
|
|
1972
|
+
return Number.isInteger(port) && port >= 1 && port <= 65535 ? port : DEFAULT_LAN_HTTP_PORT;
|
|
1973
|
+
}
|
|
1974
|
+
tlsDataDir() {
|
|
1975
|
+
return this.ctx.nodeDataDir ?? this.ctx.dataDir;
|
|
1976
|
+
}
|
|
1977
|
+
/**
|
|
1978
|
+
* The hub's name (D861) for a local root this action may CREATE (an existing root is
|
|
1979
|
+
* never renamed). Hub only: on an agent the hub's name would mislabel the agent's own
|
|
1980
|
+
* material, so it gets the plain name. A failed read falls back to the machine
|
|
1981
|
+
* hostname (what the hub shows when unnamed) and says so: a certificate action must
|
|
1982
|
+
* not fail over a label.
|
|
1983
|
+
*/
|
|
1984
|
+
async caHubName() {
|
|
1985
|
+
if ((this.ctx.kernel.localNodeId ?? "hub") !== "hub") return {};
|
|
1986
|
+
try {
|
|
1987
|
+
return { hubName: (await this.ctx.api.system.info.query()).serverName.name };
|
|
1988
|
+
} catch (err) {
|
|
1989
|
+
this.ctx.logger.warn("local-network: server name unreadable - naming the CA after the hostname", { meta: { error: errMsg(err) } });
|
|
1990
|
+
return { hubName: shortHostname(os$1.hostname()) };
|
|
1991
|
+
}
|
|
1992
|
+
}
|
|
1993
|
+
snapshotTls() {
|
|
1994
|
+
const status = readTlsAccessStatus(this.tlsDataDir(), servedHttpsLeafFingerprint());
|
|
1995
|
+
return {
|
|
1996
|
+
...status,
|
|
1997
|
+
sans: [...status.sans]
|
|
1998
|
+
};
|
|
1999
|
+
}
|
|
2000
|
+
/**
|
|
2001
|
+
* Hot-swap the HTTPS listener onto the pair now on disk. A failure is not
|
|
2002
|
+
* thrown — the files are already written and the status reports
|
|
2003
|
+
* `restartRequired` from the served-vs-disk fingerprints — but it is logged:
|
|
2004
|
+
* a certificate change that did not reach the listener must say so.
|
|
2005
|
+
*/
|
|
2006
|
+
putCertificateOnListener(action) {
|
|
2007
|
+
const outcome = applyCertificateToListener(this.tlsDataDir());
|
|
2008
|
+
if (outcome.kind === "reloaded") {
|
|
2009
|
+
this.ctx.logger.info("local-network: HTTPS listener now serves the new certificate", { meta: {
|
|
2010
|
+
action,
|
|
2011
|
+
leafFingerprintSha256: outcome.servedLeafFingerprint
|
|
2012
|
+
} });
|
|
2013
|
+
return;
|
|
2014
|
+
}
|
|
2015
|
+
this.ctx.logger.warn("local-network: certificate changed on disk but NOT on the listener", { meta: {
|
|
2016
|
+
action,
|
|
2017
|
+
reason: outcome.kind,
|
|
2018
|
+
...outcome.kind === "failed" ? { error: outcome.error } : {}
|
|
2019
|
+
} });
|
|
2020
|
+
}
|
|
2021
|
+
/**
|
|
2022
|
+
* Bind or unbind the LAN HTTP sibling from the addon's own settings, and
|
|
2023
|
+
* keep the leaf SAN in sync with `localHostname`. This is the settings
|
|
2024
|
+
* side-effect path — there is no second persist API.
|
|
2025
|
+
*/
|
|
2026
|
+
async applyLanAccessFromSettings() {
|
|
2027
|
+
const parsed = parseLocalHostname(this.config.localHostname ?? "");
|
|
2028
|
+
if (!parsed.ok) throw new Error(parsed.error);
|
|
2029
|
+
const hostname = parsed.value ?? "";
|
|
2030
|
+
const httpsPort = (await this.resolveAdvertisedListenPort(null)).port;
|
|
2031
|
+
const httpPort = this.resolvedHttpPort();
|
|
2032
|
+
if (this.config.httpEnabled !== false && httpPort === httpsPort) throw new Error(`HTTP port ${httpPort} cannot equal the HTTPS listen port`);
|
|
2033
|
+
writeTlsEnabled(this.tlsDataDir(), this.config.tlsEnabled !== false);
|
|
2034
|
+
await applyLanHttp({
|
|
2035
|
+
enabled: this.config.httpEnabled !== false,
|
|
2036
|
+
port: httpPort,
|
|
2037
|
+
host: "0.0.0.0"
|
|
2038
|
+
});
|
|
2039
|
+
if (hostname !== "") {
|
|
2040
|
+
writeExtraSans(this.tlsDataDir(), [hostname]);
|
|
2041
|
+
if (readTlsMode(this.tlsDataDir()) === "generated") {
|
|
2042
|
+
if ((await ensureTlsCert(this.tlsDataDir(), {
|
|
2043
|
+
extraSans: [hostname],
|
|
2044
|
+
hubName: shortHostname(os$1.hostname())
|
|
2045
|
+
})).generated) this.putCertificateOnListener("hostname");
|
|
2046
|
+
}
|
|
2047
|
+
} else writeExtraSans(this.tlsDataDir(), []);
|
|
2048
|
+
}
|
|
2049
|
+
/**
|
|
2050
|
+
* The port this hub is actually listening on, plus the provenance of the
|
|
2051
|
+
* number. The boot loader merges the `CAMSTACK_PORT` env override into the
|
|
2052
|
+
* persisted `server` section (`server/backend/src/boot/boot-config.ts`), so
|
|
2053
|
+
* reading that section gives the authoritative live port — no new setting,
|
|
2054
|
+
* and the same source `tailscale-client` already stamps its mesh endpoints
|
|
2055
|
+
* from, so the two cannot drift.
|
|
2056
|
+
*/
|
|
2057
|
+
async resolveAdvertisedListenPort(callerHint) {
|
|
2058
|
+
const envRaw = Number.parseInt(process.env["CAMSTACK_PORT"] ?? "", 10);
|
|
2059
|
+
return resolveAdvertisedPort({
|
|
2060
|
+
configured: await this.readConfiguredPort(),
|
|
2061
|
+
env: Number.isNaN(envRaw) ? null : envRaw,
|
|
2062
|
+
callerHint
|
|
2063
|
+
});
|
|
2064
|
+
}
|
|
2065
|
+
/** `server.port` from the live config section, or null when unreadable. */
|
|
2066
|
+
async readConfiguredPort() {
|
|
2067
|
+
const settings = this.ctx.settings;
|
|
2068
|
+
if (!settings) return null;
|
|
2069
|
+
try {
|
|
2070
|
+
const raw = (await settings.getSection("server"))["port"];
|
|
2071
|
+
if (typeof raw === "number") return raw;
|
|
2072
|
+
if (typeof raw === "string") {
|
|
2073
|
+
const parsed = Number.parseInt(raw, 10);
|
|
2074
|
+
return Number.isNaN(parsed) ? null : parsed;
|
|
2075
|
+
}
|
|
2076
|
+
return null;
|
|
2077
|
+
} catch (err) {
|
|
2078
|
+
this.ctx.logger.warn("local-network: could not read server.port", { meta: { error: err instanceof Error ? err.message : String(err) } });
|
|
2079
|
+
return null;
|
|
2080
|
+
}
|
|
2081
|
+
}
|
|
2082
|
+
enumerate() {
|
|
2083
|
+
return enumerateOsInterfaces(os$1.networkInterfaces(), readLinuxIpv6Flags());
|
|
2084
|
+
}
|
|
2085
|
+
/**
|
|
2086
|
+
* Replace rotated IPv6 and drop addresses that no longer exist, without
|
|
2087
|
+
* clearing operator extras that are still live (docker/vpn opt-in).
|
|
2088
|
+
*/
|
|
2089
|
+
async persistReconciledAllowlist(interfaces = this.enumerate()) {
|
|
2090
|
+
if (this.allowlistReconcilePending) return;
|
|
2091
|
+
this.allowlistReconcilePending = true;
|
|
2092
|
+
try {
|
|
2093
|
+
const next = reconcileAllowlist(this.config.allowedAddresses, interfaces);
|
|
2094
|
+
if (sameAddressSet(this.config.allowedAddresses, next)) return;
|
|
2095
|
+
await this.updateGlobalSettings({
|
|
2096
|
+
allowedAddresses: next,
|
|
2097
|
+
bootSeeded: true
|
|
2098
|
+
});
|
|
2099
|
+
this.ctx.logger.info("local-network: allowlist reconciled", { meta: { addresses: next } });
|
|
2100
|
+
} finally {
|
|
2101
|
+
this.allowlistReconcilePending = false;
|
|
2102
|
+
}
|
|
2103
|
+
}
|
|
2104
|
+
detectChanges() {
|
|
2105
|
+
const interfaces = this.enumerate();
|
|
2106
|
+
const key = snapshotKey(interfaces);
|
|
2107
|
+
if (key === this.lastSnapshotKey) return;
|
|
2108
|
+
this.ctx.logger.info("local-network: interface set changed", { meta: {
|
|
2109
|
+
count: interfaces.length,
|
|
2110
|
+
key
|
|
2111
|
+
} });
|
|
2112
|
+
this.lastSnapshotKey = key;
|
|
2113
|
+
this.persistReconciledAllowlist(interfaces);
|
|
2114
|
+
this.mdns?.sync();
|
|
2115
|
+
this.ctx.eventBus?.emit({
|
|
2116
|
+
id: `local-network-changed-${Date.now()}`,
|
|
2117
|
+
timestamp: /* @__PURE__ */ new Date(),
|
|
2118
|
+
source: {
|
|
2119
|
+
type: "core",
|
|
2120
|
+
id: "local-network"
|
|
2121
|
+
},
|
|
2122
|
+
category: EventCategory.LocalNetworkChanged,
|
|
2123
|
+
data: { count: interfaces.length }
|
|
2124
|
+
});
|
|
2125
|
+
}
|
|
2126
|
+
};
|
|
2127
|
+
/**
|
|
2128
|
+
* Pick the port to advertise, and say where it came from.
|
|
2129
|
+
*
|
|
2130
|
+
* The caller's hint ranks BELOW everything the hub knows about itself and above
|
|
2131
|
+
* nothing but the compiled default — it is kept only so a client written
|
|
2132
|
+
* against the old echoing contract behaves exactly as it did before, and it is
|
|
2133
|
+
* labelled `caller-hint` so that client's successor can refuse to trust it.
|
|
2134
|
+
* Values outside the valid port range are dropped rather than advertised: a
|
|
2135
|
+
* malformed `server.port` must fall through to the next source, not produce a
|
|
2136
|
+
* URL nothing can bind.
|
|
2137
|
+
*/
|
|
2138
|
+
function resolveAdvertisedPort(sources) {
|
|
2139
|
+
const configured = validPort(sources.configured);
|
|
2140
|
+
if (configured !== null) return {
|
|
2141
|
+
port: configured,
|
|
2142
|
+
source: "server-config"
|
|
2143
|
+
};
|
|
2144
|
+
const env = validPort(sources.env);
|
|
2145
|
+
if (env !== null) return {
|
|
2146
|
+
port: env,
|
|
2147
|
+
source: "server-env"
|
|
2148
|
+
};
|
|
2149
|
+
const hint = validPort(sources.callerHint);
|
|
2150
|
+
if (hint !== null) return {
|
|
2151
|
+
port: hint,
|
|
2152
|
+
source: "caller-hint"
|
|
2153
|
+
};
|
|
2154
|
+
return {
|
|
2155
|
+
port: DEFAULT_HUB_PORT,
|
|
2156
|
+
source: "default"
|
|
2157
|
+
};
|
|
2158
|
+
}
|
|
2159
|
+
function validPort(value) {
|
|
2160
|
+
if (value === null) return null;
|
|
2161
|
+
return Number.isInteger(value) && value >= 1 && value <= 65535 ? value : null;
|
|
2162
|
+
}
|
|
2163
|
+
function enumerateOsInterfaces(ifaces, ipv6Flags) {
|
|
2164
|
+
const raw = [];
|
|
2165
|
+
for (const [name, addrs] of Object.entries(ifaces)) {
|
|
2166
|
+
if (!addrs) continue;
|
|
2167
|
+
for (const a of addrs) {
|
|
2168
|
+
if (a.family !== "IPv4" && a.family !== "IPv6") continue;
|
|
2169
|
+
raw.push({
|
|
2170
|
+
name,
|
|
2171
|
+
family: a.family,
|
|
2172
|
+
address: a.address,
|
|
2173
|
+
cidr: a.cidr ?? "",
|
|
2174
|
+
netmask: a.netmask,
|
|
2175
|
+
internal: a.internal,
|
|
2176
|
+
mac: a.mac
|
|
2177
|
+
});
|
|
2178
|
+
}
|
|
2179
|
+
}
|
|
2180
|
+
const classified = raw.map((r) => {
|
|
2181
|
+
const kind = classifyKind(r.name, r.address, r.internal);
|
|
2182
|
+
const reachableKind = kind === "lan" || kind === "wifi";
|
|
2183
|
+
const hex = r.family === "IPv6" ? ipv6ToHex32(r.address) : null;
|
|
2184
|
+
const flags = hex !== null ? ipv6Flags?.get(hex) : void 0;
|
|
2185
|
+
const rangeOk = isPlausibleAutoSeed(r.address, r.family);
|
|
2186
|
+
const stableV6 = r.family !== "IPv6" || shouldAdvertiseIpv6(r.address, flags);
|
|
2187
|
+
const plausible = !r.internal && reachableKind && rangeOk && stableV6;
|
|
2188
|
+
const plausibleReason = plausible ? "" : r.family === "IPv6" && rangeOk && !stableV6 ? "IPv6 temporary / privacy address — rotates and is not advertised." : explainNonPlausible({
|
|
2189
|
+
kind,
|
|
2190
|
+
family: r.family,
|
|
2191
|
+
address: r.address,
|
|
2192
|
+
internal: r.internal
|
|
2193
|
+
});
|
|
2194
|
+
return {
|
|
2195
|
+
name: r.name,
|
|
2196
|
+
family: r.family,
|
|
2197
|
+
address: r.address,
|
|
2198
|
+
cidr: r.cidr,
|
|
2199
|
+
netmask: r.netmask,
|
|
2200
|
+
internal: r.internal,
|
|
2201
|
+
mac: r.mac,
|
|
2202
|
+
kind,
|
|
2203
|
+
preferred: false,
|
|
2204
|
+
plausible,
|
|
2205
|
+
plausibleReason
|
|
2206
|
+
};
|
|
2207
|
+
});
|
|
2208
|
+
const preferred = pickPreferred(classified);
|
|
2209
|
+
return classified.map((iface) => ({
|
|
2210
|
+
...iface,
|
|
2211
|
+
preferred: preferred !== null && iface.name === preferred.name && iface.address === preferred.address
|
|
2212
|
+
}));
|
|
2213
|
+
}
|
|
2214
|
+
/**
|
|
2215
|
+
* Filter the interface list by the operator's allowlist. Empty
|
|
2216
|
+
* allowlist = no-op (every interface passes); otherwise only entries
|
|
2217
|
+
* whose `address` matches an allowlist entry remain. IPv6 matches the
|
|
2218
|
+
* allowlisted /64 so a rotated privacy address does not hide the live
|
|
2219
|
+
* GUA. Loopback is not an advertised client route and is not forced
|
|
2220
|
+
* through.
|
|
2221
|
+
*/
|
|
2222
|
+
function applyAllowlist(interfaces, allowed) {
|
|
2223
|
+
if (allowed.length === 0) return interfaces;
|
|
2224
|
+
return interfaces.filter((i) => ipv6AllowlistMatches(i.address, allowed) || allowed.includes(i.address));
|
|
2225
|
+
}
|
|
2226
|
+
/**
|
|
2227
|
+
* Rank interfaces and pick the auto-selected outbound one. See the
|
|
2228
|
+
* cap's `getPreferred` doc for the heuristic.
|
|
2229
|
+
*/
|
|
2230
|
+
function pickPreferred(interfaces) {
|
|
2231
|
+
const candidates = interfaces.filter((i) => !i.internal && i.family === "IPv4" && !i.address.startsWith("169.254.") && i.kind !== "loopback");
|
|
2232
|
+
if (candidates.length === 0) return null;
|
|
2233
|
+
const kindRank = {
|
|
2234
|
+
lan: 1,
|
|
2235
|
+
wifi: 2,
|
|
2236
|
+
vpn: 3,
|
|
2237
|
+
docker: 4,
|
|
2238
|
+
other: 5,
|
|
2239
|
+
loopback: 99
|
|
2240
|
+
};
|
|
2241
|
+
return [...candidates].toSorted((a, b) => {
|
|
2242
|
+
const ra = kindRank[a.kind];
|
|
2243
|
+
const rb = kindRank[b.kind];
|
|
2244
|
+
if (ra !== rb) return ra - rb;
|
|
2245
|
+
return prefixLen(b.netmask) - prefixLen(a.netmask);
|
|
2246
|
+
})[0] ?? null;
|
|
2247
|
+
}
|
|
2248
|
+
/**
|
|
2249
|
+
* The CamStack app link as a palette entry (D709): the one address on the
|
|
2250
|
+
* Network page that is not this hub's. Flagging it for notifications (the
|
|
2251
|
+
* default) makes viewer taps open the native app, with the hub carried as
|
|
2252
|
+
* `hub=`. `kind: 'app-link'` keeps it out of every race and ranking; it is
|
|
2253
|
+
* only emitted on `includeAppLink: true`.
|
|
2254
|
+
*/
|
|
2255
|
+
function appLinkEndpoint() {
|
|
2256
|
+
return {
|
|
2257
|
+
label: "CamStack app link",
|
|
2258
|
+
baseUrl: CAMSTACK_APP_LINK_ORIGIN,
|
|
2259
|
+
kind: "app-link",
|
|
2260
|
+
interfaceKind: "public",
|
|
2261
|
+
plausible: true,
|
|
2262
|
+
plausibleReason: "",
|
|
2263
|
+
priority: -1
|
|
2264
|
+
};
|
|
2265
|
+
}
|
|
2266
|
+
function buildEndpoints(interfaces, port, includeLoopback, ipv4Only, publicHostname, scheme = "http", meshEndpoint = null, lanHttp = null, publicHostnameStable = true) {
|
|
2267
|
+
const out = [];
|
|
2268
|
+
let priority = 0;
|
|
2269
|
+
const preferred = pickPreferred(interfaces);
|
|
2270
|
+
const httpLan = lanHttp?.enabled === true && lanHttp.listening === true;
|
|
2271
|
+
const lanScheme = httpLan ? "http" : scheme;
|
|
2272
|
+
const lanPort = httpLan ? lanHttp.httpPort : port;
|
|
2273
|
+
const emit = (iface, kind, label, baseUrl, pri) => {
|
|
2274
|
+
out.push({
|
|
2275
|
+
label,
|
|
2276
|
+
baseUrl,
|
|
2277
|
+
kind,
|
|
2278
|
+
interfaceKind: iface.kind,
|
|
2279
|
+
plausible: iface.plausible,
|
|
2280
|
+
plausibleReason: iface.plausibleReason,
|
|
2281
|
+
priority: pri
|
|
2282
|
+
});
|
|
2283
|
+
};
|
|
2284
|
+
if (httpLan && lanHttp.localHostname) out.push({
|
|
2285
|
+
label: "Local name",
|
|
2286
|
+
baseUrl: `${lanScheme}://${lanHttp.localHostname}:${lanPort}`,
|
|
2287
|
+
kind: "lan-ipv4",
|
|
2288
|
+
interfaceKind: "lan",
|
|
2289
|
+
plausible: true,
|
|
2290
|
+
plausibleReason: "",
|
|
2291
|
+
priority: priority++
|
|
2292
|
+
});
|
|
2293
|
+
if (preferred) emit(preferred, "lan-ipv4", `${formatKind(preferred.kind)} — ${preferred.name}`, `${lanScheme}://${preferred.address}:${lanPort}`, priority++);
|
|
2294
|
+
for (const iface of interfaces) {
|
|
2295
|
+
if (iface.internal || iface.family !== "IPv4") continue;
|
|
2296
|
+
if (iface.kind === "loopback") continue;
|
|
2297
|
+
if (preferred && iface.name === preferred.name && iface.address === preferred.address) continue;
|
|
2298
|
+
if (iface.address.startsWith("169.254.")) continue;
|
|
2299
|
+
emit(iface, "lan-ipv4", `${formatKind(iface.kind)} — ${iface.name}`, `${lanScheme}://${iface.address}:${lanPort}`, 10 + priority++);
|
|
2300
|
+
}
|
|
2301
|
+
if (!ipv4Only) for (const iface of interfaces) {
|
|
2302
|
+
if (iface.internal || iface.family !== "IPv6") continue;
|
|
2303
|
+
if (iface.kind === "loopback") continue;
|
|
2304
|
+
if (iface.address.toLowerCase().startsWith("fe80:")) continue;
|
|
2305
|
+
if (!iface.plausible) continue;
|
|
2306
|
+
emit(iface, "lan-ipv6", `${formatKind(iface.kind)} — ${iface.name} (IPv6)`, `${lanScheme}://[${iface.address}]:${lanPort}`, 10 + priority++);
|
|
2307
|
+
}
|
|
2308
|
+
if (publicHostname) out.push({
|
|
2309
|
+
label: publicHostnameStable ? "Public tunnel" : "Public tunnel (temporary address)",
|
|
2310
|
+
baseUrl: `https://${publicHostname}`,
|
|
2311
|
+
kind: "public",
|
|
2312
|
+
interfaceKind: "public",
|
|
2313
|
+
plausible: true,
|
|
2314
|
+
plausibleReason: "",
|
|
2315
|
+
priority: 100,
|
|
2316
|
+
...publicHostnameStable ? {} : { stable: false }
|
|
2317
|
+
});
|
|
2318
|
+
if (meshEndpoint && meshEndpoint.host) out.push({
|
|
2319
|
+
label: "Mesh (Tailscale)",
|
|
2320
|
+
baseUrl: `https://${meshEndpoint.host}:${meshEndpoint.port}`,
|
|
2321
|
+
kind: "public",
|
|
2322
|
+
interfaceKind: "vpn",
|
|
2323
|
+
plausible: true,
|
|
2324
|
+
plausibleReason: "",
|
|
2325
|
+
priority: 150
|
|
2326
|
+
});
|
|
2327
|
+
if (includeLoopback) out.push({
|
|
2328
|
+
label: "Loopback",
|
|
2329
|
+
baseUrl: `${scheme}://127.0.0.1:${port}`,
|
|
2330
|
+
kind: "loopback",
|
|
2331
|
+
interfaceKind: "loopback",
|
|
2332
|
+
plausible: false,
|
|
2333
|
+
plausibleReason: "Loopback — last-resort fallback when no other endpoint responds.",
|
|
2334
|
+
priority: 1e3
|
|
2335
|
+
});
|
|
2336
|
+
return out.toSorted((a, b) => a.priority - b.priority);
|
|
2337
|
+
}
|
|
2338
|
+
/**
|
|
2339
|
+
* First-boot heuristic: which addresses should the allowlist start
|
|
2340
|
+
* with? Includes LAN + Wi-Fi IPv4 addresses + plausible IPv6:
|
|
2341
|
+
*
|
|
2342
|
+
* - **IPv4**: skip link-local (`169.254.*`), keep the rest.
|
|
2343
|
+
* - **IPv6**: skip link-local (`fe80::*`), unspecified, and
|
|
2344
|
+
* multicast. Keep ULAs (`fc00::/7`) and Global Unicast (`2000::/3`).
|
|
2345
|
+
* Privacy-extension temporary addresses are skipped when Linux flags
|
|
2346
|
+
* mark them non-permanent (`plausible === false`).
|
|
2347
|
+
*
|
|
2348
|
+
* Skips docker/vpn/loopback/other entirely — those stay opt-in.
|
|
2349
|
+
*/
|
|
2350
|
+
function autoSeedAllowlist(interfaces) {
|
|
2351
|
+
return [...new Set(interfaces.filter((i) => !i.internal && (i.kind === "lan" || i.kind === "wifi") && isPlausibleAutoSeed(i.address, i.family) && (i.family !== "IPv6" || i.plausible)).map((i) => i.address))];
|
|
2352
|
+
}
|
|
2353
|
+
/**
|
|
2354
|
+
* Per-interface tooltip text surfaced on the "Unlikely usable" badge.
|
|
2355
|
+
* Server-side so the UI doesn't re-derive the rationale (single source
|
|
2356
|
+
* of truth). Returns `''` for plausible entries; the addon overlays
|
|
2357
|
+
* this on the `LocalInterface.plausibleReason` field.
|
|
2358
|
+
*/
|
|
2359
|
+
function explainNonPlausible(input) {
|
|
2360
|
+
if (input.internal) return "Internal interface (loopback) — not reachable from clients.";
|
|
2361
|
+
if (input.kind === "docker") return "Docker bridge — only reachable from inside the container network.";
|
|
2362
|
+
if (input.kind === "vpn") return "VPN tunnel — only reachable while the VPN is connected.";
|
|
2363
|
+
if (input.kind === "other") return "Unrecognised interface kind — verify reachability before pinning.";
|
|
2364
|
+
if (input.family === "IPv6") {
|
|
2365
|
+
const a = input.address.toLowerCase();
|
|
2366
|
+
if (a.startsWith("fe80:")) return "IPv6 link-local — only reachable on the same link, not routed.";
|
|
2367
|
+
if (a.startsWith("ff")) return "IPv6 multicast — not a unicast address.";
|
|
2368
|
+
if (a === "::" || a === "::1") return "IPv6 loopback / unspecified — not a public address.";
|
|
2369
|
+
return "IPv6 address outside the ULA / GUA ranges — verify before pinning.";
|
|
2370
|
+
}
|
|
2371
|
+
if (input.address.startsWith("169.254.")) return "IPv4 link-local (RFC 3927) — only valid when DHCP fails.";
|
|
2372
|
+
return "Address looks unusual for client traffic — verify before pinning.";
|
|
2373
|
+
}
|
|
2374
|
+
/**
|
|
2375
|
+
* Per-address gate used by `autoSeedAllowlist`. Exposed for tests so
|
|
2376
|
+
* we can pin every classification rule without standing up the addon.
|
|
2377
|
+
*/
|
|
2378
|
+
function isPlausibleAutoSeed(address, family) {
|
|
2379
|
+
if (family === "IPv4") {
|
|
2380
|
+
if (address.startsWith("169.254.")) return false;
|
|
2381
|
+
return true;
|
|
2382
|
+
}
|
|
2383
|
+
const a = address.toLowerCase();
|
|
2384
|
+
if (a === "::" || a === "::1") return false;
|
|
2385
|
+
if (a.startsWith("fe80:")) return false;
|
|
2386
|
+
if (a.startsWith("ff")) return false;
|
|
2387
|
+
if (/^f[cd][0-9a-f]{0,2}:/.test(a)) return true;
|
|
2388
|
+
if (/^[23][0-9a-f]{0,3}:/.test(a)) return true;
|
|
2389
|
+
return false;
|
|
2390
|
+
}
|
|
2391
|
+
function classifyKind(name, address, internal) {
|
|
2392
|
+
if (internal || name === "lo" || name.startsWith("lo")) return "loopback";
|
|
2393
|
+
const n = name.toLowerCase();
|
|
2394
|
+
if (n.startsWith("docker") || n.startsWith("br-") || n.startsWith("veth")) return "docker";
|
|
2395
|
+
if (n.startsWith("tun") || n.startsWith("utun") || n.startsWith("wg") || n.startsWith("tap")) return "vpn";
|
|
2396
|
+
if (n.startsWith("wlan") || n.startsWith("wlp") || n.startsWith("wlx")) return "wifi";
|
|
2397
|
+
if (n.startsWith("eth") || /^en\d+$/.test(n)) {
|
|
2398
|
+
if (process.platform === "darwin" && /^en[1-9]\d*$/.test(n)) return "wifi";
|
|
2399
|
+
return "lan";
|
|
2400
|
+
}
|
|
2401
|
+
if (address === "127.0.0.1" || address === "::1") return "loopback";
|
|
2402
|
+
return "other";
|
|
2403
|
+
}
|
|
2404
|
+
/** Convert an IPv4/IPv6 netmask string to its prefix length (CIDR). */
|
|
2405
|
+
function prefixLen(netmask) {
|
|
2406
|
+
if (!netmask) return 0;
|
|
2407
|
+
if (netmask.includes(":")) {
|
|
2408
|
+
let bits = 0;
|
|
2409
|
+
for (const group of netmask.split(":")) {
|
|
2410
|
+
if (!group) continue;
|
|
2411
|
+
const n = parseInt(group, 16);
|
|
2412
|
+
if (!Number.isFinite(n)) break;
|
|
2413
|
+
for (let mask = 32768; mask; mask >>= 1) if (n & mask) bits++;
|
|
2414
|
+
else return bits;
|
|
2415
|
+
}
|
|
2416
|
+
return bits;
|
|
2417
|
+
}
|
|
2418
|
+
let bits = 0;
|
|
2419
|
+
for (const part of netmask.split(".")) {
|
|
2420
|
+
const n = parseInt(part, 10);
|
|
2421
|
+
if (!Number.isFinite(n)) break;
|
|
2422
|
+
for (let mask = 128; mask; mask >>= 1) if (n & mask) bits++;
|
|
2423
|
+
else return bits;
|
|
2424
|
+
}
|
|
2425
|
+
return bits;
|
|
2426
|
+
}
|
|
2427
|
+
function snapshotKey(interfaces) {
|
|
2428
|
+
return [...interfaces].map((i) => `${i.name}|${i.family}|${i.address}|${i.netmask}`).toSorted().join("\n");
|
|
2429
|
+
}
|
|
2430
|
+
function formatKind(kind) {
|
|
2431
|
+
switch (kind) {
|
|
2432
|
+
case "lan": return "LAN";
|
|
2433
|
+
case "wifi": return "Wi-Fi";
|
|
2434
|
+
case "vpn": return "VPN";
|
|
2435
|
+
case "docker": return "Docker";
|
|
2436
|
+
case "loopback": return "Loopback";
|
|
2437
|
+
case "other": return "Other";
|
|
2438
|
+
}
|
|
2439
|
+
}
|
|
2440
|
+
/**
|
|
2441
|
+
* Rewrite a persisted allowlist against the live interface set:
|
|
2442
|
+
* current auto-seed (LAN/Wi-Fi, stable IPv6) plus still-live operator
|
|
2443
|
+
* extras (docker/vpn). Empty stays empty — that is "unrestricted".
|
|
2444
|
+
*/
|
|
2445
|
+
function reconcileAllowlist(current, interfaces) {
|
|
2446
|
+
if (current.length === 0) return [];
|
|
2447
|
+
const live = new Set(interfaces.map((i) => i.address));
|
|
2448
|
+
const seed = autoSeedAllowlist(interfaces);
|
|
2449
|
+
const seedSet = new Set(seed);
|
|
2450
|
+
const extras = current.filter((a) => live.has(a) && !seedSet.has(a) && !a.includes(":"));
|
|
2451
|
+
return [...new Set([...seed, ...extras])];
|
|
2452
|
+
}
|
|
2453
|
+
function sameAddressSet(a, b) {
|
|
2454
|
+
if (a.length !== b.length) return false;
|
|
2455
|
+
const set = new Set(a);
|
|
2456
|
+
return b.every((addr) => set.has(addr));
|
|
2457
|
+
}
|
|
2458
|
+
function readLinuxIpv6Flags() {
|
|
2459
|
+
try {
|
|
2460
|
+
return parseProcIfInet6(readFileSync("/proc/net/if_inet6", "utf8"));
|
|
2461
|
+
} catch {
|
|
2462
|
+
return;
|
|
2463
|
+
}
|
|
2464
|
+
}
|
|
2465
|
+
//#endregion
|
|
2466
|
+
export { ALLOWLIST_RECONCILE_INTERVAL_MS, LocalNetworkAddon, appLinkEndpoint, applyAllowlist, autoSeedAllowlist, buildEndpoints, classifyKind, enumerateOsInterfaces, explainNonPlausible, ipv6Prefix64Key, isPlausibleAutoSeed, parseProcIfInet6, pickPreferred, prefixLen, reconcileAllowlist, resolveAdvertisedPort, shouldAdvertiseIpv6 };
|