Commit 7975a4e61e24ba1ff579ecd2d276b1fc5a4514f6
Allow local peer discovery to be enabled/disabled after load
- When enabling local gossip, init the local plugin if it did not already init. - Toggle UDP broadcast when local gossip is toggled. - As before, don't create the broadcast-stream unless it is needed, to support users who have local gossip disabled because broadcast-stream was giving them an error.cel committed on 6/24/2017, 2:51:46 AM
Parent: 76f008cfd38b579165c932d29dee723af72c9274
Files changed
plugins/gossip/index.js | changed |
plugins/local.js | changed |
plugins/gossip/index.js | ||
---|---|---|
@@ -206,8 +206,10 @@ | ||
206 | 206 … | }, |
207 | 207 … | enable: valid.sync(function (type) { |
208 | 208 … | type = type || 'global' |
209 | 209 … | setConfig(type, true) |
210 … | + if(type === 'local' && server.local && server.local.init) | |
211 … | + server.local.init() | |
210 | 212 … | return 'enabled gossip type ' + type |
211 | 213 … | }, 'string?'), |
212 | 214 … | disable: valid.sync(function (type) { |
213 | 215 … | type = type || 'global' |
plugins/local.js | ||
---|---|---|
@@ -10,11 +10,16 @@ | ||
10 | 10 … | |
11 | 11 … | module.exports = { |
12 | 12 … | name: 'local', |
13 | 13 … | version: '2.0.0', |
14 | - init: function (sbot, config) { | |
14 … | + init: function init (sbot, config) { | |
15 | 15 … | if(config.gossip && config.gossip.local === false) |
16 | - return | |
16 … | + return { | |
17 … | + init: function () { | |
18 … | + delete this.init | |
19 … | + init(sbot, config) | |
20 … | + } | |
21 … | + } | |
17 | 22 … | |
18 | 23 … | var local = broadcast(config.port) |
19 | 24 … | var addrs = {} |
20 | 25 … | var lastSeen = {} |
@@ -42,8 +47,10 @@ | ||
42 | 47 … | }) |
43 | 48 … | |
44 | 49 … | // broadcast self |
45 | 50 … | setInterval(function () { |
51 … | + if(config.gossip && config.gossip.local === false) | |
52 … | + return | |
46 | 53 … | // TODO: sign beacons, so that receipient can be confidant |
47 | 54 … | // that is really your id. |
48 | 55 … | // (which means they can update their peer table) |
49 | 56 … | // Oh if this includes your local address, |
Built with git-ssb-web