git ssb

4+

Dominic / scuttlebot



Commit 78f95a6d1fe17f7747c2076c9ca3c86762b5e7f5

Merge branch 'master' into @cel/master

cel committed on 3/6/2017, 5:18:07 AM
Parent: c2147befb1738521c99a292e22e9fc7496e7e61f
Parent: 2df2c99636d2696c17aecdfff99b2f9b184d4c40

Files changed

.travis.ymlchanged
package.jsonchanged
plugins/gossip.mdchanged
plugins/gossip/index.jschanged
plugins/local.jschanged
.travis.ymlView
@@ -1,4 +1,4 @@
11 language: node_js
22 sudo: false
33 node_js:
4- - 'iojs-v2.5.0'
4 + - '6.9.5'
package.jsonView
@@ -1,8 +1,8 @@
11 {
22 "name": "scuttlebot",
33 "description": "network protocol layer for secure-scuttlebutt",
4- "version": "9.4.3",
4 + "version": "9.4.4",
55 "homepage": "https://github.com/ssbc/scuttlebot",
66 "repository": {
77 "type": "git",
88 "url": "git://github.com/ssbc/scuttlebot.git"
plugins/gossip.mdView
@@ -36,8 +36,22 @@
3636 - `host` (host string): IP address or hostname.
3737 - `port` (port number)
3838 - `key` (feedid)
3939
40 +## remove: sync
41 +
42 +Remove an address from the peer table.
43 +
44 +```bash
45 +remove {addr}
46 +remove --host {string} --port {number} --key {feedid}
47 +```
48 +
49 +```js
50 +remove(addr)
51 +remove({ host:, port:, key: })
52 +```
53 +
4054 ## ping: duplex
4155
4256 used internally by the gossip plugin to measure latency and clock skew
4357
plugins/gossip/index.jsView
@@ -150,8 +150,15 @@
150150 f.announcers ++
151151
152152 return f
153153 }, 'string|object', 'string?'),
154 + remove: function (addr) {
155 + var peer = gossip.get(addr)
156 + var index = peers.indexOf(peer)
157 + if (~index) {
158 + peers.splice(index, 1)
159 + }
160 + },
154161 ping: function (opts) {
155162 var timeout = config.timers && config.timers.ping || 5*60e3
156163 //between 10 seconds and 30 minutes, default 5 min
157164 timeout = Math.max(10e3, Math.min(timeout, 30*60e3))
@@ -256,5 +263,4 @@
256263
257264 return gossip
258265 }
259266 }
260-
plugins/local.jsView
@@ -13,18 +13,35 @@
1313 version: '2.0.0',
1414 init: function (sbot, config) {
1515
1616 var local = broadcast(config.port)
17 + var addrs = {}
18 + var lastSeen = {}
1719
20 + // cleanup old local peers
21 + setInterval(function () {
22 + Object.keys(lastSeen).forEach((key) => {
23 + if (Date.now() - lastSeen[key] > 10e3) {
24 + sbot.gossip.remove(addrs[key])
25 + delete lastSeen[key]
26 + }
27 + })
28 + }, 5e3)
29 +
30 + // discover new local peers
1831 local.on('data', function (buf) {
19- if(buf.loopback) return
32 + if (buf.loopback) return
2033 var data = buf.toString()
21- if(ref.parseAddress(data))
34 + var peer = ref.parseAddress(data)
35 + if (peer && peer.key !== sbot.id) {
36 + addrs[peer.key] = peer
37 + lastSeen[peer.key] = Date.now()
2238 sbot.gossip.add(data, 'local')
39 + }
2340 })
2441
42 + // broadcast self
2543 setInterval(function () {
26- // broadcast self
2744 // TODO: sign beacons, so that receipient can be confidant
2845 // that is really your id.
2946 // (which means they can update their peer table)
3047 // Oh if this includes your local address,
@@ -32,7 +49,4 @@
3249 local.write(sbot.getAddress())
3350 }, 1000)
3451 }
3552 }
36-
37-
38-

Built with git-ssb-web