npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

ssb-tunnel

v2.0.0

Published

tunnel multiserver connections through ssb pubs

Readme

ssb-tunnel

Indirectly connect to a peer by tunneling through another connection. If A is connected to B, and C is connected to B, this allows C to connect to A by using B as a proxy or "portal".

With this module, a peer A with an unstable IP address can make a long term connection to a portal B, another peer C can then connect to that portal, and tunnel back up the client connection C->B, giving us a connect through B, C-(B)->A.

,---,      ,---,     ,---,
|   |----->|   |<----|   |
| A |<=====|-B-|<====| C |
|   |----->|   |<----|   |
`---`      `---`     `---`

A connects to B, and waits to receive tunnel connections. C connects to B, and then requests a tunnel through that connection (B-C) to A. B calls A, creating an incomming tunnel, and attaches one end to C's request, C then uses the standard handshake to authenticate A.

Notice that for the tunnel, A is the server and C is the client (client calls, server answers) but B is just the portal. The tunnel is inside the outer connections, which means it is encrypted twice. This means A and C can mutually authenticate each other, and B cannot see the content of their connection.

The arrows represent the direction of the connection - from the client, pointing to the server. Notice the B<=C tunnel is the same direction as the B<-C container, but the A<=B tunnel is the opposite direction as the A->B container.

address

tunnel addresses are multiserver style:

tunnel:<portal_id>:<target_id>:<instance>? for example: tunnel:@7MG1hyfz8SsxlIgansud4LKM57IHIw2Okw/hvOdeJWw=.ed25519:@1b9KP8znF7A4i8wnSevBSK2ZabI/Re4bYF/Vh3hXasQ=.ed25519~shs:7MG1hyfz8SsxlIgansud4LKM57IHIw2Okw/hvOdeJWw= (instance is optional)

It is assumed that a peer who wishes to be a client to target already has a means to connect to portal. The address of the portal is left out, so that the client can use anything, and also, to better preserve the privacy of the portal.

For the protocol portion of the multiserver address, tunnel:portal:target:instance this will include the shs portion for the portal. instance is just an integer that tells the server which ssb-tunnel instance the client wants to connect to if there are multiple.

target is a ssb feed id, which represents the peer. This tells the portal that C wants a connection to A. portal tells A how to connect to B.

config

Assuming this plugin is already installed and enabled on your pub server. You need to configure sbot with an incoming section so that it can receive tunnel connections:

incoming: {
  tunnel: [{scope: 'public', portal: <pub_id>, transform:'shs'}]
}

then, another peer will need to have the outgoing config:

outgoing: {
  tunnel: [{transform:'shs'}]
}

and have an address for pub, can do: sbot.gossip.connect('tunnel:<pub_id>:<your_id>~shs:your_key', function (err, rpc) {...}) and they'll have connection through pub to you!

privacy ideas

Instead of revealing the id of the portal, just use the hmac(portal_id, your_id) so peers that do not know of the portal do not learn about it from your address. That way only friends can connect to you.

how it works behind the scenes

for 3 peers, A, B, and C. A being the client-side server, which will receive the tunnel connection, B being the portal, and C being the client who connects to A via B.

First A connects to B normally, then calls B.tunnel.announce() This informs B that A would like to receive connections tunneled though B. (B puts A into a table of endpoints it can provide tunnels to)

Then C connects to B, and then calls B.tunnel.connect({id: A.id}) B then checks if it can provide a connection to A, which it can, and calls endpoints[A.id].tunnel.connect({id: A}) returning this stream to B (B is now connected to A via C).

B then initiates a secret-handshake through the tunnel, hiding subsequent content from B.

License

MIT