This repository has been archived by the owner on May 18, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathssb-singleton-setup.js
78 lines (73 loc) · 1.91 KB
/
ssb-singleton-setup.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
const localPrefs = require('./localprefs')
const pull = require('pull-stream')
const config = {
caps: { shs: Buffer.from(localPrefs.getCaps(), 'base64') },
friends: {
hops: localPrefs.getHops(),
hookReplicate: false
},
connections: (localPrefs.getDHTEnabled() ? {
incoming: {
tunnel: [{ scope: 'public', transform: 'shs' }],
dht: [{ scope: 'public', transform: 'shs' }]
},
outgoing: {
net: [{ transform: 'shs' }],
ws: [{ transform: 'shs' }, { transform: 'noauth' }],
tunnel: [{ transform: 'shs' }],
dht: [{ transform: 'shs' }]
}
} : {
incoming: {
tunnel: [{ scope: 'public', transform: 'shs' }]
},
outgoing: {
net: [{ transform: 'shs' }],
ws: [{ transform: 'shs' }, { transform: 'noauth' }],
tunnel: [{ transform: 'shs' }]
}
}
),
hops: localPrefs.getHops(),
core: {
startOffline: localPrefs.getOfflineMode()
},
ebt: {
logging: localPrefs.getDetailedLogging()
},
conn: {
autostart: false,
hops: localPrefs.getHops(),
populatePubs: false
}
}
function extraModules(secretStack) {
return secretStack.use({
init: function (sbot, config) {
sbot.db.registerIndex(require('ssb-db2/indexes/full-mentions'))
}
})
.use({
init: function (sbot, config) {
sbot.db.registerIndex(require('ssb-db2/indexes/about-self'))
}
})
.use({
init: function (sbot, config) {
sbot.db.registerIndex(require('./indexes/channels'))
}
})
.use(require("ssb-threads"))
}
function ssbLoaded() {
// add helper methods
SSB = window.singletonSSB
require('./net')
require('./profile')
require('./search')
pull(SSB.net.conn.hub().listen(), pull.drain((ev) => {
if (ev.type.indexOf("failed") >= 0)
console.warn("Connection error: ", ev)
}))
}
require('ssb-browser-core/ssb-singleton').init(config, extraModules, ssbLoaded)