ddmaster 2.1.4 → 2.2.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/README.md +3 -0
- package/package.json +1 -1
- package/testserverlist.js +12 -3
package/README.md
CHANGED
package/package.json
CHANGED
package/testserverlist.js
CHANGED
|
@@ -14,6 +14,16 @@ async function getrawDDNetServers() {
|
|
|
14
14
|
}
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
+
/**
|
|
18
|
+
*
|
|
19
|
+
* @param {string} addr - берёт примерно такое "tw-0.7+udp://152.89.254.27:8310"
|
|
20
|
+
* @returns {string|null} 152.89.254.27:8310 возвращает чистый адрес (если addr не валидный то null)
|
|
21
|
+
*/
|
|
22
|
+
function convertudptw(addr = 'string') {
|
|
23
|
+
const match = addr.match(/(\d{1,3}(\.\d{1,3}){3}:\d+)/);
|
|
24
|
+
return match[1];
|
|
25
|
+
}
|
|
26
|
+
|
|
17
27
|
/**
|
|
18
28
|
* Делает запрос на мастер сервер ДДНета.
|
|
19
29
|
* @returns Сервера ДДНета если все пошло хорошо. ['ip:port']
|
|
@@ -28,8 +38,7 @@ async function getDDNetServers() {
|
|
|
28
38
|
|
|
29
39
|
for (const server of servers) {
|
|
30
40
|
server.addresses.forEach(addr => {
|
|
31
|
-
|
|
32
|
-
if (match) ipv4WithPorts.push(match[1]);
|
|
41
|
+
ipv4WithPorts.push(convertudptw(addr));
|
|
33
42
|
});
|
|
34
43
|
}
|
|
35
44
|
return [...new Set(ipv4WithPorts)];
|
|
@@ -39,4 +48,4 @@ async function getDDNetServers() {
|
|
|
39
48
|
}
|
|
40
49
|
}
|
|
41
50
|
|
|
42
|
-
module.exports = { getDDNetServers, getrawDDNetServers }
|
|
51
|
+
module.exports = { getDDNetServers, getrawDDNetServers, convertudptw }
|