Skip to content

Commit

Permalink
Filter out blacklisted devices
Browse files Browse the repository at this point in the history
  • Loading branch information
simov committed May 16, 2018
1 parent 1f94d48 commit c07c13d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
1 change: 1 addition & 0 deletions bin/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ async function run ({devices, users, active}) {
}

var active = online.format({users, devices, active})
active.unknown = online.blacklist({devices: active.unknown, blacklist})
fs.writeFileSync(fpath.online, JSON.stringify(online.filter(active)), 'utf8')

}
3 changes: 3 additions & 0 deletions lib/online.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ exports.format = ({users, devices, active}) => {
}
}

exports.blacklist = ({devices, blacklist}) =>
devices.filter(({id}) => !blacklist.includes(id))

exports.filter = ({known, unknown}) => ({
known: known.map((user) => user.id),
unknown: unknown.map(({id, host, vendor}) => ({id, host, vendor}))
Expand Down

0 comments on commit c07c13d

Please sign in to comment.