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

@zkung/portcli

v0.1.0

Published

CLI for querying and managing local firewall port access on the LAN

Readme

portcli

一个轻量 Node CLI,用来查询、打开、关闭本机端口的防火墙访问规则,并尽量把范围限制在当前局域网,方便同一网络下的另一台机器访问你的服务。

功能

  • 查询某个端口当前是否有进程在监听
  • 查询该端口是否已经被系统防火墙放行
  • 默认按本机局域网网段放行,而不是直接暴露给所有来源
  • 提示当前局域网地址,方便另一台机器直接访问

适用平台

  • Linux: 优先支持 ufw,其次支持 firewalldiptables
  • Windows: 支持 netsh advfirewall
  • macOS: 仅支持查询监听状态;端口级防火墙自动管理暂未实现

安装

在当前仓库里直接使用:

npm link

然后即可执行:

portcli query 3000

也可以不全局安装,直接用:

node bin/portcli.js query 3000

用法

portcli query <port> [--protocol tcp|udp] [--json]
portcli open <port> [--protocol tcp|udp] [--scope localnet|any] [--source <CIDR/IP>] [--json]
portcli close <port> [--protocol tcp|udp] [--scope localnet|any] [--source <CIDR/IP>] [--json]
portcli localnet [--json]

示例

查询端口:

portcli query 3000

仅对当前局域网放行端口:

sudo portcli open 3000

只允许指定网段访问:

sudo portcli open 3000 --source 192.168.1.0/24

对所有来源放行:

sudo portcli open 3000 --scope any

关闭之前放行的规则:

sudo portcli close 3000
sudo portcli close 3000 --scope any

重要说明

放行防火墙端口不等于服务一定能从局域网访问。如果你的服务只监听在 127.0.0.1,另一台机器依旧无法连上。你需要确保应用监听在:

0.0.0.0

例如:

  • Node/Express: app.listen(3000, '0.0.0.0')
  • Vite: vite --host 0.0.0.0
  • Python: python -m http.server 3000 --bind 0.0.0.0

备注

  • iptables 模式下新增的规则通常不会自动持久化到重启后
  • 某些云主机或路由器还会有额外安全组/ACL,需要单独放行