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 🙏

© 2025 – Pkg Stats / Ryan Hefner

port-proxy

v0.2.0

Published

Listens to the specified port and forwards to the specified port.(监听指定的端口,并转发到指定端口。)

Readme

port-proxy —— Port Proxy Tool

简体中文 | English

Description

A lightweight port proxy tool that can forward traffic from one port to another, supporting TCP and UDP protocols, and can limit the transmission rate.

Getting Started

Install dependencies

npm i port-proxy

Import

import { PortProxy } from 'port-proxy'

Usage

// Create a TCP port proxy instance
const proxy = new PortProxy({
  // Source, new proxy service
  source: '127.0.0.1',
  sourcePort: 3001,
  // Target, original service being proxied
  target: '127.0.0.1',
  targetPort: 3000,
  // Whether to output detailed logs
  verbose: false,
  // Protocol type: 'tcp' or 'udp'
  protocol: 'tcp',
  // Single TCP service rate limit, unit B/s, rate limit has 5% fluctuation for each TCP connection
  limiteRate: 400 * 1024
})

// Start the proxy service
await proxy.start()

// Check if the proxy is running
const isRunning = proxy.isRunning()

// Get proxy status
const status = proxy.getStatus()

// Get active connection count
const connectionCount = proxy.getConnectionCount()

// Stop the proxy service
await proxy.stop()

Explanation

PortProxy Class

Constructor

new PortProxy(options: ProxyOptions)
Parameters
  • options: Object type, required, configuration options object

    Properties of options are as follows:

    • source: string type, required

      Listening address.

    • sourcePort: number type, required

      Listening port.

    • target: string type, required

      Target address.

    • targetPort: number type, required

      Target port.

    • verbose: boolean type, optional

      Whether to output detailed logs, default is false.

    • protocol: 'tcp' | 'udp' type, optional

      Protocol to use, default is 'tcp'.

    • limiteRate: number type, optional

      Single TCP service rate limit, unit B/s, rate limit has 5% fluctuation for each TCP connection. Default is 0 (no limit).

Methods

start() Promise<void>

Start the port forwarding proxy.

stop() Promise<void>

Stop the port forwarding proxy.

getStatus() Object

Get the proxy status.

Return value:

{
  listening: boolean, // Whether it is listening
  connections: number, // Current number of connections
  config: ProxyOptions // Current configuration
}
isRunning() boolean

Check if the proxy is running.

getConnectionCount() number

Get the number of active connections.

Command Line Usage

This library can also be used as a command line tool. After installing the package globally, you can use it directly:

npm install -g port-proxy
portproxy --source 127.0.0.1 --source-port 3001 --target 127.0.0.1 --target-port 3000 --verbose --protocol tcp --limite-rate 409600

Or use it in your project:

npx port-proxy --source 127.0.0.1 --source-port 3001 --target 127.0.0.1 --target-port 3000

Options

  • --source <IP>: Listening address
  • --source-port <port>: Listening port
  • --target <IP>: Target address
  • --target-port <port>: Target port
  • --protocol <protocol>: Protocol (default: tcp)
  • --verbose: Detailed output mode
  • --limite-rate <rate>: Single TCP service rate limit, unit B/s, default is 0 (no limit)
  • --help: Display help information

Example

portproxy --source 192.168.196.2 --source-port 14491 --target 127.0.0.1 --target-port 14490

🤝 Support

Enjoying this project? Show your support by giving it a star! ⭐

Your stars help the project gain visibility and encourage further development.