2015-07-16 05:51:00 +00:00
|
|
|
/* jslint node: true */
|
|
|
|
'use strict';
|
|
|
|
|
|
|
|
var events = require('events');
|
|
|
|
var assert = require('assert');
|
|
|
|
var _ = require('lodash');
|
|
|
|
|
|
|
|
module.exports = MailPacket;
|
|
|
|
|
|
|
|
function MailPacket(options) {
|
2018-06-22 05:15:04 +00:00
|
|
|
events.EventEmitter.call(this);
|
2015-07-16 05:51:00 +00:00
|
|
|
|
2018-06-22 05:15:04 +00:00
|
|
|
// map of network name -> address obj ( { zone, net, node, point, domain } )
|
|
|
|
this.nodeAddresses = options.nodeAddresses || {};
|
2015-07-16 05:51:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
require('util').inherits(MailPacket, events.EventEmitter);
|
|
|
|
|
|
|
|
MailPacket.prototype.read = function(options) {
|
2018-06-22 05:15:04 +00:00
|
|
|
//
|
|
|
|
// options.packetPath | opts.packetBuffer: supplies a path-to-file
|
|
|
|
// or a buffer containing packet data
|
|
|
|
//
|
|
|
|
// emits 'message' event per message read
|
|
|
|
//
|
|
|
|
assert(_.isString(options.packetPath) || Buffer.isBuffer(options.packetBuffer));
|
2015-07-16 05:51:00 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
MailPacket.prototype.write = function(options) {
|
2018-06-22 05:15:04 +00:00
|
|
|
//
|
|
|
|
// options.messages[]: array of message(s) to create packets from
|
|
|
|
//
|
|
|
|
// emits 'packet' event per packet constructed
|
|
|
|
//
|
|
|
|
assert(_.isArray(options.messages));
|
2018-01-15 19:22:11 +00:00
|
|
|
};
|