git ssb

16+

Dominic / patchbay



Tree: 712beb673304d8bb94ffe1f54af0249ddc3ae451

Files: 712beb673304d8bb94ffe1f54af0249ddc3ae451 / config.js

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