ssb-conn-hub
Advanced tools
Comparing version 0.0.10 to 0.1.0-rc1
@@ -109,3 +109,3 @@ "use strict"; | ||
var peer = _this._getPeerByKey(rpc.id); | ||
if (!peer) { | ||
if (!peer && isClient) { | ||
rpc._connectRetries = rpc._connectRetries || 0; | ||
@@ -118,8 +118,12 @@ if (isClient && rpc._connectRetries < 4) { | ||
} | ||
else { | ||
debug('peer %s initiated an RPC connection with us', rpc.id); | ||
else if (isClient) { | ||
debug('our secret-stack initiated an RPC connection with %s but not ' + | ||
'through the ssb-conn-hub connect() API', rpc.id); | ||
} | ||
return; | ||
} | ||
var _a = __read(peer, 2), address = _a[0], data = _a[1]; | ||
if (!peer) { | ||
debug('peer %s initiated an RPC connection with us', rpc.id); | ||
} | ||
var _a = __read(!peer ? [rpc.stream.address, { key: rpc.id }] : peer, 2), address = _a[0], data = _a[1]; | ||
var key = data.key; | ||
@@ -126,0 +130,0 @@ var state = 'connected'; |
{ | ||
"name": "ssb-conn-hub", | ||
"description": "Module that manages active connections to SSB peers", | ||
"version": "0.0.10", | ||
"version": "0.1.0-rc1", | ||
"homepage": "https://github.com/staltz/ssb-conn-hub", | ||
@@ -22,6 +22,7 @@ "main": "lib/index.js", | ||
"devDependencies": { | ||
"@staltz/secret-stack": "6.2.1-1", | ||
"@types/node": "^11.10.4", | ||
"pull-stream": "^3.6.9", | ||
"ssb-server": "~13.6.3", | ||
"ssb-keys": "~7.1.5", | ||
"ssb-caps": "~1.1.0", | ||
"ssb-keys": "~7.2.0", | ||
"tape": "^4.9.2", | ||
@@ -28,0 +29,0 @@ "typescript": "3.3.x" |
@@ -11,2 +11,7 @@ # ssb-conn-hub | ||
**Prerequisites:** | ||
- Requires **Node.js 6.5** or higher | ||
- Requires `secret-stack@^6.3.0` | ||
This module is only used to create an SSB CONN plugin, not used directly by applications. A ConnHub instance should be available on the CONN plugin, with the following API: | ||
@@ -13,0 +18,0 @@ |
@@ -103,2 +103,3 @@ import {ConnectionData as Data, ListenEvent, Address} from './types'; | ||
// isClient means "we are the client" | ||
private _onRpcConnect = (rpc: any, isClient: boolean) => { | ||
@@ -113,3 +114,3 @@ // Don't process self connections, whatever that means: | ||
if (!peer) { | ||
if (!peer && isClient) { | ||
// If peer was not registered through the public API, try again a few times | ||
@@ -123,4 +124,8 @@ // in case there was a race condition with ConnHub::connect() | ||
rpc._connectRetries += 1; | ||
} else { | ||
debug('peer %s initiated an RPC connection with us', rpc.id); | ||
} else if (isClient) { | ||
debug( | ||
'our secret-stack initiated an RPC connection with %s but not ' + | ||
'through the ssb-conn-hub connect() API', | ||
rpc.id, | ||
); | ||
} | ||
@@ -130,3 +135,8 @@ return; | ||
const [address, data] = peer; | ||
if (!peer) { | ||
// Here, weAreClient is surely `false` | ||
debug('peer %s initiated an RPC connection with us', rpc.id); | ||
} | ||
const [address, data] = !peer ? [rpc.stream.address, {key: rpc.id}] : peer; | ||
const key = data.key; | ||
@@ -133,0 +143,0 @@ |
const tape = require('tape'); | ||
const ssbKeys = require('ssb-keys'); | ||
const createSsbServer = require('ssb-server'); | ||
const SecretStack = require('@staltz/secret-stack'); | ||
const caps = require('ssb-caps'); | ||
const pull = require('pull-stream'); | ||
const ConnHub = require('../lib'); | ||
const ssbServer = createSsbServer({ | ||
const ssbServer = SecretStack({ | ||
appKey: caps.shs, | ||
temp: 'connhub', | ||
keys: ssbKeys.generate(), | ||
timeout: 1000, | ||
}); | ||
})(); | ||
@@ -13,0 +15,0 @@ const TEST_KEY = '@pAhDcHjunq6epPvYYo483vBjcuDkE10qrc2tYC827R0=.ed25519'; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
114649
927
42
7