src/nodejs-project/index.tsView |
---|
10 | 10 | const mkdirp = require('mkdirp'); |
11 | 11 | const DHT = require('multiserver-dht'); |
12 | 12 | const rnBridge = require('rn-bridge'); |
13 | 13 | const rnChannelPlugin = require('multiserver-rn-channel'); |
| 14 | +const npip = require('non-private-ip'); |
| 15 | +const injectSsbConfig = require('ssb-config/inject'); |
14 | 16 | import syncingPlugin = require('./plugins/syncing'); |
15 | 17 | import blobsFromPathPlugin = require('./plugins/blobsFromPath'); |
16 | 18 | import manifest = require('./manifest'); |
17 | 19 | |
22 | 24 | } |
23 | 25 | const keysPath = path.join(ssbPath, '/secret'); |
24 | 26 | const keys = ssbKeys.loadOrCreateSync(keysPath); |
25 | 27 | |
26 | | -const config = require('ssb-config/inject')(); |
27 | | -config.path = ssbPath; |
28 | | -config.keys = keys; |
29 | | -config.manifest = manifest; |
30 | | -config.friends.hops = 2; |
31 | | -config.connections = { |
32 | | - incoming: { |
33 | | - net: [{scope: 'private', transform: 'shs', port: 26831}], |
34 | | - dht: [{scope: 'public', transform: 'shs', port: 26832}], |
35 | | - channel: [{scope: 'device', transform: 'noauth'}], |
36 | | - }, |
37 | | - outgoing: { |
38 | | - net: [{transform: 'shs'}], |
39 | | - dht: [{transform: 'shs'}], |
40 | | - }, |
41 | | -}; |
| 28 | +const config = (() => { |
| 29 | + const c = injectSsbConfig(); |
| 30 | + const NET_PORT = 26831; |
| 31 | + const DHT_PORT = 26832; |
| 32 | + const host = npip.private(); |
| 33 | + c.path = ssbPath; |
| 34 | + c.keys = keys; |
| 35 | + c.manifest = manifest; |
| 36 | + c.friends.hops = 2; |
| 37 | + c.connections = { |
| 38 | + incoming: { |
| 39 | + net: [{scope: 'private', transform: 'shs', host, port: NET_PORT}], |
| 40 | + dht: [{scope: 'public', transform: 'shs', port: DHT_PORT}], |
| 41 | + channel: [{scope: 'device', transform: 'noauth'}], |
| 42 | + }, |
| 43 | + outgoing: { |
| 44 | + net: [{transform: 'shs'}], |
| 45 | + dht: [{transform: 'shs'}], |
| 46 | + }, |
| 47 | + }; |
| 48 | + return c; |
| 49 | +})(); |
42 | 50 | |
43 | 51 | function rnChannelTransport(_sbot: any) { |
44 | 52 | _sbot.multiserver.transport({ |
45 | 53 | name: 'channel', |