Files: 6d8b19c2ddca9ab63af6775ccb64d0942a23d808 / config.js
1279 bytesRaw
1 | const nest = require('depnest') |
2 | const Config = require('ssb-config/inject') |
3 | const ssbKeys = require('ssb-keys') |
4 | const Path = require('path') |
5 | const merge = require('lodash/merge') |
6 | |
7 | const appName = process.env.ssb_appname || 'ssb' |
8 | const opts = appName === 'ssb' ? null : null |
9 | |
10 | exports.gives = nest('config.sync.load') |
11 | exports.create = (api) => { |
12 | var config |
13 | return nest('config.sync.load', () => { |
14 | if (config) return config |
15 | |
16 | console.log('LOADING config') |
17 | config = Config(appName, opts) |
18 | config.keys = ssbKeys.loadOrCreateSync(Path.join(config.path, 'secret')) |
19 | |
20 | config = merge( |
21 | config, |
22 | Connections(config), |
23 | Remote(config) |
24 | ) |
25 | |
26 | return config |
27 | }) |
28 | } |
29 | |
30 | function Connections (config) { |
31 | const connections = (process.platform === 'win32') |
32 | ? undefined // this seems wrong? |
33 | : { incoming: { unix: [{ 'scope': 'local', 'transform': 'noauth' }] } } |
34 | |
35 | return connections ? { connections } : {} |
36 | } |
37 | |
38 | function Remote (config) { |
39 | const pubkey = config.keys.id.slice(1).replace(`.${config.keys.curve}`, '') |
40 | const remote = (process.platform === 'win32') |
41 | ? undefined // `net:127.0.0.1:${config.port}~shs:${pubkey}` // currently broken |
42 | : `unix:${Path.join(config.path, 'socket')}:~noauth:${pubkey}` |
43 | |
44 | return remote ? { remote } : {} |
45 | } |
46 |
Built with git-ssb-web