git ssb

16+

Dominic / patchbay



Tree: 66eee2b2a45a2671daed5adf10e776d7394e644c

Files: 66eee2b2a45a2671daed5adf10e776d7394e644c / config.js

1148 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'
9 ? null
10 : null // require('./default-config.json')
11
12exports.gives = nest('config.sync.load')
13exports.create = (api) => {
14 var config
15 return nest('config.sync.load', () => {
16 if (config) return config
17
18 console.log('LOADING config')
19 config = Config(appName, opts)
20 config.keys = ssbKeys.loadOrCreateSync(Path.join(config.path, 'secret'))
21 config.remote = buildRemote(config)
22
23 if (process.platform !== 'win32') {
24 config = merge(config, {
25 connections: {
26 incoming: { unix: [{ 'scope': 'local', 'transform': 'noauth' }] }
27 }
28 })
29 }
30
31 return config
32 })
33}
34
35function buildRemote (config) {
36 const pubkey = config.keys.id.slice(1).replace(`.${config.keys.curve}`, '')
37
38 return process.platform !== 'win32'
39 ? `net:127.0.0.1:${config.port}~shs:${pubkey}`
40 : `unix:${Path.join(config.path, 'socket')}:~noauth:${pubkey}`
41}
42

Built with git-ssb-web