forked from mixmix/infinite-game
-
Notifications
You must be signed in to change notification settings - Fork 2
/
config.js
46 lines (37 loc) · 1.17 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
42
43
44
45
46
const nest = require('depnest')
const Config = require('ssb-config/inject')
const { merge } = require('lodash')
const { join } = require('path')
exports.gives = nest('config.sync.load')
exports.create = (api) => {
var config
return nest('config.sync.load', () => {
if (config) return config
console.log('LOADING config')
config = Config(process.env.ssb_appname || 'ssb')
config = addSockets(config)
config = fixLocalhost(config)
return config
})
}
function addSockets (config) {
if (process.platform === 'win32') return config
const pubkey = config.keys.id.slice(1).replace(`.${config.keys.curve}`, '')
return merge(
config,
{
connections: {
incoming: { unix: [{ scope: 'local', transform: 'noauth', server: true }] }
},
remote: `unix:${join(config.path, 'socket')}:~noauth:${pubkey}` // overwrites
}
)
}
function fixLocalhost (config) {
if (process.platform !== 'win32') return config
// without this host defaults to :: which doesn't work on windows 10?
config.connections.incoming.net[0].host = '127.0.0.1'
config.connections.incoming.ws[0].host = '127.0.0.1'
config.host = '127.0.0.1'
return config
}