From 962d2e5e164da95acaa916054dddb51948280145 Mon Sep 17 00:00:00 2001 From: miketwc1984 Date: Wed, 4 Oct 2023 23:26:12 -0400 Subject: [PATCH] sync to 0.9.35 --- bin/url-plugin.js | 10 +++--- lib/comm.js | 15 ++++++-- lib/engine.js | 88 +---------------------------------------------- package.json | 4 +-- 4 files changed, 20 insertions(+), 97 deletions(-) diff --git a/bin/url-plugin.js b/bin/url-plugin.js index 07e18ff..48a3d51 100644 --- a/bin/url-plugin.js +++ b/bin/url-plugin.js @@ -33,11 +33,6 @@ stream.on('json', function(job) { // timeout request.setTimeout( (params.timeout || 0) * 1000 ); - // ssl cert bypass - if (params.ssl_cert_bypass) { - process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0"; - } - if (!params.url || !params.url.match(/^https?\:\/\/\S+$/i)) { stream.write({ complete: 1, code: 1, description: "Malformed URL: " + (params.url || '(n/a)') }); return; @@ -67,6 +62,11 @@ stream.on('json', function(job) { var opts = { method: params.method }; + + // ssl cert bypass + if (params.ssl_cert_bypass) { + opts.rejectUnauthorized = true; + } // post data if (opts.method == 'POST') { diff --git a/lib/comm.js b/lib/comm.js index d55e5ab..dcd83c6 100644 --- a/lib/comm.js +++ b/lib/comm.js @@ -306,10 +306,19 @@ module.exports = Class.create({ // start listening for websocket connections this.numSocketClients = 0; this.sockets = {}; - this.io = SocketIO({ serveClient: false }); + let io = this.io = SocketIO({ serveClient: false }); - this.io.attach( this.web.http ); - if (this.web.https) this.io.attach( this.web.https ); + if (this.web.listeners) { + // modern pixl-server-web + this.web.listeners.forEach( function(listener) { + io.attach( listener ); + } ); + } + else { + // legacy pixl-server-web + this.io.attach( this.web.http ); + if (this.web.https) this.io.attach( this.web.https ); + } this.io.on('connection', this.handleNewSocket.bind(this) ); }, diff --git a/lib/engine.js b/lib/engine.js index 6c82eb1..9f6dc97 100644 --- a/lib/engine.js +++ b/lib/engine.js @@ -120,11 +120,6 @@ module.exports = Class.create({ // construct http client for web hooks and uploading logs this.request = new Request("Cronicle " + this.server.__version); - // optionally bypass all ssl cert validation - if (this.server.config.get('ssl_cert_bypass') || this.server.config.get('web_hook_ssl_cert_bypass')) { - process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0"; - } - // register our class as an API namespace this.api.addNamespace("app", "api_", this); @@ -1402,8 +1397,7 @@ module.exports = Class.create({ if (info.length > max_rows) { // list has grown too long, needs a trim self.logDebug(3, "List " + list_path + " has grown too long, trimming to max: " + max_rows, info); - // self.storage.listSplice( list_path, max_rows, info.length - max_rows, null, callback ); - self.listRoughChop(list_path, max_rows, callback); + self.storage.listSplice( list_path, max_rows, info.length - max_rows, null, callback ); } else { // no trim needed, proceed to next list @@ -1432,86 +1426,6 @@ module.exports = Class.create({ } }, - listRoughChop: function (list_path, max_rows, callback) { - // Roughly chop the end of a list to get the size down to under specified ceiling. - // This is not exact, and will likely be off by up to one 'page_size' of items. - // The idea here is to chop without using tons of memory like listSplice does. - const self = this; - this.logDebug(4, "Roughly chopping list: " + list_path + " down to max: " + max_rows); - - self.storage._listLock(list_path, true, function () { - // list is now locked, we can work on it safely - - self.storage.listGetInfo(list_path, function (err, list) { - // check for error - if (err) { - self.logError('maint', "Failed to load list header: " + list_path + ": " + err); - self.storage._listUnlock(list_path); - return callback(); - } - - // begin chop loop - async.whilst( - function () { - // keep chopping while list is too long - return (list.length > max_rows); - }, - function (callback) { - // load last page - self.storage._listLoadPage(list_path, list.last_page, false, function (err, page) { - if (err) { - // this should never happen, and is bad - // (list is probably corrupted, and should be deleted and recreated) - return callback(new Error("Failed to load list page: " + list_path + "/" + list.last_page + ": " + err)); - } - if (!page) page = { items: [] }; - if (!page.items) page.items = []; - - list.length -= page.items.length; - - self.logDebug(5, "Deleting list page: " + list_path + "/" + list.last_page + " (" + page.items.length + " items)"); - - self.storage.delete(list_path + "/" + list.last_page, function (err) { - if (err) { - // log error but don't fail entire op - self.logError('maint', "Failed to delete list page: " + list_path + "/" + list.last_page + ": " + err); - } - - list.last_page--; - callback(); - - }); // delete page - }); // _listLoadPage - }, - function (err) { - // all done - if (err) { - self.logError('maint', err.toString()); - self.storage._listUnlock(list_path); - return callback(); - } - - // update list header with new length and last_page - self.storage.put(list_path, list, function (err) { - if (err) { - self.logError('maint', "Failed to update list header: " + list_path + ": " + err); - } - - // unlock list - self.storage._listUnlock(list_path); - - self.logDebug(4, "List chop complete: " + list_path + ", new size: " + list.length, list); - - // and we're done - callback(); - - }); // put - } // done - ); // whilst - }); // listGetInfo - }); // listLock - }, - archiveLogs: function () { // archive all logs (called once daily) const self = this; diff --git a/package.json b/package.json index dc0ffd2..19a19e6 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "cronicle-edge", - "version": "1.7.2", + "version": "1.7.3", "description": "A simple, distributed task scheduler and runner with a web based UI.", "author": "Joseph Huckaby ", "homepage": "https://github.com/jhuckaby/Cronicle", @@ -62,7 +62,7 @@ "pixl-server": "^1.0.40", "pixl-server-api": "^1.0.2", "pixl-server-storage": "^3.1.12", - "pixl-server-web": "^1.3.20", + "pixl-server-web": "^1.3.22", "pixl-tools": "^1.0.29", "pixl-webapp": "^2.0.2", "read-last-lines": "^1.8.0",