mirror of
https://github.com/nodemailer/wildduck.git
synced 2025-09-13 00:24:49 +08:00
log POP3 RETR commands
This commit is contained in:
parent
70a62a35b8
commit
2f848a232d
3 changed files with 31 additions and 0 deletions
|
@ -233,6 +233,7 @@ class FilterHandler {
|
|||
let from = parsedHeader.from || parsedHeader.sender;
|
||||
from = [].concat(from || []);
|
||||
tools.decodeAddresses(from);
|
||||
from = tools.flatAddresses(from);
|
||||
|
||||
if (from && from.length) {
|
||||
from = from[0];
|
||||
|
|
|
@ -479,6 +479,8 @@ class POP3Connection extends EventEmitter {
|
|||
short_message: '[POP3DELETE]',
|
||||
_mail_action: 'pop3_delete',
|
||||
_message_id: message.id,
|
||||
_message_uid: message.uid,
|
||||
_mailbox: message.mailbox,
|
||||
_username: this.session.user && this.session.user.username,
|
||||
_user: this.session.user && this.session.user.id,
|
||||
_sess: this.id,
|
||||
|
@ -698,6 +700,20 @@ class POP3Connection extends EventEmitter {
|
|||
stream.once('end', () => {
|
||||
// this.send('.'); // final dot is sent by DataStream
|
||||
message.fetched = true;
|
||||
|
||||
this._server.loggelf({
|
||||
short_message: '[POP3RETR]',
|
||||
_mail_action: 'pop3_retr',
|
||||
_message_id: message.id,
|
||||
_message_uid: message.uid,
|
||||
_mailbox: message.mailbox,
|
||||
_message_size: message.size,
|
||||
_username: this.session.user && this.session.user.username,
|
||||
_user: this.session.user && this.session.user.id,
|
||||
_sess: this.id,
|
||||
_ip: this.remoteAddress
|
||||
});
|
||||
|
||||
return next();
|
||||
});
|
||||
|
||||
|
|
14
lib/tools.js
14
lib/tools.js
|
@ -151,6 +151,19 @@ function decodeAddresses(addresses) {
|
|||
});
|
||||
}
|
||||
|
||||
function flatAddresses(addresses) {
|
||||
let list = [];
|
||||
let walk = address => {
|
||||
if (address.address) {
|
||||
list.push(address);
|
||||
} else if (address.group) {
|
||||
address.group.forEach(walk);
|
||||
}
|
||||
};
|
||||
walk(addresses);
|
||||
return list;
|
||||
}
|
||||
|
||||
function getMailboxCounter(db, mailbox, type, done) {
|
||||
let prefix = type ? type : 'total';
|
||||
db.redis.get(prefix + ':' + mailbox.toString(), (err, sum) => {
|
||||
|
@ -462,6 +475,7 @@ module.exports = {
|
|||
redisConfig,
|
||||
checkRangeQuery,
|
||||
decodeAddresses,
|
||||
flatAddresses,
|
||||
getMailboxCounter,
|
||||
getEmailTemplates,
|
||||
getRelayData,
|
||||
|
|
Loading…
Add table
Reference in a new issue