pinokiod 3.15.0 → 3.15.2

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.
@@ -233,7 +233,8 @@ class Api {
233
233
  id: req.params.id || requestPath,
234
234
  type: "disconnect"
235
235
  })
236
- this.kernel.refresh(true)
236
+ // console.log("kernel.refresh api.stop")
237
+ // this.kernel.refresh(true)
237
238
  return true
238
239
  }
239
240
  async startScripts() {
@@ -1153,7 +1154,8 @@ class Api {
1153
1154
  })
1154
1155
  }
1155
1156
  }
1156
- this.kernel.refresh(true)
1157
+ // console.log("kernel.refresh after step")
1158
+ // this.kernel.refresh(true)
1157
1159
  } catch (e) {
1158
1160
  ondata({ raw: e.toString() })
1159
1161
  }
@@ -1,12 +1,13 @@
1
1
  const axios = require('axios')
2
2
  const fs = require('fs')
3
+ const semver = require('semver')
3
4
 
4
5
  class Caddy {
5
6
  cmd() {
6
7
  if (this.kernel.platform === "win32") {
7
- return "caddy"
8
+ return "caddy=2.9.1"
8
9
  } else {
9
- return "caddy nss"
10
+ return "caddy=2.9.1 nss"
10
11
  }
11
12
  }
12
13
  async running() {
@@ -44,7 +45,8 @@ class Caddy {
44
45
  }
45
46
  })
46
47
  })
47
- this.kernel.refresh(true)
48
+ console.log("kernel.refresh bin.caddy.start")
49
+ // this.kernel.refresh(true)
48
50
  }
49
51
  }
50
52
  async install(req, ondata, kernel, id) {
@@ -101,14 +103,25 @@ class Caddy {
101
103
  }
102
104
  }
