-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathconfig.js
41 lines (34 loc) · 1.29 KB
/
config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
const ssbKeys = require('ssb-keys')
const Config = require('ssb-config/inject')
const path = require('path')
const merge = require('lodash.merge')
// const minimist = require('minimist')
module.exports = function buildConfig ({ appname }) {
// mix: note ssb-config uses RC, which loads config opts from process.argv
// let argv = process.argv.slice(2)
// let i = argv.indexOf('--')
// let conf = argv.slice(i + 1)
// argv = ~i ? argv.slice(0, i) : argv // mix: is this used ?
//
var config = Config(appname || process.env.ssb_appname)
config.keys = ssbKeys.loadOrCreateSync(path.join(config.path, 'secret'))
config = merge(
config,
Connections(config),
Remote(config)
)
return config
}
function Connections (config) {
const connections = (process.platform === 'win32')
? undefined // this seems wrong?
: { incoming: { unix: [{ 'scope': 'local', 'transform': 'noauth', server: true }] } }
return connections ? { connections } : {}
}
function Remote (config) {
const pubkey = config.keys.id.slice(1).replace(`.${config.keys.curve}`, '')
const remote = (process.platform === 'win32')
? undefined // `net:127.0.0.1:${config.port}~shs:${pubkey}` // currently broken
: `unix:${path.join(config.path, 'socket')}:~noauth:${pubkey}`
return remote ? { remote } : {}
}