Skip to content
This repository was archived by the owner on May 12, 2021. It is now read-only.

Commit 5294bbe

Browse files
staltzblack-puppydog
authored andcommitted
add DHT invites, only as a client
1 parent 83e7340 commit 5294bbe

File tree

10 files changed

+465
-210
lines changed

10 files changed

+465
-210
lines changed

index.js

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -201,14 +201,6 @@ function setupContext (appName, opts, cb) {
201201
dunbar: 150,
202202
hops: 2 // down from 3
203203
}
204-
// connections: { // to support DHT invites
205-
// incoming: {
206-
// dht: [{ scope: 'public', transform: 'shs', port: 8423 }]
207-
// },
208-
// outgoing: {
209-
// dht: [{ transform: 'shs' }]
210-
// }
211-
// }
212204
}, opts))
213205

214206
// disable gossip auto-population from {type: 'pub'} messages as we handle this manually in sbot/index.js
@@ -233,6 +225,9 @@ function setupContext (appName, opts, cb) {
233225
ssbConfig.connections.incoming.tunnel = [{ scope: 'public', transform: 'shs' }]
234226
ssbConfig.connections.outgoing.tunnel = [{ transform: 'shs' }]
235227

228+
// Support DHT invites (only as a client, for now)
229+
ssbConfig.connections.outgoing.dht = [{ transform: 'shs' }]
230+
236231
const redactedConfig = JSON.parse(JSON.stringify(ssbConfig))
237232
redactedConfig.keys.private = null
238233
console.dir(redactedConfig, { depth: null })

lib/depject/index.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,6 @@ module.exports = {
8585
}
8686
},
8787
invite: {
88-
dhtAcceptSheet: require('./invite/dhtAcceptSheet.js'),
89-
dhtCreateSheet: require('./invite/dhtCreateSheet.js'),
9088
invite: require('./invite/invite.js'),
9189
sheet: require('./invite/sheet.js')
9290
},

lib/depject/invite/dhtAcceptSheet.js

Lines changed: 0 additions & 76 deletions
This file was deleted.

lib/depject/invite/dhtCreateSheet.js

Lines changed: 0 additions & 77 deletions
This file was deleted.

lib/depject/invite/invite.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ const nest = require('depnest')
88
exports.needs = nest({
99
'sbot.async.publish': 'first',
1010
'sbot.async.connRememberConnect': 'first',
11+
'sbot.async.acceptDHT': 'first',
1112
'contact.async.followerOf': 'first',
1213
'keys.sync.id': 'first',
1314
'config.sync.load': 'first'
@@ -27,6 +28,10 @@ exports.create = function (api) {
2728
api.sbot.async.connRememberConnect(address, { type: 'room' }, cb)
2829
return
2930
}
31+
if (invite.startsWith('dht:')) {
32+
api.sbot.async.acceptDHT(invite, () => {})
33+
return cb(null, true)
34+
}
3035

3136
const data = ref.parseInvite(invite)
3237
const id = api.keys.sync.id()

lib/depject/page/html/render/public.js

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@ exports.needs = nest({
1818
'about.html.image': 'first',
1919
'about.obs.name': 'first',
2020
'invite.sheet': 'first',
21-
'dhtInvite.accept.sheet': 'first',
22-
'dhtInvite.create.sheet': 'first',
2321

2422
'message.html.compose': 'first',
2523
'message.async.publish': 'first',
@@ -117,17 +115,6 @@ exports.create = function (api) {
117115
'ev-click': api.invite.sheet
118116
}, i18n('+ Join Server')),
119117

120-
// disabling DHT invites until they work in sbot@13
121-
//
122-
// h('SplitButton', [
123-
// h('button -createInvite', {
124-
// 'ev-click': api.dhtInvite.create.sheet
125-
// }, i18n('Create Invite')),
126-
// h('button -acceptInvite', {
127-
// 'ev-click': api.dhtInvite.accept.sheet
128-
// }, i18n('Accept Invite'))
129-
// ]),
130-
131118
when(channelsLoading, [h('Loading')], [
132119
when(computed(recentChannels, x => x.length), [
133120
h('h2', i18n('Active Channels')),

lib/depject/sbot.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,7 @@ exports.gives = {
3030
connConnect: true,
3131
connRememberConnect: true,
3232
friendsGet: true,
33-
acceptDHT: true,
34-
createDHT: true
33+
acceptDHT: true
3534
},
3635
pull: {
3736
log: true,
@@ -215,9 +214,6 @@ exports.create = function (api) {
215214
acceptDHT: rec.async(function (opts, cb) {
216215
sbot.dhtInvite.accept(opts, cb)
217216
}),
218-
createDHT: rec.async(function (cb) {
219-
sbot.dhtInvite.create(cb)
220-
})
221217
},
222218
pull: {
223219
backlinks: rec.source(query => {

lib/server-process.js

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,6 @@ const Path = require('path')
33
const electron = require('electron')
44
const spawn = require('child_process').spawn
55
const fixPath = require('fix-path')
6-
// var DHT = require('multiserver-dht')
7-
8-
// removing DHT invites until they work in sbot@13
9-
//
10-
// function dhtTransport (sbot) {
11-
// sbot.multiserver.transport({
12-
// name: 'dht',
13-
// create: dhtConfig => {
14-
// return DHT({
15-
// keys: sbot.dhtInvite.channels(),
16-
// port: dhtConfig.por t
17-
// })
18-
// }
19-
// })
20-
// }
216

227
const createSbot = require('secret-stack')()
238
.use(require('ssb-db'))
@@ -34,8 +19,7 @@ const createSbot = require('secret-stack')()
3419
.use(require('ssb-about'))
3520
.use(require('ssb-private'))
3621
.use(require('ssb-room/tunnel/client'))
37-
// .use(require('ssb-dht-invite')) // this one must come before dhtTransport
38-
// .use(dhtTransport)
22+
.use(require('ssb-dht-invite'))
3923
.use(require('ssb-invite'))
4024
.use(require('ssb-query'))
4125
.use(require('ssb-search'))
@@ -55,9 +39,6 @@ module.exports = function (ssbConfig) {
5539
fs.writeFileSync(Path.join(ssbConfig.path, 'manifest.json'), JSON.stringify(ssbConfig.manifest))
5640
electron.ipcRenderer.send('server-started', ssbConfig)
5741

58-
// start dht invite support
59-
// context.sbot.dhtInvite.start()
60-
6142
// check if we are using a custom ssb path (which would break git-ssb-web)
6243
if (!ssbConfig.customPath) {
6344
// attempt to run git-ssb if it is installed and in path

0 commit comments

Comments
 (0)