pinokiod 3.10.6 → 3.10.8
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.
- package/kernel/index.js +0 -4
- package/kernel/procs.js +1 -17
- package/package.json +1 -1
package/kernel/index.js
CHANGED
|
@@ -263,7 +263,6 @@ class Kernel {
|
|
|
263
263
|
this.log_queue.push({ data, group, info })
|
|
264
264
|
}
|
|
265
265
|
async refresh(notify_peers) {
|
|
266
|
-
console.log("kernel.refresh", { notify_peers })
|
|
267
266
|
let env = await Environment.get(this.homedir)
|
|
268
267
|
let peer_active = false
|
|
269
268
|
// if PINOKIO_NETWORK_SHARE is 0 or false, turn it off
|
|
@@ -274,13 +273,10 @@ class Kernel {
|
|
|
274
273
|
if (env && env.PINOKIO_HTTPS_ACTIVE && (env.PINOKIO_HTTPS_ACTIVE==="1" || env.PINOKIO_HTTPS_ACTIVE.toLowerCase()==="true")) {
|
|
275
274
|
https_active = true
|
|
276
275
|
}
|
|
277
|
-
console.log({ https_active, peer_active })
|
|
278
276
|
// console.log("kernel.refresh", { active, notify_peers })
|
|
279
277
|
|
|
280
278
|
let caddy_installed = await this.bin.check_installed({ name: "caddy" })
|
|
281
279
|
|
|
282
|
-
console.log({ caddy_installed, https_active })
|
|
283
|
-
|
|
284
280
|
// 1. https
|
|
285
281
|
// 2. https + local share
|
|
286
282
|
// console.log("caddy installed?", caddy_installed)
|
package/kernel/procs.js
CHANGED
|
@@ -18,31 +18,25 @@ class Procs {
|
|
|
18
18
|
getPortPidList(callback) {
|
|
19
19
|
const isWin = platform === 'win32';
|
|
20
20
|
const cmd = isWin ? 'netstat -ano -p tcp' : 'lsof -nP -iTCP -sTCP:LISTEN';
|
|
21
|
-
exec(cmd, async (err, stdout) => {
|
|
21
|
+
exec(cmd, { maxBuffer: 10 * 1024 * 1024 }, async (err, stdout) => {
|
|
22
22
|
if (err) return callback(err);
|
|
23
23
|
|
|
24
24
|
const results = [];
|
|
25
25
|
let pids = new Set()
|
|
26
26
|
let s = stdout.trim()
|
|
27
|
-
console.log(">>>>>>>>>>", s)
|
|
28
27
|
const lines = s.split('\n');
|
|
29
28
|
|
|
30
|
-
console.log("LINES", lines)
|
|
31
29
|
for(let line of lines) {
|
|
32
|
-
console.log({ line, isWin })
|
|
33
30
|
if (isWin) {
|
|
34
31
|
// Skip headers
|
|
35
32
|
if (!line.startsWith(' TCP')) continue;
|
|
36
33
|
const parts = line.trim().split(/\s+/);
|
|
37
34
|
const [ , localAddress, , state, pid ] = parts;
|
|
38
|
-
console.log({ parts, localAddress, state, pid })
|
|
39
35
|
|
|
40
36
|
//if (state !== 'LISTENING') return;
|
|
41
37
|
let isHttp = await this.isHttp(localAddress)
|
|
42
|
-
console.log({ localAddress, isHttp })
|
|
43
38
|
if (!isHttp) continue
|
|
44
39
|
const chunks = localAddress.split(":")
|
|
45
|
-
console.log({ chunks })
|
|
46
40
|
const port = chunks.pop()
|
|
47
41
|
let ip = chunks.pop()
|
|
48
42
|
if (!ip || ip === "*") {
|
|
@@ -50,7 +44,6 @@ class Procs {
|
|
|
50
44
|
} else {
|
|
51
45
|
ip = localAddress
|
|
52
46
|
}
|
|
53
|
-
console.log({ port, ip })
|
|
54
47
|
if (pids.has(pid+"/"+port)) continue;
|
|
55
48
|
pids.add(pid+"/"+port)
|
|
56
49
|
results.push({ port, pid, ip });
|
|
@@ -58,14 +51,11 @@ class Procs {
|
|
|
58
51
|
//if (!/LISTEN/.test(line)) return;
|
|
59
52
|
const parts = line.trim().split(/\s+/);
|
|
60
53
|
const pid = parts[1];
|
|
61
|
-
console.log({ parts, pid })
|
|
62
54
|
|
|
63
55
|
const match = line.match(/([^\s]+:\d+)\s/);
|
|
64
|
-
console.log({ line, match })
|
|
65
56
|
const localAddress = match?.[1];
|
|
66
57
|
|
|
67
58
|
let isHttp = await this.isHttp(localAddress)
|
|
68
|
-
console.log({ localAddress, isHttp })
|
|
69
59
|
if (!isHttp) continue;
|
|
70
60
|
|
|
71
61
|
const chunks = localAddress.split(":")
|
|
@@ -83,8 +73,6 @@ class Procs {
|
|
|
83
73
|
if (pid && port) results.push({ port, pid, ip });
|
|
84
74
|
}
|
|
85
75
|
}
|
|
86
|
-
console.log("CALL")
|
|
87
|
-
|
|
88
76
|
callback(null, results);
|
|
89
77
|
});
|
|
90
78
|
}
|
|
@@ -110,10 +98,7 @@ class Procs {
|
|
|
110
98
|
async refresh() {
|
|
111
99
|
let map = {}
|
|
112
100
|
let list = await new Promise((resolve, reject) => {
|
|
113
|
-
console.time("getPortPidList")
|
|
114
101
|
this.getPortPidList((err, portPidList) => {
|
|
115
|
-
console.log({ portPidList })
|
|
116
|
-
console.timeEnd("getPortPidList")
|
|
117
102
|
if (err) {
|
|
118
103
|
console.log("getPortPidList Error", err)
|
|
119
104
|
reject(err)
|
|
@@ -138,7 +123,6 @@ class Procs {
|
|
|
138
123
|
return { port, pid , name, fullname, ip }
|
|
139
124
|
}
|
|
140
125
|
}).filter((x) => { return x })
|
|
141
|
-
console.log({ list })
|
|
142
126
|
resolve(list)
|
|
143
127
|
});
|
|
144
128
|
});
|