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