pinokiod 3.52.0 → 3.54.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.
- package/kernel/index.js +65 -43
- package/kernel/peer.js +21 -8
- package/kernel/router/index.js +10 -10
- package/kernel/router/localhost_static_router.js +3 -0
- package/kernel/router/peer_static_router.js +1 -0
- package/package.json +1 -1
- package/server/index.js +137 -70
- package/server/public/common.js +0 -9
- package/server/public/style.css +4 -3
- package/server/public/urldropdown.css +95 -3
- package/server/public/urldropdown.js +245 -23
- package/server/views/app.ejs +0 -2
- package/server/views/connect.ejs +3 -0
- package/server/views/container.ejs +2 -1
- package/server/views/index.ejs +3 -0
- package/server/views/init/index.ejs +3 -0
- package/server/views/net.ejs +30 -27
- package/server/views/network.ejs +4 -148
- package/server/views/screenshots.ejs +3 -0
- package/server/views/settings.ejs +3 -0
- package/server/views/tools.ejs +3 -0
- package/3 +0 -1
package/kernel/index.js
CHANGED
|
@@ -366,6 +366,10 @@ class Kernel {
|
|
|
366
366
|
await this.peer.check(this)
|
|
367
367
|
return this.peer.active
|
|
368
368
|
}
|
|
369
|
+
async peer_active() {
|
|
370
|
+
await this.peer.check(this)
|
|
371
|
+
return this.peer.peer_active
|
|
372
|
+
}
|
|
369
373
|
async network_installed() {
|
|
370
374
|
let installed = await this.bin.check_installed({ name: "caddy" })
|
|
371
375
|
return installed
|
|
@@ -386,61 +390,79 @@ class Kernel {
|
|
|
386
390
|
}
|
|
387
391
|
async refresh(notify_peers) {
|
|
388
392
|
const ts = Date.now()
|
|
389
|
-
let network_active = await this.network_active()
|
|
390
|
-
if (!network_active) {
|
|
391
|
-
return
|
|
392
|
-
}
|
|
393
|
-
let network_running = await this.network_running()
|
|
394
|
-
if (network_running) {
|
|
395
|
-
let ts = Date.now()
|
|
396
|
-
if (this.processes.refreshing) {
|
|
397
|
-
// process list refreshing. try again later
|
|
398
|
-
return
|
|
399
|
-
}
|
|
400
393
|
|
|
394
|
+
await this.peer.check(this)
|
|
395
|
+
|
|
396
|
+
if (this.peer.peer_active) {
|
|
401
397
|
// 1. get the process list
|
|
402
398
|
await this.processes.refresh()
|
|
403
399
|
|
|
404
400
|
// 2. refresh peer info to reflect the proc info
|
|
405
401
|
//await this.peer.refresh()
|
|
406
402
|
await this.peer.refresh_host(this.peer.host)
|
|
403
|
+
|
|
404
|
+
}
|
|
407
405
|
|
|
408
|
-
// 3. load custom routers from ~/pinokio/network
|
|
409
|
-
await this.router.init()
|
|
410
406
|
|
|
411
|
-
|
|
412
|
-
|
|
407
|
+
// let network_active = await this.network_active()
|
|
408
|
+
// if (!network_active) {
|
|
409
|
+
// return
|
|
410
|
+
// }
|
|
413
411
|
|
|
414
|
-
|
|
415
|
-
await this.
|
|
412
|
+
if (this.peer.https_active) {
|
|
413
|
+
let network_running = await this.network_running()
|
|
414
|
+
if (network_running) {
|
|
415
|
+
let ts = Date.now()
|
|
416
|
+
if (this.processes.refreshing) {
|
|
417
|
+
// process list refreshing. try again later
|
|
418
|
+
return
|
|
419
|
+
}
|
|
416
420
|
|
|
417
|
-
|
|
421
|
+
// // 1. get the process list
|
|
422
|
+
// await this.processes.refresh()
|
|
423
|
+
//
|
|
424
|
+
// // 2. refresh peer info to reflect the proc info
|
|
425
|
+
// //await this.peer.refresh()
|
|
426
|
+
// console.log("peer refresh_host")
|
|
427
|
+
// await this.peer.refresh_host(this.peer.host)
|
|
418
428
|
|
|
419
|
-
|
|
429
|
+
// 3. load custom routers from ~/pinokio/network
|
|
430
|
+
await this.router.init()
|
|
420
431
|
|
|
432
|
+
// 4. set current local host router info
|
|
433
|
+
await this.router.local()
|
|
421
434
|
|
|
422
|
-
|
|
435
|
+
// 7. update remote router
|
|
436
|
+
await this.router.remote()
|
|
423
437
|
|
|
424
|
-
|
|
425
|
-
|
|
438
|
+
await this.router.static()
|
|
439
|
+
|
|
440
|
+
await this.router.custom_domain()
|
|
441
|
+
|
|
442
|
+
|
|
443
|
+
this.router.fallback()
|
|
444
|
+
|
|
445
|
+
// 8. update caddy config
|
|
446
|
+
await this.router.update()
|
|
426
447
|
|
|
427
|
-
// 6. tell peers to refresh
|
|
428
|
-
let changed
|
|
429
|
-
let new_config = JSON.stringify(await this.peer.current_host())
|
|
430
|
-
if (this.old_config !== new_config) {
|
|
431
|
-
console.log("Proc config has changed. update router.")
|
|
432
|
-
changed = true
|
|
433
|
-
} else {
|
|
434
|
-
// console.log("Proc config is the same")
|
|
435
|
-
changed = false
|
|
436
|
-
}
|
|
437
|
-
this.old_config = new_config
|
|
438
|
-
if (changed) {
|
|
439
|
-
await this.peer.notify_refresh()
|
|
440
448
|
}
|
|
441
|
-
// 9. announce self to the peer network
|
|
442
|
-
this.peer.announce()
|
|
443
449
|
}
|
|
450
|
+
// 6. tell peers to refresh
|
|
451
|
+
let changed
|
|
452
|
+
let new_config = JSON.stringify(await this.peer.current_host())
|
|
453
|
+
if (this.old_config !== new_config) {
|
|
454
|
+
console.log("Proc config has changed. update router.")
|
|
455
|
+
changed = true
|
|
456
|
+
} else {
|
|
457
|
+
// console.log("Proc config is the same")
|
|
458
|
+
changed = false
|
|
459
|
+
}
|
|
460
|
+
this.old_config = new_config
|
|
461
|
+
if (changed) {
|
|
462
|
+
await this.peer.notify_refresh()
|
|
463
|
+
}
|
|
464
|
+
// 9. announce self to the peer network
|
|
465
|
+
this.peer.announce()
|
|
444
466
|
}
|
|
445
467
|
async clearLog(group) {
|
|
446
468
|
let relativePath = path.relative(this.homedir, group)
|
|
@@ -879,11 +901,11 @@ class Kernel {
|
|
|
879
901
|
// let contents = await fs.promises.readdir(this.homedir)
|
|
880
902
|
//await this.bin.init()
|
|
881
903
|
let ts = Date.now()
|
|
882
|
-
this.git.index(this).then(() => {
|
|
883
|
-
//console.log(this.git.mapping)
|
|
884
|
-
})
|
|
885
904
|
this.bin.init().then(() => {
|
|
886
905
|
if (this.homedir) {
|
|
906
|
+
this.git.index(this).then(() => {
|
|
907
|
+
//console.log(this.git.mapping)
|
|
908
|
+
})
|
|
887
909
|
this.shell.init().then(async () => {
|
|
888
910
|
this.bin.check({
|
|
889
911
|
bin: this.bin.preset("ai"),
|
|
@@ -990,8 +1012,8 @@ class Kernel {
|
|
|
990
1012
|
if (this.refresh_interval) {
|
|
991
1013
|
clearInterval(this.refresh_interval)
|
|
992
1014
|
}
|
|
993
|
-
let network_active = await this.network_active()
|
|
994
|
-
if (network_active) {
|
|
1015
|
+
//let network_active = await this.network_active()
|
|
1016
|
+
//if (network_active) {
|
|
995
1017
|
this.refresh_interval = setInterval(() => {
|
|
996
1018
|
if (this.server_running) {
|
|
997
1019
|
this.refresh(true)
|
|
@@ -999,7 +1021,7 @@ class Kernel {
|
|
|
999
1021
|
console.log("server not running yet. retry network refresh in 5 secs")
|
|
1000
1022
|
}
|
|
1001
1023
|
}, 5000)
|
|
1002
|
-
}
|
|
1024
|
+
//}
|
|
1003
1025
|
|
|
1004
1026
|
}
|
|
1005
1027
|
|
package/kernel/peer.js
CHANGED
|
@@ -40,8 +40,8 @@ class PeerDiscovery {
|
|
|
40
40
|
}
|
|
41
41
|
async check(kernel) {
|
|
42
42
|
let env = await Environment.get(kernel.homedir, kernel)
|
|
43
|
-
|
|
44
|
-
let peer_active = false
|
|
43
|
+
let peer_active = true
|
|
44
|
+
//let peer_active = false
|
|
45
45
|
if (env && env.PINOKIO_NETWORK_ACTIVE && (env.PINOKIO_NETWORK_ACTIVE==="1" || env.PINOKIO_NETWORK_ACTIVE.toLowerCase()==="true")) {
|
|
46
46
|
//if (env && env.PINOKIO_NETWORK_ACTIVE && (env.PINOKIO_NETWORK_ACTIVE==="0" || env.PINOKIO_NETWORK_ACTIVE.toLowerCase()==="false")) {
|
|
47
47
|
peer_active = true
|
|
@@ -54,10 +54,14 @@ class PeerDiscovery {
|
|
|
54
54
|
//https_active = false
|
|
55
55
|
}
|
|
56
56
|
// console.log("kernel.refresh", { active, notify_peers })
|
|
57
|
-
|
|
57
|
+
|
|
58
|
+
//this.name = os.userInfo().username
|
|
59
|
+
this.name = "p" + this.host.split(".").pop()
|
|
58
60
|
if (env && env.PINOKIO_NETWORK_NAME && env.PINOKIO_NETWORK_NAME.length > 0) {
|
|
59
61
|
this.name = env.PINOKIO_NETWORK_NAME
|
|
60
62
|
}
|
|
63
|
+
this.peer_active = peer_active
|
|
64
|
+
this.https_active = https_active
|
|
61
65
|
if (peer_active && https_active) {
|
|
62
66
|
this.active = true
|
|
63
67
|
} else {
|
|
@@ -77,7 +81,8 @@ class PeerDiscovery {
|
|
|
77
81
|
// this.active = true
|
|
78
82
|
// }
|
|
79
83
|
|
|
80
|
-
if (this.active) {
|
|
84
|
+
//if (this.active) {
|
|
85
|
+
if (this.peer_active) {
|
|
81
86
|
// Listen for incoming pings
|
|
82
87
|
this.socket = dgram.createSocket('udp4');
|
|
83
88
|
this.socket.on('message', (msg, rinfo) => {
|
|
@@ -319,8 +324,8 @@ class PeerDiscovery {
|
|
|
319
324
|
*/
|
|
320
325
|
let http_icon = null
|
|
321
326
|
let https_icon = null
|
|
322
|
-
let
|
|
323
|
-
let
|
|
327
|
+
let https_href = `https://pinokio.${this.name}.localhost/p/${folder}`
|
|
328
|
+
let http_href = `http://${this.host}:42000/p/${folder}`
|
|
324
329
|
let app_href = null
|
|
325
330
|
if (meta && !meta.init_required) {
|
|
326
331
|
if (meta.title) {
|
|
@@ -330,8 +335,6 @@ class PeerDiscovery {
|
|
|
330
335
|
https_icon = `https://pinokio.${this.name}.localhost/asset/api/${folder}/${meta.iconpath}`
|
|
331
336
|
}
|
|
332
337
|
//https_href = `https://${folder}.${this.name}.localhost`
|
|
333
|
-
https_href = `https://pinokio.${this.name}.localhost/p/${folder}`
|
|
334
|
-
http_href = `http://${this.host}:42000/p/${folder}`
|
|
335
338
|
app_href = `https://${folder}.${this.name}.localhost`
|
|
336
339
|
installed.push({
|
|
337
340
|
folder,
|
|
@@ -342,8 +345,18 @@ class PeerDiscovery {
|
|
|
342
345
|
http_href,
|
|
343
346
|
...meta
|
|
344
347
|
})
|
|
348
|
+
continue
|
|
345
349
|
}
|
|
346
350
|
}
|
|
351
|
+
|
|
352
|
+
installed.push({
|
|
353
|
+
folder,
|
|
354
|
+
https_href,
|
|
355
|
+
http_href,
|
|
356
|
+
...meta
|
|
357
|
+
})
|
|
358
|
+
|
|
359
|
+
|
|
347
360
|
}
|
|
348
361
|
return installed
|
|
349
362
|
}
|
package/kernel/router/index.js
CHANGED
|
@@ -217,16 +217,16 @@ class Router {
|
|
|
217
217
|
}
|
|
218
218
|
|
|
219
219
|
async static() {
|
|
220
|
-
this.localhost_static_router.handle()
|
|
221
|
-
for(let host in this.kernel.peer.info) {
|
|
222
|
-
let info = this.kernel.peer.info[host]
|
|
223
|
-
if (info.rewrite_mapping) {
|
|
224
|
-
for(let name in info.rewrite_mapping) {
|
|
225
|
-
this.peer_static_router.handle(info.rewrite_mapping[name])
|
|
226
|
-
}
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
this.mapping = this._mapping
|
|
220
|
+
// this.localhost_static_router.handle()
|
|
221
|
+
// for(let host in this.kernel.peer.info) {
|
|
222
|
+
// let info = this.kernel.peer.info[host]
|
|
223
|
+
// if (info.rewrite_mapping) {
|
|
224
|
+
// for(let name in info.rewrite_mapping) {
|
|
225
|
+
// this.peer_static_router.handle(info.rewrite_mapping[name])
|
|
226
|
+
// }
|
|
227
|
+
// }
|
|
228
|
+
// }
|
|
229
|
+
// this.mapping = this._mapping
|
|
230
230
|
}
|
|
231
231
|
|
|
232
232
|
// set local config
|
|
@@ -12,6 +12,7 @@ class LocalhostStaticRouter extends Processor {
|
|
|
12
12
|
this.rewriter = new Rewriter(router)
|
|
13
13
|
}
|
|
14
14
|
handle () {
|
|
15
|
+
console.log("LOCALHOST STATIC ROUTER")
|
|
15
16
|
let configs = []
|
|
16
17
|
for(let api_name in this.router.kernel.pinokio_configs) {
|
|
17
18
|
let config = this.router.kernel.pinokio_configs[api_name]
|
|
@@ -41,11 +42,13 @@ class LocalhostStaticRouter extends Processor {
|
|
|
41
42
|
let local_dial = `${this.router.default_host}:${this.router.default_port}`
|
|
42
43
|
let peer_dial = `${this.router.kernel.peer.host}:${this.router.default_port}`
|
|
43
44
|
let rewrite = `/asset/api/${api_name}`
|
|
45
|
+
console.log("LOCALHOST REWRITE HANDLE", { rewrite, localhost_match, local_dial })
|
|
44
46
|
this.rewriter.handle({
|
|
45
47
|
route: rewrite,
|
|
46
48
|
match: [localhost_match],
|
|
47
49
|
dial: local_dial,
|
|
48
50
|
})
|
|
51
|
+
console.log("LOCALHOST REWRITE HANDLE", { rewrite, peer_match, peer_dial })
|
|
49
52
|
this.rewriter.handle({
|
|
50
53
|
route: rewrite,
|
|
51
54
|
match: [peer_match],
|
|
@@ -30,6 +30,7 @@ class PeerStaticRouter extends Processor {
|
|
|
30
30
|
rewrite: /asset/api/test
|
|
31
31
|
match: test.x.localhost
|
|
32
32
|
*/
|
|
33
|
+
console.log("PEER STATIC ROUTER", rewrite_mapping)
|
|
33
34
|
let url = new URL("http://" + rewrite_mapping.external_ip)
|
|
34
35
|
let dial = url.host
|
|
35
36
|
let rewrite = url.pathname
|
package/package.json
CHANGED
package/server/index.js
CHANGED
|
@@ -280,6 +280,52 @@ class Server {
|
|
|
280
280
|
}
|
|
281
281
|
})
|
|
282
282
|
}
|
|
283
|
+
async processMenu(name, config) {
|
|
284
|
+
let cfg = config
|
|
285
|
+
if (cfg) {
|
|
286
|
+
if (cfg.menu) {
|
|
287
|
+
if (typeof cfg.menu === "function") {
|
|
288
|
+
if (cfg.menu.constructor.name === "AsyncFunction") {
|
|
289
|
+
cfg.menu = await cfg.menu(this.kernel, this.kernel.info)
|
|
290
|
+
} else {
|
|
291
|
+
cfg.menu = cfg.menu(this.kernel, this.kernel.info)
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
} else {
|
|
295
|
+
cfg = await this.renderIndex(name)
|
|
296
|
+
}
|
|
297
|
+
} else {
|
|
298
|
+
cfg = await this.renderIndex(name)
|
|
299
|
+
}
|
|
300
|
+
return cfg
|
|
301
|
+
}
|
|
302
|
+
async renderIndex(name) {
|
|
303
|
+
let p = this.kernel.path("api", name)
|
|
304
|
+
let html_path = path.resolve(p, "index.html")
|
|
305
|
+
let html_exists = await this.kernel.exists(html_path)
|
|
306
|
+
console.log({ html_path, html_exists })
|
|
307
|
+
if (html_exists) {
|
|
308
|
+
return {
|
|
309
|
+
title: name,
|
|
310
|
+
menu: [{
|
|
311
|
+
default: true,
|
|
312
|
+
icon: "fa-solid fa-link",
|
|
313
|
+
text: "index.html",
|
|
314
|
+
href: "index.html?raw=true",
|
|
315
|
+
}]
|
|
316
|
+
}
|
|
317
|
+
} else {
|
|
318
|
+
return {
|
|
319
|
+
title: name,
|
|
320
|
+
menu: [{
|
|
321
|
+
default: true,
|
|
322
|
+
icon: "fa-solid fa-link",
|
|
323
|
+
text: "Project Files",
|
|
324
|
+
href: `/files/api/${name}`,
|
|
325
|
+
}]
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
}
|
|
283
329
|
async getGit(ref, filepath) {
|
|
284
330
|
let dir = this.kernel.path("api", filepath)
|
|
285
331
|
let branches = await git.listBranches({ fs, dir });
|
|
@@ -463,31 +509,21 @@ class Server {
|
|
|
463
509
|
}
|
|
464
510
|
}
|
|
465
511
|
|
|
466
|
-
let menu = config.menu || []
|
|
467
|
-
try {
|
|
468
|
-
if (typeof config.menu === "function") {
|
|
469
|
-
if (config.menu.constructor.name === "AsyncFunction") {
|
|
470
|
-
config.menu = await config.menu(this.kernel, this.kernel.info)
|
|
471
|
-
} else {
|
|
472
|
-
config.menu = config.menu(this.kernel, this.kernel.info)
|
|
473
|
-
}
|
|
474
|
-
}
|
|
475
|
-
} catch (e) {
|
|
476
|
-
err = e.stack
|
|
477
|
-
config.menu = []
|
|
478
|
-
}
|
|
479
|
-
|
|
480
512
|
|
|
481
513
|
let uri = this.kernel.path("api")
|
|
482
514
|
try {
|
|
483
515
|
let launcher = await this.kernel.api.launcher(name)
|
|
484
516
|
req.launcher_root = launcher.launcher_root
|
|
485
|
-
await this.
|
|
517
|
+
config = await this.processMenu(name, config)
|
|
486
518
|
} catch(e) {
|
|
487
519
|
config.menu = []
|
|
488
520
|
err = e.stack
|
|
489
521
|
}
|
|
490
522
|
|
|
523
|
+
console.log("renderMenu before", config)
|
|
524
|
+
await this.renderMenu(req, uri, name, config, [])
|
|
525
|
+
console.log("renderMenu after", config)
|
|
526
|
+
|
|
491
527
|
let platform = os.platform()
|
|
492
528
|
|
|
493
529
|
await Environment.init({ name }, this.kernel)
|
|
@@ -2631,10 +2667,10 @@ class Server {
|
|
|
2631
2667
|
getPeers() {
|
|
2632
2668
|
let list = []
|
|
2633
2669
|
for(let key in this.kernel.peer.info) {
|
|
2634
|
-
if (key !== this.kernel.peer.host) {
|
|
2670
|
+
// if (key !== this.kernel.peer.host) {
|
|
2635
2671
|
let info = this.kernel.peer.info[key]
|
|
2636
2672
|
list.push(info)
|
|
2637
|
-
}
|
|
2673
|
+
// }
|
|
2638
2674
|
}
|
|
2639
2675
|
return list
|
|
2640
2676
|
}
|
|
@@ -3040,6 +3076,7 @@ class Server {
|
|
|
3040
3076
|
this.app.get("/screenshots", ex(async (req, res) => {
|
|
3041
3077
|
let list = this.getPeers()
|
|
3042
3078
|
res.render("screenshots", {
|
|
3079
|
+
current_host: this.kernel.peer.host,
|
|
3043
3080
|
version: this.version,
|
|
3044
3081
|
portal: this.portal,
|
|
3045
3082
|
logo: this.logo,
|
|
@@ -5467,60 +5504,20 @@ class Server {
|
|
|
5467
5504
|
res.send(html)
|
|
5468
5505
|
}))
|
|
5469
5506
|
this.app.get("/pinokio/sidebar/:name", ex(async (req, res) => {
|
|
5507
|
+
|
|
5508
|
+
let uri = this.kernel.path("api")
|
|
5470
5509
|
let name = req.params.name
|
|
5471
5510
|
let launcher = await this.kernel.api.launcher(name)
|
|
5472
|
-
let rawpath = "/api/" + name
|
|
5473
5511
|
let config = launcher.script
|
|
5474
|
-
|
|
5475
|
-
|
|
5476
|
-
|
|
5477
|
-
|
|
5478
|
-
|
|
5479
|
-
|
|
5480
|
-
|
|
5481
|
-
}
|
|
5482
|
-
}
|
|
5483
|
-
|
|
5484
|
-
let uri = this.kernel.path("api")
|
|
5485
|
-
await this.renderMenu(req, uri, name, config, [])
|
|
5486
|
-
} else {
|
|
5487
|
-
// if there is no menu, display all files
|
|
5488
|
-
let p = this.kernel.path("api", name)
|
|
5489
|
-
|
|
5490
|
-
let html_path = path.resolve(p, "index.html")
|
|
5491
|
-
let html_exists = await this.kernel.exists(html_path)
|
|
5492
|
-
if (html_exists) {
|
|
5493
|
-
config = {
|
|
5494
|
-
title: name,
|
|
5495
|
-
menu: [{
|
|
5496
|
-
default: true,
|
|
5497
|
-
icon: "fa-solid fa-link",
|
|
5498
|
-
text: "index.html",
|
|
5499
|
-
href: "index.html?raw=true",
|
|
5500
|
-
}]
|
|
5501
|
-
}
|
|
5502
|
-
} else {
|
|
5503
|
-
let files = await fs.promises.readdir(p, { withFileTypes: true })
|
|
5504
|
-
files = files.filter((file) => {
|
|
5505
|
-
return file.name.endsWith(".json") || file.name.endsWith(".js")
|
|
5506
|
-
}).filter((file) => {
|
|
5507
|
-
return file.name !== "pinokio.js" && file.name !== "pinokio.json" && file.name !== "pinokio_meta.json"
|
|
5508
|
-
})
|
|
5509
|
-
config = {
|
|
5510
|
-
title: name,
|
|
5511
|
-
menu: files.map((file) => {
|
|
5512
|
-
return {
|
|
5513
|
-
text: file.name,
|
|
5514
|
-
href: file.name
|
|
5515
|
-
}
|
|
5516
|
-
})
|
|
5517
|
-
}
|
|
5518
|
-
}
|
|
5519
|
-
|
|
5520
|
-
let uri = this.kernel.path("api")
|
|
5521
|
-
await this.renderMenu(req, uri, name, config, [])
|
|
5512
|
+
try {
|
|
5513
|
+
let rawpath = "/api/" + name
|
|
5514
|
+
req.launcher_root = launcher.launcher_root
|
|
5515
|
+
config = await this.processMenu(name, config)
|
|
5516
|
+
} catch(e) {
|
|
5517
|
+
config.menu = []
|
|
5518
|
+
err = e.stack
|
|
5522
5519
|
}
|
|
5523
|
-
|
|
5520
|
+
await this.renderMenu(req, uri, name, config, [])
|
|
5524
5521
|
|
|
5525
5522
|
ejs.renderFile(path.resolve(__dirname, "views/partials/menu.ejs"), { menu: config.menu }, (err, html) => {
|
|
5526
5523
|
res.send(html)
|
|
@@ -5567,11 +5564,81 @@ class Server {
|
|
|
5567
5564
|
// }))
|
|
5568
5565
|
|
|
5569
5566
|
this.app.get("/info/procs", ex(async (req, res) => {
|
|
5570
|
-
console.time("Refresh")
|
|
5571
5567
|
await this.kernel.processes.refresh()
|
|
5572
|
-
|
|
5568
|
+
|
|
5569
|
+
let info = []
|
|
5570
|
+
for(let item of this.kernel.processes.info) {
|
|
5571
|
+
info.push({
|
|
5572
|
+
online: true,
|
|
5573
|
+
host: {
|
|
5574
|
+
ip: this.kernel.peer.host,
|
|
5575
|
+
local: true,
|
|
5576
|
+
name: this.kernel.peer.name,
|
|
5577
|
+
platform: this.kernel.platform,
|
|
5578
|
+
arch: this.kernel.arch,
|
|
5579
|
+
},
|
|
5580
|
+
...item,
|
|
5581
|
+
})
|
|
5582
|
+
}
|
|
5583
|
+
// get only the parts not from this peer
|
|
5584
|
+
for(let host in this.kernel.peer.info) {
|
|
5585
|
+
let host_info = this.kernel.peer.info[host]
|
|
5586
|
+
let host_rewrites = host_info.rewrite_mapping
|
|
5587
|
+
for(let key in host_rewrites) {
|
|
5588
|
+
info.push({
|
|
5589
|
+
online: true,
|
|
5590
|
+
host: {
|
|
5591
|
+
ip: host,
|
|
5592
|
+
local: this.kernel.peer.host === host,
|
|
5593
|
+
name: host_info.name,
|
|
5594
|
+
platform: host_info.platform,
|
|
5595
|
+
arch: host_info.arch
|
|
5596
|
+
},
|
|
5597
|
+
name: `[Files] ${host_rewrites[key].name}`,
|
|
5598
|
+
ip: host_rewrites[key].external_ip
|
|
5599
|
+
})
|
|
5600
|
+
}
|
|
5601
|
+
if (this.kernel.peer.host !== host) {
|
|
5602
|
+
let host_routers = host_info.router_info
|
|
5603
|
+
for(let host_router of host_routers) {
|
|
5604
|
+
let ip
|
|
5605
|
+
// the peer sharing works only if external_ip is available (caddy is installed)
|
|
5606
|
+
if (host_router.external_ip) {
|
|
5607
|
+
ip = host_router.external_ip
|
|
5608
|
+
} else {
|
|
5609
|
+
// if caddy is not turned on, set ip as null, so that it suggests turning on peer sharing
|
|
5610
|
+
ip = null
|
|
5611
|
+
}
|
|
5612
|
+
info.push({
|
|
5613
|
+
online: true,
|
|
5614
|
+
host: {
|
|
5615
|
+
ip: host,
|
|
5616
|
+
name: host_info.name,
|
|
5617
|
+
platform: host_info.platform,
|
|
5618
|
+
arch: host_info.arch
|
|
5619
|
+
},
|
|
5620
|
+
name: host_router.title || host_router.name,
|
|
5621
|
+
ip
|
|
5622
|
+
})
|
|
5623
|
+
}
|
|
5624
|
+
}
|
|
5625
|
+
|
|
5626
|
+
for(let app of host_info.installed) {
|
|
5627
|
+
info.push({
|
|
5628
|
+
host: {
|
|
5629
|
+
ip: host,
|
|
5630
|
+
local: this.kernel.peer.host === host,
|
|
5631
|
+
name: host_info.name,
|
|
5632
|
+
platform: host_info.platform,
|
|
5633
|
+
arch: host_info.arch
|
|
5634
|
+
},
|
|
5635
|
+
name: app.title || app.folder,
|
|
5636
|
+
ip: app.http_href.replace("http://", "")
|
|
5637
|
+
})
|
|
5638
|
+
}
|
|
5639
|
+
}
|
|
5573
5640
|
res.json({
|
|
5574
|
-
info
|
|
5641
|
+
info
|
|
5575
5642
|
})
|
|
5576
5643
|
}))
|
|
5577
5644
|
|
package/server/public/common.js
CHANGED
|
@@ -477,15 +477,6 @@ document.addEventListener("DOMContentLoaded", () => {
|
|
|
477
477
|
}
|
|
478
478
|
|
|
479
479
|
|
|
480
|
-
if (document.querySelector(".urlbar")) {
|
|
481
|
-
document.querySelector(".urlbar").addEventListener("submit", (e) => {
|
|
482
|
-
debugger
|
|
483
|
-
e.preventDefault()
|
|
484
|
-
e.stopPropagation()
|
|
485
|
-
location.href = "/container?url=" + e.target.querySelector("input[type=url]").value
|
|
486
|
-
})
|
|
487
|
-
}
|
|
488
|
-
|
|
489
480
|
if (document.querySelector("#genlog")) {
|
|
490
481
|
document.querySelector("#genlog").addEventListener("click", (e) => {
|
|
491
482
|
e.preventDefault()
|
package/server/public/style.css
CHANGED
|
@@ -2363,8 +2363,6 @@ body.dark .mode-selector .btn2.selected {
|
|
|
2363
2363
|
}
|
|
2364
2364
|
|
|
2365
2365
|
|
|
2366
|
-
|
|
2367
|
-
|
|
2368
2366
|
body.minimized {
|
|
2369
2367
|
display: flex;
|
|
2370
2368
|
flex-direction: row;
|
|
@@ -2433,7 +2431,7 @@ body.minimized .appcanvas, body.minimized main {
|
|
|
2433
2431
|
body.minimized .appcanvas {
|
|
2434
2432
|
padding-top: 20px;
|
|
2435
2433
|
}
|
|
2436
|
-
body.minimized main {
|
|
2434
|
+
body.minimized main, body.minimized iframe.mainframe {
|
|
2437
2435
|
/*
|
|
2438
2436
|
padding-top: 10px;
|
|
2439
2437
|
*/
|
|
@@ -2448,6 +2446,9 @@ body.minimized .app-icon {
|
|
|
2448
2446
|
body.minimized #dragger {
|
|
2449
2447
|
display: block;
|
|
2450
2448
|
}
|
|
2449
|
+
body.minimized aside .tab.submenu {
|
|
2450
|
+
padding: 10px;
|
|
2451
|
+
}
|
|
2451
2452
|
/*
|
|
2452
2453
|
body.minimized aside {
|
|
2453
2454
|
display: none;
|