dump data

This commit is contained in:
Girish Ramakrishnan 2016-05-18 22:03:38 -07:00
parent afac513994
commit 3102d7a6af

View File

@ -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 () { });