Commit 9bb0ecd32e5c2bad9cbcfe6afef1f95f5f57dcd8
remove sbot.local override
ssbc/scuttlebot#373 will replace the need for thisMatt McKegg committed on 2/15/2017, 12:15:25 PM
Parent: 856d88afbef69775a9d80aca2652a45f598a0163
Files changed
lib/local-with-list.js | deleted |
server-process.js | changed |
lib/local-with-list.js | ||
---|---|---|
@@ -1,66 +1,0 @@ | ||
1 | -// FROM: https://github.com/ssbc/scuttlebot/blob/master/plugins/local.js | |
2 | - | |
3 | -var broadcast = require('broadcast-stream') | |
4 | -var ref = require('ssb-ref') | |
5 | -var valid = require('scuttlebot/lib/validators') | |
6 | - | |
7 | -// local plugin | |
8 | -// broadcasts the address:port:pubkey triple of the sbot server | |
9 | -// on the LAN, using multicast UDP | |
10 | - | |
11 | -function isFunction (f) { | |
12 | - return 'function' === typeof f | |
13 | -} | |
14 | - | |
15 | -module.exports = { | |
16 | - name: 'local', | |
17 | - version: '2.0.0', | |
18 | - manifest: { | |
19 | - list: 'sync' | |
20 | - }, | |
21 | - init: function (sbot, config) { | |
22 | - var local = broadcast(config.port) | |
23 | - var lastSeen = {} | |
24 | - var addrs = {} | |
25 | - var localKeys = new Set() | |
26 | - | |
27 | - setInterval(function () { | |
28 | - Object.keys(lastSeen).forEach((key) => { | |
29 | - if (Date.now() - lastSeen[key] < 10e3) { | |
30 | - localKeys.add(key) | |
31 | - } else { | |
32 | - localKeys.delete(key) | |
33 | - sbot.gossip.delete(addrs[key]) | |
34 | - delete lastSeen[key] | |
35 | - } | |
36 | - }) | |
37 | - }, 5e3) | |
38 | - | |
39 | - local.on('data', function (buf) { | |
40 | - if (buf.loopback) return | |
41 | - var data = buf.toString() | |
42 | - var peer = ref.parseAddress(data) | |
43 | - if (peer && peer.key !== sbot.id) { | |
44 | - addrs[peer.key] = peer | |
45 | - lastSeen[peer.key] = Date.now() | |
46 | - sbot.gossip.add(data, 'local') | |
47 | - } | |
48 | - }) | |
49 | - | |
50 | - setInterval(function () { | |
51 | - // broadcast self | |
52 | - // TODO: sign beacons, so that receipient can be confidant | |
53 | - // that is really your id. | |
54 | - // (which means they can update their peer table) | |
55 | - // Oh if this includes your local address, | |
56 | - // then it becomes unforgeable. | |
57 | - local.write(sbot.getAddress()) | |
58 | - }, 1000) | |
59 | - | |
60 | - return { | |
61 | - list: valid.sync(function () { | |
62 | - return Array.from(localKeys) | |
63 | - }) | |
64 | - } | |
65 | - } | |
66 | -} |
server-process.js | ||
---|---|---|
@@ -4,15 +4,15 @@ | ||
4 | 4 … | var electron = require('electron') |
5 | 5 … | |
6 | 6 … | var createSbot = require('scuttlebot') |
7 | 7 … | .use(require('scuttlebot/plugins/master')) |
8 | - .use(require('scuttlebot/plugins/gossip')) // override | |
8 … | + .use(require('scuttlebot/plugins/gossip')) | |
9 | 9 … | .use(require('scuttlebot/plugins/friends')) |
10 | 10 … | .use(require('scuttlebot/plugins/replicate')) |
11 | 11 … | .use(require('ssb-blobs')) |
12 | 12 … | .use(require('scuttlebot/plugins/invite')) |
13 | 13 … | .use(require('scuttlebot/plugins/block')) |
14 | - .use(require('./lib/local-with-list')) | |
14 … | + .use(require('scuttlebot/plugins/local')) | |
15 | 15 … | .use(require('scuttlebot/plugins/logging')) |
16 | 16 … | .use(require('scuttlebot/plugins/private')) |
17 | 17 … | .use(require('ssb-links')) |
18 | 18 … | .use(require('ssb-query')) |
Built with git-ssb-web