works with hub-client

This commit is contained in:
Andre Staltz 2023-06-16 12:29:09 +03:00
parent c5085c64cf
commit 6e278ebf34
No known key found for this signature in database
GPG Key ID: 9EDE23EA7E8A4890
4 changed files with 28 additions and 17 deletions

View File

@ -13,10 +13,16 @@ module.exports = function startPeer() {
.call(null, {
caps: { shse: 'p2pLq5VZKvNWaaafMUEcxH9BKm2WjNBCxsc8TRQV5gS' },
keypair,
port: 8008,
host: '0.0.0.0',
conn: {
autostart: false,
},
connections: {
incoming: {
net: [{scope: 'public', transform: 'shse', port: 8008, host: '0.0.0.0'}],
},
outgoing: {
net: [{transform: 'shse'}],
},
},
})
}

View File

@ -29,14 +29,17 @@ module.exports = {
allow: ['createTunnel', 'ping', 'attendants', 'createToken'],
},
},
init(me) {
if (!me.conn || !me.conn.connect) {
init(sstack) {
if (!sstack.conn || !sstack.conn.connect) {
throw new Error('tunnel plugin is missing the required ssb-conn plugin')
}
debug('running multiserver at %s', sstack.getAddress('public'))
// Ensure that incoming connections are only from members
me.auth.hook(function (fn, args) {
sstack.auth.hook(function (fn, args) {
const [incomingId, cb] = args
cb(null, true)
// fn.apply(this, args)
// FIXME:
// if (members.has(incomingId)) {
@ -51,7 +54,7 @@ module.exports = {
const notifyAttendants = Notify()
pull(
me.conn.hub().listen(),
sstack.conn.hub().listen(),
pull.filter(
({ type }) => type === 'connecting-failed' || type === 'disconnected'
),
@ -70,10 +73,10 @@ module.exports = {
return {
attendants() {
const clientId = this.id
if (clientId && clientId !== me.id) {
if (clientId && clientId !== sstack.id) {
debug('welcome %s', clientId)
if (!attendants.has(clientId)) {
attendants.set(clientId, me.peers[clientId][0])
attendants.set(clientId, sstack.peers[clientId][0])
notifyAttendants([...attendants.keys()])
}
}

16
package-lock.json generated
View File

@ -22,7 +22,7 @@
"rehype-stringify": "9.0.3",
"remark-parse": "10.0.2",
"remark-rehype": "10.1.0",
"secret-handshake-ext": "0.0.4",
"secret-handshake-ext": "0.0.6",
"secret-stack": "6.4.1",
"ssb-caps": "1.1.0",
"ssb-conn": "6.0.4",
@ -2906,12 +2906,13 @@
}
},
"node_modules/secret-handshake-ext": {
"version": "0.0.4",
"resolved": "https://registry.npmjs.org/secret-handshake-ext/-/secret-handshake-ext-0.0.4.tgz",
"integrity": "sha512-imReIhhpvLLXw+4arj4xBl9bei/4VArqfA/rQwCc7RSXpZBwUX9TC/pGuPAClRLiLAveyKHKTeTeqyB/QdZ+og==",
"version": "0.0.6",
"resolved": "https://registry.npmjs.org/secret-handshake-ext/-/secret-handshake-ext-0.0.6.tgz",
"integrity": "sha512-cAyQpQYdzvIVhBWzG4qKWBkJh+AZWBP/ny0B5DiMgWWTeISucwm99Kw0noW6SmsbrG+UJNcSpiMYzJFWotpfoQ==",
"dependencies": {
"b4a": "~1.6.4",
"bs58": "~5.0.0",
"debug": "^4.3.4",
"pull-box-stream": "~1.0.13",
"pull-handshake": "~1.1.4",
"pull-stream": "~3.7.0",
@ -5972,12 +5973,13 @@
}
},
"secret-handshake-ext": {
"version": "0.0.4",
"resolved": "https://registry.npmjs.org/secret-handshake-ext/-/secret-handshake-ext-0.0.4.tgz",
"integrity": "sha512-imReIhhpvLLXw+4arj4xBl9bei/4VArqfA/rQwCc7RSXpZBwUX9TC/pGuPAClRLiLAveyKHKTeTeqyB/QdZ+og==",
"version": "0.0.6",
"resolved": "https://registry.npmjs.org/secret-handshake-ext/-/secret-handshake-ext-0.0.6.tgz",
"integrity": "sha512-cAyQpQYdzvIVhBWzG4qKWBkJh+AZWBP/ny0B5DiMgWWTeISucwm99Kw0noW6SmsbrG+UJNcSpiMYzJFWotpfoQ==",
"requires": {
"b4a": "~1.6.4",
"bs58": "~5.0.0",
"debug": "^4.3.4",
"pull-box-stream": "~1.0.13",
"pull-handshake": "~1.1.4",
"pull-stream": "~3.7.0",

View File

@ -35,7 +35,7 @@
"pull-notify": "0.1.2",
"pull-stream": "3.7.0",
"secret-stack": "6.4.1",
"secret-handshake-ext": "0.0.4",
"secret-handshake-ext": "0.0.6",
"ssb-caps": "1.1.0",
"ssb-conn": "6.0.4",
"unified": "10.1.2",
@ -50,7 +50,7 @@
},
"scripts": {
"setup": "npm install --omit=dev",
"start": "DEBUG=*,-avvio node lib/index.js",
"start": "DEBUG=*,-avvio,-shse node lib/index.js",
"test": "node --test",
"format-code": "prettier --write \"(lib|test)/**/*.(c)?js\"",
"format-code-staged": "pretty-quick --staged --pattern \"(lib|test)/**/*.(c)?js\"",