rareivy/portscanner
GitHub: rareivy/portscanner
一个零依赖的 Node.js 快速 TCP 端口扫描器,支持命令行和 API 两种方式扫描指定端口范围内的开放端口。
Stars: 0 | Forks: 0
# portscanner
适用于 Node.js 的快速 TCP 端口扫描器。支持可配置的并发和超时来扫描端口范围。零依赖。
## 用法
```
node src/cli.js localhost 1 1024
```
```
Scanning localhost ports 1-1024...
✓ Port 22 is open
✓ Port 80 is open
✓ Port 443 is open
Done in 2.3s — 3 open port(s) found
```
## API
```
const { scan, checkPort } = require('./src');
// Scan a range
const openPorts = await scan('example.com', 80, 443, {
concurrency: 50,
timeout: 2000,
onOpen: (port) => console.log(`Found: ${port}`),
});
// Check a single port
const isOpen = await checkPort('localhost', 3000);
```
## 选项
| 选项 | 默认值 | 描述 |
|--------|---------|-------------|
| `concurrency` | `100` | 最大并发连接数 |
| `timeout` | `1500` | 单个端口超时时间(毫秒) |
| `onOpen` | `null` | 每个开放端口触发的回调 |
## 许可证
MIT
标签:GNU通用公共许可证, MITM代理, Node.js, SOC Prime, 开发工具, 插件系统, 数据可视化, 数据统计, 端口扫描, 网络工具, 自定义脚本