From 3102d7a6afc13e9f2d23c0e35b91234436a2825c Mon Sep 17 00:00:00 2001 From: Girish Ramakrishnan Date: Wed, 18 May 2016 22:03:38 -0700 Subject: [PATCH] dump data --- cloudron.js | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/cloudron.js b/cloudron.js index 5a0f849..3e7abc7 100644 --- a/cloudron.js +++ b/cloudron.js @@ -525,6 +525,7 @@ Cloudron.prototype.checkMail = function (owner, callback) { Cloudron.prototype.saveSieveScript = function (owner, callback) { var authString = 'AUTHENTICATE "PLAIN" "' + new Buffer('\0' + owner.username + '\0' + owner.password).toString('base64') + '"'; + var data = ''; callback = once(callback); @@ -534,11 +535,16 @@ Cloudron.prototype.saveSieveScript = function (owner, callback) { socket.write(authString + '\n'); socket.write('PUTSCRIPT \"hutsefluts\" {6+}\nkeep;\nQUIT\n'); - setTimeout(function () { socket.end(); callback(new Error('Could not auth with sieve')); }, 5000); // give it 5 seconds + setTimeout(function () { + socket.end(); + callback(new Error('Could not auth with sieve.\n' + data)); + }, 5000); // give it 5 seconds }); socket.on('data', function (chunk) { - if (chunk.toString('utf8').indexOf('OK "Logged in."') !== -1) return callback(); + data += chunk.toString('utf8'); + + if (data.toString('utf8').indexOf('OK "Logged in."') !== -1) return callback(); }); socket.on('end', function () { }); @@ -547,6 +553,7 @@ Cloudron.prototype.saveSieveScript = function (owner, callback) { Cloudron.prototype.checkSieveScript = function (owner, callback) { var authString = 'AUTHENTICATE "PLAIN" "' + new Buffer('\0' + owner.username + '\0' + owner.password).toString('base64') + '"'; + var data = ''; callback = once(callback); @@ -556,11 +563,16 @@ Cloudron.prototype.checkSieveScript = function (owner, callback) { socket.write(authString + '\n'); socket.write('LISTSCRIPTS\nQUIT\n'); - setTimeout(function () { socket.end(); callback(new Error('Could not auth with sieve')); }, 5000); // give it 5 seconds + setTimeout(function () { + socket.end(); + callback(new Error('Could not auth with sieve.\n' + data)); + }, 5000); // give it 5 seconds }); socket.on('data', function (chunk) { - if (chunk.toString('utf8').indexOf('"hutsefluts"') !== -1) return callback(); + data += chunk.toString('utf8'); + + if (data.toString('utf8').indexOf('"hutsefluts"') !== -1) return callback(); }); socket.on('end', function () { });