homebridge-xbox-tv 2.10.0-beta.21 → 2.10.0-beta.23
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/package.json +1 -1
- package/src/localApi/message.js +13 -11
- package/src/localApi/simple.js +25 -23
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"displayName": "Xbox TV",
|
|
3
3
|
"name": "homebridge-xbox-tv",
|
|
4
|
-
"version": "2.10.0-beta.
|
|
4
|
+
"version": "2.10.0-beta.23",
|
|
5
5
|
"description": "Homebridge plugin (https://github.com/homebridge/homebridge) to control Xbox game consoles.",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"author": "grzegorz914",
|
package/src/localApi/message.js
CHANGED
|
@@ -9,9 +9,9 @@ class MESSAGE {
|
|
|
9
9
|
//type
|
|
10
10
|
this.type = type;
|
|
11
11
|
|
|
12
|
-
//
|
|
13
|
-
|
|
14
|
-
this.
|
|
12
|
+
//structure
|
|
13
|
+
const structure = new Packets();
|
|
14
|
+
this.structure = structure[type];
|
|
15
15
|
|
|
16
16
|
//channelId
|
|
17
17
|
this.channelId = '\x00\x00\x00\x00\x00\x00\x00\x00';
|
|
@@ -128,10 +128,10 @@ class MESSAGE {
|
|
|
128
128
|
set(key, value, subkey = false) {
|
|
129
129
|
switch (subkey) {
|
|
130
130
|
case true:
|
|
131
|
-
this.
|
|
131
|
+
this.structure[subkey][key].value = value;
|
|
132
132
|
break;
|
|
133
133
|
case false:
|
|
134
|
-
this.
|
|
134
|
+
this.structure[key].value = value;
|
|
135
135
|
break;
|
|
136
136
|
};
|
|
137
137
|
};
|
|
@@ -141,8 +141,8 @@ class MESSAGE {
|
|
|
141
141
|
const structure = new Structure();
|
|
142
142
|
let packet;
|
|
143
143
|
|
|
144
|
-
for (const name in this.
|
|
145
|
-
this.
|
|
144
|
+
for (const name in this.structure) {
|
|
145
|
+
this.structure[name].pack(structure);
|
|
146
146
|
}
|
|
147
147
|
|
|
148
148
|
const header = new Structure();
|
|
@@ -201,10 +201,12 @@ class MESSAGE {
|
|
|
201
201
|
packet.payloadDecrypted = new Structure(payloadDecrypted).toBuffer();
|
|
202
202
|
packet.payloadProtected = {};
|
|
203
203
|
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
204
|
+
let packetStructureProtected = new Packets();
|
|
205
|
+
packetStructureProtected = packetStructureProtected[packet.type];
|
|
206
|
+
|
|
207
|
+
const packetDecrypted = new Structure(payloadDecrypted);
|
|
208
|
+
for (const name in packetStructureProtected) {
|
|
209
|
+
packet.payloadProtected[name] = packetStructureProtected[name].unpack(packetDecrypted);
|
|
208
210
|
};
|
|
209
211
|
};
|
|
210
212
|
|
package/src/localApi/simple.js
CHANGED
|
@@ -7,23 +7,23 @@ class SIMPLE {
|
|
|
7
7
|
//type
|
|
8
8
|
this.type = type;
|
|
9
9
|
|
|
10
|
-
//
|
|
11
|
-
|
|
12
|
-
this.
|
|
13
|
-
this.
|
|
10
|
+
//structure
|
|
11
|
+
const structure = new Packets();
|
|
12
|
+
this.structure = structure[type];
|
|
13
|
+
this.structureProtected = this.structure.payloadProtected !== undefined ? structure[`${type}Protected`] : false;
|
|
14
14
|
};
|
|
15
15
|
|
|
16
16
|
set(key, value, isProtected = false) {
|
|
17
17
|
switch (isProtected) {
|
|
18
18
|
case true:
|
|
19
|
-
const structureProtectedLength = this.
|
|
20
|
-
this.
|
|
21
|
-
this.
|
|
19
|
+
const structureProtectedLength = this.structureProtected[key].length || 0;
|
|
20
|
+
this.structureProtected[key].value = value;
|
|
21
|
+
this.structureProtected[key].length = structureProtectedLength > 0 ? value.length : structureProtectedLength;
|
|
22
22
|
break;
|
|
23
23
|
case false:
|
|
24
|
-
const structureLength = this.
|
|
25
|
-
this.
|
|
26
|
-
this.
|
|
24
|
+
const structureLength = this.structure[key].length || 0;
|
|
25
|
+
this.structure[key].value = value;
|
|
26
|
+
this.structure[key].length = structureLength > 0 ? value.length : structureLength;
|
|
27
27
|
break;
|
|
28
28
|
};
|
|
29
29
|
}
|
|
@@ -34,15 +34,15 @@ class SIMPLE {
|
|
|
34
34
|
let payloadProtectedLength = 0;
|
|
35
35
|
let payloadProtectedLengthReal = 0;
|
|
36
36
|
|
|
37
|
-
for (const name in this.
|
|
37
|
+
for (const name in this.structure) {
|
|
38
38
|
switch (name) {
|
|
39
39
|
case 'payloadProtected':
|
|
40
40
|
const packetStructureProtected = new Structure();
|
|
41
|
-
for (const nameStruct in this.
|
|
42
|
-
if (this.
|
|
43
|
-
this.
|
|
41
|
+
for (const nameStruct in this.structureProtected) {
|
|
42
|
+
if (this.structure.payloadProtected.value !== undefined) {
|
|
43
|
+
this.structureProtected[nameStruct].value = this.structure.payloadProtected.value[nameStruct];
|
|
44
44
|
}
|
|
45
|
-
this.
|
|
45
|
+
this.structureProtected[nameStruct].pack(packetStructureProtected);
|
|
46
46
|
}
|
|
47
47
|
payloadProtectedLength = packetStructureProtected.toBuffer().length;
|
|
48
48
|
|
|
@@ -56,11 +56,11 @@ class SIMPLE {
|
|
|
56
56
|
}
|
|
57
57
|
|
|
58
58
|
payloadProtectedLengthReal = packetStructureProtected.toBuffer().length;
|
|
59
|
-
const payloadEncrypted = crypto.encrypt(packetStructureProtected.toBuffer(), crypto.getKey(), this.
|
|
59
|
+
const payloadEncrypted = crypto.encrypt(packetStructureProtected.toBuffer(), crypto.getKey(), this.structure.iv.value);
|
|
60
60
|
structure.writeBytes(payloadEncrypted);
|
|
61
61
|
break;
|
|
62
62
|
default:
|
|
63
|
-
this.
|
|
63
|
+
this.structure[name].pack(structure);
|
|
64
64
|
}
|
|
65
65
|
}
|
|
66
66
|
|
|
@@ -153,8 +153,8 @@ class SIMPLE {
|
|
|
153
153
|
packet.version = structure.readUInt16();
|
|
154
154
|
}
|
|
155
155
|
|
|
156
|
-
for (const name in this.
|
|
157
|
-
packet[name] = this.
|
|
156
|
+
for (const name in this.structure) {
|
|
157
|
+
packet[name] = this.structure[name].unpack(structure);
|
|
158
158
|
this.set(name, packet[name]);
|
|
159
159
|
}
|
|
160
160
|
|
|
@@ -166,10 +166,12 @@ class SIMPLE {
|
|
|
166
166
|
const payloadDecrypted = crypto.decrypt(packet.payloadProtected, packet.iv).slice(0, packet.payloadProtectedLength);
|
|
167
167
|
packet.payloadProtected = {};
|
|
168
168
|
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
169
|
+
let packetStructureProtected = new Packets();
|
|
170
|
+
packetStructureProtected = packetStructureProtected[`${packet.type}Protected`];
|
|
171
|
+
|
|
172
|
+
const packetDecrypted = new Structure(payloadDecrypted);
|
|
173
|
+
for (const name in packetStructureProtected) {
|
|
174
|
+
packet.payloadProtected[name] = packetStructureProtected[name].unpack(packetDecrypted);
|
|
173
175
|
this.set('payloadProtected', packet.payloadProtected);
|
|
174
176
|
}
|
|
175
177
|
}
|