pinokiod 3.17.2 → 3.17.3
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/socket.js +3 -0
- package/server/views/install.ejs +32 -7
- 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/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) {
|
package/server/views/setup.ejs
CHANGED