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