1
0
mirror of https://github.com/moparisthebest/mail synced 2024-12-22 07:18:49 -05:00

[WO-567] fix TLS worker handling

This commit is contained in:
Felix Hammerl 2014-10-15 19:58:26 +02:00
parent 7be6c63060
commit 3a6e0463fb
5 changed files with 34 additions and 20 deletions

View File

@ -126,6 +126,12 @@ module.exports = function(grunt) {
}, },
options: browserifyOpt options: browserifyOpt
}, },
tlsWorker: {
files: {
'dist/js/tcp-socket-tls-worker.browserified.js': ['node_modules/tcp-socket/src/tcp-socket-tls-worker.js']
},
options: browserifyOpt
},
unitTest: { unitTest: {
files: { files: {
'test/unit/index.browserified.js': [ 'test/unit/index.browserified.js': [
@ -249,6 +255,15 @@ module.exports = function(grunt) {
sourceMapName: 'dist/js/mailreader-parser-worker.min.js.map' sourceMapName: 'dist/js/mailreader-parser-worker.min.js.map'
} }
}, },
tlsWorker: {
files: {
'dist/js/tcp-socket-tls-worker.min.js': ['dist/js/tcp-socket-tls-worker.browserified.js']
},
options: {
sourceMap: true,
sourceMapName: 'dist/js/tcp-socket-tls-worker.min.js.map'
}
},
unitTest: { unitTest: {
files: { files: {
'test/unit/index.js': [ 'test/unit/index.js': [
@ -321,13 +336,6 @@ module.exports = function(grunt) {
src: ['openpgp/openpgp.js', 'openpgp/openpgp.worker.js', 'forge/forge.min.js'], src: ['openpgp/openpgp.js', 'openpgp/openpgp.worker.js', 'forge/forge.min.js'],
dest: 'dist/js/' dest: 'dist/js/'
}, },
tls: {
expand: true,
flatten: true,
cwd: 'node_modules/tcp-socket/src/',
src: ['tcp-socket-tls-worker.js', 'tcp-socket-tls.js'],
dest: 'dist/js/'
},
font: { font: {
expand: true, expand: true,
cwd: 'src/font/', cwd: 'src/font/',

View File

@ -43,7 +43,7 @@
"pgpbuilder": "~0.4.0", "pgpbuilder": "~0.4.0",
"pgpmailer": "~0.4.0", "pgpmailer": "~0.4.0",
"socket.io": "^1.0.6", "socket.io": "^1.0.6",
"tcp-socket": "https://github.com/whiteout-io/tcp-socket/tarball/dev/WO-567", "tcp-socket": "~0.3.13",
"wo-smtpclient": "^0.3.8" "wo-smtpclient": "^0.3.8"
}, },
"devDependencies": { "devDependencies": {

View File

@ -227,7 +227,7 @@ ctrl.onConnect = function(callback) {
credentials.imap.maxUpdateSize = config.imapUpdateBatchSize; credentials.imap.maxUpdateSize = config.imapUpdateBatchSize;
// tls socket worker path for multithreaded tls in non-native tls environments // tls socket worker path for multithreaded tls in non-native tls environments
credentials.imap.tlsWorkerPath = credentials.smtp.tlsWorkerPath = config.workerPath + '/tcp-socket-tls-worker.js'; credentials.imap.tlsWorkerPath = credentials.smtp.tlsWorkerPath = config.workerPath + '/tcp-socket-tls-worker.min.js';
var pgpMailer = new PgpMailer(credentials.smtp, ctrl._pgpbuilder); var pgpMailer = new PgpMailer(credentials.smtp, ctrl._pgpbuilder);
var imapClient = new ImapClient(credentials.imap); var imapClient = new ImapClient(credentials.imap);

View File

@ -30,6 +30,8 @@ var NO_INBOX = ConnectionDoctor.NO_INBOX = 47;
var GENERIC_ERROR = ConnectionDoctor.GENERIC_ERROR = 48; var GENERIC_ERROR = ConnectionDoctor.GENERIC_ERROR = 48;
var WORKER_PATH = cfg.workerPath + '/tcp-socket-tls-worker.min.js';
// //
// Public API // Public API
// //
@ -52,7 +54,7 @@ ConnectionDoctor.prototype.configure = function(credentials) {
secure: this.credentials.imap.secure, secure: this.credentials.imap.secure,
ignoreTLS: this.credentials.imap.ignoreTLS, ignoreTLS: this.credentials.imap.ignoreTLS,
ca: this.credentials.imap.ca, ca: this.credentials.imap.ca,
tlsWorkerPath: cfg.workerPath + '/tcp-socket-tls-worker.js', tlsWorkerPath: WORKER_PATH,
auth: { auth: {
user: this.credentials.username, user: this.credentials.username,
pass: this.credentials.password, pass: this.credentials.password,
@ -64,7 +66,7 @@ ConnectionDoctor.prototype.configure = function(credentials) {
useSecureTransport: this.credentials.smtp.secure, useSecureTransport: this.credentials.smtp.secure,
ignoreTLS: this.credentials.smtp.ignoreTLS, ignoreTLS: this.credentials.smtp.ignoreTLS,
ca: this.credentials.smtp.ca, ca: this.credentials.smtp.ca,
tlsWorkerPath: cfg.workerPath + '/tcp-socket-tls-worker.js', tlsWorkerPath: WORKER_PATH,
auth: { auth: {
user: this.credentials.username, user: this.credentials.username,
pass: this.credentials.password, pass: this.credentials.password,
@ -159,7 +161,7 @@ ConnectionDoctor.prototype._checkReachable = function(options, callback) {
binaryType: 'arraybuffer', binaryType: 'arraybuffer',
useSecureTransport: options.secure, useSecureTransport: options.secure,
ca: options.ca, ca: options.ca,
tlsWorkerPath: cfg.workerPath + '/tcp-socket-tls-worker.js' tlsWorkerPath: WORKER_PATH
}); });
socket.ondata = function() {}; // we don't actually care about the data socket.ondata = function() {}; // we don't actually care about the data

View File

@ -8,7 +8,7 @@ var TCPSocket = require('tcp-socket'),
describe('Connection Doctor', function() { describe('Connection Doctor', function() {
var doctor; var doctor;
var socketStub, imapStub, smtpStub, credentials; var socketStub, imapStub, smtpStub, credentials, workerPath;
beforeEach(function() { beforeEach(function() {
// //
@ -22,6 +22,7 @@ describe('Connection Doctor', function() {
} }
}; };
workerPath = 'js/tcp-socket-tls-worker.min.js';
imapStub = sinon.createStubInstance(ImapClient); imapStub = sinon.createStubInstance(ImapClient);
smtpStub = sinon.createStubInstance(SmtpClient); smtpStub = sinon.createStubInstance(SmtpClient);
@ -84,7 +85,8 @@ describe('Connection Doctor', function() {
expect(TCPSocket.open.calledWith(credentials.imap.host, credentials.imap.port, { expect(TCPSocket.open.calledWith(credentials.imap.host, credentials.imap.port, {
binaryType: 'arraybuffer', binaryType: 'arraybuffer',
useSecureTransport: credentials.imap.secure, useSecureTransport: credentials.imap.secure,
ca: credentials.imap.ca ca: credentials.imap.ca,
tlsWorkerPath: workerPath
})).to.be.true; })).to.be.true;
done(); done();
@ -108,7 +110,8 @@ describe('Connection Doctor', function() {
expect(TCPSocket.open.calledWith(credentials.imap.host, credentials.imap.port, { expect(TCPSocket.open.calledWith(credentials.imap.host, credentials.imap.port, {
binaryType: 'arraybuffer', binaryType: 'arraybuffer',
useSecureTransport: credentials.imap.secure, useSecureTransport: credentials.imap.secure,
ca: credentials.imap.ca ca: credentials.imap.ca,
tlsWorkerPath: workerPath
})).to.be.true; })).to.be.true;
done(); done();
@ -125,7 +128,8 @@ describe('Connection Doctor', function() {
expect(TCPSocket.open.calledWith(credentials.imap.host, credentials.imap.port, { expect(TCPSocket.open.calledWith(credentials.imap.host, credentials.imap.port, {
binaryType: 'arraybuffer', binaryType: 'arraybuffer',
useSecureTransport: credentials.imap.secure, useSecureTransport: credentials.imap.secure,
ca: credentials.imap.ca ca: credentials.imap.ca,
tlsWorkerPath: workerPath
})).to.be.true; })).to.be.true;
done(); done();