@fastybird/smart-panel-backend 1.1.0-alpha.6 → 1.1.0-alpha.61
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/app.module.js +2 -1
- package/dist/app.module.js.map +1 -1
- package/dist/common/utils/cancellable-exec.utils.d.ts +5 -0
- package/dist/common/utils/cancellable-exec.utils.js +34 -0
- package/dist/common/utils/cancellable-exec.utils.js.map +1 -0
- package/dist/common/utils/remote-access-observation.utils.d.ts +11 -0
- package/dist/common/utils/remote-access-observation.utils.js +89 -0
- package/dist/common/utils/remote-access-observation.utils.js.map +1 -0
- package/dist/dataSource.js +1 -0
- package/dist/dataSource.js.map +1 -1
- package/dist/migrations/1000000000026-AddHardwareInputCategories.d.ts +7 -0
- package/dist/migrations/1000000000026-AddHardwareInputCategories.js +364 -0
- package/dist/migrations/1000000000026-AddHardwareInputCategories.js.map +1 -0
- package/dist/modules/auth/auth.module.js +4 -0
- package/dist/modules/auth/auth.module.js.map +1 -1
- package/dist/modules/auth/guards/auth.guard.js +8 -21
- package/dist/modules/auth/guards/auth.guard.js.map +1 -1
- package/dist/modules/auth/services/token-metadata.service.d.ts +42 -0
- package/dist/modules/auth/services/token-metadata.service.js +202 -0
- package/dist/modules/auth/services/token-metadata.service.js.map +1 -0
- package/dist/modules/auth/services/token-usage.service.d.ts +22 -0
- package/dist/modules/auth/services/token-usage.service.js +93 -0
- package/dist/modules/auth/services/token-usage.service.js.map +1 -0
- package/dist/modules/auth/services/tokens.service.d.ts +10 -3
- package/dist/modules/auth/services/tokens.service.js +26 -10
- package/dist/modules/auth/services/tokens.service.js.map +1 -1
- package/dist/modules/devices/controllers/channels.controller.d.ts +5 -1
- package/dist/modules/devices/controllers/channels.controller.js +34 -2
- package/dist/modules/devices/controllers/channels.controller.js.map +1 -1
- package/dist/modules/devices/controllers/channels.properties.controller.js +5 -0
- package/dist/modules/devices/controllers/channels.properties.controller.js.map +1 -1
- package/dist/modules/devices/controllers/devices.channels.controller.d.ts +5 -1
- package/dist/modules/devices/controllers/devices.channels.controller.js +38 -2
- package/dist/modules/devices/controllers/devices.channels.controller.js.map +1 -1
- package/dist/modules/devices/controllers/devices.channels.properties.controller.js +5 -0
- package/dist/modules/devices/controllers/devices.channels.properties.controller.js.map +1 -1
- package/dist/modules/devices/devices.constants.d.ts +6 -0
- package/dist/modules/devices/devices.constants.js +6 -0
- package/dist/modules/devices/devices.constants.js.map +1 -1
- package/dist/modules/devices/devices.module.js +18 -0
- package/dist/modules/devices/devices.module.js.map +1 -1
- package/dist/modules/devices/devices.openapi.d.ts +3 -1
- package/dist/modules/devices/devices.openapi.js +7 -0
- package/dist/modules/devices/devices.openapi.js.map +1 -1
- package/dist/modules/devices/dto/channel-input-occurrence.dto.d.ts +10 -0
- package/dist/modules/devices/dto/channel-input-occurrence.dto.js +99 -0
- package/dist/modules/devices/dto/channel-input-occurrence.dto.js.map +1 -0
- package/dist/modules/devices/dto/property-command.dto.js +2 -8
- package/dist/modules/devices/dto/property-command.dto.js.map +1 -1
- package/dist/modules/devices/models/channel-input-capabilities.model.d.ts +20 -0
- package/dist/modules/devices/models/channel-input-capabilities.model.js +111 -0
- package/dist/modules/devices/models/channel-input-capabilities.model.js.map +1 -0
- package/dist/modules/devices/models/channel-input-occurrence.model.d.ts +22 -0
- package/dist/modules/devices/models/channel-input-occurrence.model.js +154 -0
- package/dist/modules/devices/models/channel-input-occurrence.model.js.map +1 -0
- package/dist/modules/devices/services/channel-input-deduplication.service.d.ts +17 -0
- package/dist/modules/devices/services/channel-input-deduplication.service.js +88 -0
- package/dist/modules/devices/services/channel-input-deduplication.service.js.map +1 -0
- package/dist/modules/devices/services/channel-input-occurrences.service.d.ts +21 -0
- package/dist/modules/devices/services/channel-input-occurrences.service.js +163 -0
- package/dist/modules/devices/services/channel-input-occurrences.service.js.map +1 -0
- package/dist/modules/devices/services/channels.properties.service.d.ts +10 -1
- package/dist/modules/devices/services/channels.properties.service.js +108 -44
- package/dist/modules/devices/services/channels.properties.service.js.map +1 -1
- package/dist/modules/devices/services/channels.service.d.ts +1 -0
- package/dist/modules/devices/services/channels.service.js +10 -0
- package/dist/modules/devices/services/channels.service.js.map +1 -1
- package/dist/modules/devices/services/command-latency-trace-collector.service.d.ts +101 -0
- package/dist/modules/devices/services/command-latency-trace-collector.service.js +451 -0
- package/dist/modules/devices/services/command-latency-trace-collector.service.js.map +1 -0
- package/dist/modules/devices/services/device-command-graph.service.d.ts +18 -0
- package/dist/modules/devices/services/device-command-graph.service.js +92 -0
- package/dist/modules/devices/services/device-command-graph.service.js.map +1 -0
- package/dist/modules/devices/services/devices.service.d.ts +2 -0
- package/dist/modules/devices/services/devices.service.js +41 -31
- package/dist/modules/devices/services/devices.service.js.map +1 -1
- package/dist/modules/devices/services/platform.registry.service.d.ts +2 -2
- package/dist/modules/devices/services/platform.registry.service.js.map +1 -1
- package/dist/modules/devices/services/property-command-dispatch.service.d.ts +7 -3
- package/dist/modules/devices/services/property-command-dispatch.service.js +38 -25
- package/dist/modules/devices/services/property-command-dispatch.service.js.map +1 -1
- package/dist/modules/devices/services/property-command-window.service.d.ts +2 -1
- package/dist/modules/devices/services/property-command-window.service.js +6 -0
- package/dist/modules/devices/services/property-command-window.service.js.map +1 -1
- package/dist/modules/devices/services/property-command.service.d.ts +9 -5
- package/dist/modules/devices/services/property-command.service.js +54 -21
- package/dist/modules/devices/services/property-command.service.js.map +1 -1
- package/dist/modules/devices/services/property-metadata.service.d.ts +38 -0
- package/dist/modules/devices/services/property-metadata.service.js +210 -0
- package/dist/modules/devices/services/property-metadata.service.js.map +1 -0
- package/dist/modules/devices/services/property-value-lock.service.d.ts +4 -1
- package/dist/modules/devices/services/property-value-lock.service.js +16 -2
- package/dist/modules/devices/services/property-value-lock.service.js.map +1 -1
- package/dist/modules/devices/services/property-value.service.d.ts +2 -0
- package/dist/modules/devices/services/property-value.service.js +25 -5
- package/dist/modules/devices/services/property-value.service.js.map +1 -1
- package/dist/modules/devices/utils/device-graph-query.utils.d.ts +3 -0
- package/dist/modules/devices/utils/device-graph-query.utils.js +23 -0
- package/dist/modules/devices/utils/device-graph-query.utils.js.map +1 -0
- package/dist/modules/devices/utils/schema.utils.js +1 -1
- package/dist/modules/devices/utils/schema.utils.js.map +1 -1
- package/dist/modules/devices/validators/channel-exists-constraint.validator.d.ts +1 -3
- package/dist/modules/devices/validators/channel-exists-constraint.validator.js +3 -14
- package/dist/modules/devices/validators/channel-exists-constraint.validator.js.map +1 -1
- package/dist/modules/devices/validators/channel-property-exists-constraint.validator.d.ts +1 -3
- package/dist/modules/devices/validators/channel-property-exists-constraint.validator.js +3 -14
- package/dist/modules/devices/validators/channel-property-exists-constraint.validator.js.map +1 -1
- package/dist/modules/devices/validators/device-exists-constraint.validator.js +1 -2
- package/dist/modules/devices/validators/device-exists-constraint.validator.js.map +1 -1
- package/dist/modules/devices/validators/property-command-target-constraint.validator.d.ts +9 -0
- package/dist/modules/devices/validators/property-command-target-constraint.validator.js +58 -0
- package/dist/modules/devices/validators/property-command-target-constraint.validator.js.map +1 -0
- package/dist/modules/mdns/services/mdns.service.js +3 -1
- package/dist/modules/mdns/services/mdns.service.js.map +1 -1
- package/dist/modules/platform/platforms/abstract.platform.d.ts +2 -1
- package/dist/modules/platform/platforms/abstract.platform.js +2 -1
- package/dist/modules/platform/platforms/abstract.platform.js.map +1 -1
- package/dist/modules/platform/platforms/raspberry.platform.js +5 -10
- package/dist/modules/platform/platforms/raspberry.platform.js.map +1 -1
- package/dist/modules/platform/utils/linux-network-interface.utils.d.ts +3 -0
- package/dist/modules/platform/utils/linux-network-interface.utils.js +48 -0
- package/dist/modules/platform/utils/linux-network-interface.utils.js.map +1 -0
- package/dist/modules/remote-access/controllers/remote-access.controller.js +11 -6
- package/dist/modules/remote-access/controllers/remote-access.controller.js.map +1 -1
- package/dist/modules/remote-access/models/provider.model.d.ts +3 -0
- package/dist/modules/remote-access/models/provider.model.js +23 -0
- package/dist/modules/remote-access/models/provider.model.js.map +1 -1
- package/dist/modules/remote-access/models/status.model.d.ts +2 -0
- package/dist/modules/remote-access/models/status.model.js +18 -1
- package/dist/modules/remote-access/models/status.model.js.map +1 -1
- package/dist/modules/remote-access/models/urls.model.d.ts +2 -0
- package/dist/modules/remote-access/models/urls.model.js +17 -0
- package/dist/modules/remote-access/models/urls.model.js.map +1 -1
- package/dist/modules/remote-access/platforms/remote-access-provider.platform.d.ts +18 -1
- package/dist/modules/remote-access/remote-access.constants.d.ts +2 -1
- package/dist/modules/remote-access/remote-access.constants.js +2 -1
- package/dist/modules/remote-access/remote-access.constants.js.map +1 -1
- package/dist/modules/remote-access/services/remote-access-proxy-contribution.service.d.ts +1 -0
- package/dist/modules/remote-access/services/remote-access-proxy-contribution.service.js +4 -1
- package/dist/modules/remote-access/services/remote-access-proxy-contribution.service.js.map +1 -1
- package/dist/modules/remote-access/services/remote-access-status.service.d.ts +40 -8
- package/dist/modules/remote-access/services/remote-access-status.service.js +314 -65
- package/dist/modules/remote-access/services/remote-access-status.service.js.map +1 -1
- package/dist/modules/remote-access/services/remote-access-url.service.d.ts +2 -2
- package/dist/modules/remote-access/services/remote-access-url.service.js +4 -2
- package/dist/modules/remote-access/services/remote-access-url.service.js.map +1 -1
- package/dist/modules/spaces/services/module-reset.service.d.ts +5 -1
- package/dist/modules/spaces/services/module-reset.service.js +10 -2
- package/dist/modules/spaces/services/module-reset.service.js.map +1 -1
- package/dist/modules/spaces/services/space-activity.service.d.ts +14 -0
- package/dist/modules/spaces/services/space-activity.service.js +56 -0
- package/dist/modules/spaces/services/space-activity.service.js.map +1 -0
- package/dist/modules/spaces/spaces.module.js +5 -0
- package/dist/modules/spaces/spaces.module.js.map +1 -1
- package/dist/modules/spaces/subscribers/space-activity.subscriber.d.ts +17 -0
- package/dist/modules/spaces/subscribers/space-activity.subscriber.js +89 -0
- package/dist/modules/spaces/subscribers/space-activity.subscriber.js.map +1 -0
- package/dist/modules/storage/services/storage-write-buffer.d.ts +17 -0
- package/dist/modules/storage/services/storage-write-buffer.js +67 -0
- package/dist/modules/storage/services/storage-write-buffer.js.map +1 -0
- package/dist/modules/storage/services/storage.service.d.ts +9 -2
- package/dist/modules/storage/services/storage.service.js +54 -1
- package/dist/modules/storage/services/storage.service.js.map +1 -1
- package/dist/modules/system/scripts/update-worker.sh +1168 -61
- package/dist/modules/system/services/privileged-worker.service.d.ts +10 -0
- package/dist/modules/system/services/privileged-worker.service.js +241 -32
- package/dist/modules/system/services/privileged-worker.service.js.map +1 -1
- package/dist/modules/system/services/system.service.d.ts +2 -0
- package/dist/modules/system/services/system.service.js +22 -1
- package/dist/modules/system/services/system.service.js.map +1 -1
- package/dist/modules/system/services/update-executor.service.d.ts +20 -2
- package/dist/modules/system/services/update-executor.service.js +272 -26
- package/dist/modules/system/services/update-executor.service.js.map +1 -1
- package/dist/modules/websocket/gateway/websocket.gateway.d.ts +4 -1
- package/dist/modules/websocket/gateway/websocket.gateway.js +29 -5
- package/dist/modules/websocket/gateway/websocket.gateway.js.map +1 -1
- package/dist/modules/websocket/services/command-acknowledgement-trace.service.d.ts +143 -0
- package/dist/modules/websocket/services/command-acknowledgement-trace.service.js +523 -0
- package/dist/modules/websocket/services/command-acknowledgement-trace.service.js.map +1 -0
- package/dist/modules/websocket/services/ws-auth.service.js +12 -35
- package/dist/modules/websocket/services/ws-auth.service.js.map +1 -1
- package/dist/modules/websocket/websocket.module.js +9 -1
- package/dist/modules/websocket/websocket.module.js.map +1 -1
- package/dist/plugins/devices-home-assistant/devices-home-assistant.openapi.d.ts +2 -2
- package/dist/plugins/devices-home-assistant/devices-home-assistant.plugin.d.ts +6 -1
- package/dist/plugins/devices-home-assistant/devices-home-assistant.plugin.js +16 -1
- package/dist/plugins/devices-home-assistant/devices-home-assistant.plugin.js.map +1 -1
- package/dist/plugins/devices-home-assistant/dto/mapping-preview.dto.d.ts +1 -0
- package/dist/plugins/devices-home-assistant/dto/mapping-preview.dto.js +11 -0
- package/dist/plugins/devices-home-assistant/dto/mapping-preview.dto.js.map +1 -1
- package/dist/plugins/devices-home-assistant/mappers/button.entity.mapper.service.d.ts +19 -0
- package/dist/plugins/devices-home-assistant/mappers/button.entity.mapper.service.js +51 -0
- package/dist/plugins/devices-home-assistant/mappers/button.entity.mapper.service.js.map +1 -0
- package/dist/plugins/devices-home-assistant/mappings/definitions/entity-mappings.yaml +56 -7
- package/dist/plugins/devices-home-assistant/models/mapping-preview.model.d.ts +1 -0
- package/dist/plugins/devices-home-assistant/models/mapping-preview.model.js +11 -0
- package/dist/plugins/devices-home-assistant/models/mapping-preview.model.js.map +1 -1
- package/dist/plugins/devices-home-assistant/services/device-adoption.service.js +17 -0
- package/dist/plugins/devices-home-assistant/services/device-adoption.service.js.map +1 -1
- package/dist/plugins/devices-home-assistant/services/ha-mdns-discoverer.service.js +3 -1
- package/dist/plugins/devices-home-assistant/services/ha-mdns-discoverer.service.js.map +1 -1
- package/dist/plugins/devices-home-assistant/services/home-assistant-raw-event.service.d.ts +27 -0
- package/dist/plugins/devices-home-assistant/services/home-assistant-raw-event.service.js +271 -0
- package/dist/plugins/devices-home-assistant/services/home-assistant-raw-event.service.js.map +1 -0
- package/dist/plugins/devices-home-assistant/services/home-assistant.ws.service.d.ts +2 -2
- package/dist/plugins/devices-home-assistant/services/home-assistant.ws.service.js +33 -14
- package/dist/plugins/devices-home-assistant/services/home-assistant.ws.service.js.map +1 -1
- package/dist/plugins/devices-home-assistant/services/mapping-preview.service.js +24 -4
- package/dist/plugins/devices-home-assistant/services/mapping-preview.service.js.map +1 -1
- package/dist/plugins/devices-home-assistant/services/state-changed.event.service.d.ts +4 -1
- package/dist/plugins/devices-home-assistant/services/state-changed.event.service.js +82 -2
- package/dist/plugins/devices-home-assistant/services/state-changed.event.service.js.map +1 -1
- package/dist/plugins/devices-home-assistant/services/wizard.service.js +1 -0
- package/dist/plugins/devices-home-assistant/services/wizard.service.js.map +1 -1
- package/dist/plugins/devices-home-assistant/utils/ha-event.utils.d.ts +2 -0
- package/dist/plugins/devices-home-assistant/utils/ha-event.utils.js +50 -0
- package/dist/plugins/devices-home-assistant/utils/ha-event.utils.js.map +1 -0
- package/dist/plugins/devices-homekit/listeners/homekit-event.listener.d.ts +4 -1
- package/dist/plugins/devices-homekit/listeners/homekit-event.listener.js +34 -4
- package/dist/plugins/devices-homekit/listeners/homekit-event.listener.js.map +1 -1
- package/dist/plugins/devices-homekit/mappers/base.mapper.js +3 -2
- package/dist/plugins/devices-homekit/mappers/base.mapper.js.map +1 -1
- package/dist/plugins/devices-homekit/mappers/button.mapper.d.ts +15 -0
- package/dist/plugins/devices-homekit/mappers/button.mapper.js +143 -0
- package/dist/plugins/devices-homekit/mappers/button.mapper.js.map +1 -0
- package/dist/plugins/devices-homekit/mappers/characteristic-write.d.ts +2 -0
- package/dist/plugins/devices-homekit/mappers/characteristic-write.js +17 -0
- package/dist/plugins/devices-homekit/mappers/characteristic-write.js.map +1 -0
- package/dist/plugins/devices-homekit/mappers/homekit-mapper.interface.d.ts +9 -1
- package/dist/plugins/devices-homekit/mappers/thermostat-coordinator.js +13 -12
- package/dist/plugins/devices-homekit/mappers/thermostat-coordinator.js.map +1 -1
- package/dist/plugins/devices-homekit/services/homekit-bridge.service.js +2 -0
- package/dist/plugins/devices-homekit/services/homekit-bridge.service.js.map +1 -1
- package/dist/plugins/devices-homekit/services/homekit-mapper-registry.service.d.ts +5 -1
- package/dist/plugins/devices-homekit/services/homekit-mapper-registry.service.js +42 -0
- package/dist/plugins/devices-homekit/services/homekit-mapper-registry.service.js.map +1 -1
- package/dist/plugins/devices-homekit/utils/ciao-receive-guard.d.ts +1 -0
- package/dist/plugins/devices-homekit/utils/ciao-receive-guard.js +36 -0
- package/dist/plugins/devices-homekit/utils/ciao-receive-guard.js.map +1 -0
- package/dist/plugins/devices-homey/mappings/definitions/channels.yaml +50 -0
- package/dist/plugins/devices-homey/mappings/definitions/devices.yaml +18 -0
- package/dist/plugins/devices-homey/mappings/definitions/properties.yaml +55 -0
- package/dist/plugins/devices-homey/mappings/device-support.js +10 -0
- package/dist/plugins/devices-homey/mappings/device-support.js.map +1 -1
- package/dist/plugins/devices-homey/mappings/mapping-loader.service.d.ts +1 -0
- package/dist/plugins/devices-homey/mappings/mapping-loader.service.js +66 -8
- package/dist/plugins/devices-homey/mappings/mapping-loader.service.js.map +1 -1
- package/dist/plugins/devices-homey/models/inventory.model.d.ts +2 -1
- package/dist/plugins/devices-homey/models/inventory.model.js +1 -0
- package/dist/plugins/devices-homey/models/inventory.model.js.map +1 -1
- package/dist/plugins/devices-homey/models/mapping-preview.model.d.ts +1 -0
- package/dist/plugins/devices-homey/models/mapping-preview.model.js +1 -0
- package/dist/plugins/devices-homey/models/mapping-preview.model.js.map +1 -1
- package/dist/plugins/devices-homey/services/homey-mapping-preview.service.js +7 -0
- package/dist/plugins/devices-homey/services/homey-mapping-preview.service.js.map +1 -1
- package/dist/plugins/devices-homey/services/homey-synchronizer.service.d.ts +3 -1
- package/dist/plugins/devices-homey/services/homey-synchronizer.service.js +37 -6
- package/dist/plugins/devices-homey/services/homey-synchronizer.service.js.map +1 -1
- package/dist/plugins/devices-reterminal/services/reterminal-button.service.d.ts +7 -3
- package/dist/plugins/devices-reterminal/services/reterminal-button.service.js +63 -17
- package/dist/plugins/devices-reterminal/services/reterminal-button.service.js.map +1 -1
- package/dist/plugins/devices-shelly-ng/delegates/delegates-manager.service.d.ts +25 -3
- package/dist/plugins/devices-shelly-ng/delegates/delegates-manager.service.js +607 -48
- package/dist/plugins/devices-shelly-ng/delegates/delegates-manager.service.js.map +1 -1
- package/dist/plugins/devices-shelly-ng/delegates/shelly-device.delegate.d.ts +6 -0
- package/dist/plugins/devices-shelly-ng/delegates/shelly-device.delegate.js +51 -2
- package/dist/plugins/devices-shelly-ng/delegates/shelly-device.delegate.js.map +1 -1
- package/dist/plugins/devices-shelly-ng/devices-shelly-ng.constants.js +3 -2
- package/dist/plugins/devices-shelly-ng/devices-shelly-ng.constants.js.map +1 -1
- package/dist/plugins/devices-shelly-ng/devices-shelly-ng.plugin.js +2 -0
- package/dist/plugins/devices-shelly-ng/devices-shelly-ng.plugin.js.map +1 -1
- package/dist/plugins/devices-shelly-ng/mappings/definitions/inputs.yaml +80 -0
- package/dist/plugins/devices-shelly-ng/mappings/mapping-loader.service.js +7 -1
- package/dist/plugins/devices-shelly-ng/mappings/mapping-loader.service.js.map +1 -1
- package/dist/plugins/devices-shelly-ng/mappings/mapping.types.d.ts +6 -3
- package/dist/plugins/devices-shelly-ng/mappings/schema/mapping-schema.json +5 -0
- package/dist/plugins/devices-shelly-ng/services/device-manager.service.js +153 -8
- package/dist/plugins/devices-shelly-ng/services/device-manager.service.js.map +1 -1
- package/dist/plugins/devices-shelly-ng/services/poll-placement-diagnostics.service.d.ts +51 -0
- package/dist/plugins/devices-shelly-ng/services/poll-placement-diagnostics.service.js +549 -0
- package/dist/plugins/devices-shelly-ng/services/poll-placement-diagnostics.service.js.map +1 -0
- package/dist/plugins/devices-shelly-ng/services/shelly-ng.service.d.ts +6 -1
- package/dist/plugins/devices-shelly-ng/services/shelly-ng.service.js +84 -14
- package/dist/plugins/devices-shelly-ng/services/shelly-ng.service.js.map +1 -1
- package/dist/plugins/devices-shelly-ng/services/shelly-rpc-client.service.js +3 -0
- package/dist/plugins/devices-shelly-ng/services/shelly-rpc-client.service.js.map +1 -1
- package/dist/plugins/devices-shelly-ng/services/shelly-ws-server.service.d.ts +1 -0
- package/dist/plugins/devices-shelly-ng/services/shelly-ws-server.service.js +13 -1
- package/dist/plugins/devices-shelly-ng/services/shelly-ws-server.service.js.map +1 -1
- package/dist/plugins/devices-shelly-v1/devices-shelly-v1.constants.d.ts +2 -0
- package/dist/plugins/devices-shelly-v1/devices-shelly-v1.constants.js +66 -4
- package/dist/plugins/devices-shelly-v1/devices-shelly-v1.constants.js.map +1 -1
- package/dist/plugins/devices-shelly-v1/devices-shelly-v1.plugin.js +2 -0
- package/dist/plugins/devices-shelly-v1/devices-shelly-v1.plugin.js.map +1 -1
- package/dist/plugins/devices-shelly-v1/platforms/shelly-v1.device.platform.js +7 -0
- package/dist/plugins/devices-shelly-v1/platforms/shelly-v1.device.platform.js.map +1 -1
- package/dist/plugins/devices-shelly-v1/services/device-mapper.service.d.ts +3 -1
- package/dist/plugins/devices-shelly-v1/services/device-mapper.service.js +20 -2
- package/dist/plugins/devices-shelly-v1/services/device-mapper.service.js.map +1 -1
- package/dist/plugins/devices-shelly-v1/services/shelly-v1-input-tracker.service.d.ts +16 -0
- package/dist/plugins/devices-shelly-v1/services/shelly-v1-input-tracker.service.js +107 -0
- package/dist/plugins/devices-shelly-v1/services/shelly-v1-input-tracker.service.js.map +1 -0
- package/dist/plugins/devices-shelly-v1/services/shelly-v1.service.d.ts +7 -1
- package/dist/plugins/devices-shelly-v1/services/shelly-v1.service.js +98 -3
- package/dist/plugins/devices-shelly-v1/services/shelly-v1.service.js.map +1 -1
- package/dist/plugins/devices-third-party/controllers/third-party-inputs.controller.d.ts +17 -0
- package/dist/plugins/devices-third-party/controllers/third-party-inputs.controller.js +205 -0
- package/dist/plugins/devices-third-party/controllers/third-party-inputs.controller.js.map +1 -0
- package/dist/plugins/devices-third-party/devices-third-party.openapi.d.ts +1 -1
- package/dist/plugins/devices-third-party/devices-third-party.plugin.js +2 -1
- package/dist/plugins/devices-third-party/devices-third-party.plugin.js.map +1 -1
- package/dist/plugins/devices-third-party/dto/report-input-occurrence-response.dto.d.ts +5 -0
- package/dist/plugins/devices-third-party/dto/report-input-occurrence-response.dto.js +50 -0
- package/dist/plugins/devices-third-party/dto/report-input-occurrence-response.dto.js.map +1 -0
- package/dist/plugins/devices-third-party/dto/report-input-occurrence.dto.d.ts +8 -0
- package/dist/plugins/devices-third-party/dto/report-input-occurrence.dto.js +81 -0
- package/dist/plugins/devices-third-party/dto/report-input-occurrence.dto.js.map +1 -0
- package/dist/plugins/devices-third-party/platforms/third-party-device.platform.js +19 -4
- package/dist/plugins/devices-third-party/platforms/third-party-device.platform.js.map +1 -1
- package/dist/plugins/devices-virtual/listeners/virtual-projection.listener.d.ts +2 -0
- package/dist/plugins/devices-virtual/listeners/virtual-projection.listener.js +57 -0
- package/dist/plugins/devices-virtual/listeners/virtual-projection.listener.js.map +1 -1
- package/dist/plugins/devices-virtual/platforms/virtual-device.platform.d.ts +3 -8
- package/dist/plugins/devices-virtual/platforms/virtual-device.platform.js +6 -31
- package/dist/plugins/devices-virtual/platforms/virtual-device.platform.js.map +1 -1
- package/dist/plugins/devices-wled/services/wled-mdns-discoverer.service.js +3 -1
- package/dist/plugins/devices-wled/services/wled-mdns-discoverer.service.js.map +1 -1
- package/dist/plugins/devices-zigbee2mqtt/devices-zigbee2mqtt.constants.d.ts +3 -0
- package/dist/plugins/devices-zigbee2mqtt/devices-zigbee2mqtt.constants.js +41 -5
- package/dist/plugins/devices-zigbee2mqtt/devices-zigbee2mqtt.constants.js.map +1 -1
- package/dist/plugins/devices-zigbee2mqtt/interfaces/zigbee2mqtt.interface.d.ts +7 -1
- package/dist/plugins/devices-zigbee2mqtt/mappings/config-driven.converter.js +16 -15
- package/dist/plugins/devices-zigbee2mqtt/mappings/config-driven.converter.js.map +1 -1
- package/dist/plugins/devices-zigbee2mqtt/mappings/definitions/remotes.yaml +505 -74
- package/dist/plugins/devices-zigbee2mqtt/mappings/schema/mapping-schema.json +3 -3
- package/dist/plugins/devices-zigbee2mqtt/mappings/transformers/transformer.types.d.ts +1 -1
- package/dist/plugins/devices-zigbee2mqtt/services/base-client-adapter.d.ts +8 -2
- package/dist/plugins/devices-zigbee2mqtt/services/base-client-adapter.js +6 -5
- package/dist/plugins/devices-zigbee2mqtt/services/base-client-adapter.js.map +1 -1
- package/dist/plugins/devices-zigbee2mqtt/services/device-adoption.service.js +18 -11
- package/dist/plugins/devices-zigbee2mqtt/services/device-adoption.service.js.map +1 -1
- package/dist/plugins/devices-zigbee2mqtt/services/device-mapper.service.d.ts +9 -3
- package/dist/plugins/devices-zigbee2mqtt/services/device-mapper.service.js +166 -3
- package/dist/plugins/devices-zigbee2mqtt/services/device-mapper.service.js.map +1 -1
- package/dist/plugins/devices-zigbee2mqtt/services/mqtt-client-adapter.service.js +5 -2
- package/dist/plugins/devices-zigbee2mqtt/services/mqtt-client-adapter.service.js.map +1 -1
- package/dist/plugins/devices-zigbee2mqtt/services/zigbee2mqtt.service.d.ts +1 -0
- package/dist/plugins/devices-zigbee2mqtt/services/zigbee2mqtt.service.js +44 -4
- package/dist/plugins/devices-zigbee2mqtt/services/zigbee2mqtt.service.js.map +1 -1
- package/dist/plugins/influx-v1/services/influx-v1-managed.service.js +2 -2
- package/dist/plugins/influx-v1/services/influx-v1-managed.service.js.map +1 -1
- package/dist/plugins/influx-v2/services/influx-v2-managed.service.js +2 -2
- package/dist/plugins/influx-v2/services/influx-v2-managed.service.js.map +1 -1
- package/dist/plugins/memory-storage/services/memory-storage-managed.service.js +2 -2
- package/dist/plugins/memory-storage/services/memory-storage-managed.service.js.map +1 -1
- package/dist/plugins/remote-access-cloudflare-tunnel/controllers/setup.controller.d.ts +6 -4
- package/dist/plugins/remote-access-cloudflare-tunnel/controllers/setup.controller.js +28 -16
- package/dist/plugins/remote-access-cloudflare-tunnel/controllers/setup.controller.js.map +1 -1
- package/dist/plugins/remote-access-cloudflare-tunnel/controllers/status.controller.d.ts +4 -6
- package/dist/plugins/remote-access-cloudflare-tunnel/controllers/status.controller.js +18 -17
- package/dist/plugins/remote-access-cloudflare-tunnel/controllers/status.controller.js.map +1 -1
- package/dist/plugins/remote-access-cloudflare-tunnel/models/status.model.d.ts +2 -0
- package/dist/plugins/remote-access-cloudflare-tunnel/models/status.model.js +17 -0
- package/dist/plugins/remote-access-cloudflare-tunnel/models/status.model.js.map +1 -1
- package/dist/plugins/remote-access-cloudflare-tunnel/remote-access-cloudflare-tunnel.constants.d.ts +1 -0
- package/dist/plugins/remote-access-cloudflare-tunnel/remote-access-cloudflare-tunnel.constants.js +2 -1
- package/dist/plugins/remote-access-cloudflare-tunnel/remote-access-cloudflare-tunnel.constants.js.map +1 -1
- package/dist/plugins/remote-access-cloudflare-tunnel/remote-access-cloudflare-tunnel.plugin.js +1 -1
- package/dist/plugins/remote-access-cloudflare-tunnel/remote-access-cloudflare-tunnel.plugin.js.map +1 -1
- package/dist/plugins/remote-access-cloudflare-tunnel/scripts/cloudflared-setup.sh +1 -1
- package/dist/plugins/remote-access-cloudflare-tunnel/services/cloudflare-tunnel-managed.service.d.ts +21 -2
- package/dist/plugins/remote-access-cloudflare-tunnel/services/cloudflare-tunnel-managed.service.js +132 -56
- package/dist/plugins/remote-access-cloudflare-tunnel/services/cloudflare-tunnel-managed.service.js.map +1 -1
- package/dist/plugins/remote-access-cloudflare-tunnel/services/cloudflare-tunnel-provider.service.d.ts +13 -1
- package/dist/plugins/remote-access-cloudflare-tunnel/services/cloudflare-tunnel-provider.service.js +8 -2
- package/dist/plugins/remote-access-cloudflare-tunnel/services/cloudflare-tunnel-provider.service.js.map +1 -1
- package/dist/plugins/remote-access-cloudflare-tunnel/services/cloudflare-tunnel-setup.service.js +1 -0
- package/dist/plugins/remote-access-cloudflare-tunnel/services/cloudflare-tunnel-setup.service.js.map +1 -1
- package/dist/plugins/remote-access-cloudflare-tunnel/services/cloudflared-cli.service.d.ts +1 -1
- package/dist/plugins/remote-access-cloudflare-tunnel/services/cloudflared-cli.service.js +12 -24
- package/dist/plugins/remote-access-cloudflare-tunnel/services/cloudflared-cli.service.js.map +1 -1
- package/dist/plugins/remote-access-cloudflare-tunnel/services/cloudflared-metrics.service.d.ts +1 -1
- package/dist/plugins/remote-access-cloudflare-tunnel/services/cloudflared-metrics.service.js +5 -2
- package/dist/plugins/remote-access-cloudflare-tunnel/services/cloudflared-metrics.service.js.map +1 -1
- package/dist/plugins/remote-access-cloudflare-tunnel/services/cloudflared-process.service.d.ts +4 -3
- package/dist/plugins/remote-access-cloudflare-tunnel/services/cloudflared-process.service.js +109 -49
- package/dist/plugins/remote-access-cloudflare-tunnel/services/cloudflared-process.service.js.map +1 -1
- package/dist/plugins/remote-access-tailscale/controllers/setup.controller.d.ts +11 -6
- package/dist/plugins/remote-access-tailscale/controllers/setup.controller.js +115 -25
- package/dist/plugins/remote-access-tailscale/controllers/setup.controller.js.map +1 -1
- package/dist/plugins/remote-access-tailscale/controllers/status.controller.d.ts +6 -5
- package/dist/plugins/remote-access-tailscale/controllers/status.controller.js +26 -16
- package/dist/plugins/remote-access-tailscale/controllers/status.controller.js.map +1 -1
- package/dist/plugins/remote-access-tailscale/models/status.model.d.ts +16 -0
- package/dist/plugins/remote-access-tailscale/models/status.model.js +100 -1
- package/dist/plugins/remote-access-tailscale/models/status.model.js.map +1 -1
- package/dist/plugins/remote-access-tailscale/remote-access-tailscale.constants.d.ts +3 -0
- package/dist/plugins/remote-access-tailscale/remote-access-tailscale.constants.js +4 -1
- package/dist/plugins/remote-access-tailscale/remote-access-tailscale.constants.js.map +1 -1
- package/dist/plugins/remote-access-tailscale/remote-access-tailscale.exceptions.d.ts +17 -1
- package/dist/plugins/remote-access-tailscale/remote-access-tailscale.exceptions.js +33 -1
- package/dist/plugins/remote-access-tailscale/remote-access-tailscale.exceptions.js.map +1 -1
- package/dist/plugins/remote-access-tailscale/remote-access-tailscale.openapi.d.ts +2 -2
- package/dist/plugins/remote-access-tailscale/remote-access-tailscale.openapi.js +1 -0
- package/dist/plugins/remote-access-tailscale/remote-access-tailscale.openapi.js.map +1 -1
- package/dist/plugins/remote-access-tailscale/remote-access-tailscale.plugin.js +3 -1
- package/dist/plugins/remote-access-tailscale/remote-access-tailscale.plugin.js.map +1 -1
- package/dist/plugins/remote-access-tailscale/scripts/tailscale-setup.sh +37 -4
- package/dist/plugins/remote-access-tailscale/services/tailscale-cli.service.d.ts +9 -4
- package/dist/plugins/remote-access-tailscale/services/tailscale-cli.service.js +63 -15
- package/dist/plugins/remote-access-tailscale/services/tailscale-cli.service.js.map +1 -1
- package/dist/plugins/remote-access-tailscale/services/tailscale-login.service.d.ts +8 -3
- package/dist/plugins/remote-access-tailscale/services/tailscale-login.service.js +175 -151
- package/dist/plugins/remote-access-tailscale/services/tailscale-login.service.js.map +1 -1
- package/dist/plugins/remote-access-tailscale/services/tailscale-node-managed.service.d.ts +55 -7
- package/dist/plugins/remote-access-tailscale/services/tailscale-node-managed.service.js +551 -109
- package/dist/plugins/remote-access-tailscale/services/tailscale-node-managed.service.js.map +1 -1
- package/dist/plugins/remote-access-tailscale/services/tailscale-operation-coordinator.service.d.ts +33 -0
- package/dist/plugins/remote-access-tailscale/services/tailscale-operation-coordinator.service.js +167 -0
- package/dist/plugins/remote-access-tailscale/services/tailscale-operation-coordinator.service.js.map +1 -0
- package/dist/plugins/remote-access-tailscale/services/tailscale-provider.service.d.ts +13 -1
- package/dist/plugins/remote-access-tailscale/services/tailscale-provider.service.js +8 -2
- package/dist/plugins/remote-access-tailscale/services/tailscale-provider.service.js.map +1 -1
- package/dist/plugins/remote-access-tailscale/services/tailscale-serve.service.d.ts +1 -1
- package/dist/plugins/remote-access-tailscale/services/tailscale-serve.service.js +7 -6
- package/dist/plugins/remote-access-tailscale/services/tailscale-serve.service.js.map +1 -1
- package/dist/plugins/remote-access-tailscale/services/tailscale-setup.service.d.ts +1 -3
- package/dist/plugins/remote-access-tailscale/services/tailscale-setup.service.js +11 -11
- package/dist/plugins/remote-access-tailscale/services/tailscale-setup.service.js.map +1 -1
- package/dist/plugins/remote-access-tailscale/utils/tailscale-control.utils.d.ts +5 -0
- package/dist/plugins/remote-access-tailscale/utils/tailscale-control.utils.js +36 -0
- package/dist/plugins/remote-access-tailscale/utils/tailscale-control.utils.js.map +1 -0
- package/dist/plugins/simulator/controllers/simulator.controller.d.ts +8 -2
- package/dist/plugins/simulator/controllers/simulator.controller.js +102 -2
- package/dist/plugins/simulator/controllers/simulator.controller.js.map +1 -1
- package/dist/plugins/simulator/dto/simulate-occurrence.dto.d.ts +12 -0
- package/dist/plugins/simulator/dto/simulate-occurrence.dto.js +122 -0
- package/dist/plugins/simulator/dto/simulate-occurrence.dto.js.map +1 -0
- package/dist/plugins/simulator/models/simulator-response.model.d.ts +12 -0
- package/dist/plugins/simulator/models/simulator-response.model.js +84 -1
- package/dist/plugins/simulator/models/simulator-response.model.js.map +1 -1
- package/dist/plugins/simulator/scenarios/definitions/small-apartment.yaml +78 -0
- package/dist/plugins/simulator/services/scenario-executor.service.js +3 -1
- package/dist/plugins/simulator/services/scenario-executor.service.js.map +1 -1
- package/dist/plugins/simulator/services/simulation.service.js +10 -1
- package/dist/plugins/simulator/services/simulation.service.js.map +1 -1
- package/dist/plugins/simulator/simulator.openapi.d.ts +3 -2
- package/dist/plugins/simulator/simulator.openapi.js +5 -0
- package/dist/plugins/simulator/simulator.openapi.js.map +1 -1
- package/dist/plugins/simulator/simulators/device-simulator.interface.d.ts +2 -0
- package/dist/plugins/simulator/simulators/device-simulator.interface.js +83 -0
- package/dist/plugins/simulator/simulators/device-simulator.interface.js.map +1 -1
- package/dist/plugins/simulator/simulators/index.d.ts +1 -0
- package/dist/plugins/simulator/simulators/index.js +1 -0
- package/dist/plugins/simulator/simulators/index.js.map +1 -1
- package/dist/plugins/simulator/simulators/input-controller.simulator.d.ts +10 -0
- package/dist/plugins/simulator/simulators/input-controller.simulator.js +57 -0
- package/dist/plugins/simulator/simulators/input-controller.simulator.js.map +1 -0
- package/dist/plugins/simulator/simulators/lighting.simulator.js +1 -0
- package/dist/plugins/simulator/simulators/lighting.simulator.js.map +1 -1
- package/dist/plugins/spaces-home-control/listeners/space-activity.listener.d.ts +6 -7
- package/dist/plugins/spaces-home-control/listeners/space-activity.listener.js +19 -44
- package/dist/plugins/spaces-home-control/listeners/space-activity.listener.js.map +1 -1
- package/dist/plugins/spaces-home-control/listeners/space-climate-state.listener.d.ts +4 -4
- package/dist/plugins/spaces-home-control/listeners/space-climate-state.listener.js +9 -22
- package/dist/plugins/spaces-home-control/listeners/space-climate-state.listener.js.map +1 -1
- package/dist/plugins/spaces-home-control/listeners/space-lighting-state.listener.d.ts +4 -4
- package/dist/plugins/spaces-home-control/listeners/space-lighting-state.listener.js +9 -22
- package/dist/plugins/spaces-home-control/listeners/space-lighting-state.listener.js.map +1 -1
- package/dist/plugins/spaces-home-control/listeners/space-sensor-state.listener.d.ts +4 -4
- package/dist/plugins/spaces-home-control/listeners/space-sensor-state.listener.js +9 -22
- package/dist/plugins/spaces-home-control/listeners/space-sensor-state.listener.js.map +1 -1
- package/dist/plugins/spaces-home-control/services/space-climate-state.service.d.ts +3 -5
- package/dist/plugins/spaces-home-control/services/space-climate-state.service.js +9 -12
- package/dist/plugins/spaces-home-control/services/space-climate-state.service.js.map +1 -1
- package/dist/plugins/spaces-home-control/services/space-lighting-state.service.d.ts +3 -5
- package/dist/plugins/spaces-home-control/services/space-lighting-state.service.js +7 -10
- package/dist/plugins/spaces-home-control/services/space-lighting-state.service.js.map +1 -1
- package/dist/plugins/spaces-home-control/services/space-sensor-state.service.d.ts +3 -5
- package/dist/plugins/spaces-home-control/services/space-sensor-state.service.js +7 -10
- package/dist/plugins/spaces-home-control/services/space-sensor-state.service.js.map +1 -1
- package/dist/plugins/spaces-home-control/services/space-state-read.service.d.ts +47 -0
- package/dist/plugins/spaces-home-control/services/space-state-read.service.js +262 -0
- package/dist/plugins/spaces-home-control/services/space-state-read.service.js.map +1 -0
- package/dist/plugins/spaces-home-control/spaces-home-control.plugin.js +4 -0
- package/dist/plugins/spaces-home-control/spaces-home-control.plugin.js.map +1 -1
- package/dist/spec/channels.d.ts +51 -1
- package/dist/spec/channels.js +64 -1
- package/dist/spec/channels.js.map +1 -1
- package/dist/spec/devices.d.ts +155 -2
- package/dist/spec/devices.js +161 -2
- package/dist/spec/devices.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +4 -4
|
@@ -8,20 +8,24 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
8
8
|
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
9
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
10
|
};
|
|
11
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
11
14
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
15
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
16
|
};
|
|
14
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
18
|
exports.TailscaleNodeManagedService = void 0;
|
|
16
19
|
exports.compareTailscaleVersions = compareTailscaleVersions;
|
|
17
|
-
const node_child_process_1 = require("node:child_process");
|
|
18
20
|
const os_1 = __importDefault(require("os"));
|
|
19
21
|
const path_1 = require("path");
|
|
20
22
|
const common_1 = require("@nestjs/common");
|
|
21
23
|
const config_1 = require("@nestjs/config");
|
|
22
24
|
const event_emitter_1 = require("@nestjs/event-emitter");
|
|
23
25
|
const logger_1 = require("../../../common/logger");
|
|
26
|
+
const cancellable_exec_utils_1 = require("../../../common/utils/cancellable-exec.utils");
|
|
24
27
|
const config_utils_1 = require("../../../common/utils/config.utils");
|
|
28
|
+
const remote_access_observation_utils_1 = require("../../../common/utils/remote-access-observation.utils");
|
|
25
29
|
const config_service_1 = require("../../../modules/config/services/config.service");
|
|
26
30
|
const base_managed_extension_service_1 = require("../../../modules/extensions/services/base-managed-extension.service");
|
|
27
31
|
const platform_constants_1 = require("../../../modules/platform/platform.constants");
|
|
@@ -31,9 +35,9 @@ const config_model_1 = require("../models/config.model");
|
|
|
31
35
|
const remote_access_tailscale_constants_1 = require("../remote-access-tailscale.constants");
|
|
32
36
|
const remote_access_tailscale_exceptions_1 = require("../remote-access-tailscale.exceptions");
|
|
33
37
|
const tailscale_cli_service_1 = require("./tailscale-cli.service");
|
|
38
|
+
const tailscale_operation_coordinator_service_1 = require("./tailscale-operation-coordinator.service");
|
|
34
39
|
const tailscale_serve_service_1 = require("./tailscale-serve.service");
|
|
35
40
|
const tailscale_status_mapper_service_1 = require("./tailscale-status-mapper.service");
|
|
36
|
-
const TAILSCALE_REQUIREMENTS_PERIODIC_REFRESH_MS = 5 * 60 * 1000;
|
|
37
41
|
const TAILSCALE_PRINT_PLAN_TIMEOUT_MS = 2_000;
|
|
38
42
|
const OPERATOR_GRANTED_SATISFIED_MESSAGE = 'The smart-panel operator is granted.';
|
|
39
43
|
const TAILSCALE_DOCUMENTATION_URL = 'https://smart-panel.fastybird.com/docs';
|
|
@@ -52,7 +56,7 @@ function compareTailscaleVersions(a, b) {
|
|
|
52
56
|
}
|
|
53
57
|
const UNEVALUATED_MESSAGE = 'Not evaluated: the platform requirement is not satisfied.';
|
|
54
58
|
let TailscaleNodeManagedService = class TailscaleNodeManagedService extends base_managed_extension_service_1.BaseManagedExtensionService {
|
|
55
|
-
constructor(cli, mapper, configService, nestConfigService, platformService, eventEmitter, serveService) {
|
|
59
|
+
constructor(cli, mapper, configService, nestConfigService, platformService, eventEmitter, serveService, operations = new tailscale_operation_coordinator_service_1.TailscaleOperationCoordinatorService()) {
|
|
56
60
|
super();
|
|
57
61
|
this.cli = cli;
|
|
58
62
|
this.mapper = mapper;
|
|
@@ -61,22 +65,120 @@ let TailscaleNodeManagedService = class TailscaleNodeManagedService extends base
|
|
|
61
65
|
this.platformService = platformService;
|
|
62
66
|
this.eventEmitter = eventEmitter;
|
|
63
67
|
this.serveService = serveService;
|
|
68
|
+
this.operations = operations;
|
|
64
69
|
this.logger = (0, logger_1.createExtensionLogger)(remote_access_tailscale_constants_1.REMOTE_ACCESS_TAILSCALE_PLUGIN_NAME, 'TailscaleNodeManagedService');
|
|
65
70
|
this.owner = { kind: 'plugin', type: remote_access_tailscale_constants_1.REMOTE_ACCESS_TAILSCALE_PLUGIN_NAME };
|
|
66
71
|
this.serviceId = 'node';
|
|
67
72
|
this.activationPolicy = 'owner-enabled';
|
|
73
|
+
this.observations = new remote_access_observation_utils_1.RemoteAccessObservation();
|
|
74
|
+
this.requirementObservations = new remote_access_observation_utils_1.RemoteAccessObservation();
|
|
75
|
+
this.authentication = 'unknown';
|
|
76
|
+
this.identity = {};
|
|
77
|
+
this.connectPromise = null;
|
|
78
|
+
this.stopPromise = null;
|
|
68
79
|
this.pollTimer = null;
|
|
69
80
|
this.lastStatus = null;
|
|
70
81
|
this.lastError = null;
|
|
71
82
|
this.pluginConfig = null;
|
|
83
|
+
this.pendingAdvertiseTags = null;
|
|
72
84
|
this.requirementsCache = null;
|
|
73
|
-
this.requirementsRefreshedAt = 0;
|
|
74
85
|
this.lastServeConvergeDenied = false;
|
|
75
86
|
this.reconnectAttempts = 0;
|
|
76
87
|
this.nextReconnectAttemptAt = 0;
|
|
88
|
+
this.operations.onSettled((operation) => {
|
|
89
|
+
if (operation !== 'serve' && operation !== 'reconnect') {
|
|
90
|
+
this.schedulePoll(0);
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
getOperationCoordinator() {
|
|
95
|
+
return this.operations;
|
|
96
|
+
}
|
|
97
|
+
getControlState() {
|
|
98
|
+
return {
|
|
99
|
+
enabled: this.isPluginEnabled(),
|
|
100
|
+
serviceState: this.state,
|
|
101
|
+
authentication: this.authentication,
|
|
102
|
+
operation: this.operations.getOperation(),
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
isPluginEnabled() {
|
|
106
|
+
try {
|
|
107
|
+
return this.configService.getPluginConfig(remote_access_tailscale_constants_1.REMOTE_ACCESS_TAILSCALE_PLUGIN_NAME).enabled;
|
|
108
|
+
}
|
|
109
|
+
catch {
|
|
110
|
+
return false;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
clearAuthentication() {
|
|
114
|
+
this.authentication = 'required';
|
|
115
|
+
this.identity = {};
|
|
116
|
+
}
|
|
117
|
+
observeAuthentication(status) {
|
|
118
|
+
if (status.BackendState === 'NeedsLogin') {
|
|
119
|
+
this.clearAuthentication();
|
|
120
|
+
}
|
|
121
|
+
else if (['Running', 'Starting', 'Stopped', 'NeedsMachineAuth'].includes(status.BackendState)) {
|
|
122
|
+
this.authentication = 'authenticated';
|
|
123
|
+
this.identity = this.mapper.map(status, { port: this.getBackendPort() }).details;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
async onModuleDestroy() {
|
|
127
|
+
await this.stop();
|
|
128
|
+
}
|
|
129
|
+
async ensureSupervisorStartedForLogin() {
|
|
130
|
+
if (!this.isPluginEnabled()) {
|
|
131
|
+
throw new remote_access_tailscale_exceptions_1.TailscalePluginDisabledException();
|
|
132
|
+
}
|
|
133
|
+
if (this.state !== 'started') {
|
|
134
|
+
await this.startNode(false);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
assertRequirements(requirements) {
|
|
138
|
+
const failed = requirements.find((requirement) => !requirement.satisfied);
|
|
139
|
+
if (failed) {
|
|
140
|
+
throw new remote_access_tailscale_exceptions_1.TailscaleRequirementUnsatisfiedException(failed);
|
|
141
|
+
}
|
|
142
|
+
if (requirements.length === 0) {
|
|
143
|
+
throw new tailscale_cli_service_1.TailscaleCliError('unknown', 'Tailscale setup could not be verified. Re-check setup before connecting.');
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
async connect() {
|
|
147
|
+
if (!this.isPluginEnabled()) {
|
|
148
|
+
throw new remote_access_tailscale_exceptions_1.TailscalePluginDisabledException();
|
|
149
|
+
}
|
|
150
|
+
if (this.connectPromise !== null) {
|
|
151
|
+
return this.connectPromise;
|
|
152
|
+
}
|
|
153
|
+
this.connectPromise = (this.state === 'started'
|
|
154
|
+
? this.operations.run('connect', async (token) => {
|
|
155
|
+
const config = this.getPluginConfig();
|
|
156
|
+
const requirements = await this.refreshRequirements('start');
|
|
157
|
+
this.operations.assertCurrent(token);
|
|
158
|
+
this.assertRequirements(requirements);
|
|
159
|
+
const status = await this.cli.getStatus();
|
|
160
|
+
this.operations.assertCurrent(token);
|
|
161
|
+
this.observeAuthentication(status);
|
|
162
|
+
if (!this.mapper.hasExistingKey(status)) {
|
|
163
|
+
throw new tailscale_cli_service_1.TailscaleCliError('needs-login', 'Sign in to Tailscale before connecting.');
|
|
164
|
+
}
|
|
165
|
+
if (this.mapper.map(status, { port: this.getBackendPort() }).state === 'connected') {
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
await this.applyNodePreferences(config);
|
|
169
|
+
this.operations.assertCurrent(token);
|
|
170
|
+
this.schedulePoll(0);
|
|
171
|
+
})
|
|
172
|
+
: this.startNode(true)).finally(() => {
|
|
173
|
+
this.connectPromise = null;
|
|
174
|
+
});
|
|
175
|
+
return this.connectPromise;
|
|
77
176
|
}
|
|
78
177
|
async start() {
|
|
79
|
-
|
|
178
|
+
return this.startNode(false);
|
|
179
|
+
}
|
|
180
|
+
async startNode(strict) {
|
|
181
|
+
await this.operations.run('connect', async (token) => {
|
|
80
182
|
if (this.state === 'started') {
|
|
81
183
|
return;
|
|
82
184
|
}
|
|
@@ -85,18 +187,33 @@ let TailscaleNodeManagedService = class TailscaleNodeManagedService extends base
|
|
|
85
187
|
this.reconnectAttempts = 0;
|
|
86
188
|
this.nextReconnectAttemptAt = 0;
|
|
87
189
|
const config = this.getPluginConfig();
|
|
190
|
+
this.pendingAdvertiseTags = config.advertiseTags.join(',');
|
|
88
191
|
this.logger.log('Starting Tailscale node service');
|
|
89
192
|
try {
|
|
90
193
|
const requirements = await this.refreshRequirements('start');
|
|
194
|
+
this.operations.assertCurrent(token);
|
|
195
|
+
if (strict) {
|
|
196
|
+
this.assertRequirements(requirements);
|
|
197
|
+
}
|
|
91
198
|
if (this.requirementsSatisfied(requirements)) {
|
|
92
199
|
const status = await this.getStatusOrNull();
|
|
200
|
+
this.operations.assertCurrent(token);
|
|
201
|
+
if (status) {
|
|
202
|
+
this.observeAuthentication(status);
|
|
203
|
+
}
|
|
93
204
|
if (status && this.mapper.hasExistingKey(status)) {
|
|
94
|
-
await this.
|
|
95
|
-
await this.cli.up(this.buildUpFlags(config));
|
|
205
|
+
await this.applyNodePreferences(config);
|
|
96
206
|
}
|
|
97
207
|
}
|
|
98
208
|
}
|
|
99
209
|
catch (error) {
|
|
210
|
+
this.operations.assertCurrent(token);
|
|
211
|
+
if (strict) {
|
|
212
|
+
this.state = 'error';
|
|
213
|
+
this.lastError = error instanceof Error ? error.message : 'Unknown Tailscale failure.';
|
|
214
|
+
await this.emitStatus();
|
|
215
|
+
throw error;
|
|
216
|
+
}
|
|
100
217
|
if (error instanceof tailscale_cli_service_1.TailscaleCliError && error.kind === 'permission-denied') {
|
|
101
218
|
await this.refreshRequirements('permission-denied').catch(() => undefined);
|
|
102
219
|
}
|
|
@@ -109,59 +226,155 @@ let TailscaleNodeManagedService = class TailscaleNodeManagedService extends base
|
|
|
109
226
|
});
|
|
110
227
|
});
|
|
111
228
|
}
|
|
112
|
-
this.
|
|
229
|
+
this.operations.assertCurrent(token);
|
|
113
230
|
this.state = 'started';
|
|
231
|
+
this.lastError = null;
|
|
232
|
+
this.schedulePoll(0);
|
|
114
233
|
this.logger.log('Tailscale node service started');
|
|
115
234
|
});
|
|
235
|
+
if (strict && this.authentication !== 'authenticated') {
|
|
236
|
+
throw new tailscale_cli_service_1.TailscaleCliError('needs-login', 'Sign in to Tailscale before connecting.');
|
|
237
|
+
}
|
|
116
238
|
}
|
|
117
239
|
async stop() {
|
|
118
|
-
|
|
119
|
-
|
|
240
|
+
if (this.stopPromise !== null) {
|
|
241
|
+
return this.stopPromise;
|
|
242
|
+
}
|
|
243
|
+
const shouldDown = this.state !== 'stopped' || this.operations.getOperation() !== null || this.operations.hasPendingChildren();
|
|
244
|
+
this.state = 'stopping';
|
|
245
|
+
this.observations.invalidate();
|
|
246
|
+
this.requirementObservations.invalidate();
|
|
247
|
+
this.clearPoll();
|
|
248
|
+
this.stopPromise = this.operations
|
|
249
|
+
.interrupt('disconnect', async (token) => {
|
|
250
|
+
if (!shouldDown) {
|
|
251
|
+
this.state = 'stopped';
|
|
252
|
+
await this.emitStatus();
|
|
120
253
|
return;
|
|
121
254
|
}
|
|
122
|
-
this.state = 'stopping';
|
|
123
|
-
this.clearPoll();
|
|
124
255
|
try {
|
|
125
256
|
await this.cli.down();
|
|
257
|
+
this.operations.assertCurrent(token);
|
|
126
258
|
this.state = 'stopped';
|
|
127
259
|
}
|
|
128
260
|
catch (error) {
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
}
|
|
135
|
-
else {
|
|
136
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
137
|
-
this.state = 'error';
|
|
138
|
-
this.lastError = message;
|
|
139
|
-
this.logger.error('Failed to stop the Tailscale node service', { message });
|
|
140
|
-
await this.emitStatus();
|
|
141
|
-
throw new remote_access_tailscale_exceptions_1.TailscaleNodeStopFailedException(message);
|
|
261
|
+
this.operations.assertCurrent(token);
|
|
262
|
+
const tolerated = await this.isStopFailureTolerated(error);
|
|
263
|
+
this.operations.assertCurrent(token);
|
|
264
|
+
if (!tolerated) {
|
|
265
|
+
throw error;
|
|
142
266
|
}
|
|
267
|
+
this.state = 'stopped';
|
|
268
|
+
}
|
|
269
|
+
this.lastError = null;
|
|
270
|
+
await this.emitStatus();
|
|
271
|
+
})
|
|
272
|
+
.catch(async (error) => {
|
|
273
|
+
if (error instanceof remote_access_tailscale_exceptions_1.TailscaleOperationCancelledException) {
|
|
274
|
+
throw error;
|
|
143
275
|
}
|
|
276
|
+
this.state = 'error';
|
|
277
|
+
this.lastError = error instanceof Error ? error.message : 'Unknown Tailscale failure.';
|
|
144
278
|
await this.emitStatus();
|
|
145
|
-
|
|
279
|
+
if (error instanceof Error && 'code' in error) {
|
|
280
|
+
throw error;
|
|
281
|
+
}
|
|
282
|
+
throw new remote_access_tailscale_exceptions_1.TailscaleNodeStopFailedException(this.lastError);
|
|
283
|
+
})
|
|
284
|
+
.finally(() => {
|
|
285
|
+
this.stopPromise = null;
|
|
146
286
|
});
|
|
287
|
+
return this.stopPromise;
|
|
147
288
|
}
|
|
148
289
|
async isStopFailureTolerated(error) {
|
|
149
290
|
if (error instanceof tailscale_cli_service_1.TailscaleCliError &&
|
|
150
291
|
(error.kind === 'needs-login' || error.kind === 'daemon-down' || error.kind === 'not-installed')) {
|
|
151
292
|
return true;
|
|
152
293
|
}
|
|
153
|
-
const status = await this.
|
|
294
|
+
const status = await this.getStatusOrNullWithin(remote_access_tailscale_constants_1.TAILSCALE_STOP_STATUS_TIMEOUT_MS);
|
|
154
295
|
return status?.BackendState === 'Stopped';
|
|
155
296
|
}
|
|
297
|
+
async getStatusOrNullWithin(timeoutMs) {
|
|
298
|
+
let timer;
|
|
299
|
+
try {
|
|
300
|
+
return await Promise.race([
|
|
301
|
+
this.getStatusOrNull(),
|
|
302
|
+
new Promise((resolve, reject) => {
|
|
303
|
+
timer = setTimeout(() => {
|
|
304
|
+
void this.operations.reapPendingChildren().then(() => resolve(null), reject);
|
|
305
|
+
}, timeoutMs);
|
|
306
|
+
}),
|
|
307
|
+
]);
|
|
308
|
+
}
|
|
309
|
+
finally {
|
|
310
|
+
if (timer) {
|
|
311
|
+
clearTimeout(timer);
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
}
|
|
156
315
|
async emitStatus() {
|
|
157
|
-
const
|
|
316
|
+
const generation = this.operations.getGeneration();
|
|
317
|
+
const status = this.state === 'stopped' || this.state === 'stopping' || this.state === 'error'
|
|
318
|
+
? this.buildStatus(this.state === 'error' ? 'error' : 'disconnected', this.lastError ?? 'The node service is stopped.', this.identity)
|
|
319
|
+
: await this.computeStatus();
|
|
320
|
+
if (!this.operations.isCurrent(generation)) {
|
|
321
|
+
return;
|
|
322
|
+
}
|
|
323
|
+
this.operations.assertCurrent();
|
|
158
324
|
this.lastStatus = status;
|
|
159
|
-
this.eventEmitter.emit(remote_access_constants_1.EventType.
|
|
325
|
+
this.eventEmitter.emit(remote_access_constants_1.EventType.PROVIDER_OBSERVATION, {
|
|
326
|
+
status,
|
|
327
|
+
metadata: { requirements: this.getRequirements(), control: this.getControlState() },
|
|
328
|
+
});
|
|
160
329
|
}
|
|
161
330
|
async onConfigChanged() {
|
|
331
|
+
this.observations.invalidate();
|
|
332
|
+
this.requirementObservations.invalidate();
|
|
333
|
+
if (this.stopPromise !== null) {
|
|
334
|
+
await this.stopPromise;
|
|
335
|
+
}
|
|
336
|
+
this.clearPoll();
|
|
337
|
+
return this.operations.interrupt('config', async (token) => {
|
|
338
|
+
let result;
|
|
339
|
+
try {
|
|
340
|
+
result = await this.applyConfigChange();
|
|
341
|
+
}
|
|
342
|
+
catch (error) {
|
|
343
|
+
this.operations.assertCurrent(token);
|
|
344
|
+
this.state = 'error';
|
|
345
|
+
this.lastError = error instanceof Error ? error.message : 'Unknown Tailscale failure.';
|
|
346
|
+
await this.emitStatus();
|
|
347
|
+
throw error;
|
|
348
|
+
}
|
|
349
|
+
this.operations.assertCurrent(token);
|
|
350
|
+
if (this.isPollable()) {
|
|
351
|
+
this.schedulePoll(0);
|
|
352
|
+
}
|
|
353
|
+
return result;
|
|
354
|
+
});
|
|
355
|
+
}
|
|
356
|
+
async applyConfigChange() {
|
|
162
357
|
const previous = this.pluginConfig;
|
|
163
358
|
this.pluginConfig = null;
|
|
164
359
|
const next = this.getPluginConfig();
|
|
360
|
+
if (this.pendingAdvertiseTags !== null || previous?.advertiseTags.join(',') !== next.advertiseTags.join(',')) {
|
|
361
|
+
this.pendingAdvertiseTags = next.advertiseTags.join(',');
|
|
362
|
+
}
|
|
363
|
+
if (!next.enabled) {
|
|
364
|
+
this.state = 'stopping';
|
|
365
|
+
try {
|
|
366
|
+
await this.cli.down();
|
|
367
|
+
}
|
|
368
|
+
catch (error) {
|
|
369
|
+
if (!(await this.isStopFailureTolerated(error))) {
|
|
370
|
+
throw error;
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
this.operations.assertCurrent();
|
|
374
|
+
this.state = 'stopped';
|
|
375
|
+
await this.emitStatus();
|
|
376
|
+
return { restartRequired: false };
|
|
377
|
+
}
|
|
165
378
|
if (!previous || previous.loginServer !== next.loginServer) {
|
|
166
379
|
this.logger.log('Tailscale login_server changed (or its prior value was unknown), restart required');
|
|
167
380
|
try {
|
|
@@ -178,22 +391,41 @@ let TailscaleNodeManagedService = class TailscaleNodeManagedService extends base
|
|
|
178
391
|
throw error;
|
|
179
392
|
}
|
|
180
393
|
}
|
|
394
|
+
this.operations.assertCurrent();
|
|
395
|
+
this.clearAuthentication();
|
|
181
396
|
return { restartRequired: true };
|
|
182
397
|
}
|
|
398
|
+
if (!this.isPollable()) {
|
|
399
|
+
return { restartRequired: false };
|
|
400
|
+
}
|
|
183
401
|
try {
|
|
184
402
|
const requirements = await this.refreshRequirements('start');
|
|
185
403
|
if (this.requirementsSatisfied(requirements)) {
|
|
186
|
-
|
|
404
|
+
let status = await this.getStatusOrNull();
|
|
187
405
|
if (status && this.mapper.hasExistingKey(status)) {
|
|
188
|
-
|
|
406
|
+
this.operations.assertCurrent();
|
|
407
|
+
if (this.pendingAdvertiseTags !== null) {
|
|
408
|
+
await this.applyNodePreferences(next);
|
|
409
|
+
this.operations.assertCurrent();
|
|
410
|
+
status = await this.getStatusOrNull();
|
|
411
|
+
this.operations.assertCurrent();
|
|
412
|
+
if (status) {
|
|
413
|
+
this.observeAuthentication(status);
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
else {
|
|
417
|
+
await this.cli.set(this.buildPreferenceFlags(next));
|
|
418
|
+
this.operations.assertCurrent();
|
|
419
|
+
}
|
|
189
420
|
const port = this.getBackendPort();
|
|
190
|
-
if (this.mapper.map(status, { port }).state === 'connected') {
|
|
421
|
+
if (status && this.mapper.map(status, { port }).state === 'connected') {
|
|
191
422
|
await this.convergeServe(next, port, status);
|
|
192
423
|
}
|
|
193
424
|
}
|
|
194
425
|
}
|
|
195
426
|
}
|
|
196
427
|
catch (error) {
|
|
428
|
+
this.operations.assertCurrent();
|
|
197
429
|
if (error instanceof tailscale_cli_service_1.TailscaleCliError && error.kind === 'permission-denied') {
|
|
198
430
|
await this.refreshRequirements('permission-denied').catch(() => undefined);
|
|
199
431
|
}
|
|
@@ -204,52 +436,112 @@ let TailscaleNodeManagedService = class TailscaleNodeManagedService extends base
|
|
|
204
436
|
return { restartRequired: false };
|
|
205
437
|
}
|
|
206
438
|
async isHealthy() {
|
|
439
|
+
const generation = this.operations.getGeneration();
|
|
440
|
+
if (!this.isPollable()) {
|
|
441
|
+
return false;
|
|
442
|
+
}
|
|
207
443
|
if (!this.requirementsSatisfied(this.getRequirements())) {
|
|
208
444
|
return false;
|
|
209
445
|
}
|
|
210
446
|
try {
|
|
211
|
-
const status = await this.
|
|
212
|
-
return
|
|
447
|
+
const { raw: status } = await this.computeStatusWithRawStatus();
|
|
448
|
+
return (this.isPollable() &&
|
|
449
|
+
this.operations.isCurrent(generation) &&
|
|
450
|
+
status?.BackendState === 'Running' &&
|
|
451
|
+
status.Self?.Online === true);
|
|
213
452
|
}
|
|
214
453
|
catch {
|
|
215
454
|
return false;
|
|
216
455
|
}
|
|
217
456
|
}
|
|
218
457
|
async factoryReset() {
|
|
219
|
-
|
|
458
|
+
this.state = 'stopping';
|
|
459
|
+
this.observations.invalidate();
|
|
460
|
+
this.requirementObservations.invalidate();
|
|
461
|
+
this.clearPoll();
|
|
220
462
|
try {
|
|
221
|
-
await this.
|
|
222
|
-
|
|
463
|
+
return await this.operations.interrupt('reset', async (token) => {
|
|
464
|
+
await this.cli.down().catch((error) => this.isStopFailureTolerated(error).then((safe) => {
|
|
465
|
+
if (!safe) {
|
|
466
|
+
throw error;
|
|
467
|
+
}
|
|
468
|
+
}));
|
|
469
|
+
this.operations.assertCurrent(token);
|
|
470
|
+
await this.cli.serveReset().catch(() => undefined);
|
|
471
|
+
this.operations.assertCurrent(token);
|
|
472
|
+
await this.cli.logout().catch((error) => {
|
|
473
|
+
if (!(error instanceof tailscale_cli_service_1.TailscaleCliError && ['not-installed', 'needs-login', 'daemon-down'].includes(error.kind))) {
|
|
474
|
+
throw error;
|
|
475
|
+
}
|
|
476
|
+
});
|
|
477
|
+
this.operations.assertCurrent(token);
|
|
478
|
+
this.clearAuthentication();
|
|
479
|
+
this.state = 'stopped';
|
|
480
|
+
await this.emitStatus();
|
|
481
|
+
return { success: true };
|
|
482
|
+
});
|
|
223
483
|
}
|
|
224
484
|
catch (error) {
|
|
225
|
-
if (error instanceof
|
|
226
|
-
|
|
485
|
+
if (!(error instanceof remote_access_tailscale_exceptions_1.TailscaleOperationCancelledException)) {
|
|
486
|
+
this.state = 'error';
|
|
487
|
+
this.lastError = error instanceof Error ? error.message : 'Unknown error';
|
|
488
|
+
await this.emitStatus();
|
|
227
489
|
}
|
|
228
490
|
return { success: false, reason: error instanceof Error ? error.message : 'Unknown error' };
|
|
229
491
|
}
|
|
230
492
|
}
|
|
231
493
|
async evaluateRequirements() {
|
|
232
|
-
return this.refreshRequirements('
|
|
494
|
+
return this.refreshRequirements('setup-complete');
|
|
495
|
+
}
|
|
496
|
+
async reconcileSetup(generation) {
|
|
497
|
+
if (!this.operations.isCurrent(generation) || !this.getControlState().enabled) {
|
|
498
|
+
return;
|
|
499
|
+
}
|
|
500
|
+
await this.operations.run('config', async (token) => {
|
|
501
|
+
this.operations.assertCurrent(token);
|
|
502
|
+
if (!this.operations.isCurrent(generation)) {
|
|
503
|
+
return;
|
|
504
|
+
}
|
|
505
|
+
if (this.state !== 'started') {
|
|
506
|
+
await this.startNode(false);
|
|
507
|
+
}
|
|
508
|
+
else {
|
|
509
|
+
const status = await this.cli.getStatus();
|
|
510
|
+
this.operations.assertCurrent(token);
|
|
511
|
+
this.observeAuthentication(status);
|
|
512
|
+
if (this.mapper.hasExistingKey(status)) {
|
|
513
|
+
await this.applyNodePreferences(this.getPluginConfig());
|
|
514
|
+
this.operations.assertCurrent(token);
|
|
515
|
+
}
|
|
516
|
+
this.schedulePoll(0);
|
|
517
|
+
}
|
|
518
|
+
});
|
|
233
519
|
}
|
|
234
520
|
getRequirements() {
|
|
235
521
|
return this.requirementsCache ?? [];
|
|
236
522
|
}
|
|
237
|
-
async refreshRequirements(reason) {
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
523
|
+
async refreshRequirements(reason, signal) {
|
|
524
|
+
const generation = this.operations.getGeneration();
|
|
525
|
+
const readOnly = reason === 'periodic' || reason === 'status-read';
|
|
526
|
+
const requirements = await (readOnly
|
|
527
|
+
? this.requirementObservations.run((readSignal) => this.evaluateRequirementsLive(generation, false, readSignal), signal)
|
|
528
|
+
: this.evaluateRequirementsLive(generation, true, signal));
|
|
529
|
+
signal?.throwIfAborted();
|
|
530
|
+
if (!this.operations.isCurrent(generation)) {
|
|
531
|
+
return this.getRequirements();
|
|
242
532
|
}
|
|
243
|
-
const requirements = await this.evaluateRequirementsLive();
|
|
244
533
|
this.requirementsCache = requirements;
|
|
245
|
-
this.requirementsRefreshedAt = Date.now();
|
|
246
534
|
return requirements;
|
|
247
535
|
}
|
|
248
536
|
requirementsSatisfied(requirements) {
|
|
249
537
|
return requirements.length > 0 && requirements.every((requirement) => requirement.satisfied);
|
|
250
538
|
}
|
|
251
|
-
async evaluateRequirementsLive() {
|
|
539
|
+
async evaluateRequirementsLive(generation, allowProbe = false, signal) {
|
|
252
540
|
const platform = await this.evaluatePlatformSupported();
|
|
541
|
+
signal?.throwIfAborted();
|
|
542
|
+
if (!this.operations.isCurrent(generation)) {
|
|
543
|
+
return this.getRequirements();
|
|
544
|
+
}
|
|
253
545
|
if (!platform.satisfied) {
|
|
254
546
|
return [
|
|
255
547
|
await this.finalizeRequirement(platform),
|
|
@@ -259,20 +551,34 @@ let TailscaleNodeManagedService = class TailscaleNodeManagedService extends base
|
|
|
259
551
|
this.unevaluatedRequirement('version-supported'),
|
|
260
552
|
];
|
|
261
553
|
}
|
|
262
|
-
const
|
|
263
|
-
this.evaluateBinaryAndVersion(),
|
|
264
|
-
this.evaluateDaemonActive(),
|
|
265
|
-
this.evaluateOperatorGranted(),
|
|
554
|
+
const results = await Promise.allSettled([
|
|
555
|
+
this.evaluateBinaryAndVersion(signal),
|
|
556
|
+
this.evaluateDaemonActive(signal),
|
|
557
|
+
this.evaluateOperatorGranted(generation, allowProbe, signal),
|
|
266
558
|
]);
|
|
267
|
-
|
|
559
|
+
signal?.throwIfAborted();
|
|
560
|
+
const [binaryResult, daemonResult, operatorResult] = results;
|
|
561
|
+
if (binaryResult.status === 'rejected') {
|
|
562
|
+
throw binaryResult.reason;
|
|
563
|
+
}
|
|
564
|
+
if (daemonResult.status === 'rejected') {
|
|
565
|
+
throw daemonResult.reason;
|
|
566
|
+
}
|
|
567
|
+
if (operatorResult.status === 'rejected') {
|
|
568
|
+
throw operatorResult.reason;
|
|
569
|
+
}
|
|
570
|
+
const { binary, version } = binaryResult.value;
|
|
571
|
+
const daemonActive = daemonResult.value;
|
|
572
|
+
const operatorGranted = operatorResult.value;
|
|
573
|
+
return this.attachRemedies([platform, binary, daemonActive, operatorGranted, version], signal);
|
|
268
574
|
}
|
|
269
575
|
unevaluatedRequirement(code) {
|
|
270
576
|
return { code, satisfied: false, message: UNEVALUATED_MESSAGE, remedy: null };
|
|
271
577
|
}
|
|
272
|
-
async attachRemedies(requirements) {
|
|
578
|
+
async attachRemedies(requirements, signal) {
|
|
273
579
|
let installRemedyPromise = null;
|
|
274
580
|
const getInstallRemedy = () => {
|
|
275
|
-
installRemedyPromise ??= this.buildInstallRemedy();
|
|
581
|
+
installRemedyPromise ??= this.buildInstallRemedy(signal);
|
|
276
582
|
return installRemedyPromise;
|
|
277
583
|
};
|
|
278
584
|
return Promise.all(requirements.map((requirement) => this.finalizeRequirement(requirement, getInstallRemedy)));
|
|
@@ -301,9 +607,9 @@ let TailscaleNodeManagedService = class TailscaleNodeManagedService extends base
|
|
|
301
607
|
return { commands: [], note: TAILSCALE_DOCUMENTATION_URL };
|
|
302
608
|
}
|
|
303
609
|
}
|
|
304
|
-
async buildInstallRemedy() {
|
|
610
|
+
async buildInstallRemedy(signal) {
|
|
305
611
|
try {
|
|
306
|
-
const stdout = await this.runSetupScriptPrintPlan(
|
|
612
|
+
const stdout = await this.runSetupScriptPrintPlan(signal);
|
|
307
613
|
const lines = stdout
|
|
308
614
|
.split('\n')
|
|
309
615
|
.map((line) => line.trim())
|
|
@@ -323,37 +629,100 @@ let TailscaleNodeManagedService = class TailscaleNodeManagedService extends base
|
|
|
323
629
|
return { commands: [], note: TAILSCALE_VENDOR_DOWNLOAD_URL };
|
|
324
630
|
}
|
|
325
631
|
}
|
|
326
|
-
runSetupScriptPrintPlan(
|
|
632
|
+
async runSetupScriptPrintPlan(signal) {
|
|
327
633
|
const script = (0, path_1.join)(__dirname, '..', 'scripts', 'tailscale-setup.sh');
|
|
328
|
-
return
|
|
329
|
-
(0, node_child_process_1.execFile)('bash', [script, '--print-plan', `--step=${step}`], { timeout: TAILSCALE_PRINT_PLAN_TIMEOUT_MS }, (error, stdout) => {
|
|
330
|
-
if (error) {
|
|
331
|
-
reject(error);
|
|
332
|
-
return;
|
|
333
|
-
}
|
|
334
|
-
resolve(stdout ?? '');
|
|
335
|
-
});
|
|
336
|
-
});
|
|
634
|
+
return (await (0, cancellable_exec_utils_1.cancellableExecFile)('bash', [script, '--print-plan', '--step=install'], signal, TAILSCALE_PRINT_PLAN_TIMEOUT_MS)).stdout;
|
|
337
635
|
}
|
|
338
|
-
async computeStatus(
|
|
339
|
-
return (await this.computeStatusWithRawStatus(
|
|
636
|
+
async computeStatus(_requirementsReason = 'status-read', options) {
|
|
637
|
+
return (await this.computeStatusWithRawStatus(options)).status;
|
|
340
638
|
}
|
|
341
|
-
async
|
|
639
|
+
async awaitObservationIdle() {
|
|
640
|
+
await Promise.all([this.observations.awaitIdle(), this.requirementObservations.awaitIdle()]);
|
|
641
|
+
}
|
|
642
|
+
async getStatusSnapshot(options) {
|
|
643
|
+
const observation = await this.computeStatusWithRawStatus(options);
|
|
644
|
+
return {
|
|
645
|
+
status: observation.status,
|
|
646
|
+
metadata: { requirements: observation.requirements, control: this.getControlState() },
|
|
647
|
+
};
|
|
648
|
+
}
|
|
649
|
+
async computeStatusWithRawStatus(options) {
|
|
650
|
+
const generation = this.operations.getGeneration();
|
|
651
|
+
const revision = this.operations.getObservationRevision();
|
|
652
|
+
try {
|
|
653
|
+
const result = await this.observations.run(async (signal) => {
|
|
654
|
+
const requirements = await this.refreshRequirements('status-read', signal);
|
|
655
|
+
const collected = await this.collectStatusWithRawStatus(generation, signal, requirements);
|
|
656
|
+
signal.throwIfAborted();
|
|
657
|
+
return { ...collected, requirements };
|
|
658
|
+
}, options?.signal);
|
|
659
|
+
if (!this.operations.isCurrent(generation) || !this.operations.isObservationCurrent(revision)) {
|
|
660
|
+
return this.supersededObservation();
|
|
661
|
+
}
|
|
662
|
+
if (result.raw && this.isPollable()) {
|
|
663
|
+
this.observeAuthentication(result.raw);
|
|
664
|
+
}
|
|
665
|
+
return result;
|
|
666
|
+
}
|
|
667
|
+
catch (error) {
|
|
668
|
+
if (!this.operations.isCurrent(generation) ||
|
|
669
|
+
!this.operations.isObservationCurrent(revision) ||
|
|
670
|
+
!this.isPollable()) {
|
|
671
|
+
return this.supersededObservation();
|
|
672
|
+
}
|
|
673
|
+
return {
|
|
674
|
+
status: this.buildStatus('error', error instanceof Error ? error.message : 'The status observation failed.'),
|
|
675
|
+
raw: null,
|
|
676
|
+
requirements: this.getRequirements(),
|
|
677
|
+
};
|
|
678
|
+
}
|
|
679
|
+
}
|
|
680
|
+
supersededObservation() {
|
|
681
|
+
return {
|
|
682
|
+
status: this.buildStatus(this.state === 'error' ? 'error' : 'disconnected', this.lastError ?? 'The observation was superseded by a lifecycle action.'),
|
|
683
|
+
raw: null,
|
|
684
|
+
requirements: this.getRequirements(),
|
|
685
|
+
};
|
|
686
|
+
}
|
|
687
|
+
async collectStatusWithRawStatus(generation = this.operations.getGeneration(), signal, requirements = this.getRequirements()) {
|
|
342
688
|
if (this.state === 'stopped' || this.state === 'stopping') {
|
|
343
|
-
return { status: this.buildStatus('disconnected', 'The node service is stopped.'), raw: null };
|
|
689
|
+
return { status: this.buildStatus('disconnected', 'The node service is stopped.', this.identity), raw: null };
|
|
344
690
|
}
|
|
345
691
|
if (this.state === 'error') {
|
|
346
692
|
return { status: this.buildStatus('error', this.lastError ?? 'The Tailscale node service failed.'), raw: null };
|
|
347
693
|
}
|
|
348
|
-
const platform =
|
|
694
|
+
const platform = requirements.find((requirement) => requirement.code === 'platform-supported') ?? {
|
|
695
|
+
satisfied: false,
|
|
696
|
+
message: 'Platform detection did not complete.',
|
|
697
|
+
};
|
|
698
|
+
signal?.throwIfAborted();
|
|
699
|
+
if (!this.operations.isCurrent(generation)) {
|
|
700
|
+
return {
|
|
701
|
+
status: this.buildStatus('disconnected', 'The observation was superseded by a lifecycle action.', this.identity),
|
|
702
|
+
raw: null,
|
|
703
|
+
};
|
|
704
|
+
}
|
|
349
705
|
if (!platform.satisfied) {
|
|
350
706
|
return { status: this.buildStatus('unsupported', platform.message), raw: null };
|
|
351
707
|
}
|
|
352
708
|
try {
|
|
353
|
-
const status = await this.cli.getStatus();
|
|
709
|
+
const status = await this.cli.getStatus(signal);
|
|
710
|
+
signal?.throwIfAborted();
|
|
711
|
+
if (!this.operations.isCurrent(generation)) {
|
|
712
|
+
return {
|
|
713
|
+
status: this.buildStatus('disconnected', 'The observation was superseded by a lifecycle action.', this.identity),
|
|
714
|
+
raw: null,
|
|
715
|
+
};
|
|
716
|
+
}
|
|
354
717
|
const port = this.getBackendPort();
|
|
355
718
|
const postureAdvisories = this.buildPostureAdvisories(status);
|
|
356
|
-
|
|
719
|
+
signal?.throwIfAborted();
|
|
720
|
+
if (!this.operations.isCurrent(generation)) {
|
|
721
|
+
return {
|
|
722
|
+
status: this.buildStatus('disconnected', 'The observation was superseded by a lifecycle action.', this.identity),
|
|
723
|
+
raw: null,
|
|
724
|
+
};
|
|
725
|
+
}
|
|
357
726
|
const operatorRequirement = requirements.find((requirement) => requirement.code === 'operator-granted');
|
|
358
727
|
if (operatorRequirement && !operatorRequirement.satisfied) {
|
|
359
728
|
return {
|
|
@@ -372,7 +741,7 @@ let TailscaleNodeManagedService = class TailscaleNodeManagedService extends base
|
|
|
372
741
|
};
|
|
373
742
|
}
|
|
374
743
|
const config = this.getPluginConfig();
|
|
375
|
-
const serveResult = await this.serveService.read(config, port, status);
|
|
744
|
+
const serveResult = await this.serveService.read(config, port, status, signal);
|
|
376
745
|
return {
|
|
377
746
|
status: this.buildStatus(mapped.state, mapped.message, mapped.details, [...mapped.proxyAddresses, ...serveResult.proxyAddresses], [...mapped.endpoints, ...serveResult.endpoints], [...postureAdvisories, ...serveResult.advisories]),
|
|
378
747
|
raw: status,
|
|
@@ -398,7 +767,11 @@ let TailscaleNodeManagedService = class TailscaleNodeManagedService extends base
|
|
|
398
767
|
}
|
|
399
768
|
}
|
|
400
769
|
async convergeServe(config, port, status) {
|
|
401
|
-
const result = await this.
|
|
770
|
+
const result = await this.operations.run('serve', async (token) => {
|
|
771
|
+
const converged = await this.serveService.converge(config, port, status);
|
|
772
|
+
this.operations.assertCurrent(token);
|
|
773
|
+
return converged;
|
|
774
|
+
}, false);
|
|
402
775
|
if (result.permissionDenied) {
|
|
403
776
|
if (!this.lastServeConvergeDenied) {
|
|
404
777
|
this.lastServeConvergeDenied = true;
|
|
@@ -437,9 +810,9 @@ let TailscaleNodeManagedService = class TailscaleNodeManagedService extends base
|
|
|
437
810
|
message: `Tailscale is not supported on the '${platformType}' platform.`,
|
|
438
811
|
};
|
|
439
812
|
}
|
|
440
|
-
async evaluateBinaryAndVersion() {
|
|
813
|
+
async evaluateBinaryAndVersion(signal) {
|
|
441
814
|
try {
|
|
442
|
-
const info = await this.cli.getVersion();
|
|
815
|
+
const info = await this.cli.getVersion(signal);
|
|
443
816
|
const supported = compareTailscaleVersions(info.version, remote_access_tailscale_constants_1.TAILSCALE_MIN_VERSION) >= 0;
|
|
444
817
|
return {
|
|
445
818
|
binary: { code: 'binary-installed', satisfied: true, message: `Tailscale ${info.version} is installed.` },
|
|
@@ -468,21 +841,24 @@ let TailscaleNodeManagedService = class TailscaleNodeManagedService extends base
|
|
|
468
841
|
};
|
|
469
842
|
}
|
|
470
843
|
}
|
|
471
|
-
async evaluateDaemonActive() {
|
|
472
|
-
const active = await this.isSystemdUnitActive('tailscaled');
|
|
844
|
+
async evaluateDaemonActive(signal) {
|
|
845
|
+
const active = await this.isSystemdUnitActive('tailscaled', signal);
|
|
473
846
|
return {
|
|
474
847
|
code: 'daemon-active',
|
|
475
848
|
satisfied: active,
|
|
476
849
|
message: active ? 'tailscaled is active.' : 'tailscaled is not active. Run setup or start the service.',
|
|
477
850
|
};
|
|
478
851
|
}
|
|
479
|
-
async evaluateOperatorGranted() {
|
|
852
|
+
async evaluateOperatorGranted(generation = this.operations.getGeneration(), allowProbe = false, signal) {
|
|
480
853
|
const serviceUser = os_1.default.userInfo().username;
|
|
481
854
|
try {
|
|
482
|
-
const prefs = await this.cli.getPrefs();
|
|
855
|
+
const prefs = await this.cli.getPrefs(signal);
|
|
483
856
|
return this.buildOperatorRequirement(prefs.OperatorUser === serviceUser, serviceUser);
|
|
484
857
|
}
|
|
485
858
|
catch (error) {
|
|
859
|
+
if (!this.operations.isCurrent(generation)) {
|
|
860
|
+
return { code: 'operator-granted', satisfied: false, message: 'The requirement observation was superseded.' };
|
|
861
|
+
}
|
|
486
862
|
if (error instanceof tailscale_cli_service_1.TailscaleCliError) {
|
|
487
863
|
if (error.kind === 'daemon-down') {
|
|
488
864
|
return {
|
|
@@ -499,12 +875,22 @@ let TailscaleNodeManagedService = class TailscaleNodeManagedService extends base
|
|
|
499
875
|
};
|
|
500
876
|
}
|
|
501
877
|
}
|
|
878
|
+
if (!allowProbe) {
|
|
879
|
+
const verified = this.getRequirements().find((requirement) => requirement.code === 'operator-granted');
|
|
880
|
+
return verified?.satisfied
|
|
881
|
+
? verified
|
|
882
|
+
: {
|
|
883
|
+
code: 'operator-granted',
|
|
884
|
+
satisfied: false,
|
|
885
|
+
message: 'The operator grant cannot be verified by this Tailscale version. Run Set up or Connect to verify management access.',
|
|
886
|
+
};
|
|
887
|
+
}
|
|
502
888
|
return this.evaluateOperatorGrantedViaProbe(serviceUser);
|
|
503
889
|
}
|
|
504
890
|
}
|
|
505
891
|
async evaluateOperatorGrantedViaProbe(serviceUser) {
|
|
506
892
|
try {
|
|
507
|
-
await this.cli.set([`--operator=${serviceUser}`]);
|
|
893
|
+
await this.operations.run('preferences', async () => this.cli.set([`--operator=${serviceUser}`]), false);
|
|
508
894
|
return this.buildOperatorRequirement(true, serviceUser);
|
|
509
895
|
}
|
|
510
896
|
catch (error) {
|
|
@@ -547,16 +933,15 @@ let TailscaleNodeManagedService = class TailscaleNodeManagedService extends base
|
|
|
547
933
|
return null;
|
|
548
934
|
}
|
|
549
935
|
}
|
|
550
|
-
isSystemdUnitActive(unit) {
|
|
551
|
-
|
|
552
|
-
(0,
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
});
|
|
936
|
+
async isSystemdUnitActive(unit, signal) {
|
|
937
|
+
try {
|
|
938
|
+
const result = await (0, cancellable_exec_utils_1.cancellableExecFile)('systemctl', ['is-active', unit], signal, remote_access_tailscale_constants_1.TAILSCALE_SYSTEMCTL_PROBE_TIMEOUT_MS);
|
|
939
|
+
return result.exitCode === 0 && result.stdout.trim() === 'active';
|
|
940
|
+
}
|
|
941
|
+
catch {
|
|
942
|
+
signal?.throwIfAborted();
|
|
943
|
+
return false;
|
|
944
|
+
}
|
|
560
945
|
}
|
|
561
946
|
isPollable() {
|
|
562
947
|
return this.state === 'starting' || this.state === 'started';
|
|
@@ -567,7 +952,7 @@ let TailscaleNodeManagedService = class TailscaleNodeManagedService extends base
|
|
|
567
952
|
return;
|
|
568
953
|
}
|
|
569
954
|
this.pollTimer = setTimeout(() => {
|
|
570
|
-
void this.pollTick();
|
|
955
|
+
this.operations.withoutOperation(() => void this.pollTick());
|
|
571
956
|
}, delayMs);
|
|
572
957
|
this.pollTimer.unref?.();
|
|
573
958
|
}
|
|
@@ -578,9 +963,13 @@ let TailscaleNodeManagedService = class TailscaleNodeManagedService extends base
|
|
|
578
963
|
}
|
|
579
964
|
}
|
|
580
965
|
async pollTick() {
|
|
966
|
+
const generation = this.operations.getGeneration();
|
|
967
|
+
let revision = this.operations.getObservationRevision();
|
|
581
968
|
try {
|
|
582
|
-
let { status, raw } = await this.computeStatusWithRawStatus(
|
|
583
|
-
if (!this.isPollable()
|
|
969
|
+
let { status, raw, requirements } = await this.computeStatusWithRawStatus();
|
|
970
|
+
if (!this.isPollable() ||
|
|
971
|
+
!this.operations.isCurrent(generation) ||
|
|
972
|
+
!this.operations.isObservationCurrent(revision)) {
|
|
584
973
|
return;
|
|
585
974
|
}
|
|
586
975
|
if (status.state === 'connected') {
|
|
@@ -593,27 +982,39 @@ let TailscaleNodeManagedService = class TailscaleNodeManagedService extends base
|
|
|
593
982
|
this.requirementsSatisfied(this.getRequirements()) &&
|
|
594
983
|
Date.now() >= this.nextReconnectAttemptAt) {
|
|
595
984
|
const reconnected = await this.attemptReconnect();
|
|
596
|
-
|
|
985
|
+
revision = this.operations.getObservationRevision();
|
|
986
|
+
if (!this.isPollable() || !this.operations.isCurrent(generation)) {
|
|
597
987
|
return;
|
|
598
988
|
}
|
|
599
989
|
if (reconnected) {
|
|
600
|
-
({ status, raw } = await this.computeStatusWithRawStatus(
|
|
601
|
-
if (!this.isPollable()) {
|
|
990
|
+
({ status, raw, requirements } = await this.computeStatusWithRawStatus());
|
|
991
|
+
if (!this.isPollable() || !this.operations.isCurrent(generation)) {
|
|
602
992
|
return;
|
|
603
993
|
}
|
|
604
994
|
}
|
|
605
995
|
}
|
|
606
|
-
if (
|
|
607
|
-
|
|
996
|
+
if (!this.isPollable() ||
|
|
997
|
+
!this.operations.isCurrent(generation) ||
|
|
998
|
+
!this.operations.isObservationCurrent(revision)) {
|
|
999
|
+
return;
|
|
608
1000
|
}
|
|
609
1001
|
if (this.hasStatusChanged(this.lastStatus, status)) {
|
|
610
1002
|
this.lastStatus = status;
|
|
611
|
-
this.eventEmitter.emit(remote_access_constants_1.EventType.
|
|
1003
|
+
this.eventEmitter.emit(remote_access_constants_1.EventType.PROVIDER_OBSERVATION, {
|
|
1004
|
+
status,
|
|
1005
|
+
metadata: { requirements, control: this.getControlState() },
|
|
1006
|
+
});
|
|
1007
|
+
}
|
|
1008
|
+
if (raw && status.state === 'connected' && this.requirementsSatisfied(this.getRequirements())) {
|
|
1009
|
+
await this.convergeServe(this.getPluginConfig(), this.getBackendPort(), raw);
|
|
1010
|
+
}
|
|
1011
|
+
if (!this.isPollable() || !this.operations.isCurrent(generation)) {
|
|
1012
|
+
return;
|
|
612
1013
|
}
|
|
613
1014
|
this.schedulePoll(status.state === 'connecting' ? remote_access_tailscale_constants_1.TAILSCALE_POLL_INTERVAL_TRANSITIONING_MS : remote_access_tailscale_constants_1.TAILSCALE_POLL_INTERVAL_STABLE_MS);
|
|
614
1015
|
}
|
|
615
1016
|
catch (error) {
|
|
616
|
-
if (!this.isPollable()) {
|
|
1017
|
+
if (!this.isPollable() || !this.operations.isCurrent(generation)) {
|
|
617
1018
|
return;
|
|
618
1019
|
}
|
|
619
1020
|
this.logger.error('Tailscale status poll failed', {
|
|
@@ -623,20 +1024,21 @@ let TailscaleNodeManagedService = class TailscaleNodeManagedService extends base
|
|
|
623
1024
|
}
|
|
624
1025
|
}
|
|
625
1026
|
async attemptReconnect() {
|
|
626
|
-
return this.
|
|
1027
|
+
return this.operations.run('reconnect', async (token) => {
|
|
627
1028
|
if (this.state !== 'started') {
|
|
628
1029
|
return false;
|
|
629
1030
|
}
|
|
630
1031
|
try {
|
|
631
1032
|
const config = this.getPluginConfig();
|
|
632
|
-
await this.
|
|
633
|
-
|
|
1033
|
+
await this.applyNodePreferences(config);
|
|
1034
|
+
this.operations.assertCurrent(token);
|
|
634
1035
|
this.reconnectAttempts = 0;
|
|
635
1036
|
this.nextReconnectAttemptAt = 0;
|
|
636
1037
|
this.logger.log('Tailscale node reconnected automatically after being found unexpectedly disconnected.');
|
|
637
1038
|
return true;
|
|
638
1039
|
}
|
|
639
1040
|
catch (error) {
|
|
1041
|
+
this.operations.assertCurrent(token);
|
|
640
1042
|
this.reconnectAttempts += 1;
|
|
641
1043
|
const delayMs = Math.min(remote_access_tailscale_constants_1.TAILSCALE_RECONNECT_BASE_DELAY_MS * 2 ** (this.reconnectAttempts - 1), remote_access_tailscale_constants_1.TAILSCALE_RECONNECT_MAX_DELAY_MS);
|
|
642
1044
|
this.nextReconnectAttemptAt = Date.now() + delayMs;
|
|
@@ -663,18 +1065,56 @@ let TailscaleNodeManagedService = class TailscaleNodeManagedService extends base
|
|
|
663
1065
|
JSON.stringify(previous.proxyAddresses) !== JSON.stringify(next.proxyAddresses) ||
|
|
664
1066
|
JSON.stringify(previous.advisories) !== JSON.stringify(next.advisories));
|
|
665
1067
|
}
|
|
1068
|
+
async applyNodePreferences(config) {
|
|
1069
|
+
this.operations.assertCurrent();
|
|
1070
|
+
const tags = config.advertiseTags.join(',');
|
|
1071
|
+
this.pendingAdvertiseTags = tags;
|
|
1072
|
+
await this.cli.set(this.buildPreferenceFlags(config));
|
|
1073
|
+
this.operations.assertCurrent();
|
|
1074
|
+
const upOnlyPreferencesMatch = await this.upOnlyPreferencesMatch(config);
|
|
1075
|
+
this.operations.assertCurrent();
|
|
1076
|
+
await this.cli.up(upOnlyPreferencesMatch ? [] : this.buildUpFlags(config));
|
|
1077
|
+
this.operations.assertCurrent();
|
|
1078
|
+
if (this.pendingAdvertiseTags === tags) {
|
|
1079
|
+
this.pendingAdvertiseTags = null;
|
|
1080
|
+
}
|
|
1081
|
+
}
|
|
1082
|
+
async upOnlyPreferencesMatch(config) {
|
|
1083
|
+
try {
|
|
1084
|
+
const prefs = await this.cli.getPrefs();
|
|
1085
|
+
this.operations.assertCurrent();
|
|
1086
|
+
if (typeof prefs.ControlURL !== 'string') {
|
|
1087
|
+
return false;
|
|
1088
|
+
}
|
|
1089
|
+
const controlUrl = prefs.ControlURL || remote_access_tailscale_constants_1.TAILSCALE_DEFAULT_LOGIN_SERVER;
|
|
1090
|
+
const tags = prefs.AdvertiseTags === null ? [] : prefs.AdvertiseTags;
|
|
1091
|
+
if (controlUrl !== config.loginServer || !Array.isArray(tags) || !tags.every((tag) => typeof tag === 'string')) {
|
|
1092
|
+
return false;
|
|
1093
|
+
}
|
|
1094
|
+
const advertisedTags = new Set(tags);
|
|
1095
|
+
const configuredTags = new Set(config.advertiseTags);
|
|
1096
|
+
return advertisedTags.size === configuredTags.size && [...configuredTags].every((tag) => advertisedTags.has(tag));
|
|
1097
|
+
}
|
|
1098
|
+
catch {
|
|
1099
|
+
this.operations.assertCurrent();
|
|
1100
|
+
return false;
|
|
1101
|
+
}
|
|
1102
|
+
}
|
|
666
1103
|
buildPreferenceFlags(config) {
|
|
667
1104
|
return [
|
|
668
1105
|
`--hostname=${config.hostname}`,
|
|
669
1106
|
`--accept-dns=${config.acceptDns}`,
|
|
670
1107
|
`--accept-routes=${config.acceptRoutes}`,
|
|
671
|
-
`--advertise-tags=${config.advertiseTags.join(',')}`,
|
|
672
1108
|
`--ssh=${config.ssh}`,
|
|
673
1109
|
`--operator=${os_1.default.userInfo().username}`,
|
|
674
1110
|
];
|
|
675
1111
|
}
|
|
676
1112
|
buildUpFlags(config) {
|
|
677
|
-
return [
|
|
1113
|
+
return [
|
|
1114
|
+
...this.buildPreferenceFlags(config),
|
|
1115
|
+
`--advertise-tags=${config.advertiseTags.join(',')}`,
|
|
1116
|
+
`--login-server=${config.loginServer}`,
|
|
1117
|
+
];
|
|
678
1118
|
}
|
|
679
1119
|
buildStatus(state, message, details = {}, proxyAddresses = [], endpoints = [], advisories = []) {
|
|
680
1120
|
return {
|
|
@@ -730,12 +1170,14 @@ let TailscaleNodeManagedService = class TailscaleNodeManagedService extends base
|
|
|
730
1170
|
exports.TailscaleNodeManagedService = TailscaleNodeManagedService;
|
|
731
1171
|
exports.TailscaleNodeManagedService = TailscaleNodeManagedService = __decorate([
|
|
732
1172
|
(0, common_1.Injectable)(),
|
|
1173
|
+
__param(7, (0, common_1.Optional)()),
|
|
733
1174
|
__metadata("design:paramtypes", [tailscale_cli_service_1.TailscaleCliService,
|
|
734
1175
|
tailscale_status_mapper_service_1.TailscaleStatusMapperService,
|
|
735
1176
|
config_service_1.ConfigService,
|
|
736
1177
|
config_1.ConfigService,
|
|
737
1178
|
platform_service_1.PlatformService,
|
|
738
1179
|
event_emitter_1.EventEmitter2,
|
|
739
|
-
tailscale_serve_service_1.TailscaleServeService
|
|
1180
|
+
tailscale_serve_service_1.TailscaleServeService,
|
|
1181
|
+
tailscale_operation_coordinator_service_1.TailscaleOperationCoordinatorService])
|
|
740
1182
|
], TailscaleNodeManagedService);
|
|
741
1183
|
//# sourceMappingURL=tailscale-node-managed.service.js.map
|