103
105
  async installed() {
104
- let e = await this.kernel.exists(this.kernel.path("cache/XDG_DATA_HOME/caddy/pki/authorities/local/root.crt"))
105
- if (e) {
106
- if (this.kernel.platform === "win32") {
107
- return this.kernel.bin.installed.conda.has("caddy")
106
+ try {
107
+ let version = this.kernel.bin.installed.conda_versions.caddy
108
+ let coerced = semver.coerce(version)
109
+ let requirement = "<2.10.0"
110
+ let satisfied = semver.satisfies(coerced, requirement)
111
+ if (!satisfied) {
112
+ return false
113
+ }
114
+ let e = await this.kernel.exists(this.kernel.path("cache/XDG_DATA_HOME/caddy/pki/authorities/local/root.crt"))
115
+ if (e) {
116
+ if (this.kernel.platform === "win32") {
117
+ return this.kernel.bin.installed.conda.has("caddy")
118
+ } else {
119
+ return this.kernel.bin.installed.conda.has("caddy") && this.kernel.bin.installed.conda.has("nss")
120
+ }
108
121
  } else {
109
- return this.kernel.bin.installed.conda.has("caddy") && this.kernel.bin.installed.conda.has("nss")
122
+ return false
110
123
  }
111
- } else {
124
+ } catch (e) {
112
125
  return false
113
126
  }
114
127
  }
@@ -159,7 +159,6 @@ module.exports = {
159
159
  { name: "caddy", },
160
160
  { name: "py", },
161
161
  ])
162
- console.log("Setup.network", requirements)
163
162
  return {
164
163
  icon: "fa-solid fa-wifi",
165
164
  title: "Network",
@@ -187,7 +186,6 @@ module.exports = {
187
186
  { name: "caddy", },
188
187
  { name: "py", },
189
188
  ])
190
- console.log("Setup.connect", requirements)
191
189
  return {
192
190
  icon: "fa-solid fa-wifi",
193
191
  title: "API Connect",
package/kernel/index.js CHANGED
@@ -262,57 +262,87 @@ class Kernel {
262
262
  log(data, group, info) {
263
263
  this.log_queue.push({ data, group, info })
264
264
  }
265
- async refresh(notify_peers) {
266
- let env = await Environment.get(this.homedir)
267
- let peer_active = true
268
- // if PINOKIO_NETWORK_SHARE is 0 or false, turn it off
269
- // By default it should be on.
270
- // It's off if the value is set, and it's 0 or false
265
+ async should_refresh() {
266
+ if (this.refresh_cached) {
267
+ return this.cached_refresh_value
268
+ } else {
269
+ let env = await Environment.get(this.homedir)
270
+ let peer_active = true
271
+ // if PINOKIO_NETWORK_SHARE is 0 or false, turn it off
272
+ // By default it should be on.
273
+ // It's off if the value is set, and it's 0 or false
274
+
275
+ //if (env && env.PINOKIO_NETWORK_ACTIVE && (env.PINOKIO_NETWORK_ACTIVE==="1" || env.PINOKIO_NETWORK_ACTIVE.toLowerCase()==="true")) {
276
+ if (env && env.PINOKIO_NETWORK_ACTIVE && (env.PINOKIO_NETWORK_ACTIVE==="0" || env.PINOKIO_NETWORK_ACTIVE.toLowerCase()==="false")) {
277
+ peer_active = false
278
+ }
279
+ let https_active = true
280
+ //if (env && env.PINOKIO_HTTPS_ACTIVE && (env.PINOKIO_HTTPS_ACTIVE==="1" || env.PINOKIO_HTTPS_ACTIVE.toLowerCase()==="true")) {
281
+ if (env && env.PINOKIO_HTTPS_ACTIVE && (env.PINOKIO_HTTPS_ACTIVE==="0" || env.PINOKIO_HTTPS_ACTIVE.toLowerCase()==="false")) {
282
+ //https_active = true
283
+ https_active = false
284
+ }
285
+ // console.log("kernel.refresh", { active, notify_peers })
271
286
 
272
- //if (env && env.PINOKIO_NETWORK_ACTIVE && (env.PINOKIO_NETWORK_ACTIVE==="1" || env.PINOKIO_NETWORK_ACTIVE.toLowerCase()==="true")) {
273
- if (env && env.PINOKIO_NETWORK_ACTIVE && (env.PINOKIO_NETWORK_ACTIVE==="0" || env.PINOKIO_NETWORK_ACTIVE.toLowerCase()==="false")) {
274
- peer_active = false
275
- }
276
- let https_active = true
277
- //if (env && env.PINOKIO_HTTPS_ACTIVE && (env.PINOKIO_HTTPS_ACTIVE==="1" || env.PINOKIO_HTTPS_ACTIVE.toLowerCase()==="true")) {
278
- if (env && env.PINOKIO_HTTPS_ACTIVE && (env.PINOKIO_HTTPS_ACTIVE==="0" || env.PINOKIO_HTTPS_ACTIVE.toLowerCase()==="false")) {
279
- //https_active = true
280
- https_active = false
287
+ let caddy_installed = await this.bin.check_installed({ name: "caddy" })
288
+ this.refresh_cached = true
289
+ this.cached_refresh_value = caddy_installed && https_active
290
+ return this.cached_refresh_value
281
291
  }
282
- // console.log("kernel.refresh", { active, notify_peers })
292
+ }
293
+ async refresh(notify_peers) {
294
+ const ts = Date.now()
295
+ let should_refresh = await this.should_refresh()
296
+ if (should_refresh) {
283
297
 
284
- let caddy_installed = await this.bin.check_installed({ name: "caddy" })
285
298
 
286
- // 1. https
287
- // 2. https + local share
288
- // console.log("caddy installed?", caddy_installed)
289
- if (caddy_installed && https_active) {
299
+ let ts = Date.now()
300
+ if (this.processes.refreshing) {
301
+ // process list refreshing. try again later
302
+ return
303
+ }
290
304
 
291
305
  // 1. get the process list
306
+ // console.time("> 1. Proc Refresh"+ts)
292
307
  await this.processes.refresh()
308
+ // console.timeEnd("> 1. Proc Refresh"+ts)
293
309
 
294
310
  // 2. refresh peer info to reflect the proc info
311
+ // console.time("> 2. Peer Refresh"+ts)
295
312
  await this.peer.refresh()
313
+ // console.timeEnd("> 2. Peer Refresh"+ts)
296
314
 
297
315
  // 3. load custom routers from ~/pinokio/network
316
+ // console.time("> 3. Router Init"+ts)
298
317
  await this.router.init()
318
+ // console.timeEnd("> 3. Router Init"+ts)
299
319
 
300
320
  // 4. set current local host router info
321
+ // console.time("> 4. Router Local"+ts)
301
322
  await this.router.local()
323
+ // console.timeEnd("> 4. Router Local"+ts)
302
324
 
303
325
  // 5. refresh peer info to reflect the updated router info
326
+ // console.time("> 5. Peer Refresh"+ts)
304
327
  await this.peer.refresh()
328
+ // console.timeEnd("> 5. Peer Refresh"+ts)
305
329
 
306
330
  // 6. tell peers to refresh
307
331
  if (notify_peers) {
332
+ // console.time("> 6. Peer Notify Peers"+ts)
308
333
  await this.peer.notify_peers()
334
+ // console.timeEnd("> 6. Peer Notify Peers"+ts)
309
335
  }
310
336
 
311
337
  // 7. update remote router
338
+ // console.time("> 7. Router Remote"+ts)
312
339
  await this.router.remote()
340
+ // console.timeEnd("> 7. Router Remote"+ts)
313
341
 
314
342
  // 8. update caddy config
343
+ // console.time("> 8. Router Update"+ts)
315
344
  await this.router.update()
345
+ // console.timeEnd("> 8. Router Update"+ts)
316
346
 
317
347
  // 9. announce self to the peer network
318
348
  this.peer.announce()
@@ -549,7 +579,7 @@ class Kernel {
549
579
  this.pipe = new Pipe(this)
550
580
  this.proto = new Proto(this)
551
581
  this.plugin = new Plugin(this)
552
- this.processes = new Procs()
582
+ this.processes = new Procs(this)
553
583
  this.kv = new KV(this)
554
584
  this.cloudflare = new Cloudflare()
555
585
  this.peer = new Peer()
@@ -768,11 +798,16 @@ class Kernel {
768
798
  return this.api.get_proxy_url("/proxy", port)
769
799
  },
770
800
  })
801
+ // setTimeout(() => {
802
+ // this.refresh()
803
+ // }, 3000)
771
804
 
772
805
  // refresh every 5 second
773
- if (this.refresh_interval) {
774
- clearInterval(this.refresh_interval)
775
- }
806
+ // if (this.refresh_interval) {
807
+ // clearInterval(this.refresh_interval)
808
+ // }
809
+ this.refresh_cached = false
810
+ this.cached_refresh_value = false
776
811
  this.refresh_interval = setInterval(() => {
777
812
  this.refresh()
778
813
  }, 5000)
package/kernel/procs.js CHANGED
@@ -1,11 +1,14 @@
1
1
  const os = require('os')
2
2
  const path = require('path')
3
3
  const axios = require('axios')
4
- const { fork, exec } = require('child_process');
4
+ const { fork, exec, spawn } = require('child_process');
5
5
  const platform = os.platform();
6
+ const isWin = platform === 'win32';
7
+ const cls = isWin ? 'cls' : 'clear'
6
8
  class Procs {
7
- constructor () {
8
- console.log("Initializing procs")
9
+ constructor (kernel) {
10
+ // console.log("Initializing procs")
11
+ this.kernel = kernel
9
12
  this.cache = {}
10
13
  }
11
14
  async isHttp(localAddress) {
@@ -21,129 +24,235 @@ class Procs {
21
24
  return false;
22
25
  }
23
26
  }
24
- getPortPidList(callback) {
25
- const isWin = platform === 'win32';
26
- const cmd = isWin ? 'netstat -ano -p tcp' : 'lsof -nP -iTCP -sTCP:LISTEN';
27
- exec(cmd, { maxBuffer: 10 * 1024 * 1024 }, async (err, stdout) => {
28
- if (err) return callback(err);
29
-
30
- const results = [];
31
- let pids = new Set()
32
- let s = stdout.trim()
33
- // console.log(">> getPortPidList", s)
34
- const lines = s.split('\n');
27
+ emit(id, cmd) {
28
+ // console.log("emit", { id, cmd })
29
+ this.kernel.shell.emit({
30
+ emit: "\r\n",
31
+ id,
32
+ })
33
+ this.kernel.shell.emit({
34
+ emit: cmd + "\r\n" + cls,
35
+ id,
36
+ })
37
+ }
38
+ async get_pids (stdout) {
39
+ // console.log("get_pids size", stdout.length)
40
+ const results = [];
41
+ let pids = new Set()
42
+ let s = stdout.trim()
43
+ const lines = s.split('\n');
35
44
 
36
- for(let line of lines) {
37
- if (isWin) {
38
- // Skip headers
39
- try {
40
- if (!line.startsWith(' TCP')) continue;
41
- const parts = line.trim().split(/\s+/);
42
- const [ , localAddress, , state, pid ] = parts;
45
+ for(let line of lines) {
46
+ if (isWin) {
47
+ // Skip headers
48
+ try {
49
+ if (!line.startsWith(' TCP')) continue;
50
+ const parts = line.trim().split(/\s+/);
51
+ const [ , localAddress, , state, pid ] = parts;
43
52
 
44
- let pid_int = parseInt(pid)
45
- if (pid_int === 0 || pid_int === 4) {
46
- // pid 0 => killed processes => irrelevant
47
- // pid 4 => system process => irrelevant
48
- continue
49
- }
53
+ let pid_int = parseInt(pid)
54
+ if (pid_int === 0 || pid_int === 4) {
55
+ // pid 0 => killed processes => irrelevant
56
+ // pid 4 => system process => irrelevant
57
+ continue
58
+ }
50
59
 
51
- //if (state !== 'LISTENING') continue;
52
- const chunks = localAddress.split(":")
53
- const port = chunks.pop()
54
- let ip = chunks.pop()
55
- if (!ip || ip === "*") {
56
- ip = "127.0.0.1:" + port
57
- } else {
58
- ip = localAddress
59
- }
60
+ //if (state !== 'LISTENING') continue;
61
+ const chunks = localAddress.split(":")
62
+ const port = chunks.pop()
63
+ let ip = chunks.pop()
64
+ if (!ip || ip === "*") {
65
+ ip = "127.0.0.1:" + port
66
+ } else {
67
+ ip = localAddress
68
+ }
60
69
 
61
- let isHttp = await this.isHttp(ip)
62
- if (!isHttp) continue
70
+ let isHttp = await this.isHttp(ip)
71
+ if (!isHttp) continue
63
72
 
64
- if (pids.has(pid+"/"+port)) continue;
65
- pids.add(pid+"/"+port)
66
- results.push({ port, pid, ip });
67
- } catch (e) {
73
+ if (pids.has(pid+"/"+port)) continue;
74
+ pids.add(pid+"/"+port)
75
+ results.push({ port, pid, ip });
76
+ } catch (e) {
68
77
  // console.log("ERROR", e)
69
- }
70
- } else {
78
+ }
79
+ } else {
71
80
  // if (!/LISTEN/.test(line)) continue;
72
- try {
73
- const parts = line.trim().split(/\s+/);
74
- const pid = parts[1];
75
- let pid_int = parseInt(pid)
76
- if (pid_int === 0 || pid_int === 4) {
77
- // pid 0 => killed processes => irrelevant
78
- // pid 4 => system process => irrelevant
79
- continue
80
- }
81
+ try {
82
+ const parts = line.trim().split(/\s+/);
83
+ const pid = parts[1];
84
+ let pid_int = parseInt(pid)
85
+ if (pid_int === 0 || pid_int === 4) {
86
+ // pid 0 => killed processes => irrelevant
87
+ // pid 4 => system process => irrelevant
88
+ continue
89
+ }
81
90
 
82
- const match = line.match(/([^\s]+:\d+)\s/);
83
- const localAddress = match?.[1];
91
+ const match = line.match(/([^\s]+:\d+)\s/);
92
+ const localAddress = match?.[1];
84
93
 
85
- const chunks = localAddress.split(":")
86
- const port = chunks.pop()
87
- let ip = chunks.pop()
88
- if (!ip || ip === "*") {
89
- ip = "127.0.0.1:" + port
90
- } else {
91
- ip = localAddress
92
- }
94
+ const chunks = localAddress.split(":")
95
+ const port = chunks.pop()
96
+ let ip = chunks.pop()
97
+ if (!ip || ip === "*") {
98
+ ip = "127.0.0.1:" + port
99
+ } else {
100
+ ip = localAddress
101
+ }
93
102
 
94
- let isHttp = await this.isHttp(ip)
95
- if (!isHttp) continue;
103
+ let isHttp = await this.isHttp(ip)
104
+ if (!isHttp) continue;
96
105
 
97
- //const portMatch = line.match(/:(\d+)\s/);
98
- //const port = portMatch?.[1];
99
- if (pids.has(pid+"/"+port)) continue;
100
- pids.add(pid+"/"+port)
101
- if (pid && port) results.push({ port, pid, ip });
102
- } catch (e) {
106
+ //const portMatch = line.match(/:(\d+)\s/);
107
+ //const port = portMatch?.[1];
108
+ if (pids.has(pid+"/"+port)) continue;
109
+ pids.add(pid+"/"+port)
110
+ if (pid && port) results.push({ port, pid, ip });
111
+ } catch (e) {
103
112
  // console.log("Error", e)
104
- }
105
113
  }
106
114
  }
107
- callback(null, results);
108
- });
115
+ }
116
+ return results
109
117
  }
110
- getPidToNameMap(callback) {
111
- const isWin = platform === 'win32';
112
- const cmd = isWin ? 'tasklist /fo csv /nh' : 'ps -Ao pid,comm';
113
- exec(cmd, (err, stdout) => {
114
- if (err) return callback(err);
115
- const lines = stdout.trim().split('\n');
116
- const map = {};
117
- lines.forEach(line => {
118
- if (isWin) {
119
- const [name, pid] = line.split('","').map(s => s.replace(/(^"|"$)/g, ''));
118
+ getPortPidList(cb) {
119
+ // if (this.portPidList) {
120
+ // cb(this.portPidList)
121
+ // return
122
+ // }
123
+ const cmd = isWin ? 'netstat -ano -p tcp' : 'lsof -nP -iTCP -sTCP:LISTEN';
124
+ let id = "Procs.getPortPidList"
125
+ let sh = this.kernel.shell.get(id)
126
+ this.port_cb = cb
127
+ this.port_running = true
128
+ if (sh) {
129
+ this.emit(id, cmd)
130
+ } else {
131
+ this.kernel.exec({
132
+ id,
133
+ conda: {
134
+ skip: true,
135
+ },
136
+ onready: () => {
137
+ // console.log("ON READY")
138
+ this.emit(id, cmd)
139
+ },
140
+ input: true
141
+ }, (e) => {
142
+ if (e.state && e.state.includes(cls)) {
143
+ if (this.port_running) {
144
+ this.port_running = false
145
+ // console.log("GET PIDS")
146
+ this.get_pids(e.state).then((pids) => {
147
+ this.portPidList = pids
148
+ this.port_cb(pids)
149
+ })
150
+ }
151
+ }
152
+ }).then((result) => {
153
+ this.port_running = false
154
+ console.log("Exec Finished", {result})
155
+ })
156
+ }
157
+ // exec(cmd, { maxBuffer: 10 * 1024 * 1024 }, async (err, stdout) => {
158
+ // if (err) return callback(err);
159
+ //
160
+ // callback(null, results);
161
+ // });
162
+ }
163
+ get_name(stdout) {
164
+ // console.log("get_name size", stdout.length)
165
+ const lines = stdout.trim().split('\n');
166
+ const map = {};
167
+ lines.forEach(line => {
168
+ if (isWin) {
169
+ const [name, pid] = line.split('","').map(s => s.replace(/(^"|"$)/g, ''));
170
+ if (/^[0-9]+$/.test(pid)) {
171
+ // it is pid
120
172
  map[pid] = name;
121
- } else {
122
- const [pid, ...nameParts] = line.trim().split(/\s+/);
173
+ }
174
+ } else {
175
+ const [pid, ...nameParts] = line.trim().split(/\s+/);
176
+ if (/^[0-9]+$/.test(pid)) {
123
177
  map[pid] = nameParts.join(' ');
124
178
  }
125
- });
126
- callback(null, map);
179
+ }
127
180
  });
181
+ return map
182
+ }
183
+ getPidToNameMap(portPidList, cb) {
184
+ let cached = false
185
+ if (this.port_map) {
186
+ cached = true
187
+ for(let { pid, port } of portPidList) {
188
+ let exists = this.port_map["" + pid]
189
+ // console.log({ pid, exists })
190
+ if (!exists) {
191
+ cached = false
192
+ break;
193
+ }
194
+ }
195
+ }
196
+ if (cached) {
197
+ // console.log("already cached")
198
+ cb(this.port_map)
199
+ return
200
+ }
201
+ // console.log("not cached")
202
+ const cmd = isWin ? 'tasklist /fo csv /nh' : 'ps -Ao pid,comm';
203
+ let id = "Procs.getPidToNameMap"
204
+ let sh = this.kernel.shell.get(id)
205
+ this.pid_cb = cb
206
+ this.pid_running = true
207
+ if (sh) {
208
+ this.emit(id, cmd)
209
+ } else {
210
+ this.kernel.exec({
211
+ id,
212
+ conda: {
213
+ skip: true,
214
+ },
215
+ onready: () => {
216
+ // console.log("ON READY")
217
+ this.emit(id, cmd)
218
+ },
219
+ input: true
220
+ }, async (e) => {
221
+ if (e.state && e.state.includes(cls)) {
222
+ if (this.pid_running) {
223
+ // console.log("GET MAP")
224
+ this.pid_running = false
225
+ let map = this.get_name(e.state)
226
+ this.port_map = map
227
+ this.pid_cb(map)
228
+ }
229
+ }
230
+ }).then((result) => {
231
+ this.pid_running = false
232
+ console.log("Exec Finished", {result})
233
+ })
234
+ }
128
235
  }
129
236
  async refresh() {
130
237
  let map = {}
238
+ if (this.refreshing) {
239
+ // console.log("still refreshing. retry later")
240
+ return
241
+ }
242
+ this.refreshing = true
243
+ let ts = Date.now()
131
244
  let list = await new Promise((resolve, reject) => {
132
- this.getPortPidList((err, portPidList) => {
245
+ // console.time(">>>>>>>>GET PORTS " + ts)
246
+ this.getPortPidList((portPidList) => {
247
+ // console.timeEnd(">>>>>>>>GET PORTS " + ts)
248
+ // console.time(">>>>>>> GET PIDS " + ts)
133
249
  // console.log({ portPidList })
134
- if (err) {
135
- console.log("getPortPidList Error", err)
136
- reject(err)
137
- return
138
- }
139
250
 
140
- this.getPidToNameMap((err, pidToName) => {
141
- if (err) {
142
- console.log("getPidToNameMap Error", err)
143
- reject(err)
144
- return
145
- }
251
+ // if there's any new port, run getPidToNameMap
252
+
146
253
 
254
+ this.getPidToNameMap(portPidList, (pidToName) => {
255
+ // console.timeEnd(">>>>>>> GET PIDS " + ts)
147
256
  let list = portPidList.map(({ port, pid, ip }) => {
148
257
  const fullname = pidToName[pid] || 'Unknown';
149
258
  const name = fullname.split(path.sep).pop()
@@ -156,11 +265,12 @@ class Procs {
156
265
  }
157
266
  }).filter((x) => { return x })
158
267
  resolve(list)
159
- });
160
- });
268
+ })
269
+ })
161
270
  })
162
271
  this.info = list
163
272
  this.map = map
273
+ this.refreshing = false
164
274
  }
165
275
  }
166
276
  module.exports = Procs
package/kernel/shell.js CHANGED
@@ -349,6 +349,7 @@ class Shell {
349
349
  }
350
350
  }
351
351
  emit(message) {
352
+ //console.log("emit", { message, input: this.input, pty: this.ptyProcess })
352
353
  if (this.input) {
353
354
  if (this.ptyProcess) {
354
355
  if (message.length > 1024) {
@@ -938,6 +939,7 @@ class Shell {
938
939
  this.done = false
939
940
  this.ptyProcess = pty.spawn(this.shell, this.args, config)
940
941
  this.ptyProcess.onData((data) => {
942
+ // console.log("onData", { data })
941
943
  if (!this.done) {
942
944
  this.queue.push(data)
943
945
  }
@@ -988,6 +990,7 @@ class Shell {
988
990
  }
989
991
  this.vt.dispose()
990
992
  this.queue.killAndDrain()
993
+ console.log("KILL PTY", this.id)
991
994
  if (this.ptyProcess) {
992
995
  if (cb) {
993
996
  kill(this.ptyProcess.pid, "SIGKILL", true)
@@ -1025,7 +1028,7 @@ class Shell {
1025
1028
  // id: this.id,
1026
1029
  // type: "disconnect"
1027
1030
  // })
1028
- this.kernel.refresh(true)
1031
+ // this.kernel.refresh(true)
1029
1032
 
1030
1033
 
1031
1034
  }
@@ -1166,6 +1169,9 @@ ${cleaned}
1166
1169
  if (test) {
1167
1170
  if (test.length > 0) {
1168
1171
  this.ready = true
1172
+ if (this.params && this.params.onready) {
1173
+ this.params.onready()
1174
+ }
1169
1175
  if (this.ptyProcess) {
1170
1176
  this.ptyProcess.write(`${this.cmd}${os.EOL}`)
1171
1177
  // setTimeout(() => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pinokiod",
3
- "version": "3.15.0",
3
+ "version": "3.15.2",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/server/index.js CHANGED
@@ -3359,6 +3359,8 @@ class Server {
3359
3359
  this.app.post("/network/reset", ex(async (req, res) => {
3360
3360
  let caddy_path = this.kernel.path("cache/XDG_DATA_HOME/caddy")
3361
3361
  await rimraf(caddy_path)
3362
+ let caddy_path2 = this.kernel.path("cache/XDG_CONFIG_HOME/caddy")
3363
+ await rimraf(caddy_path2)
3362
3364
  res.json({ success: true })
3363
3365
  }))
3364
3366
  this.app.get("/network", ex(async (req, res) => {
@@ -4256,6 +4258,7 @@ class Server {
4256
4258
  }))
4257
4259
  this.app.post("/pinokio/peer/refresh", ex(async (req, res) => {
4258
4260
  // refresh and broadcast
4261
+ console.log("kernel.refresh /pinokio/peer/refresh")
4259
4262
  await this.kernel.refresh()
4260
4263
  res.json({ success: true })
4261
4264
  }))