diff --git a/config.js b/config.js index c6fa6a2..78ac49e 100644 --- a/config.js +++ b/config.js @@ -21,8 +21,6 @@ servers: [ // SSL options rejectUnauthorized: true, - - highWaterMark: 0, // disable node's internal bufferring to improve our timings (we always send full chunks, so bufferring by node isn't needed) }, secure: false, // set to true to use SSL user: '', diff --git a/lib/nntp.js b/lib/nntp.js index 5486946..1a1ecc5 100644 --- a/lib/nntp.js +++ b/lib/nntp.js @@ -84,21 +84,22 @@ function NNTP(opts, rawSpeedTracker) { this.dataLength = 0; this._connectRetries = opts.connectRetries; - var connectOpts = opts.connect; + var connectOpts = util.extend({ + port: opts.secure ? 563 : 119, + readableHighWaterMark: 0, // disable buffering + writableHighWaterMark: 1 // Node 20 seems to go wonky with a value of 0, so use 1 instead + }, opts.connect); // although the feature was added in node 12.10.0, it's crashy on Linux until 13.13.0 / 12.16.3 // reported as unstable on 15.7.0, so we'll disable it everywhere until we get more info on it: https://github.com/animetosho/Nyuu/issues/87 var supportsOnread = false; - if(supportsOnread || !opts.connect.port) { - connectOpts = util.extend({}, opts.connect); - this.opts = util.extend({}, this.opts, {connect: connectOpts}); - if(!opts.connect.port) - connectOpts.port = opts.secure ? 563 : 119; - if(supportsOnread) - connectOpts.onread = this.opts.useThreads ? true : { - buffer: Buffer.allocUnsafe(4096), - callback: this._onDataStatic.bind(this) - }; - } + if(supportsOnread) + connectOpts.onread = this.opts.useThreads ? true : { + buffer: Buffer.allocUnsafe(4096), + callback: this._onDataStatic.bind(this) + }; + if(+process.version.replace(/\.\d+$/, '').replace(/^v/, '') < 8.4) // Node < 8.4.0 + connectOpts.highWaterMark = 0; + this.postMethod = (opts.postMethod || '').toUpperCase(); if(!(this.postMethod in VALID_POST_CODES))