* Fix String vs Address when creating (NetMail) packets causing orig address info to not be recorded correctly

This commit is contained in:
Bryan Ashby 2018-01-05 22:02:36 -07:00
parent b97f96ce18
commit f967ce1ce6
3 changed files with 41 additions and 26 deletions

View File

@ -19,15 +19,6 @@ const moment = require('moment');
exports.Packet = Packet;
/*
:TODO: things
* Test SAUCE ignore/extraction
* FSP-1010 for netmail (see SBBS)
* Syncronet apparently uses odd origin lines
* Origin lines starting with "#" instead of "*" ?
*/
const FTN_PACKET_HEADER_SIZE = 58; // fixed header size
const FTN_PACKET_HEADER_TYPE = 2;
const FTN_PACKET_MESSAGE_TYPE = 2;
@ -63,7 +54,7 @@ class PacketHeader {
this.capWord = 0x0001;
this.capWordValidate = ((this.capWord & 0xff) << 8) | ((this.capWord >> 8) & 0xff); // swap
this.prodCodeHi = 0xfe; // see above
this.prodRevHi = 0;
}
@ -358,9 +349,9 @@ function Packet(options) {
buffer.writeUInt16LE(packetHeader.origPoint, 50);
buffer.writeUInt16LE(packetHeader.destPoint, 52);
buffer.writeUInt32LE(packetHeader.prodData, 54);
ws.write(buffer);
return buffer.length;
};
@ -646,9 +637,29 @@ function Packet(options) {
});
});
};
this.sanatizeFtnProperties = function(message) {
[
Message.FtnPropertyNames.FtnOrigNode,
Message.FtnPropertyNames.FtnDestNode,
Message.FtnPropertyNames.FtnOrigNetwork,
Message.FtnPropertyNames.FtnDestNetwork,
Message.FtnPropertyNames.FtnAttrFlags,
Message.FtnPropertyNames.FtnCost,
Message.FtnPropertyNames.FtnOrigZone,
Message.FtnPropertyNames.FtnDestZone,
Message.FtnPropertyNames.FtnOrigPoint,
Message.FtnPropertyNames.FtnDestPoint,
Message.FtnPropertyNames.FtnAttribute,
].forEach( propName => {
if(message.meta.FtnProperty[propName]) {
message.meta.FtnProperty[propName] = parseInt(message.meta.FtnProperty[propName]) || 0;
}
});
};
this.getMessageEntryBuffer = function(message, options, cb) {
function getAppendMeta(k, m, sepChar=':') {
let append = '';
if(m) {
@ -667,7 +678,10 @@ function Packet(options) {
[
function prepareHeaderAndKludges(callback) {
const basicHeader = new Buffer(34);
// ensure address FtnProperties are numbers
self.sanatizeFtnProperties(message);
basicHeader.writeUInt16LE(FTN_PACKET_MESSAGE_TYPE, 0);
basicHeader.writeUInt16LE(message.meta.FtnProperty.ftn_orig_node, 2);
basicHeader.writeUInt16LE(message.meta.FtnProperty.ftn_dest_node, 4);

View File

@ -189,7 +189,7 @@ function getQuotePrefix(name) {
//
function getOrigin(address) {
const origin = _.has(Config, 'messageNetworks.originLine') ?
Config.messageNetworks.originLine :
Config.messageNetworks.originLine :
Config.general.boardName;
const addrStr = new Address(address).toString('5D');

View File

@ -308,16 +308,18 @@ function FTNMessageScanTossModule() {
//
// Set various FTN kludges/etc.
//
const localAddress = new Address(options.network.localAddress); // ensure we have an Address obj not a string version
message.meta.FtnProperty = message.meta.FtnProperty || {};
message.meta.FtnKludge = message.meta.FtnKludge || {};
message.meta.FtnProperty.ftn_orig_node = options.network.localAddress.node;
message.meta.FtnProperty.ftn_orig_network = options.network.localAddress.net;
message.meta.FtnProperty.ftn_orig_node = localAddress.node;
message.meta.FtnProperty.ftn_orig_network = localAddress.net;
message.meta.FtnProperty.ftn_cost = 0;
// tear line and origin can both go in EchoMail & NetMail
message.meta.FtnProperty.ftn_tear_line = ftnUtil.getTearLine();
message.meta.FtnProperty.ftn_origin = ftnUtil.getOrigin(options.network.localAddress);
message.meta.FtnProperty.ftn_origin = ftnUtil.getOrigin(localAddress);
let ftnAttribute = ftnMailPacket.Packet.Attribute.Local; // message from our system
@ -345,10 +347,10 @@ function FTNMessageScanTossModule() {
// We need to set INTL, and possibly FMPT and/or TOPT
// See http://retro.fidoweb.ru/docs/index=ftsc&doc=FTS-4001&enc=mac
//
message.meta.FtnKludge.INTL = ftnUtil.getIntl(options.destAddress, options.network.localAddress);
message.meta.FtnKludge.INTL = ftnUtil.getIntl(options.destAddress, localAddress);
if(_.isNumber(options.network.localAddress.point) && options.network.localAddress.point > 0) {
message.meta.FtnKludge.FMPT = options.network.localAddress.point;
if(_.isNumber(localAddress.point) && localAddress.point > 0) {
message.meta.FtnKludge.FMPT = localAddress.point;
}
if(_.get(message, 'meta.FtnProperty.ftn_dest_point', 0) > 0) {
@ -378,15 +380,14 @@ function FTNMessageScanTossModule() {
// with remote address(s) we are exporting to.
//
const seenByAdditions =
[ `${options.network.localAddress.net}/${options.network.localAddress.node}` ].concat(Config.messageNetworks.ftn.areas[message.areaTag].uplinks);
[ `${localAddress.net}/${localAddress.node}` ].concat(Config.messageNetworks.ftn.areas[message.areaTag].uplinks);
message.meta.FtnProperty.ftn_seen_by =
ftnUtil.getUpdatedSeenByEntries(message.meta.FtnProperty.ftn_seen_by, seenByAdditions);
//
// And create/update PATH for ourself
//
message.meta.FtnKludge.PATH =
ftnUtil.getUpdatedPathEntries(message.meta.FtnKludge.PATH, options.network.localAddress);
message.meta.FtnKludge.PATH = ftnUtil.getUpdatedPathEntries(message.meta.FtnKludge.PATH, localAddress);
}
message.meta.FtnProperty.ftn_attr_flags = ftnAttribute;
@ -398,7 +399,7 @@ function FTNMessageScanTossModule() {
// export that failed to finish
//
if(!message.meta.FtnKludge.MSGID) {
message.meta.FtnKludge.MSGID = ftnUtil.getMessageIdentifier(message, options.network.localAddress);
message.meta.FtnKludge.MSGID = ftnUtil.getMessageIdentifier(message, localAddress);
}
message.meta.FtnKludge.TZUTC = ftnUtil.getUTCTimeZoneOffset();