mirror of
https://github.com/nodemailer/wildduck.git
synced 2025-09-08 06:04:42 +08:00
Suppress ETIMEDOUT errors
This commit is contained in:
parent
a531356424
commit
670fd379e3
1 changed files with 18 additions and 0 deletions
|
@ -7,6 +7,7 @@ const tlsOptions = require('../../imap-core/lib/tls-options');
|
|||
const shared = require('nodemailer/lib/shared');
|
||||
const POP3Connection = require('./connection');
|
||||
const punycode = require('punycode');
|
||||
const errors = require('../errors');
|
||||
|
||||
const CLOSE_TIMEOUT = 1 * 1000; // how much to wait until pending connections are terminated
|
||||
|
||||
|
@ -63,12 +64,28 @@ class POP3Server extends EventEmitter {
|
|||
SNICallback: this.options.SNICallback
|
||||
};
|
||||
|
||||
let remoteAddress = socket.remoteAddress;
|
||||
|
||||
let returned = false;
|
||||
let onError = err => {
|
||||
if (returned) {
|
||||
return;
|
||||
}
|
||||
returned = true;
|
||||
if (err && /SSL23_GET_CLIENT_HELLO/.test(err.message)) {
|
||||
let message = err.message;
|
||||
err.message = 'Failed to establish TLS session on connection to ' + remoteAddress;
|
||||
err.meta = {
|
||||
message,
|
||||
remoteAddress
|
||||
};
|
||||
}
|
||||
if (!err) {
|
||||
err = new Error('Socket closed unexpectedly to ' + remoteAddress);
|
||||
err.meta = {
|
||||
remoteAddress
|
||||
};
|
||||
}
|
||||
callback(err || new Error('Socket closed unexpectedly'));
|
||||
};
|
||||
|
||||
|
@ -200,6 +217,7 @@ class POP3Server extends EventEmitter {
|
|||
* @event
|
||||
*/
|
||||
_onError(err) {
|
||||
errors.notifyConnection(false, err);
|
||||
this.emit('error', err);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue