git ssb

16+

Dominic / patchbay



Tree: df5498c00b9dbc44e316e9e81294f5e27dc557af

Files: df5498c00b9dbc44e316e9e81294f5e27dc557af / config.js

1204 bytesRaw
1const nest = require('depnest')
2const Config = require('ssb-config/inject')
3const Path = require('path')
4const merge = require('lodash/merge')
5
6exports.gives = nest('config.sync.load')
7exports.create = (api) => {
8 var config
9 return nest('config.sync.load', () => {
10 if (config) return config
11
12 console.log('LOADING config')
13 config = Config(process.env.ssb_appname || 'ssb')
14
15 config = addSockets(config)
16 config = fixLocalhost(config)
17
18 return config
19 })
20}
21
22function addSockets (config) {
23 if (process.platform === 'win32') return config
24
25 const pubkey = config.keys.id.slice(1).replace(`.${config.keys.curve}`, '')
26 return merge(
27 config,
28 {
29 connections: {
30 incoming: { unix: [{ scope: 'local', transform: 'noauth', server: true }] }
31 },
32 remote: `unix:${Path.join(config.path, 'socket')}:~noauth:${pubkey}` // overwrites
33 }
34 )
35}
36
37function fixLocalhost (config) {
38 if (process.platform !== 'win32') return config
39
40 // without this host defaults to :: which doesn't work on windows 10?
41 config.connections.incoming.net[0].host = '127.0.0.1'
42 config.connections.incoming.ws[0].host = '127.0.0.1'
43 config.host = '127.0.0.1'
44 return config
45}
46

Built with git-ssb-web