config/inject.jsView |
---|
1 | 1 | var path = require('path') |
2 | 2 | var home = require('os-homedir') |
| 3 | + |
3 | 4 | var nonPrivate = require('non-private-ip') |
4 | 5 | var merge = require('deep-extend') |
5 | | -var id = require('ssb-keys') |
| 6 | + |
6 | 7 | var RC = require('rc') |
| 8 | + |
7 | 9 | var SEC = 1e3 |
8 | 10 | var MIN = 60*SEC |
9 | 11 | |
10 | 12 | module.exports = function (name, override) { |
11 | | - console.log('Using the ' + name + ' config') |
12 | | - |
13 | | - var network |
14 | | - |
15 | | - if (name === 'ssb') { |
16 | | - network = { |
17 | | - port: 8008, |
18 | | - ws: { |
19 | | - port: 8989 |
20 | | - }, |
21 | | - caps: { |
22 | | - shs: '1KHLiKZvAvjbY1ziZEHMXawbCEIM6qwjCDm3VYRan/s=', |
23 | | - sign: null |
24 | | - } |
25 | | - } |
26 | | - } |
27 | | - |
28 | | - if (name === 'decent') { |
29 | | - network = { |
30 | | - port: 3333, |
31 | | - ws: { |
32 | | - port: 3939 |
33 | | - }, |
34 | | - caps: { |
35 | | - shs: 'EVRctE2Iv8GrO/BpQCF34e2FMPsDJot9x0j846LjVtc=', |
36 | | - sign: null |
37 | | - } |
38 | | - } |
39 | | - } |
40 | | - |
41 | | - if (name === 'testnet') { |
42 | | - network = { |
43 | | - port: 9999, |
44 | | - ws: { |
45 | | - port: 9191 |
46 | | - }, |
47 | | - caps: { |
48 | | - shs: 'sR74I0+OW6LBYraQQ2YtFtqV5Ns77Tv5DyMfyWbrlpI=', |
49 | | - sign: null |
50 | | - } |
51 | | - } |
52 | | - } |
53 | | - |
| 13 | + name = name || 'ssb' |
54 | 14 | var HOME = home() || 'browser' |
55 | | - |
56 | | - return RC(name, merge(network, { |
57 | | - name: name, |
58 | | - |
| 15 | + var result = RC(name || 'ssb', merge({ |
| 16 | + |
| 17 | + |
| 18 | + |
| 19 | + |
| 20 | + party: true, |
59 | 21 | host: nonPrivate.v4 || '', |
| 22 | + port: 8008, |
60 | 23 | timeout: 0, |
61 | | - allowPrivate: true, |
62 | 24 | pub: true, |
63 | 25 | local: true, |
64 | 26 | friends: { |
65 | 27 | dunbar: 150, |
66 | 28 | hops: 3 |
67 | 29 | }, |
| 30 | + ws: { |
| 31 | + port: 8989 |
| 32 | + }, |
68 | 33 | gossip: { |
69 | 34 | connections: 3 |
70 | 35 | }, |
71 | 36 | connections: { |
72 | | - incoming: { |
73 | | - net: [{ port: 8008, host: "localhost", scope: "local", "transform": "shs" }], |
74 | | - ws: [{ "scope": "public", "transform": "shs" }] |
75 | | - }, |
76 | 37 | outgoing: { |
77 | | - net: [{ transform: "shs" }], |
78 | | - ws: [{ "scope": "public", "transform": "shs" }] |
| 38 | + net: [{ transform: "shs" }] |
79 | 39 | } |
80 | 40 | }, |
81 | 41 | path: path.join(HOME, '.' + name), |
82 | 42 | timers: { |
84 | 44 | reconnect: 5*SEC, |
85 | 45 | ping: 5*MIN, |
86 | 46 | handshake: 5*SEC |
87 | 47 | }, |
| 48 | + |
| 49 | + caps: { |
| 50 | + |
| 51 | + |
| 52 | + |
| 53 | + |
| 54 | + shs: '1KHLiKZvAvjbY1ziZEHMXawbCEIM6qwjCDm3VYRan/s=', |
| 55 | + |
| 56 | + |
| 57 | + sign: null |
| 58 | + }, |
88 | 59 | master: [], |
89 | | - party: true |
| 60 | + logging: { level: 'notice' } |
90 | 61 | }, override || {})) |
| 62 | + |
| 63 | + if (!result.connections.incoming) { |
| 64 | + result.connections.incoming = { |
| 65 | + net: [{ host: result.host, port: result.port, scope: "public", "transform": "shs" }], |
| 66 | + ws: [{ host: result.host, scope: "device", "transform": "shs" }] |
| 67 | + } |
| 68 | + } |
| 69 | + return result |
91 | 70 | } |