Commit 14955bd14de37455c5c7c93c09692bb20eab43cb
fix windows config with a patch
mixmix committed on 1/24/2019, 4:17:32 AMParent: 5fe0e8a6f94d635713a10e68c26fa7ab8d857f80
Files changed
config.js | changed |
config.js | ||
---|---|---|
@@ -2,42 +2,44 @@ | ||
2 | 2 … | const Config = require('ssb-config/inject') |
3 | 3 … | const Path = require('path') |
4 | 4 … | const merge = require('lodash/merge') |
5 | 5 … | |
6 | -const appName = process.env.ssb_appname || 'ssb' | |
7 | -const opts = appName === 'ssb' ? null : null | |
8 | - | |
9 | 6 … | exports.gives = nest('config.sync.load') |
10 | 7 … | exports.create = (api) => { |
11 | 8 … | var config |
12 | 9 … | return nest('config.sync.load', () => { |
13 | 10 … | if (config) return config |
14 | 11 … | |
15 | 12 … | console.log('LOADING config') |
16 | - config = Config(appName, opts) | |
13 … | + config = Config(process.env.ssb_appname || 'ssb') | |
17 | 14 … | |
18 | - config = merge( | |
19 | - config, | |
20 | - Connections(config), | |
21 | - Remote(config) | |
22 | - ) | |
15 … | + config = addSockets(config) | |
16 … | + config = fixLocalhost(config) | |
23 | 17 … | |
24 | 18 … | return config |
25 | 19 … | }) |
26 | 20 … | } |
27 | 21 … | |
28 | -function Connections (config) { | |
29 | - const connections = (process.platform === 'win32') | |
30 | - ? undefined | |
31 | - : { incoming: { unix: [{ scope: 'local', transform: 'noauth', server: true }] } } | |
22 … | +function addSockets (config) { | |
23 … | + if (process.platform === 'win32') return config | |
32 | 24 … | |
33 | - return connections ? { connections } : {} | |
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 … | + ) | |
34 | 35 … | } |
35 | 36 … | |
36 | -function Remote (config) { | |
37 | - const pubkey = config.keys.id.slice(1).replace(`.${config.keys.curve}`, '') | |
38 | - const remote = (process.platform === 'win32') | |
39 | - ? undefined // `net:127.0.0.1:${config.port}~shs:${pubkey}` // currently broken | |
40 | - : `unix:${Path.join(config.path, 'socket')}:~noauth:${pubkey}` | |
37 … | +function fixLocalhost (config) { | |
38 … | + if (process.platform !== 'win32') return config | |
41 | 39 … | |
42 | - return remote ? { remote } : {} | |
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 | |
43 | 45 … | } |
Built with git-ssb-web