Socket
Socket
Sign inDemoInstall

ssb-conn

Package Overview
Dependencies
96
Maintainers
1
Versions
92
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.15.2 to 0.16.0

2

lib/conn-scheduler.d.ts

@@ -24,3 +24,3 @@ export declare class ConnScheduler {

private updateSoon;
private markDefunct;
private removeDefunct;
private populateWithSeeds;

@@ -27,0 +27,0 @@ private setupPubDiscovery;

@@ -45,5 +45,2 @@ "use strict";

}
function notDefunct(peer) {
return peer[1].defunct !== true;
}
function take(n) {

@@ -117,3 +114,3 @@ return (arr) => arr.slice(0, Math.max(n, 0));

for (let peer of this.ssb.conn.dbPeers()) {
const [address, { source, type, failure }] = peer;
const [address, { source, type }] = peer;
if (source === 'local' ||

@@ -125,4 +122,4 @@ source === 'bt' ||

}
if ((failure !== null && failure !== void 0 ? failure : 0 > 200)) {
this.markDefunct(peer);
if (isDefunct(peer)) {
this.removeDefunct(address);
}

@@ -235,3 +232,2 @@ }

peersDown
.filter(notDefunct)
.filter(p => !this.weBlockThem(p))

@@ -252,3 +248,2 @@ .filter(canBeConnected)

.peersConnectable('db')
.filter(notDefunct)
.filter(p => !this.weBlockThem(p))

@@ -260,3 +255,2 @@ .filter(([, data]) => data.autoconnect === false)

.peersConnectable('staging')
.filter(isDefunct)
.filter(this.weBlockThem)

@@ -375,6 +369,4 @@ .forEach(([addr]) => this.ssb.conn.unstage(addr));

}
markDefunct([addr, data]) {
this.ssb.conn
.db()
.replace(addr, { defunct: true, birth: data.birth, autoconnect: false });
removeDefunct(addr) {
this.ssb.conn.db().update(addr, { defunct: void 0, autoconnect: false });
}

@@ -381,0 +373,0 @@ populateWithSeeds() {

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

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

@@ -108,4 +108,2 @@ <div style="text-align:center" align="center">

🔸 `defunct?: boolean`: a flag that (when `true`) indicates that this peer was deemed "no longer operative" by the default CONN scheduler, after hundreds of failed attempts were made to connect with it
🔸 `name?: string`: a nickname for this peer, when there isn't an [ssb-about](https://github.com/ssbc/ssb-about) name

@@ -187,3 +185,3 @@

In none of the cases above shall we connect to a peer that we block, not those that are marked "defunct". In addition to the above, the following actions happen automatically every (approximately) 1 second:
In none of the cases above shall we connect to a peer that we block. In addition to the above, the following actions happen automatically every (approximately) 1 second:

@@ -198,3 +196,3 @@ - Connect to (at most 3) staged peers we follow

- For other types of peers, "too long" means 10sec
- Stage non-blocked non-defunct peers that are in ConnDB marked as `autoconnect=false`
- Stage non-blocked peers that are in ConnDB marked as `autoconnect=false`
- Unstage peers that have just been blocked by us

@@ -209,3 +207,2 @@ - Unstage LAN peers that haven't been updated in ConnStaging in 10 seconds

- Remove database entries for any LAN or Bluetooth peers (these are rediscovered just-in-time)
- Mark database entries "defunct" if, after 200 attempts, we still fail to connect with them

@@ -212,0 +209,0 @@ **Other events:**

@@ -50,10 +50,6 @@ import ConnQuery = require('ssb-conn-query');

function isDefunct(peer: Peer): boolean {
function isDefunct(peer: Peer | [string, DBData]): boolean {
return peer[1].defunct !== true;
}
function notDefunct(peer: Peer): boolean {
return peer[1].defunct !== true;
}
function take(n: number) {

@@ -227,3 +223,2 @@ return <T>(arr: Array<T>) => arr.slice(0, Math.max(n, 0));

peersDown
.filter(notDefunct)
.filter(p => !this.weBlockThem(p))

@@ -249,3 +244,2 @@ .filter(canBeConnected)

.peersConnectable('db')
.filter(notDefunct)
.filter(p => !this.weBlockThem(p))

@@ -255,7 +249,6 @@ .filter(([, data]) => data.autoconnect === false)

// Purge staged peers that are now blocked or defunct
// Purge staged peers that are now blocked
this.ssb.conn
.query()
.peersConnectable('staging')
.filter(isDefunct)
.filter(this.weBlockThem)

@@ -395,6 +388,4 @@ .forEach(([addr]) => this.ssb.conn.unstage(addr));

private markDefunct([addr, data]: [string, DBData]) {
this.ssb.conn
.db()
.replace(addr, {defunct: true, birth: data.birth, autoconnect: false});
private removeDefunct(addr: string) {
this.ssb.conn.db().update(addr, {defunct: void 0, autoconnect: false});
}

@@ -539,3 +530,3 @@

for (let peer of this.ssb.conn.dbPeers()) {
const [address, {source, type, failure}] = peer;
const [address, {source, type}] = peer;
if (

@@ -549,4 +540,4 @@ source === 'local' ||

}
if (failure ?? 0 > 200) {
this.markDefunct(peer);
if (isDefunct(peer)) {
this.removeDefunct(address);
}

@@ -553,0 +544,0 @@ }

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc