diff --git a/lib/peer.cjs b/lib/peer.cjs index 4818225..2aac6a3 100644 --- a/lib/peer.cjs +++ b/lib/peer.cjs @@ -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'}], + }, + }, }) } diff --git a/lib/plugin-hub.cjs b/lib/plugin-hub.cjs index 0ac42b5..d79862a 100644 --- a/lib/plugin-hub.cjs +++ b/lib/plugin-hub.cjs @@ -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()]) } } diff --git a/package-lock.json b/package-lock.json index ca5a25b..136309f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -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", diff --git a/package.json b/package.json index c38b656..37a8f03 100644 --- a/package.json +++ b/package.json @@ -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\"",