Files: f6f02149a4304abe8de319ba4e68f1a4f03c9f80 / config / inject.js
1889 bytesRaw
1 | var path = require('path') |
2 | var home = require('os-homedir') |
3 | |
4 | var nonPrivate = require('non-private-ip') |
5 | var merge = require('deep-extend') |
6 | |
7 | var RC = require('rc') |
8 | |
9 | var SEC = 1e3 |
10 | var MIN = 60*SEC |
11 | |
12 | module.exports = function (name, override) { |
13 | name = name || 'ssb' |
14 | var HOME = home() || 'browser' //most probably browser |
15 | var result = RC(name || 'ssb', merge({ |
16 | //just use an ipv4 address by default. |
17 | //there have been some reports of seemingly non-private |
18 | //ipv6 addresses being returned and not working. |
19 | //https://github.com/ssbc/scuttlebot/pull/102 |
20 | allowPrivate: true, |
21 | party: true, |
22 | host: nonPrivate.v4 || '', |
23 | port: 8008, |
24 | timeout: 0, |
25 | pub: true, |
26 | local: true, |
27 | friends: { |
28 | dunbar: 150, |
29 | hops: 1 |
30 | }, |
31 | ws: { |
32 | port: 8989 |
33 | }, |
34 | gossip: { |
35 | connections: 3 |
36 | }, |
37 | connections: { |
38 | outgoing: { |
39 | net: [{ transform: "shs" }] |
40 | } |
41 | }, |
42 | path: path.join(HOME, '.' + name), |
43 | timers: { |
44 | connection: 0, |
45 | reconnect: 5*SEC, |
46 | ping: 5*MIN, |
47 | handshake: 5*SEC |
48 | }, |
49 | //change these to make a test network that will not connect to the main network. |
50 | caps: { |
51 | //this is the key for accessing the ssb protocol. |
52 | //this will be updated whenever breaking changes are made. |
53 | //(see secret-handshake paper for a full explaination) |
54 | //(generated by crypto.randomBytes(32).toString('base64')) |
55 | shs: '1KHLiKZvAvjbY1ziZEHMXawbCEIM6qwjCDm3VYRan/s=', |
56 | |
57 | //used to sign messages |
58 | sign: null |
59 | }, |
60 | master: [], |
61 | logging: { level: 'notice' } |
62 | }, override || {})) |
63 | |
64 | if (!result.connections.incoming) { |
65 | result.connections.incoming = { |
66 | net: [{ host: result.host, port: result.port, scope: "public", "transform": "shs" }], |
67 | ws: [{ host: result.host, port: result.ws.port, scope: "public", "transform": "shs" }] |
68 | } |
69 | } |
70 | return result |
71 | } |
72 | |
73 | |
74 |
Built with git-ssb-web