git ssb

1+

punkmonk.termux / mvd



forked from ev / mvd

Commit 03ba4f6100e6c42a83ad6c770c69bb63a5d6fd7b

update to scuttlebot@13.0.3

Ev Bogue committed on 11/5/2018, 6:45:30 PM
Parent: 7ede3c7a935ddf6b575e9a503f49956005a87a3d

Files changed

bin.jschanged
config.jschanged
config/inject.jschanged
package-lock.jsonchanged
package.jsonchanged
bin.jsView
@@ -1,73 +1,104 @@
1-var fs = require('fs')
2-var path = require('path')
3-var ssbKeys = require('ssb-keys')
4-var stringify = require('pull-stringify')
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')
517 var open = require('opn')
6-var home = require('os-homedir')()
7-var nonPrivate = require('non-private-ip')
8-var muxrpcli = require('muxrpcli')
918
10-var SEC = 1e3
11-var MIN = 60*SEC
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
1225
13-var config = require('./config/inject')()
26+var config = require('./config/inject')(process.env.ssb_appname, minimist(conf))
1427
15-config.keys = ssbKeys.loadOrCreateSync(path.join(config.path, 'secret'))
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'))
1632
17-var mvdClient = fs.readFileSync(path.join('./build/index.html'))
33+var compiledClient = fs.readFileSync(path.join('./build/index.html'))
1834
1935 var manifestFile = path.join(config.path, 'manifest.json')
2036
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
37+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)
2540
26-if (argv[0] == 'server') {
27-
41+ // special server command:
42+ // import sbot and start the server
43+
2844 var createSbot = require('scuttlebot')
45+ .use(require('scuttlebot/plugins/unix-socket'))
46+ .use(require('scuttlebot/plugins/no-auth'))
47+ .use(require('scuttlebot/plugins/plugins'))
2948 .use(require('scuttlebot/plugins/master'))
3049 .use(require('scuttlebot/plugins/gossip'))
3150 .use(require('scuttlebot/plugins/replicate'))
3251 .use(require('ssb-friends'))
3352 .use(require('ssb-blobs'))
34- .use(require('ssb-backlinks'))
53+ .use(require('scuttlebot/plugins/invite'))
54+ .use(require('scuttlebot/plugins/local'))
55+ .use(require('scuttlebot/plugins/logging'))
3556 .use(require('ssb-query'))
3657 .use(require('./mvd-indexes'))
3758 .use(require('ssb-links'))
59+ .use(require('ssb-ws'))
3860 .use(require('ssb-ebt'))
39- .use(require('ssb-search'))
40- .use(require('scuttlebot/plugins/invite'))
41- .use(require('scuttlebot/plugins/local'))
42- .use(require('decent-ws'))
4361 .use({
4462 name: 'serve',
4563 version: '1.0.0',
4664 init: function (sbot) {
4765 sbot.ws.use(function (req, res, next) {
4866 var send = config
49- delete send.keys // very important to keep this, as it removes the server keys from the config before broadcast
50- send.address = sbot.ws.getAddress()
51- sbot.invite.create({modern: true}, function (err, cb) {
67+ delete send.keys
68+ /*sbot.invite.create(1, function (err, cb) {
5269 send.invite = cb
53- })
70+ })*/
71+ send.address = sbot.getAddress()
5472 if(req.url == '/')
55- res.end(mvdClient)
73+ res.end(compiledClient)
5674 if(req.url == '/get-config')
5775 res.end(JSON.stringify(send))
5876 else next()
5977 })
6078 }
6179 })
62-
80+ // add third-party plugins
81+ require('scuttlebot/plugins/plugins').loadUserPlugins(createSbot, config)
82+
83+ // start server
84+
6385 open('http://localhost:' + config.ws.port, {wait: false})
64-
86+
87+ config.keys = keys
6588 var server = createSbot(config)
66-
89+
90+ // write RPC manifest to ~/.ssb/manifest.json
6791 fs.writeFileSync(manifestFile, JSON.stringify(server.getManifest(), null, 2))
92+
93+ if(process.stdout.isTTY && (config.logging.level != 'info'))
94+ ProgressBar(server.progress)
6895 } else {
6996
97+ // normal command:
98+ // create a client connection to the server
99+
100+ // read manifest.json
70101 var manifest
71102 try {
72103 manifest = JSON.parse(fs.readFileSync(manifestFile))
73104 } catch (err) {
@@ -77,37 +108,73 @@
77108 )
78109 }
79110
80111 // connect
81- require('ssb-client')(config.keys, {
112+ require('ssb-client')(keys, {
82113 manifest: manifest,
83114 port: config.port,
84115 host: config.host||'localhost',
85116 caps: config.caps,
86- key: config.key || config.keys.id
117+ key: config.key || keys.id
87118 }, function (err, rpc) {
88119 if(err) {
89120 if (/could not connect/.test(err.message)) {
90- console.log('Error: Could not connect to the scuttlebot server.')
91- console.log('Use the "server" command to start it.')
121+ var serverAddr = (config.host || 'localhost') + ":" + config.port;
122+ console.error('Error: Could not connect to the scuttlebot server ' + serverAddr)
123+ console.error('Use the "server" command to start it.')
92124 if(config.verbose) throw err
93125 process.exit(1)
94126 }
95127 throw err
96128 }
97129
130+ // add aliases
131+ for (var k in cmdAliases) {
132+ rpc[k] = rpc[cmdAliases[k]]
133+ manifest[k] = manifest[cmdAliases[k]]
134+ }
135+
98136 // add some extra commands
99- manifest.version = 'async'
137+// manifest.version = 'async'
100138 manifest.config = 'sync'
101- rpc.version = function (cb) {
102- console.log(require('./package.json').version)
103- cb()
104- }
139+// rpc.version = function (cb) {
140+// console.log(packageJson.version)
141+// cb()
142+// }
105143 rpc.config = function (cb) {
106144 console.log(JSON.stringify(config, null, 2))
107145 cb()
108146 }
109147
148+ // HACK
149+ // we need to output the hash of blobs that are added via blobs.add
150+ // because muxrpc doesnt support the `sink` callback yet, we need this manual override
151+ // -prf
152+ if (process.argv[2] === 'blobs.add') {
153+ var filename = process.argv[3]
154+ var source =
155+ filename ? File(process.argv[3])
156+ : !process.stdin.isTTY ? toPull.source(process.stdin)
157+ : (function () {
158+ console.error('USAGE:')
159+ console.error(' blobs.add <filename> # add a file')
160+ console.error(' source | blobs.add # read from stdin')
161+ process.exit(1)
162+ })()
163+ var hasher = createHash('sha256')
164+ pull(
165+ source,
166+ hasher,
167+ rpc.blobs.add(function (err) {
168+ if (err)
169+ throw err
170+ console.log('&'+hasher.digest)
171+ process.exit()
172+ })
173+ )
174+ return
175+ }
176+
110177 // run commandline flow
111178 muxrpcli(argv, manifest, rpc, config.verbose)
112179 })
113180 }
config.jsView
@@ -2,8 +2,9 @@
22
33 module.exports = function () {
44 var host = window.location.origin
55
6+ //var config = require('./config/inject')()
67 function getConfig () {
78 http.get(host + '/get-config', function (res) {
89 res.on('data', function (data, remote) {
910 var config = data
@@ -21,14 +22,14 @@
2122 location.reload()
2223 }, 1000)
2324 }
2425
25- config.blobsUrl = host + '/blobs/get/'
26- config.emojiUrl = host + '/img/emoji/'
26+ config.blobsUrl = 'http://localhost:8989/blobs/get/'
27+ config.emojiUrl = 'http://localhost:8989/img/emoji/'
28+ if (config.address) {
29+ addies = config.address.split(';')
30+ config.remote = addies[1]
31+ console.log(addies[1])
32+ }
2733
28- if (config.ws.remote)
29- config.remote = config.ws.remote
30- else
31- config.remote = config.address
32-
3334 return config
3435 }
config/inject.jsView
@@ -16,8 +16,9 @@
1616 //just use an ipv4 address by default.
1717 //there have been some reports of seemingly non-private
1818 //ipv6 addresses being returned and not working.
1919 //https://github.com/ssbc/scuttlebot/pull/102
20+ allowPrivate: true,
2021 party: true,
2122 host: nonPrivate.v4 || '',
2223 port: 8008,
2324 timeout: 0,
@@ -62,9 +63,11 @@
6263
6364 if (!result.connections.incoming) {
6465 result.connections.incoming = {
6566 net: [{ host: result.host, port: result.port, scope: "public", "transform": "shs" }],
66- ws: [{ host: result.host, scope: "device", "transform": "shs" }]
67+ ws: [{ host: result.host, port: result.ws.port, scope: "public", "transform": "shs" }]
6768 }
6869 }
6970 return result
7071 }
72+
73+
package-lock.jsonView
The diff is too large to show. Use a local git client to view these changes.
Old file size: 227598 bytes
New file size: 234753 bytes
package.jsonView
@@ -20,8 +20,10 @@
2020 "dataurl-": "^0.1.0",
2121 "decent-ws": "1.0.4",
2222 "deep-extend": "^0.6.0",
2323 "diff": "^3.5.0",
24+ "ecstatic": "^3.3.0",
25+ "flumeview-query": "^7.1.0",
2426 "human-time": "0.0.1",
2527 "hyperfile": "^2.0.0",
2628 "hyperloadmore": "^1.1.0",
2729 "hyperscript": "^2.0.2",
@@ -35,24 +37,24 @@
3537 "pull-reconnect": "0.0.3",
3638 "pull-stream": "^3.6.9",
3739 "pull-stringify": "^2.0.0",
3840 "rc": "^1.2.8",
39- "scuttlebot": "^13.0.0",
41+ "scuttlebot": "^13.0.3",
4042 "simple-mime": "^0.1.0",
4143 "split-buffer": "^1.0.0",
4244 "ssb-avatar": "^0.2.0",
4345 "ssb-backlinks": "^0.7.3",
44- "ssb-blobs": "^1.1.5",
46+ "ssb-blobs": "^1.1.6",
4547 "ssb-client": "^4.6.0",
46- "ssb-ebt": "^5.2.3",
48+ "ssb-ebt": "^5.2.7",
4749 "ssb-feed": "^2.3.0",
48- "ssb-friends": "^3.1.3",
50+ "ssb-friends": "^3.1.5",
4951 "ssb-keys": "^7.1.3",
5052 "ssb-links": "^3.0.3",
5153 "ssb-markdown": "^3.6.0",
5254 "ssb-mentions": "^0.5.0",
5355 "ssb-query": "^2.3.0",
54- "ssb-ref": "^2.12.0",
56+ "ssb-ref": "^2.13.5",
5557 "ssb-search": "^1.1.2",
5658 "visualize-buffer": "0.0.1"
5759 }
5860 }

Built with git-ssb-web