git ssb

16+

Dominic / patchbay



Tree: dd6a279d35c61c3c1a36d453b6e27af326a3fc67

Files: dd6a279d35c61c3c1a36d453b6e27af326a3fc67 / config.js

1279 bytesRaw
1const nest = require('depnest')
2const Config = require('ssb-config/inject')
3const ssbKeys = require('ssb-keys')
4const Path = require('path')
5const merge = require('lodash/merge')
6
7const appName = process.env.ssb_appname || 'ssb'
8const opts = appName === 'ssb' ? null : null
9
10exports.gives = nest('config.sync.load')
11exports.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
30function 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
38function 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