git ssb

0+

alanz / patchwork



forked from Matt McKegg / patchwork

Tree: 13be5ee9906beb5d8c2a24db46c68ef183c78d3a

Files: 13be5ee9906beb5d8c2a24db46c68ef183c78d3a / modules / obs-local.js

726 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 console.log(peer)
21 result.add(peer.key)
22 }
23 })
24 })
25 }, 5000)
26
27 cache = result
28 return result
29 }
30}
31

Built with git-ssb-web