From 5c324788fe7ac54d4237d3ca5f85b39003d72d35 Mon Sep 17 00:00:00 2001 From: Bryan Ashby Date: Tue, 1 Mar 2016 22:42:29 -0700 Subject: [PATCH] * Minor work on FTN/BSO import * Minor work on message network docs --- core/config.js | 2 + core/scanner_tossers/ftn_bso.js | 26 +++++++- docs/msg_networks.md | 105 ++++++++++++++++++++++++++++++++ 3 files changed, 130 insertions(+), 3 deletions(-) create mode 100644 docs/msg_networks.md diff --git a/core/config.js b/core/config.js index c0749e10..33a55d09 100644 --- a/core/config.js +++ b/core/config.js @@ -245,6 +245,8 @@ function getDefaultConfig() { outbound : paths.join(__dirname, './../mail/ftn_out/'), inbound : paths.join(__dirname, './../mail/ftn_in/'), secInbound : paths.join(__dirname, './../mail/ftn_secin/'), + + // :TODO: use general temp path - system temp by default...or just always system temp? temp : paths.join(__dirname, './../mail/ftn_temp'), }, diff --git a/core/scanner_tossers/ftn_bso.js b/core/scanner_tossers/ftn_bso.js index 9399b6d0..b6dcbc28 100644 --- a/core/scanner_tossers/ftn_bso.js +++ b/core/scanner_tossers/ftn_bso.js @@ -588,6 +588,10 @@ function FTNMessageScanTossModule() { }, cb); // complete }; + this.importMessagesFromPacketFile = function(path, packetFileName, cb) { + cb(null); + }; + this.importMessagesFromDirectory = function(importDir, cb) { async.waterfall( [ @@ -611,11 +615,27 @@ function FTNMessageScanTossModule() { }); } }, (err, identifiedFiles) => { - callback(err, identifiedFiles); + if(err) { + return callback(err); + } + + const fileGroups = _.partition(identifiedFiles, entry => 'packet' === entry.type); + callback(null, fileGroups[0], fileGroups[1]); }); }, - function importPacketFiles(identifiedFiles, callback) { - + function importPacketFiles(packetFiles, bundleFiles, callback) { + async.each(packetFiles, (packetFile, nextFile) => { + self.importMessagesFromPacketFile(importDir, packetFile.file, err => { + // :TODO: check err! + nextFile(); + }); + }, err => { + // :TODO: Handle err! we should try to keep going though... + callback(null, bundleFiles); + }); + }, + function importBundles(bundleFiles, callback) { + // :TODO: for each bundle, extract to temp location -> process each packet } ], err => { diff --git a/docs/msg_networks.md b/docs/msg_networks.md new file mode 100644 index 00000000..17611f0e --- /dev/null +++ b/docs/msg_networks.md @@ -0,0 +1,105 @@ +# Message Networks +Message networks are configured in `messageNetworks` section of `config.hjson`. Each network type has it's own sub section such as `ftn` for FidoNet Technology Network (FTN) style networks. + +## FidoNet Technology Network (FTN) +FTN networks are configured under the `messageNetworks::ftn` section of `config.hjson`. + +### Networks +The `networks` section contains a sub section for network(s) you wish you join your board with. Each entry's key name can be referenced elsewhere in `config.hjson` for FTN oriented configurations. + +Members: + * `localAddress` (required): FTN address of **your local system** + +Example: +```hjson +{ + networks: { + agoranet: { + localAddress: "46:3/102" + } + } +} +``` + +### Areas +The `areas` section defines a mapping of local **area tags** to a message network (from `networks` described previously), a FTN area tag, and remote uplink address(s). This section can be thought of similar to the *AREAS.BBS* file used by other BBS packages. + +Members: + * `network` (required): Associated network from the `networks` section + * `tag` (required): FTN area tag + * `uplinks`: An array of FTN address uplink(s) for this network + +Example: +```hjson +{ + ftn: { + areas: { + agoranet_bbs: { + network: agoranet + tag: AGN_BBS + uplinks: "46:1/100" + } + } + } +} +``` + +### BSO Import / Export +The scanner/tosser module `ftn_bso` provides **B**inkley **S**tyle **O**utbound (BSO) import/toss & scan/export of messages EchoMail and NetMail messages. Configuration is supplied in `config.hjson` under `scannerTossers::ftn_bso`. + +Members: + * `defaultZone` (required): Sets the default BSO outbound zone + * `defaultNetwork` (optional): Sets the default network name from `messageNetworks::ftn::networks`. **Required if more than one network is defined**. + * `paths` (optional): Override default paths set by the system. This section may contain `outbound`, `inbound`, and `secInbound`. + * `packetTargetByteSize` (optional): Overrides the system *target* packet (.pkt) size of 512000 bytes (512k) + * `bundleTargetByteSize` (optional): Overrides the system *target* ArcMail bundle size of 2048000 bytes (2M) + * `schedule` (required): See Scheduling + * `nodes` (required): See Nodes + +#### Nodes +The `nodes` section defines how to export messages for one or more uplinks. + +A node entry starts with a FTN style address (up to 5D) **as a key** in `config.hjson`. This key may contain wildcard(s) for net/zone/node/point/domain. + +Members: + * `packetType` (optional): `2`, `2.2`, or `2+`. Defaults to `2+` for modern mailer compatiability + * `packetPassword` (optional): Password for the packet + * `encoding` (optional): Encoding to use for message bodies; Defaults to `utf-8` + * `archiveType` (optional): Specifies the archive type for ArcMail bundles. Must be a valid archiver name such as `zip` (See archiver configuration) + +Example: +```hjson +{ + ftn_bso: { + nodes: { + "46:*: { + packetType: 2+ + packetPassword: mypass + encoding: cp437 + archiveType: zip + } + } + } +} +``` + +#### Scheduling +Schedules can be defined for importing and exporting via `import` and `export` under `schedule`. Each entry is allowed a "free form" text and/or special indicators for immediate export or watch file triggers. + + * `@immediate`: Currently only makes sense for exporting: A message will be immediately exported if this trigger is defined in a schedule. + * `@watch:/path/to/file`: This trigger watches the path specified for changes and will trigger an import or export when such events occur. + * Free form text can be things like `at 5:00 pm` or `every 2 hours`. + +See [Later text parsing documentation](http://bunkat.github.io/later/parsers.html#text) for more information. + +Example: +```hjson +{ + ftn_bso: { + schedule: { + import: every 1 hours or @watch:/path/to/watchfile.ext + export: every 1 hours or @immediate + } + } +} +``` \ No newline at end of file