git ssb

10+

Matt McKegg / patchwork



Tree: b6089670d854fcefa6bc5ca05636a801707deb30

Files: b6089670d854fcefa6bc5ca05636a801707deb30 / modules / obs-local.js

696 bytesRaw
1var MutantSet = require('@mmckegg/mutant/set')
2var plugs = require('patchbay/plugs')
3var sbot_gossip_peers = plugs.first(exports.sbot_gossip_peers = [])
4var ip = require('ip')
5
6var cache = null
7
8exports.obs_local = function () {
9 if (cache) {
10 return cache
11 } else {
12 var result = MutantSet([], {nextTick: true})
13 // todo: make this clean up on unlisten
14
15 setTimeout(() => {
16 sbot_gossip_peers((err, peers) => {
17 if (err) throw console.log(err)
18 peers.filter((peer) => {
19 if (ip.isPrivate(peer.host) && (peer.source === 'local')) {
20 result.add(peer.key)
21 }
22 })
23 })
24 }, 5000)
25
26 cache = result
27 return result
28 }
29}
30

Built with git-ssb-web