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

@cliz/inlets

v1.3.0

Published

Cloud Native Tunnel

Readme

Inlets

Cloud Native Tunnel - 支持 HTTP 和 TCP 隧道的云原生隧道服务

功能特性

  • ✅ HTTP & TCP 双隧道支持
  • ✅ Token / Credentials / Public 三种认证方式
  • ✅ 自动重连、心跳保活
  • ✅ 流量统计(按客户端统计)
  • 带宽限制(全局和客户端级别)
  • ✅ 配置文件热重载
  • ✅ 通知集成(Webhook)

快速开始

服务器端

# 使用配置文件启动
inlets server --domain tunnels.example.com --config /path/to/inlets.yml

# 或使用命令行参数
inlets server --domain tunnels.example.com --token your-token

客户端

# HTTP 隧道
inlets http 127.0.0.1:9000 -s myapp -t token

# TCP 隧道
inlets tcp 127.0.0.1:22 -p 20100 --credentials clientId:clientSecret

配置文件

基础配置

创建配置文件 inlets.yml

domain: tunnels.example.com
port: 8080
tcpPort: 8443
secure: true
token: your-shared-token

客户端配置

domain: tunnels.example.com

clients:
  - clientId: client-a
    clientSecret: secret-a
  - clientId: client-b
    clientSecret: secret-b

带宽限制配置

全局带宽限制

为所有客户端设置默认带宽限制:

domain: tunnels.example.com
token: your-token

bandwidthLimits:
  global:
    uploadBytesPerSecond: 1048576      # 1 MB/s 上传
    downloadBytesPerSecond: 2097152    # 2 MB/s 下载

客户端级带宽限制

为特定客户端设置独立的带宽限制:

domain: tunnels.example.com

clients:
  - clientId: premium-client
    clientSecret: premium-secret
    bandwidthLimit:
      uploadBytesPerSecond: 5242880      # 5 MB/s
      downloadBytesPerSecond: 10485760   # 10 MB/s

bandwidthLimits:
  global:
    uploadBytesPerSecond: 1048576        # 默认:1 MB/s
    downloadBytesPerSecond: 2097152      # 默认:2 MB/s
  clients:
    standard-client:
      uploadBytesPerSecond: 2048000      # 2 MB/s
      downloadBytesPerSecond: 4096000    # 4 MB/s

带宽限制规则:

  1. 客户端级别限制:如果配置了客户端限制,该客户端不能超过自己的限制
  2. 全局限制:如果配置了全局限制,所有客户端的总带宽不能超过全局限制
  3. 双重限制:如果同时配置了客户端限制和全局限制,两个限制都需要满足
  4. 优先级:客户端限制 > 全局限制 > 无限制

带宽单位:

  • 使用字节/秒(bytes per second)
  • 1 MB/s = 1048576 字节/秒
  • 1 KB/s = 1024 字节/秒

完整配置示例

domain: tunnels.example.com
port: 8080
tcpPort: 8443
secure: true
token: your-shared-token

clients:
  - clientId: premium-client
    clientSecret: premium-secret
    bandwidthLimit:
      uploadBytesPerSecond: 5242880      # 5 MB/s
      downloadBytesPerSecond: 10485760   # 10 MB/s
  - clientId: standard-client
    clientSecret: standard-secret

bandwidthLimits:
  global:
    uploadBytesPerSecond: 1048576        # 1 MB/s
    downloadBytesPerSecond: 2097152      # 2 MB/s
  clients:
    standard-client:
      uploadBytesPerSecond: 2048000      # 2 MB/s
      downloadBytesPerSecond: 4096000    # 4 MB/s

notification:
  provider: webhook
  url: https://hooks.example.com/inlets
  interval: 60000

配置说明

服务器配置项

| 配置项 | 说明 | 默认值 | | --- | --- | --- | | domain | 服务器域名(必填) | - | | port | HTTP 服务端口 | 8080 | | tcpPort | TCP 服务端口 | 8443 | | secure | 是否使用 HTTPS | false | | token | 共享 token(token 认证模式) | - | | clients | 客户端列表(credentials 认证模式) | - | | bandwidthLimits | 带宽限制配置 | - | | notification | 通知配置 | - |

带宽限制配置项

| 配置项 | 说明 | 单位 | | --- | --- | --- | | uploadBytesPerSecond | 上行带宽限制 | 字节/秒 | | downloadBytesPerSecond | 下行带宽限制 | 字节/秒 |

客户端配置项

| 配置项 | 说明 | | --- | --- | | clientId | 客户端 ID(必填) | | clientSecret | 客户端密钥(必填) | | bandwidthLimit | 客户端带宽限制(可选) | | config | 客户端特定配置(可选) |

配置文件热重载

服务器支持配置文件热重载。当配置文件发生变化时,服务器会自动重新加载配置,包括:

  • 客户端列表
  • 带宽限制设置
  • 通知配置

注意: 带宽限制的更改会在新的连接上生效,现有连接会继续使用旧的限制直到断开。

带宽限制实现

  • 算法:使用令牌桶算法实现平滑的带宽限制
  • 检查时机:在数据发送/接收时实时检查
  • 超限处理:超过限制的数据会被延迟或丢弃
  • 性能影响:带宽限制会增加少量 CPU 开销,通常可以忽略不计

更多文档

许可证

MIT