git ssb

4+

Dominic / scuttlebot



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.jschanged
plugins/local.jschanged
plugins/gossip/index.jsView
@@ -206,8 +206,10 @@
206206 },
207207 enable: valid.sync(function (type) {
208208 type = type || 'global'
209209 setConfig(type, true)
210 + if(type === 'local' && server.local && server.local.init)
211 + server.local.init()
210212 return 'enabled gossip type ' + type
211213 }, 'string?'),
212214 disable: valid.sync(function (type) {
213215 type = type || 'global'
plugins/local.jsView
@@ -10,11 +10,16 @@
1010
1111 module.exports = {
1212 name: 'local',
1313 version: '2.0.0',
14- init: function (sbot, config) {
14 + init: function init (sbot, config) {
1515 if(config.gossip && config.gossip.local === false)
16- return
16 + return {
17 + init: function () {
18 + delete this.init
19 + init(sbot, config)
20 + }
21 + }
1722
1823 var local = broadcast(config.port)
1924 var addrs = {}
2025 var lastSeen = {}
@@ -42,8 +47,10 @@
4247 })
4348
4449 // broadcast self
4550 setInterval(function () {
51 + if(config.gossip && config.gossip.local === false)
52 + return
4653 // TODO: sign beacons, so that receipient can be confidant
4754 // that is really your id.
4855 // (which means they can update their peer table)
4956 // Oh if this includes your local address,

Built with git-ssb-web