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

hyproxy

v0.2.1

Published

Proxy TCP connections over hypercore-protocol

Downloads

14

Readme

hyproxy

A peer-to-peer proxy server and client that uses Hypercore Protocol to proxy TCP connections over hyperswarm and hypercore-protocol.

This provides an easy way to e.g. share an HTTP server running on your computer with friends, without having to deal with port forwardings etc, because Hypercore Protocol handles this for you.

This is an experiment and not yet tested for anything serious.

  • When opening an inbound proxy server, a random key will be created and printed
  • Anyone who knows this key can connect to the proxy and expose it as if it were a local server
  • There can be more than one inbound proxy per key. When connecting, currently whatever peer answers first is used, and others are fallbacks if the first fails.
  • TODO: Add optional capability creation when opening inbound proxies and verification when connecting to them

Installation

npm install -g hyproxy

Example

Let's say you want to share a HTTP server from your computer with friends. Maybe to quickly share some files, or to test some web app, or whatever. For example, you can npm install -g http-server for a simple http server.

Now, you can do the following:

$ http-server /some/directory

Starting up http-server, serving .
Available on:
  http://127.0.0.1:8080

$ hyproxy listen -p 8080

inbound proxy to localhost:8080 listening.
access via f1dd4fa6801a659168c48eab3018f168a621f58677f5cfa6e495da16a7dd5218

and then send the printed long key to others. they can then do:

$ hyproxy connect -k f1dd4fa6801a659168c48eab3018f168a621f58677f5cfa6e495da16a7dd5218
outbound proxy to f1dd4fa6801a659168c48eab3018f168a621f58677f5cfa6e495da16a7dd5218 opened.
access via localhost:9999

and then your friends can open http://localhost:9999 to access the HTTP server you just opened.

Command-line usage

USAGE: hyproxy [options] <listen|connect>

Options in listen mode:
 -p, --port     Port to proxy to (required)
 -h, --host     Hostname to proxy to (default: localhost)
 -s, --storage  Storage directory to persist keys across restarts (optional)

Options in connect mode:
 -k, --key      Key to connect to (required)
 -p, --port     Port for local proxy server (default: 9990 or a free port)
 -h, --host     Hostname for local proxy server (default: localhost)

API usage

const HyperProxy = require('hyproxy')
const hyproxy = new HyperProxy({ storage: '/tmp/hyproxy' })
await hyproxy.outbound(key, port, host)

proxy = new HyperProxy(opts)

Create a new proxy manager.

Options include:

  • storage: Storage to persist keys (optional, default to in-memory)
  • corestore: Pass your corestore instance (optional)
  • networker: Pass your @corestore/networker instance (optional)

await proxy.outbound(key, port, host)

Create a new outbound proxy that connects to a peer on key and exposes a local proxy server on host:port.

  • key: The key to an inbound hyproxy server (required)
  • port: Port for local proxy server (defaults to a free port)
  • host: Hostname on which the local proxy server binds (defaults to localhost)

Returns an object with { key, port, host }.

await proxy.inbound(key, port, host)

Create a new inbound proxy that listens for peers on key and forwards connections to host:port.

  • key: Hypercore key to accept connections on. May be null, then the key will be derived so that it stays the same for the same host:port pairs (if storage is not inmemory)
  • port: Port to forward connections to (required)
  • host: Host to forward connections to

Returns an object with { key, port, host }.