pinokiod 3.17.2 → 3.17.4
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/bin/caddy.js +36 -17
- package/kernel/peer.js +33 -9
- package/kernel/shell.js +1 -1
- package/package.json +1 -1
- package/server/index.js +27 -2
- package/server/socket.js +3 -0
- package/server/views/install.ejs +32 -7
- package/server/views/settings.ejs +39 -19
- package/server/views/setup.ejs +0 -1
- package/server/views/terminal.ejs +0 -1
package/kernel/bin/caddy.js
CHANGED
|
@@ -88,27 +88,46 @@ class Caddy {
|
|
|
88
88
|
ondata(e)
|
|
89
89
|
})
|
|
90
90
|
} else {
|
|
91
|
-
ondata({
|
|
92
|
-
title: "Password",
|
|
93
|
-
description: "Enter your system password to add the HTTPS certificate",
|
|
94
|
-
form: [{
|
|
95
|
-
type: "password",
|
|
96
|
-
autofocus: true,
|
|
97
|
-
key: "password",
|
|
98
|
-
placeholder: "System password",
|
|
99
|
-
}]
|
|
100
|
-
}, "input")
|
|
101
|
-
let response = await this.kernel.api.wait(id)
|
|
91
|
+
// ondata({
|
|
92
|
+
// title: "Password",
|
|
93
|
+
// description: "Enter your system password to add the HTTPS certificate",
|
|
94
|
+
// form: [{
|
|
95
|
+
// type: "password",
|
|
96
|
+
// autofocus: true,
|
|
97
|
+
// key: "password",
|
|
98
|
+
// placeholder: "System password",
|
|
99
|
+
// }]
|
|
100
|
+
// }, "input")
|
|
101
|
+
// let response = await this.kernel.api.wait(id)
|
|
102
|
+
// await this.kernel.exec({
|
|
103
|
+
// message: `echo ${response.password} | sudo -S caddy trust`,
|
|
104
|
+
// path: this.kernel.homedir
|
|
105
|
+
// }, (e) => {
|
|
106
|
+
// // ondata(e)
|
|
107
|
+
// // console.log(e)
|
|
108
|
+
// // if (/Caddy Local Authority/i.test(e.cleaned)) {
|
|
109
|
+
// // trusted = true
|
|
110
|
+
// // }
|
|
111
|
+
// })
|
|
112
|
+
|
|
113
|
+
//let response = await this.kernel.api.wait(id)
|
|
114
|
+
console.log("ondata", ondata.toString())
|
|
115
|
+
setTimeout(() => {
|
|
116
|
+
ondata({ html: `<b><i class="fa-solid fa-keyboard"></i> Enter the system password to generate a certificate</b>` }, "notify3")
|
|
117
|
+
}, 2000)
|
|
102
118
|
await this.kernel.exec({
|
|
103
|
-
|
|
119
|
+
input: true,
|
|
120
|
+
//message: "sudo -s && caddy trust",
|
|
121
|
+
//message: "sudo -s",
|
|
122
|
+
message: "caddy trust",
|
|
123
|
+
onprompt: (shell) => {
|
|
124
|
+
shell.kill("Done")
|
|
125
|
+
},
|
|
104
126
|
path: this.kernel.homedir
|
|
105
127
|
}, (e) => {
|
|
106
|
-
|
|
107
|
-
// console.log(e)
|
|
108
|
-
// if (/Caddy Local Authority/i.test(e.cleaned)) {
|
|
109
|
-
// trusted = true
|
|
110
|
-
// }
|
|
128
|
+
ondata(e)
|
|
111
129
|
})
|
|
130
|
+
ondata({ html: `<b><i class="fa-solid fa-check"></i> HTTPS certificate create step finished</b>` }, "notify3")
|
|
112
131
|
}
|
|
113
132
|
}
|
|
114
133
|
async installed() {
|
package/kernel/peer.js
CHANGED
|
@@ -9,6 +9,7 @@ class PeerDiscovery {
|
|
|
9
9
|
this.interval = interval;
|
|
10
10
|
this.peers = new Set();
|
|
11
11
|
this.host = this._getLocalIPAddress()
|
|
12
|
+
console.log("THIS>HOST", this.host)
|
|
12
13
|
this.default_port = 42000
|
|
13
14
|
this.peers.add(this.host)
|
|
14
15
|
// this.start();
|
|
@@ -160,27 +161,50 @@ class PeerDiscovery {
|
|
|
160
161
|
_isLocalLAN(ip) {
|
|
161
162
|
return ip.startsWith('192.168.') || ip.startsWith('10.') || (ip.startsWith('172.') && is172Private(ip));
|
|
162
163
|
}
|
|
164
|
+
//_getLocalIPAddress() {
|
|
165
|
+
// const interfaces = os.networkInterfaces();
|
|
166
|
+
// for (const ifaceList of Object.values(interfaces)) {
|
|
167
|
+
// for (const iface of ifaceList) {
|
|
168
|
+
// console.log({ iface })
|
|
169
|
+
// if (iface.family === 'IPv4' && !iface.internal) {
|
|
170
|
+
// const ip = iface.address;
|
|
171
|
+
// if (
|
|
172
|
+
// ip.startsWith('10.') ||
|
|
173
|
+
// ip.startsWith('192.168.') ||
|
|
174
|
+
// (ip.startsWith('172.') && is172Private(ip))
|
|
175
|
+
// ) {
|
|
176
|
+
// return ip;
|
|
177
|
+
// }
|
|
178
|
+
// }
|
|
179
|
+
// }
|
|
180
|
+
// }
|
|
181
|
+
// return null;
|
|
182
|
+
// function is172Private(ip) {
|
|
183
|
+
// const secondOctet = parseInt(ip.split('.')[1], 10);
|
|
184
|
+
// return secondOctet >= 16 && secondOctet <= 31;
|
|
185
|
+
// }
|
|
186
|
+
//}
|
|
163
187
|
_getLocalIPAddress() {
|
|
164
188
|
const interfaces = os.networkInterfaces();
|
|
165
189
|
for (const ifaceList of Object.values(interfaces)) {
|
|
166
190
|
for (const iface of ifaceList) {
|
|
167
191
|
if (iface.family === 'IPv4' && !iface.internal) {
|
|
168
192
|
const ip = iface.address;
|
|
169
|
-
if (
|
|
170
|
-
ip.startsWith('10.') ||
|
|
171
|
-
ip.startsWith('192.168.') ||
|
|
172
|
-
(ip.startsWith('172.') && is172Private(ip))
|
|
173
|
-
) {
|
|
193
|
+
if (this.isPrivateOrCGNAT(ip)) {
|
|
174
194
|
return ip;
|
|
175
195
|
}
|
|
176
196
|
}
|
|
177
197
|
}
|
|
178
198
|
}
|
|
179
199
|
return null;
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
200
|
+
}
|
|
201
|
+
isPrivateOrCGNAT(ip) {
|
|
202
|
+
const octets = ip.split('.').map(Number);
|
|
203
|
+
if (octets[0] === 10) return true;
|
|
204
|
+
if (octets[0] === 172 && octets[1] >= 16 && octets[1] <= 31) return true;
|
|
205
|
+
if (octets[0] === 192 && octets[1] === 168) return true;
|
|
206
|
+
if (octets[0] === 100 && octets[1] >= 64 && octets[1] <= 127) return true; // CGNAT
|
|
207
|
+
return false;
|
|
184
208
|
}
|
|
185
209
|
}
|
|
186
210
|
|
package/kernel/shell.js
CHANGED
package/package.json
CHANGED
package/server/index.js
CHANGED
|
@@ -719,6 +719,10 @@ class Server {
|
|
|
719
719
|
key: "theme",
|
|
720
720
|
val: this.theme,
|
|
721
721
|
options: ["light", "dark"]
|
|
722
|
+
}, {
|
|
723
|
+
key: "mode",
|
|
724
|
+
val: this.mode,
|
|
725
|
+
options: ["full", "minimal"]
|
|
722
726
|
}, {
|
|
723
727
|
key: "HTTP_PROXY",
|
|
724
728
|
val: (system_env.HTTP_PROXY || ""),
|
|
@@ -2116,6 +2120,7 @@ class Server {
|
|
|
2116
2120
|
|
|
2117
2121
|
// 1. THEME
|
|
2118
2122
|
this.theme = this.kernel.store.get("theme") || "light"
|
|
2123
|
+
this.mode = this.kernel.store.get("mode") || "app"
|
|
2119
2124
|
if (this.theme === "dark") {
|
|
2120
2125
|
this.colors = {
|
|
2121
2126
|
color: "rgb(27, 28, 29)",
|
|
@@ -2212,6 +2217,7 @@ class Server {
|
|
|
2212
2217
|
async setConfig(config) {
|
|
2213
2218
|
let home = this.kernel.store.get("home")
|
|
2214
2219
|
let theme = this.kernel.store.get("theme")
|
|
2220
|
+
let mode = this.kernel.store.get("mode")
|
|
2215
2221
|
// let drive = this.kernel.store.get("drive")
|
|
2216
2222
|
|
|
2217
2223
|
// 1. Handle THEME
|
|
@@ -2243,6 +2249,14 @@ class Server {
|
|
|
2243
2249
|
}
|
|
2244
2250
|
|
|
2245
2251
|
}
|
|
2252
|
+
|
|
2253
|
+
let mode_changed = false
|
|
2254
|
+
if (config.mode) {
|
|
2255
|
+
if (config.mode !== mode) {
|
|
2256
|
+
mode_changed = true
|
|
2257
|
+
}
|
|
2258
|
+
this.kernel.store.set("mode", config.mode)
|
|
2259
|
+
}
|
|
2246
2260
|
// // 3. Handle Drive
|
|
2247
2261
|
// if (config.drive) {
|
|
2248
2262
|
// // if the home is different from the existing home, go forward
|
|
@@ -2293,6 +2307,13 @@ class Server {
|
|
|
2293
2307
|
this.kernel.store.set("HTTP_PROXY", config.HTTP_PROXY)
|
|
2294
2308
|
this.kernel.store.set("HTTPS_PROXY", config.HTTPS_PROXY)
|
|
2295
2309
|
this.kernel.store.set("NO_PROXY", config.NO_PROXY)
|
|
2310
|
+
|
|
2311
|
+
if (mode_changed) {
|
|
2312
|
+
return {
|
|
2313
|
+
title: "Restart Required",
|
|
2314
|
+
text: "Please restart the app"
|
|
2315
|
+
}
|
|
2316
|
+
}
|
|
2296
2317
|
}
|
|
2297
2318
|
async startLogging(homedir) {
|
|
2298
2319
|
if (!this.debug) {
|
|
@@ -2671,6 +2692,10 @@ class Server {
|
|
|
2671
2692
|
key: "theme",
|
|
2672
2693
|
val: this.theme,
|
|
2673
2694
|
options: ["light", "dark"]
|
|
2695
|
+
}, {
|
|
2696
|
+
key: "mode",
|
|
2697
|
+
val: this.mode,
|
|
2698
|
+
options: ["full", "minimal"]
|
|
2674
2699
|
}, {
|
|
2675
2700
|
key: "HTTP_PROXY",
|
|
2676
2701
|
val: (system_env.HTTP_PROXY || ""),
|
|
@@ -4899,8 +4924,8 @@ class Server {
|
|
|
4899
4924
|
|
|
4900
4925
|
this.app.post("/config", ex(async (req, res) => {
|
|
4901
4926
|
try {
|
|
4902
|
-
await this.setConfig(req.body)
|
|
4903
|
-
res.json({ success: true })
|
|
4927
|
+
let message = await this.setConfig(req.body)
|
|
4928
|
+
res.json({ success: true, message })
|
|
4904
4929
|
} catch (e) {
|
|
4905
4930
|
res.json({ error: e.stack })
|
|
4906
4931
|
}
|
package/server/socket.js
CHANGED
|
@@ -59,6 +59,8 @@ class Socket {
|
|
|
59
59
|
await this.parent.kernel.api.init()
|
|
60
60
|
// look for repos that match
|
|
61
61
|
|
|
62
|
+
console.log({ req })
|
|
63
|
+
|
|
62
64
|
if (req.uri) {
|
|
63
65
|
if (req.mode === "open") {
|
|
64
66
|
// get the default script and respond
|
|
@@ -149,6 +151,7 @@ class Socket {
|
|
|
149
151
|
} else if (req.emit) {
|
|
150
152
|
this.parent.kernel.shell.emit(req)
|
|
151
153
|
} else if (req.key && req.id) {
|
|
154
|
+
console.log({ req })
|
|
152
155
|
this.parent.kernel.shell.emit({
|
|
153
156
|
id: req.id,
|
|
154
157
|
emit: req.key,
|
package/server/views/install.ejs
CHANGED
|
@@ -98,16 +98,20 @@ body {
|
|
|
98
98
|
box-sizing: border-box;
|
|
99
99
|
width: 100%;
|
|
100
100
|
margin: 0;
|
|
101
|
+
/*
|
|
101
102
|
margin-bottom: 10px;
|
|
103
|
+
*/
|
|
102
104
|
overflow: auto;
|
|
103
|
-
|
|
105
|
+
background: royalblue;
|
|
106
|
+
color: white;
|
|
104
107
|
/*
|
|
108
|
+
border-left: 5px solid royalblue;
|
|
105
109
|
color: rgb(27, 28, 29);
|
|
106
110
|
*/
|
|
107
111
|
}
|
|
108
112
|
#status-screen b {
|
|
113
|
+
color: white;
|
|
109
114
|
font-weight: normal;
|
|
110
|
-
color: royalblue;
|
|
111
115
|
font-size: 16px;
|
|
112
116
|
}
|
|
113
117
|
</style>
|
|
@@ -133,10 +137,10 @@ body {
|
|
|
133
137
|
</head>
|
|
134
138
|
<body class='<%=theme%>' data-agent="<%=agent%>">
|
|
135
139
|
<header class='grabbable'></header>
|
|
136
|
-
<div id='status-screen'><b><i class="fas fa-circle-notch fa-spin"></i> Setting up...</b><br>Setting up core modules including conda, uv, git, etc.</div>
|
|
137
140
|
<div class='terminal-container'>
|
|
138
141
|
<div id='terminal'></div>
|
|
139
142
|
</div>
|
|
143
|
+
<div id='status-screen'><b><i class="fas fa-circle-notch fa-spin"></i> Setting up...</b><br>Setting up core modules including conda, uv, git, etc.</div>
|
|
140
144
|
<input id='requirements' type='hidden' value="<%=requirements%>">
|
|
141
145
|
<input id='callback' type='hidden' value="<%=callback%>">
|
|
142
146
|
<script>
|
|
@@ -206,10 +210,17 @@ document.addEventListener("DOMContentLoaded", async () => {
|
|
|
206
210
|
}
|
|
207
211
|
}
|
|
208
212
|
term.onKey((e) => {
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
+
if (shell_id) {
|
|
214
|
+
socket.emit({
|
|
215
|
+
id: shell_id,
|
|
216
|
+
key: e.key
|
|
217
|
+
})
|
|
218
|
+
}
|
|
219
|
+
//console.log({ e })
|
|
220
|
+
//socket.emit({
|
|
221
|
+
// id: location.pathname,
|
|
222
|
+
// emit: e.key
|
|
223
|
+
//})
|
|
213
224
|
})
|
|
214
225
|
let observer = new ResizeObserver(() => {
|
|
215
226
|
fitAddon.fit()
|
|
@@ -255,6 +266,20 @@ document.addEventListener("DOMContentLoaded", async () => {
|
|
|
255
266
|
type: "moddal",
|
|
256
267
|
description: packet.data
|
|
257
268
|
})
|
|
269
|
+
} else if (packet.type === "notify3") {
|
|
270
|
+
console.log("HTML", packet.data)
|
|
271
|
+
if (packet.data) {
|
|
272
|
+
let payload = {}
|
|
273
|
+
if (packet.data.html) {
|
|
274
|
+
payload.text = packet.data.html
|
|
275
|
+
}
|
|
276
|
+
if (packet.data.type) {
|
|
277
|
+
payload.type = packet.data.type
|
|
278
|
+
}
|
|
279
|
+
document.querySelector("#status-screen").innerHTML = packet.data.html
|
|
280
|
+
let audio = new Audio("/pop.mp3")
|
|
281
|
+
audio.play()
|
|
282
|
+
}
|
|
258
283
|
} else if (packet.type === "notify2") {
|
|
259
284
|
console.log("HTML", packet.data)
|
|
260
285
|
if (packet.data) {
|
|
@@ -244,6 +244,12 @@ body.dark .keys pre {
|
|
|
244
244
|
margin: 20px 0;
|
|
245
245
|
background: rgba(0,0,100,0.04) !important;
|
|
246
246
|
}
|
|
247
|
+
.swal2-actions {
|
|
248
|
+
justify-content: center !important;
|
|
249
|
+
}
|
|
250
|
+
.swal2-title {
|
|
251
|
+
text-align: center !important;
|
|
252
|
+
}
|
|
247
253
|
</style>
|
|
248
254
|
<script src="/hotkeys.min.js"></script>
|
|
249
255
|
<script src="/sweetalert2.js"></script>
|
|
@@ -631,26 +637,40 @@ console.log("body", body)
|
|
|
631
637
|
return res.json()
|
|
632
638
|
})
|
|
633
639
|
if (r.success) {
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
if (res.success) {
|
|
645
|
-
document.querySelector(".loading").classList.add("hidden")
|
|
646
|
-
setTimeout(() => {
|
|
647
|
-
location.href = "/"
|
|
648
|
-
}, 1000)
|
|
640
|
+
if (r.message) {
|
|
641
|
+
Swal.fire({
|
|
642
|
+
title: r.message.title,
|
|
643
|
+
text: r.message.text,
|
|
644
|
+
allowOutsideClick: false,
|
|
645
|
+
allowEscapeKey: false,
|
|
646
|
+
allowEnterKey: false,
|
|
647
|
+
showConfirmButton: false,
|
|
648
|
+
didOpen: () => {
|
|
649
|
+
Swal.showLoading();
|
|
649
650
|
}
|
|
650
|
-
}
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
651
|
+
});
|
|
652
|
+
} else {
|
|
653
|
+
//alert("Successfully updated the pinokio home to " + val)
|
|
654
|
+
fetch("/restart", {
|
|
655
|
+
method: "post"
|
|
656
|
+
}, () => {
|
|
657
|
+
})
|
|
658
|
+
setInterval(async () => {
|
|
659
|
+
try {
|
|
660
|
+
let res = await fetch("/check").then((res) => {
|
|
661
|
+
return res.json()
|
|
662
|
+
})
|
|
663
|
+
if (res.success) {
|
|
664
|
+
document.querySelector(".loading").classList.add("hidden")
|
|
665
|
+
setTimeout(() => {
|
|
666
|
+
location.href = "/"
|
|
667
|
+
}, 1000)
|
|
668
|
+
}
|
|
669
|
+
} catch (e) {
|
|
670
|
+
console.log(e)
|
|
671
|
+
}
|
|
672
|
+
}, 1000)
|
|
673
|
+
}
|
|
654
674
|
} else if (r.error) {
|
|
655
675
|
alert(r.error)
|
|
656
676
|
location.href = location.href
|
package/server/views/setup.ejs
CHANGED