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

@dignetwork/dig-nat-tools

v1.1.1

Published

Decentralized P2P file transfer with NAT traversal

Readme

DIG NAT Tools

Decentralized P2P file transfer with NAT traversal.

Features

  • TCP, UDP, WebRTC, and GUN relay protocol support
  • NAT traversal using NAT-PMP and PCP
  • Public IP address discovery
  • Multi-peer downloads
  • Progress tracking

Installation

npm install @dignetwork/dig-nat-tools

Usage

Check the examples directory for complete usage examples:

  • simple-example.ts: Simple file transfer example
  • host-example.ts: Setting up a file host
  • client-example.ts: Client downloading a file
  • multi-peer-client-example.ts: Downloading from multiple peers
  • ip-discovery-example.ts: Discovering public IP addresses

Development

Setup

npm install

Building

npm run build

Running Tests

The project includes a comprehensive test suite that tests file transfers using each supported protocol (TCP, UDP, WebRTC, and GUN relay) as well as multi-protocol downloads.

There are several test commands available:

# Run all tests (may not work reliably in CI environments)
npm test

# Run only the protocol tests (may fail in CI environments)
npm run test:protocols

# Run specific protocol tests (not recommended for CI)
npm run test:tcp    # TCP tests only
npm run test:udp    # UDP tests only
npm run test:webrtc # WebRTC tests only
npm run test:gun    # GUN relay tests only
npm run test:multi  # Multi-protocol tests only

# Run all protocol tests sequentially with better error handling
npm run test:sequential

# CI-safe testing options (recommended for CI environments)
npm run test:all-safe       # Run all tests in a CI-safe manner with mocking (best for CI)
npm run test:ci-safe        # Run only the fully mocked network manager tests
npm run test:protocols-comprehensive  # Run all protocol tests with mocking enabled
npm run test:protocols-debug # Run protocol tests with enhanced debugging output

# Run individual protocol tests with mocking (safe for CI)
npm run test:tcp-safe    # TCP tests with mocking
npm run test:udp-safe    # UDP tests with mocking
npm run test:webrtc-safe # WebRTC tests with mocking
npm run test:gun-safe    # GUN relay tests with mocking
npm run test:multi-safe  # Multi-protocol tests with mocking

Note: P2P protocol tests can be flaky in CI environments due to network constraints. For reliable CI testing, use the test:all-safe script which enables comprehensive mocking of all network operations, ensuring tests run consistently without actual network connections. For more details on the testing approach, see the README-TESTING.md file.

Protocols

This library uses multiple protocols to transfer files:

  1. TCP - Most reliable, but requires port forwarding or NAT traversal
  2. UDP - Can work through some NATs, but less reliable
  3. WebRTC - Works through most NATs using STUN/TURN servers
  4. GUN relay - Works through strict firewalls by using a relay, but slower

License

MIT