@scrypted/server 0.0.83 → 0.0.87
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.
Potentially problematic release.
This version of @scrypted/server might be problematic. Click here for more details.
- package/dist/plugin/plugin-console.js +93 -0
- package/dist/plugin/plugin-console.js.map +1 -0
- package/dist/plugin/plugin-host.js +67 -168
- package/dist/plugin/plugin-host.js.map +1 -1
- package/dist/plugin/plugin-npm-dependencies.js +2 -2
- package/dist/plugin/plugin-npm-dependencies.js.map +1 -1
- package/dist/plugin/plugin-remote.js +7 -9
- package/dist/plugin/plugin-remote.js.map +1 -1
- package/dist/plugin/plugin-repl.js +69 -0
- package/dist/plugin/plugin-repl.js.map +1 -0
- package/dist/scrypted-main.js +15 -30
- package/dist/scrypted-main.js.map +1 -1
- package/dist/services/plugin.js +8 -0
- package/dist/services/plugin.js.map +1 -1
- package/package.json +1 -1
- package/python/plugin-remote.py +70 -30
- package/python/rpc.py +1 -1
- package/src/plugin/plugin-console.ts +115 -0
- package/src/plugin/plugin-host.ts +67 -194
- package/src/plugin/plugin-npm-dependencies.ts +2 -3
- package/src/plugin/plugin-remote.ts +11 -10
- package/src/plugin/plugin-repl.ts +74 -0
- package/src/scrypted-main.ts +15 -32
- package/src/services/plugin.ts +8 -0
package/src/scrypted-main.ts
CHANGED
|
@@ -63,43 +63,19 @@ else {
|
|
|
63
63
|
})
|
|
64
64
|
}
|
|
65
65
|
|
|
66
|
-
const debuggers = new Map<number, net.Socket[]>();
|
|
67
66
|
const debugServer = net.createServer(async (socket) => {
|
|
68
67
|
if (!workerInspectPort) {
|
|
69
68
|
socket.destroy();
|
|
70
69
|
return;
|
|
71
70
|
}
|
|
72
71
|
|
|
73
|
-
const entry = debuggers.get(workerInspectPort);
|
|
74
|
-
if (!entry) {
|
|
75
|
-
debuggers.set(workerInspectPort, [socket]);
|
|
76
|
-
}
|
|
77
|
-
else {
|
|
78
|
-
entry.push(socket);
|
|
79
|
-
}
|
|
80
|
-
|
|
81
72
|
for (let i = 0; i < 10; i++) {
|
|
82
73
|
try {
|
|
83
74
|
const target = await doconnect();
|
|
84
75
|
socket.pipe(target).pipe(socket);
|
|
85
76
|
const destroy = () => {
|
|
86
|
-
socket.end();
|
|
87
77
|
socket.destroy();
|
|
88
|
-
target.end();
|
|
89
78
|
target.destroy();
|
|
90
|
-
|
|
91
|
-
if (!entry) {
|
|
92
|
-
const sockets = debuggers.get(workerInspectPort);
|
|
93
|
-
if (!debuggers.delete(workerInspectPort))
|
|
94
|
-
return;
|
|
95
|
-
setTimeout(() => {
|
|
96
|
-
if (debuggers.has(workerInspectPort))
|
|
97
|
-
return;
|
|
98
|
-
for (const s of sockets) {
|
|
99
|
-
s.destroy();
|
|
100
|
-
}
|
|
101
|
-
}, 500)
|
|
102
|
-
}
|
|
103
79
|
}
|
|
104
80
|
socket.on('error', destroy);
|
|
105
81
|
target.on('error', destroy);
|
|
@@ -185,7 +161,7 @@ else {
|
|
|
185
161
|
|
|
186
162
|
// legacy secure port 9443 is now in use by portainer.
|
|
187
163
|
let shownLegacyPortAlert = false
|
|
188
|
-
const legacySecure = https.createServer(
|
|
164
|
+
const legacySecure = https.createServer(mergedHttpsServerOptions, (req, res) => {
|
|
189
165
|
if (!shownLegacyPortAlert) {
|
|
190
166
|
const core = scrypted.findPluginDevice('@scrypted/core');
|
|
191
167
|
if (core) {
|
|
@@ -273,8 +249,8 @@ else {
|
|
|
273
249
|
console.log('Ports can be changed with environment variables.')
|
|
274
250
|
console.log('https: $SCRYPTED_SECURE_PORT')
|
|
275
251
|
console.log('http : $SCRYPTED_INSECURE_PORT')
|
|
276
|
-
console.log('Certificate can be
|
|
277
|
-
console.log('JSON file
|
|
252
|
+
console.log('Certificate can be modified via tls.createSecureContext options in')
|
|
253
|
+
console.log('JSON file located at SCRYPTED_HTTPS_OPTIONS_FILE environment variable:');
|
|
278
254
|
console.log('export SCRYPTED_HTTPS_OPTIONS_FILE=/path/to/options.json');
|
|
279
255
|
console.log('https://nodejs.org/api/tls.html#tlscreatesecurecontextoptions')
|
|
280
256
|
console.log('#######################################################');
|
|
@@ -370,15 +346,22 @@ else {
|
|
|
370
346
|
}
|
|
371
347
|
|
|
372
348
|
const waitDebug = new Promise<void>((resolve, reject) => {
|
|
373
|
-
setTimeout(() => reject(new Error('timed out waiting for debug session')),
|
|
349
|
+
setTimeout(() => reject(new Error('timed out waiting for debug session')), 30000);
|
|
374
350
|
debugServer.on('connection', resolve);
|
|
375
351
|
});
|
|
376
352
|
|
|
377
353
|
workerInspectPort = Math.round(Math.random() * 10000) + 30000;
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
354
|
+
try {
|
|
355
|
+
await scrypted.installPlugin(plugin, {
|
|
356
|
+
waitDebug,
|
|
357
|
+
inspectPort: workerInspectPort,
|
|
358
|
+
});
|
|
359
|
+
}
|
|
360
|
+
catch (e) {
|
|
361
|
+
res.status(500);
|
|
362
|
+
res.send(e.toString());
|
|
363
|
+
return
|
|
364
|
+
}
|
|
382
365
|
|
|
383
366
|
res.send({
|
|
384
367
|
workerInspectPort,
|
package/src/services/plugin.ts
CHANGED
|
@@ -119,6 +119,14 @@ export class PluginComponent {
|
|
|
119
119
|
}
|
|
120
120
|
|
|
121
121
|
async getRemoteServicePort(pluginId: string, name: string): Promise<number> {
|
|
122
|
+
if (name === 'console') {
|
|
123
|
+
const consoleServer = await this.scrypted.plugins[pluginId].consoleServer;
|
|
124
|
+
return consoleServer.readPort;
|
|
125
|
+
}
|
|
126
|
+
if (name === 'console-writer') {
|
|
127
|
+
const consoleServer = await this.scrypted.plugins[pluginId].consoleServer;
|
|
128
|
+
return consoleServer.writePort;
|
|
129
|
+
}
|
|
122
130
|
return this.scrypted.plugins[pluginId].remote.getServicePort(name);
|
|
123
131
|
}
|
|
124
132
|
}
|