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 🙏

© 2024 – Pkg Stats / Ryan Hefner

ataraxia-tcp

v0.12.0

Published

TCP transport for Ataraxia P2P messaging

Downloads

35

Readme

ataraxia-tcp

npm version Dependencies Typedoc

TCP transport for Ataraxia. This transport can discover and automatically connect to other peers using a discovery. A discovery is available based on mDNS and DNS-SD that automatically connects to other instances on the same local network.

Installation

npm install ataraxia-tcp

Simple usage

Create a TCP transport that will bind to a random free port and announce its availability on the local network:

import { Network, AnonymousAuth } from 'ataraxia';
import { TCPTransport, TCPPeerMDNSDiscovery } from 'ataraxia-tcp';

// Setup a network with anonymous authentication
const net = new Network({
  name: 'name-of-your-app-or-network',
  
  transports: [
    new TCPTransport({
      // Discover other peers on the same physical network
      discovery: new TCPPeerMDNSDiscovery(),

      // Use anonymous authentication
      authentication: [
        new AnonymousAuth()
      ]
    })
  ]
});

// Join the network
await net.join();

Well-known ports and manual peers

In some cases you want to run a network that can be connected to from outside your local network. In that case its possible to define a port that the TCP transport will listen to:

import { Network, AnonymousAuth } from 'ataraxia';
import { TCPTransport, TCPPeerMDNSDiscovery } from 'ataraxia-tcp';

// Setup a network with anonymous authentication
const net = new Network({
  name: 'name-of-your-app-or-network',

  transports: [
    new TCPTransport({
      // A well known port - define your own or even better use a config file,
      port: 30000,

      // Use anonymous authentication
      authentication: [
        new AnonymousAuth()
      ]
    })
  ]
});

// Join the network
await net.join();

Another instance can then connect to that specific port:

import { Network, AnonymousAuth } from 'ataraxia';
import { TCPTransport, TCPPeerMDNSDiscovery } from 'ataraxia-tcp';

// Setup a network with anonymous authentication
const net = new Network({
  name: 'name-of-your-app-or-network'
});

const tcp = new TCPTransport({
  authentication: [
    new AnonymousAuth()
  ]
}):

// Add a manual addressing to the peer
tcp.addManualPeer({
  host: 'address-to-server',
  port: 30000
});

net.addTransport(tcp);

// Join the network
await net.join();

Ataraxia will attempt to connect to the manually added peers and will attempt to keep the connection available.

API

TCPTransport

  • new TCPTransport(options)

    Create a new instance of this transport.

    • options
      • port?: number, port number that the server should bind to. Leave undefined for automatic assignment.
      • discovery?: TCPPeerDiscovery, discovery instance used to discover and announce availability to other peers.
      • authentication: AuthProvider[], array of authentication providers that this transport will use.
  • port: number

    Port number bound to, will be 0 if no server was bound

  • addManualPeer(hostAndPort: { host: string, port: number }): void

    Add a peer that should be manually connected to.

TCPPeerMDNSDiscovery

  • new TCPPeerMDNSDiscovery()

    Create a discovery instance that will use mDNS and DNS-SD on the local physical network.