Socket
Socket
Sign inDemoInstall

ssb-conn

Package Overview
Dependencies
Maintainers
1
Versions
92
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ssb-conn - npm Package Compare versions

Comparing version 0.9.2 to 0.9.3

5

lib/conn-scheduler.js

@@ -69,3 +69,4 @@ "use strict";

return false;
return this.hops[data.key] > 0;
const h = this.hops[data.key];
return h > 0 && h <= 1;
};

@@ -190,3 +191,3 @@ this.start = () => {

if (this.ssb.conn.query().peersInConnection().length === 0) {
this.updateTheseConnections(_p => true, {
this.updateTheseConnections(() => true, {
quota: 1,

@@ -193,0 +194,0 @@ backoffStep: 1e3,

@@ -53,2 +53,8 @@ "use strict";

return false;
if (data.key) {
for (const other of this._hub.entries()) {
if (other[1].key === data.key)
return false;
}
}
return this._staging.stage(address, data);

@@ -55,0 +61,0 @@ };

2

package.json
{
"name": "ssb-conn",
"description": "SSB plugin for establishing and managing peer connections",
"version": "0.9.2",
"version": "0.9.3",
"homepage": "https://github.com/staltz/ssb-conn",

@@ -6,0 +6,0 @@ "main": "lib/index.js",

@@ -153,3 +153,4 @@ import ConnQuery = require('ssb-conn-query');

if (!data || !data.key) return false;
return this.hops[data.key] > 0;
const h = this.hops[data.key];
return h > 0 && h <= 1;
};

@@ -213,3 +214,3 @@

if (this.ssb.conn.query().peersInConnection().length === 0) {
this.updateTheseConnections(_p => true, {
this.updateTheseConnections(() => true, {
quota: 1,

@@ -216,0 +217,0 @@ backoffStep: 1e3,

@@ -136,2 +136,7 @@ import ConnDB = require('ssb-conn-db');

if (!!this._hub.getState(address)) return false;
if (data.key) {
for (const other of this._hub.entries()) {
if (other[1].key === data.key) return false;
}
}

@@ -138,0 +143,0 @@ return this._staging.stage(address, data);

const tape = require('tape');
const mock = require('./mock');
const TEST_KEY = '@pAhDcHjunq6epPvYYo483vBjcuDkE10qrc2tYC827R0=.ed25519';
const TEST_ADDR =
'net:localhost:9752~shs:pAhDcHjunq6epPvYYo483vBjcuDkE10qrc2tYC827R0=';
const TEST_ADDR2 =
'net:localhost:1234~shs:pAhDcHjunq6epPvYYo483vBjcuDkE10qrc2tYC827R0=';
tape('CONN refuses to stage an already connected peer', t => {
tape('CONN refuses to stage an already connected address', t => {
t.plan(4);

@@ -26,2 +29,23 @@ const ssb = mock();

tape('CONN refuses to stage an ssb key that already has a connection', t => {
t.plan(4);
const ssb = mock();
ssb.conn.connect(TEST_ADDR, {key: TEST_KEY}, (err, result) => {
t.error(err, 'no error');
t.ok(result, 'connect was succesful');
const stagingResult = ssb.conn.stage(TEST_ADDR2, {
mode: 'internet',
key: TEST_KEY,
});
t.equals(stagingResult, false, 'stage() should refuse');
const entries1 = Array.from(ssb.conn.staging().entries());
t.equals(entries1.length, 0, 'there is nothing in staging');
t.end();
});
});
tape('automatically unstage upon connHub "connected" event', t => {

@@ -28,0 +52,0 @@ t.plan(6);

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc