Commit 9c46fa792313eae0c2a42a1c99894cc71567d11c
better config
mixmix committed on 11/11/2018, 10:47:32 PMParent: 8beaa8d9c8e1fe17f0b1ee4190029fae0b937a35
Files changed
config.js | changed |
config.js | |||
---|---|---|---|
@@ -4,11 +4,9 @@ | |||
4 | 4 … | const Path = require('path') | |
5 | 5 … | const merge = require('lodash/merge') | |
6 | 6 … | ||
7 | 7 … | const appName = process.env.ssb_appname || 'ssb' | |
8 | -const opts = appName === 'ssb' | ||
9 | - ? null | ||
10 | - : null // require('./default-config.json') | ||
8 … | +const opts = appName === 'ssb' ? null : null | ||
11 | 9 … | ||
12 | 10 … | exports.gives = nest('config.sync.load') | |
13 | 11 … | exports.create = (api) => { | |
14 | 12 … | var config | |
@@ -17,25 +15,31 @@ | |||
17 | 15 … | ||
18 | 16 … | console.log('LOADING config') | |
19 | 17 … | config = Config(appName, opts) | |
20 | 18 … | config.keys = ssbKeys.loadOrCreateSync(Path.join(config.path, 'secret')) | |
21 | - config.remote = buildRemote(config) | ||
22 | 19 … | ||
23 | - if (process.platform !== 'win32') { | ||
24 | - config = merge(config, { | ||
25 | - connections: { | ||
26 | - incoming: { unix: [{ 'scope': 'local', 'transform': 'noauth' }] } | ||
27 | - } | ||
28 | - }) | ||
29 | - } | ||
20 … | + config = merge( | ||
21 … | + config, | ||
22 … | + Connections(config), | ||
23 … | + Remote(config) | ||
24 … | + ) | ||
30 | 25 … | ||
31 | 26 … | return config | |
32 | 27 … | }) | |
33 | 28 … | } | |
34 | 29 … | ||
35 | -function buildRemote (config) { | ||
30 … | +function 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 … | + | ||
38 … | +function Remote (config) { | ||
36 | 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}` | ||
37 | 43 … | ||
38 | - return process.platform !== 'win32' | ||
39 | - ? `net:127.0.0.1:${config.port}~shs:${pubkey}` | ||
40 | - : `unix:${Path.join(config.path, 'socket')}:~noauth:${pubkey}` | ||
44 … | + return remote ? { remote } : {} | ||
41 | 45 … | } |
Built with git-ssb-web