teeworlds 2.4.5 → 2.4.7

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/test.js ADDED
@@ -0,0 +1,57 @@
1
+ let crypto = require('crypto');
2
+ let list = {
3
+ "WHAT_IS": Buffer.from([0x24, 0x5e, 0x50, 0x97, 0x9f, 0xe0, 0x39, 0xd6, 0xbf, 0x7d, 0x9a, 0x29, 0xe1, 0x69, 0x1e, 0x4c]),
4
+ "IT_IS": Buffer.from([0x69, 0x54, 0x84, 0x7e, 0x2e, 0x87, 0x36, 0x03, 0xb5, 0x62, 0x36, 0xda, 0x29, 0xed, 0x1a, 0xca]),
5
+ "I_DONT_KNOW": Buffer.from([0x41, 0x69, 0x11, 0xb5, 0x79, 0x73, 0x33, 0xbf, 0x8d, 0x52, 0x7b, 0xf0, 0x1e, 0x51, 0x9c, 0xf0]),
6
+ "RCON_TYPE": Buffer.from([0x12, 0x81, 0x0e, 0x1f, 0xa1, 0xdb, 0x33, 0x78, 0xb4, 0xfb, 0x16, 0x4e, 0xd6, 0x50, 0x59, 0x26]),
7
+ "MAP_DETAILS": Buffer.from([0xf9, 0x11, 0x7b, 0x3c, 0x80, 0x39, 0x34, 0x16, 0x9f, 0xc0, 0xae, 0xf2, 0xbc, 0xb7, 0x5c, 0x03]),
8
+ "CAPABILITIES": Buffer.from([0xf6, 0x21, 0xa5, 0xa1, 0xf5, 0x85, 0x37, 0x75, 0x8e, 0x73, 0x41, 0xbe, 0xee, 0x79, 0xf2, 0xb2]),
9
+ "CLIENT_VERSION": Buffer.from([0x8c, 0x00, 0x13, 0x04, 0x84, 0x61, 0x3e, 0x47, 0x87, 0x87, 0xf6, 0x72, 0xb3, 0x83, 0x5b, 0xd4]),
10
+ // "PING_EX": Buffer.from([]),
11
+ // "PONG_EX": Buffer.from([]),
12
+ // "CHECKSUM_REQUEST": Buffer.from([]),
13
+ // "CHECKSUM_RESPONSE": Buffer.from([]),
14
+ // "CHECKSUM_ERROR": Buffer.from([])
15
+ }
16
+ let newList = {
17
+ "what_is": ("what-is@ddnet.tw"),
18
+ "it_is": ("it-is@ddnet.tw"),
19
+ "i_dont_know": ("i-dont-know@ddnet.tw"),
20
+ "rcon_type": ("rcon-type@ddnet.tw"),
21
+ "map_details": ("map-details@ddnet.tw"),
22
+ "capabilities": ("capabilities@ddnet.tw"),
23
+ "client_version": ("clientver@ddnet.tw"),
24
+ "ping": ("ping@ddnet.tw"),
25
+ "pong": ("pong@ddnet.tw"),
26
+ "checksum_request": ("checksum-request@ddnet.tw"),
27
+ "checksum_response": ("checksum-response@ddnet.tw"),
28
+ "checksum_error": ("checksum-error@ddnet.tw")
29
+ }
30
+
31
+ const createTwMD5Hash = (name) => { // https://github.com/ddnet/ddnet/blob/6d9284adc1e0be4b5348447d857eae575e06e654/src/engine/shared/uuid_manager.cpp#L26
32
+ let hash = crypto.createHash("md5")
33
+ .update(Buffer.from([0xe0, 0x5d, 0xda, 0xaa, 0xc4, 0xe6, 0x4c, 0xfb, 0xb6, 0x42, 0x5d, 0x48, 0xe8, 0x0c, 0x00, 0x29]))
34
+ .update(name)
35
+ .digest()
36
+ hash[6] &= 0x0f;
37
+ hash[6] |= 0x30;
38
+ hash[8] &= 0x3f;
39
+ hash[8] |= 0x80;
40
+ return hash;
41
+ }
42
+
43
+ Object.keys(newList).forEach(name => {
44
+ let el = newList[name];
45
+ let el_old = list[name.toUpperCase()];
46
+ if (el_old == undefined)
47
+ return;
48
+ // let hash = crypto.createHash("md5")
49
+ // .update(Buffer.from([0xe0, 0x5d, 0xda, 0xaa, 0xc4, 0xe6, 0x4c, 0xfb, 0xb6, 0x42, 0x5d, 0x48, 0xe8, 0x0c, 0x00, 0x29]))
50
+ // .update(name).digest()
51
+
52
+ let hash = createTwMD5Hash(el);
53
+ console.log(hash.compare(el_old), name)
54
+ if (hash.compare(el_old) !== 0)
55
+ console.log(name, hash, el_old)
56
+ // it_is <Buffer 69 54 84 7e 2e 87 c6 03 75 62 36 da 29 ed 1a ca> <Buffer 69 54 84 7e 2e 87 36 03 b5 62 36 da 29 ed 1a ca>
57
+ });