git ssb

2+

ev / mvd



Commit 2ab67531b8a5ecdd7419f3c8d9fa0ccee8cb9377

revert to scuttlebot@11.4.3 LTS

Ev Bogue committed on 2/3/2019, 5:36:02 PM
Parent: 863e8a538677038443dd0724e2e80cf71c5b62a0

Files changed

bin.jschanged
config.jschanged
config/inject.jschanged
package-lock.jsonchanged
package.jsonchanged
query/index.jsadded
bin.jsView
@@ -1,106 +1,76 @@
1-#! /usr/bin/env node
2-
3-var fs = require('fs')
4-var path = require('path')
5-var pull = require('pull-stream')
6-var toPull = require('stream-to-pull-stream')
7-var File = require('pull-file')
8-var explain = require('explain-error')
9-var ssbKeys = require('ssb-keys')
10-var stringify = require('pull-stringify')
11-var createHash = require('multiblob/util').createHash
12-var minimist = require('minimist')
13-var muxrpcli = require('muxrpcli')
14-var cmdAliases = require('scuttlebot/lib/cli-cmd-aliases')
15-var ProgressBar = require('scuttlebot/lib/progress')
16-var packageJson = require('scuttlebot/package.json')
1 +var fs = require('fs')
2 +var path = require('path')
3 +var ssbKeys = require('ssb-keys')
4 +var stringify = require('pull-stringify')
175 var open = require('opn')
6 +var home = require('os-homedir')()
7 +var nonPrivate = require('non-private-ip')
8 +var muxrpcli = require('muxrpcli')
189
19-//get config as cli options after --, options before that are
20-//options to the command.
21-var argv = process.argv.slice(2)
22-var i = argv.indexOf('--')
23-var conf = argv.slice(i+1)
24-argv = ~i ? argv.slice(0, i) : argv
10 +var SEC = 1e3
11 +var MIN = 60*SEC
2512
26-var config = require('./config/inject')(process.env.ssb_appname, minimist(conf))
13 +var network = 'ssb'
14 +//var network = 'decent'
15 +//var network = 'testnet'
2716
28-var keys = ssbKeys.loadOrCreateSync(path.join(config.path, 'secret'))
29-if(keys.curve === 'k256')
30- throw new Error('k256 curves are no longer supported,'+
31- 'please delete' + path.join(config.path, 'secret'))
17 +var config = require('./config/inject')(network)
3218
33-var compiledClient = fs.readFileSync(path.join('./build/index.html'))
19 +config.keys = ssbKeys.loadOrCreateSync(path.join(config.path, 'secret'))
3420
21 +var mvdClient = fs.readFileSync(path.join('./build/index.html'))
22 +
3523 var manifestFile = path.join(config.path, 'manifest.json')
3624
25 +var argv = process.argv.slice(2)
26 +var i = argv.indexOf('--')
27 +var conf = argv.slice(i+1)
28 +argv = ~i ? argv.slice(0, i) : argv
29 +
3730 if (argv[0] == 'server') {
38- console.log(packageJson.name, packageJson.version, config.path, 'logging.level:'+config.logging.level)
39- console.log('my key ID:', keys.public)
40-
41- // special server command:
42- // import sbot and start the server
43-
44- var createSbot = require('scuttlebot')
45- .use(require('scuttlebot/plugins/unix-socket'))
46- .use(require('scuttlebot/plugins/no-auth'))
47- .use(require('scuttlebot/plugins/plugins'))
48- .use(require('scuttlebot/plugins/master'))
49- .use(require('scuttlebot/plugins/gossip'))
50- .use(require('scuttlebot/plugins/replicate'))
31 +
32 + var createSbot = require('scuttlebot-release/node_modules/scuttlebot')
33 + .use(require('scuttlebot-release/node_modules/scuttlebot/plugins/master'))
34 + .use(require('scuttlebot-release/node_modules/scuttlebot/plugins/gossip'))
35 + .use(require('scuttlebot-release/node_modules/scuttlebot/plugins/replicate'))
5136 .use(require('ssb-friends'))
5237 .use(require('ssb-blobs'))
53- .use(require('scuttlebot/plugins/invite'))
54- .use(require('scuttlebot/plugins/local'))
55- .use(require('scuttlebot/plugins/logging'))
56- .use(require('ssb-query'))
5738 .use(require('ssb-backlinks'))
39 + .use(require('./query'))
40 + .use(require('ssb-links'))
41 + .use(require('ssb-ebt'))
5842 .use(require('ssb-search'))
59- .use(require('./mvd-indexes'))
60- .use(require('ssb-links'))
43 + .use(require('scuttlebot-release/node_modules/scuttlebot/plugins/invite'))
44 + .use(require('scuttlebot-release/node_modules/scuttlebot/plugins/local'))
6145 .use(require('decent-ws'))
62- .use(require('ssb-ebt'))
6346 .use({
6447 name: 'serve',
6548 version: '1.0.0',
6649 init: function (sbot) {
6750 sbot.ws.use(function (req, res, next) {
6851 var send = config
69- delete send.keys
70- /*sbot.invite.create(1, function (err, cb) {
52 + delete send.keys // very important to keep this, as it removes the server keys from the config before broadcast
53 + send.address = sbot.ws.getAddress()
54 + sbot.invite.create({modern: true}, function (err, cb) {
7155 send.invite = cb
72- })*/
73- send.address = sbot.getAddress()
56 + })
7457 if(req.url == '/')
75- res.end(compiledClient)
58 + res.end(mvdClient)
7659 if(req.url == '/get-config')
7760 res.end(JSON.stringify(send))
7861 else next()
7962 })
8063 }
8164 })
82- // add third-party plugins
83- require('scuttlebot/plugins/plugins').loadUserPlugins(createSbot, config)
84-
85- // start server
86-
65 +
8766 open('http://localhost:' + config.ws.port, {wait: false})
88-
89- config.keys = keys
67 +
9068 var server = createSbot(config)
91-
92- // write RPC manifest to ~/.ssb/manifest.json
69 +
9370 fs.writeFileSync(manifestFile, JSON.stringify(server.getManifest(), null, 2))
94-
95- if(process.stdout.isTTY && (config.logging.level != 'info'))
96- ProgressBar(server.progress)
9771 } else {
9872
99- // normal command:
100- // create a client connection to the server
101-
102- // read manifest.json
10373 var manifest
10474 try {
10575 manifest = JSON.parse(fs.readFileSync(manifestFile))
10676 } catch (err) {
@@ -110,73 +80,37 @@
11080 )
11181 }
11282
11383 // connect
114- require('ssb-client')(keys, {
84 + require('ssb-client')(config.keys, {
11585 manifest: manifest,
11686 port: config.port,
11787 host: config.host||'localhost',
11888 caps: config.caps,
119- key: config.key || keys.id
89 + key: config.key || config.keys.id
12090 }, function (err, rpc) {
12191 if(err) {
12292 if (/could not connect/.test(err.message)) {
123- var serverAddr = (config.host || 'localhost') + ":" + config.port;
124- console.error('Error: Could not connect to the scuttlebot server ' + serverAddr)
125- console.error('Use the "server" command to start it.')
93 + console.log('Error: Could not connect to the scuttlebot server.')
94 + console.log('Use the "server" command to start it.')
12695 if(config.verbose) throw err
12796 process.exit(1)
12897 }
12998 throw err
13099 }
131100
132- // add aliases
133- for (var k in cmdAliases) {
134- rpc[k] = rpc[cmdAliases[k]]
135- manifest[k] = manifest[cmdAliases[k]]
136- }
137-
138101 // add some extra commands
139-// manifest.version = 'async'
102 + manifest.version = 'async'
140103 manifest.config = 'sync'
141-// rpc.version = function (cb) {
142-// console.log(packageJson.version)
143-// cb()
144-// }
104 + rpc.version = function (cb) {
105 + console.log(require('./package.json').version)
106 + cb()
107 + }
145108 rpc.config = function (cb) {
146109 console.log(JSON.stringify(config, null, 2))
147110 cb()
148111 }
149112
150- // HACK
151- // we need to output the hash of blobs that are added via blobs.add
152- // because muxrpc doesnt support the `sink` callback yet, we need this manual override
153- // -prf
154- if (process.argv[2] === 'blobs.add') {
155- var filename = process.argv[3]
156- var source =
157- filename ? File(process.argv[3])
158- : !process.stdin.isTTY ? toPull.source(process.stdin)
159- : (function () {
160- console.error('USAGE:')
161- console.error(' blobs.add <filename> # add a file')
162- console.error(' source | blobs.add # read from stdin')
163- process.exit(1)
164- })()
165- var hasher = createHash('sha256')
166- pull(
167- source,
168- hasher,
169- rpc.blobs.add(function (err) {
170- if (err)
171- throw err
172- console.log('&'+hasher.digest)
173- process.exit()
174- })
175- )
176- return
177- }
178-
179113 // run commandline flow
180114 muxrpcli(argv, manifest, rpc, config.verbose)
181115 })
182116 }
config.jsView
@@ -2,9 +2,8 @@
22
33 module.exports = function () {
44 var host = window.location.origin
55
6- //var config = require('./config/inject')()
76 function getConfig () {
87 http.get(host + '/get-config', function (res) {
98 res.on('data', function (data, remote) {
109 var config = data
@@ -21,15 +20,15 @@
2120 setTimeout(function () {
2221 location.reload()
2322 }, 1000)
2423 }
25- config.host = host
24 +
2625 config.blobsUrl = host + '/blobs/get/'
2726 config.emojiUrl = host + '/img/emoji/'
2827
29- if (config.address) {
30- addies = config.address.split(';')
31- config.remote = addies[1]
32- }
28 + if (config.ws.remote)
29 + config.remote = config.ws.remote
30 + else
31 + config.remote = config.address
3332
3433 return config
3534 }
config/inject.jsView
@@ -1,73 +1,81 @@
11 var path = require('path')
22 var home = require('os-homedir')
3-
43 var nonPrivate = require('non-private-ip')
54 var merge = require('deep-extend')
6-
5 +var id = require('ssb-keys')
76 var RC = require('rc')
8-
97 var SEC = 1e3
108 var MIN = 60*SEC
119
1210 module.exports = function (name, override) {
13- name = name || 'ssb'
11 + console.log('Using the ' + name + ' config')
12 +
13 + var network
14 +
15 + if (name === 'ssb') {
16 + network = {
17 + port: 8008,
18 + ws: {
19 + port: 8989
20 + },
21 + caps: {
22 + shs: '1KHLiKZvAvjbY1ziZEHMXawbCEIM6qwjCDm3VYRan/s=',
23 + sign: null
24 + }
25 + }
26 + }
27 +
28 + if (name === 'decent') {
29 + network = {
30 + port: 3333,
31 + ws: {
32 + port: 3939
33 + },
34 + caps: {
35 + shs: 'EVRctE2Iv8GrO/BpQCF34e2FMPsDJot9x0j846LjVtc=',
36 + sign: null
37 + }
38 + }
39 + }
40 +
41 + if (name === 'testnet') {
42 + network = {
43 + port: 9999,
44 + ws: {
45 + port: 9191
46 + },
47 + caps: {
48 + shs: 'sR74I0+OW6LBYraQQ2YtFtqV5Ns77Tv5DyMfyWbrlpI=',
49 + sign: null
50 + }
51 + }
52 + }
53 +
1454 var HOME = home() || 'browser' //most probably browser
15- var result = RC(name || 'ssb', merge({
16- //just use an ipv4 address by default.
17- //there have been some reports of seemingly non-private
18- //ipv6 addresses being returned and not working.
19- //https://github.com/ssbc/scuttlebot/pull/102
20- allowPrivate: true,
21- party: true,
55 +
56 + return RC(name, merge(network, {
57 + name: name,
58 + //standard stuff that probably doesn't need to change below
2259 host: nonPrivate.v4 || '',
23- port: 8008,
2460 timeout: 0,
61 + allowPrivate: true,
2562 pub: true,
2663 local: true,
2764 friends: {
2865 dunbar: 150,
2966 hops: 3
3067 },
31- ws: {
32- port: 8989
33- },
3468 gossip: {
3569 connections: 3
3670 },
37- connections: {
38- outgoing: {
39- net: [{ transform: "shs" }]
40- }
41- },
4271 path: path.join(HOME, '.' + name),
4372 timers: {
4473 connection: 0,
4574 reconnect: 5*SEC,
4675 ping: 5*MIN,
4776 handshake: 5*SEC
4877 },
49- //change these to make a test network that will not connect to the main network.
50- caps: {
51- //this is the key for accessing the ssb protocol.
52- //this will be updated whenever breaking changes are made.
53- //(see secret-handshake paper for a full explaination)
54- //(generated by crypto.randomBytes(32).toString('base64'))
55- shs: '1KHLiKZvAvjbY1ziZEHMXawbCEIM6qwjCDm3VYRan/s=',
56-
57- //used to sign messages
58- sign: null
59- },
6078 master: [],
61- logging: { level: 'notice' }
79 + party: true //disable quotas
6280 }, override || {}))
63-
64- if (!result.connections.incoming) {
65- result.connections.incoming = {
66- net: [{ host: result.host, port: result.port, scope: "public", "transform": "shs" }],
67- ws: [{ host: result.host, port: result.ws.port, scope: "public", "transform": "shs" }]
68- }
69- }
70- return result
7181 }
72-
73-
package-lock.jsonView
The diff is too large to show. Use a local git client to view these changes.
Old file size: 237872 bytes
New file size: 303372 bytes
package.jsonView
@@ -1,7 +1,7 @@
11 {
22 "name": "mvd",
3- "version": "1.15.3",
3 + "version": "1.16.0",
44 "description": "minimum viable decent",
55 "main": "index.js",
66 "scripts": {
77 "start": "node bin server",
@@ -10,50 +10,51 @@
1010 "testnet": "node bin server --appname=testnet",
1111 "build": "node style.js && mkdir -p build && browserify index.js | indexhtmlify > build/index.html"
1212 },
1313 "devDependencies": {
14- "browserify": "^16.2.3",
14 + "browserify": "^16.2.2",
1515 "indexhtmlify": "^1.3.1"
1616 },
1717 "author": "Ev Bogue <ev@evbogue.com>",
1818 "license": "MIT",
1919 "dependencies": {
2020 "dataurl-": "^0.1.0",
21- "decent-ws": "^1.1.0",
21 + "decent-ws": "1.0.4",
2222 "deep-extend": "^0.6.0",
2323 "diff": "^3.5.0",
24- "flumeview-query": "^7.1.0",
24 + "emoji-server": "^1.0.0",
2525 "human-time": "0.0.1",
2626 "hyperfile": "^2.0.0",
2727 "hyperloadmore": "^1.1.0",
2828 "hyperscript": "^2.0.2",
2929 "hyperscroll": "^1.0.0",
30 + "multiblob-http": "^0.4.2",
3031 "muxrpcli": "^1.1.0",
31- "non-private-ip": "^1.4.4",
32- "opn": "^5.4.0",
32 + "non-private-ip": "^1.4.3",
33 + "opn": "^5.3.0",
3334 "os-homedir": "^1.0.2",
3435 "pull-more": "^1.1.0",
3536 "pull-next-query": "^1.0.0",
3637 "pull-reconnect": "0.0.3",
37- "pull-stream": "^3.6.9",
38 + "pull-stream": "^3.6.8",
3839 "pull-stringify": "^2.0.0",
39- "rc": "^1.2.8",
40- "scuttlebot": "13.0.3",
40 + "rc": "^1.2.7",
41 + "scuttlebot-release": "ssbc/scuttlebot-release#11.3.x-fixups",
4142 "simple-mime": "^0.1.0",
4243 "split-buffer": "^1.0.0",
4344 "ssb-avatar": "^0.2.0",
44- "ssb-backlinks": "^0.7.3",
45- "ssb-blobs": "^1.1.6",
46- "ssb-client": "^4.6.0",
47- "ssb-ebt": "^5.2.7",
45 + "ssb-backlinks": "^0.7.1",
46 + "ssb-blobs": "^1.1.5",
47 + "ssb-client": "^4.5.7",
48 + "ssb-ebt": "^5.1.5",
4849 "ssb-feed": "^2.3.0",
49- "ssb-friends": "^3.1.6",
50- "ssb-keys": "^7.1.3",
50 + "ssb-friends": "^2.4.0",
51 + "ssb-keys": "^7.0.16",
5152 "ssb-links": "^3.0.3",
5253 "ssb-markdown": "^3.6.0",
5354 "ssb-mentions": "^0.5.0",
54- "ssb-query": "^2.3.0",
55- "ssb-ref": "^2.13.6",
56- "ssb-search": "^1.1.2",
55 + "ssb-ref": "^2.11.1",
56 + "ssb-search": "^1.0.1",
57 + "stack": "^0.1.0",
5758 "visualize-buffer": "0.0.1"
5859 }
5960 }
query/index.jsView
@@ -1,0 +1,68 @@
1 +var pull = require('pull-stream')
2 +var path = require('path')
3 +var FlumeQuery = require('flumeview-query')
4 +var explain = require('explain-error')
5 +
6 +function isString(s) {
7 + return 'string' === typeof s
8 +}
9 +
10 +exports.name = 'query'
11 +exports.version = '1.0.0'
12 +exports.manifest = {
13 + read: 'source',
14 + explain: 'sync'
15 +}
16 +
17 +//what are links used for?
18 +//query follows
19 +//query replies
20 +//query mentions (backlinks & mentions)
21 +//query votes
22 +
23 +
24 +var INDEX_VERSION = 8
25 +var indexes = [
26 + {key: 'log', value: ['timestamp']},
27 + {key: 'clk', value: [['value', 'author'], ['value', 'sequence']] },
28 + {key: 'typ', value: [['value', 'content', 'type'], ['timestamp']] },
29 + {key: 'tya', value: [['value', 'content', 'type'], ['value', 'timestamp']] },
30 + {key: 'cha', value: [['value', 'content', 'channel'], ['timestamp']] },
31 + {key: 'aty', value: [['value', 'author'], ['value', 'content', 'type'], ['timestamp']]},
32 + {key: 'ata', value: [['value', 'author'], ['value', 'content', 'type'], ['value', 'timestamp']]},
33 + {key: 'art', value: [['value', 'content', 'root'], ['value', 'timestamp']]},
34 + {key: 'lor', value: [['value', 'timestamp' ]]}
35 +]
36 +
37 +//createHistoryStream( id, seq )
38 +//[{$filter: {author: <id>, sequence: {$gt: <seq>}}}, {$map: true}]
39 +
40 +//messagesByType (type)
41 +
42 +//[{$filter: {content: {type: <type>}}}, {$map: true}]
43 +
44 +exports.init = function (ssb, config) {
45 + var s = ssb._flumeUse('query', FlumeQuery(INDEX_VERSION, {indexes: indexes}))
46 + var read = s.read
47 + var explain = s.explain
48 + s.explain = function (opts) {
49 + if(!opts) opts = {}
50 + if(isString(opts))
51 + opts = {query: JSON.parse(opts)}
52 + else if(isString(opts.query))
53 + opts.query = JSON.parse(opts.query)
54 + return explain(opts)
55 + }
56 +
57 + s.read = function (opts) {
58 + if(!opts) opts = {}
59 + if(isString(opts))
60 + opts = {query: JSON.parse(opts)}
61 + else if(isString(opts.query))
62 + opts.query = JSON.parse(opts.query)
63 + return read(opts)
64 + }
65 + return s
66 +}
67 +
68 +

Built with git-ssb-web