Skip to content

Commit

Permalink
Setup Interfaces Serially
Browse files Browse the repository at this point in the history
Fix #1
added promiseSerial - self explanitory.
setupInterfaces now returns a promise returned from promiseSerial.
  • Loading branch information
Dustyn Blackmore committed Apr 18, 2018
1 parent 0579475 commit 1e5c52d
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,19 +68,29 @@ function getInterfaces (path) {
: [];
}

const promiseSerial = funcs =>
funcs.reduce((promise, func) =>
promise.then(result =>
func().then(Array.prototype.concat.bind(result))),
Promise.resolve([]))

function setupInterfaces () {
let interfacePromises = [];
let outInterfaces = getInterfaces(sysClassNetInterfaces);


getInterfaces(sysClassNetInterfaces).forEach(interface => {
let zone = 'untrusted'
if (systemInterfaces[interface] && systemInterfaces[interface].zone)
{
zone = systemInterfaces[interface].zone || 'untrusted';
}
let newInterface = { name: interface, number: interfaces.length + 1, zone };
interfacePromises.push(insertInterfaceRules(newInterface))
interfacePromises.push(() => insertInterfaceRules(newInterface))
interfaces.push(newInterface);
});
return Promise.all(interfacePromises);

return promiseSerial(interfacePromises)
};

function determineVerdict (interface, packet, direction) {
Expand Down

0 comments on commit 1e5c52d

Please sign in to comment.