alphatheta-connect 0.25.2 → 0.26.0

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/lib/cli.js CHANGED
@@ -7111,7 +7111,12 @@ class ProlinkNetwork {
7111
7111
  }
7112
7112
  const tx = Telemetry.startTransaction({ name: 'connect' });
7113
7113
  const connectMethod = (_a = __classPrivateFieldGet(this, _ProlinkNetwork_config, "f").connectMethod) !== null && _a !== void 0 ? _a : 'active';
7114
+ // Pick the device number once and keep it. A CDJ-3000 that already holds
7115
+ // a record for our IP ignores a re-claim under a different number, so a
7116
+ // disconnect/connect cycle must present the same identity (see
7117
+ // getStagehandMac).
7114
7118
  const vcdjId = (_b = __classPrivateFieldGet(this, _ProlinkNetwork_config, "f").vcdjId) !== null && _b !== void 0 ? _b : (connectMethod === 'stagehand' ? (0, virtualcdj_1.generateStagehandDeviceId)() : constants_1.DEFAULT_VCDJ_ID);
7119
+ __classPrivateFieldGet(this, _ProlinkNetwork_config, "f").vcdjId = vcdjId;
7115
7120
  const vcdjName = (_c = __classPrivateFieldGet(this, _ProlinkNetwork_config, "f").vcdjName) !== null && _c !== void 0 ? _c : (connectMethod === 'stagehand' ? 'Stagehand' : undefined);
7116
7121
  // Create VCDJ or Stagehand device
7117
7122
  const vcdj = connectMethod === 'stagehand'
@@ -12000,7 +12005,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
12000
12005
  var _StagehandAnnouncer_instances, _StagehandAnnouncer_announceSocket, _StagehandAnnouncer_vcdj, _StagehandAnnouncer_intervalHandle, _StagehandAnnouncer_currentStage, _StagehandAnnouncer_stageCounter, _StagehandAnnouncer_iface, _StagehandAnnouncer_logger, _StagehandAnnouncer_onStartupComplete, _StagehandAnnouncer_mac, _StagehandAnnouncer_startStartup, _StagehandAnnouncer_sendPacket, _StagehandAnnouncer_sendStagePackets, _StagehandAnnouncer_advanceStage, _StagehandAnnouncer_startKeepAlive;
12001
12006
  Object.defineProperty(exports, "__esModule", ({ value: true }));
12002
12007
  exports.StagehandAnnouncer = exports.getVirtualStagehand = exports.StagehandStartupStage = exports.STAGEHAND_KEEP_ALIVE_INTERVAL = exports.STAGEHAND_STARTUP_INTERVAL = void 0;
12003
- exports.generateStagehandMac = generateStagehandMac;
12008
+ exports.getStagehandMac = getStagehandMac;
12004
12009
  exports.generateStagehandDeviceId = generateStagehandDeviceId;
12005
12010
  exports.makeStagehand0aPacket = makeStagehand0aPacket;
12006
12011
  exports.makeStagehand02Packet = makeStagehand02Packet;
@@ -12019,17 +12024,21 @@ var StagehandStartupStage;
12019
12024
  StagehandStartupStage[StagehandStartupStage["KeepAlive"] = 6] = "KeepAlive";
12020
12025
  })(StagehandStartupStage || (exports.StagehandStartupStage = StagehandStartupStage = {}));
12021
12026
  /**
12022
- * Generates a randomized MAC address with the AlphaTheta OUI (c8:3d:fc).
12027
+ * The protocol-layer MAC a Stagehand device embeds in its 0x02 claim and 0x06
12028
+ * keep-alive: the AlphaTheta OUI (c8:3d:fc) followed by the low three bytes of
12029
+ * the interface's own MAC.
12030
+ *
12031
+ * This must stay stable for the life of the host. A CDJ-3000 records a peer by
12032
+ * the identity in its claim, and once it holds a record for our IP it ignores
12033
+ * later claims from the same IP that carry a different MAC or device number:
12034
+ * the new peer never receives the unicast status/position stream. Observed on
12035
+ * emulated CDJ-3000 firmware 3.20: a freshly randomized identity on every
12036
+ * connect() was served once and then never again until the player rebooted,
12037
+ * while the previously registered identity kept being served immediately.
12023
12038
  */
12024
- function generateStagehandMac() {
12025
- const mac = new Uint8Array(6);
12026
- mac[0] = 0xc8;
12027
- mac[1] = 0x3d;
12028
- mac[2] = 0xfc;
12029
- mac[3] = Math.floor(Math.random() * 256);
12030
- mac[4] = Math.floor(Math.random() * 256);
12031
- mac[5] = Math.floor(Math.random() * 256);
12032
- return mac;
12039
+ function getStagehandMac(iface) {
12040
+ const ifaceMac = iface.mac.split(':').map(s => parseInt(s, 16));
12041
+ return Uint8Array.from([0xc8, 0x3d, 0xfc, ...ifaceMac.slice(3, 6)]);
12033
12042
  }
12034
12043
  /**
12035
12044
  * Generates a random Stagehand device ID in the observed range of 141 to 211.
@@ -12043,9 +12052,9 @@ function generateStagehandDeviceId() {
12043
12052
  * @param iface - The network interface to use
12044
12053
  * @param id - The device ID to use (defaults to random Stagehand ID)
12045
12054
  * @param name - The device name (defaults to 'Stagehand')
12046
- * @param macAddr - The optional randomized MAC address
12055
+ * @param macAddr - The protocol-layer MAC (defaults to one derived from iface)
12047
12056
  */
12048
- const getVirtualStagehand = (iface, id = generateStagehandDeviceId(), name = 'Stagehand', macAddr = generateStagehandMac()) => ({
12057
+ const getVirtualStagehand = (iface, id = generateStagehandDeviceId(), name = 'Stagehand', macAddr = getStagehandMac(iface)) => ({
12049
12058
  id,
12050
12059
  name,
12051
12060
  type: types_1.DeviceType.Stagehand,