Skip to content

Commit d2b0765

Browse files
author
Taois
committed
fix: docs error
1 parent 1535355 commit d2b0765

File tree

1 file changed

+56
-12
lines changed

1 file changed

+56
-12
lines changed

README.md

Lines changed: 56 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,12 @@
1212
- 🎨 现代化 Web 演示界面
1313
- 📦 支持打包成二进制文件,无需安装 Node.js
1414

15+
## 系统要求
16+
17+
- **Chrome 浏览器**: 系统需要安装 Chrome 浏览器(Puppeteer 依赖)
18+
- **Node.js**: 从源码运行需要 Node.js >= 18.0.0
19+
- **操作系统**: 支持 Windows、Linux、macOS
20+
1521
## 快速开始
1622

1723
### 方式一:使用二进制文件(推荐)
@@ -26,12 +32,22 @@
2632

2733
3. 直接运行二进制文件:
2834
```bash
29-
# Windows
35+
# Windows - 默认端口启动
3036
./pup-sniffer-win.exe
3137

32-
# Linux/macOS
38+
# Windows - 指定端口启动
39+
./pup-sniffer-win.exe -port 8080
40+
41+
# Linux/macOS - 默认端口启动
3342
./pup-sniffer-linux
3443
./pup-sniffer-macos
44+
45+
# Linux/macOS - 指定端口启动
46+
./pup-sniffer-linux -port 8080
47+
./pup-sniffer-macos -port 8080
48+
49+
# 查看帮助信息
50+
./pup-sniffer-win.exe --help
3551
```
3652

3753
### 方式二:从源码运行
@@ -43,10 +59,20 @@
4359

4460
2. 启动服务:
4561
```bash
62+
# 默认端口启动(自动查找可用端口,从57573开始)
4663
npm start
64+
65+
# 或直接使用 node 命令
66+
node server.cjs
67+
68+
# 指定端口启动
69+
node server.cjs -port 8080
70+
71+
# 查看帮助信息
72+
node server.cjs --help
4773
```
4874

49-
服务将在 http://localhost:57573 启动
75+
服务默认在 http://localhost:57573 启动(如果端口被占用会自动查找下一个可用端口)
5076

5177
## 构建二进制文件
5278

@@ -185,10 +211,16 @@ npm run build:macos-arm
185211

186212
## 使用示例
187213

214+
**注意**:以下示例使用默认端口 57573,如果您使用了 `-port` 参数指定了其他端口,请相应调整 URL 中的端口号。
215+
188216
### 基本嗅探
189217

190218
```bash
219+
# 默认端口
191220
curl "http://localhost:57573/sniffer?url=https://example.com/play"
221+
222+
# 自定义端口(如果使用 -port 8080 启动)
223+
curl "http://localhost:8080/sniffer?url=https://example.com/play"
192224
```
193225

194226
### 多链接嗅探
@@ -220,19 +252,31 @@ curl "http://localhost:57573/fetCodeByWebView?url=https://example.com"
220252
## 测试
221253

222254
```bash
223-
# 测试 Sniffer 类
255+
# 运行测试脚本
224256
npm test
225-
226-
# 测试服务器接口(需要先启动服务)
227-
npm run test:server
228257
```
229258

259+
**注意**: 测试前请确保服务器已启动 (`npm start`)。
260+
261+
## 命令行参数
262+
263+
| 参数 | 说明 | 示例 |
264+
|------|------|------|
265+
| `-port <端口号>` | 指定服务器端口号 (1-65535) | `-port 8080` |
266+
| `-h, --help` | 显示帮助信息 | `--help` |
267+
268+
**端口说明**
269+
- 如果不指定端口号,程序将从 57573 开始自动查找可用端口
270+
- 如果指定的端口被占用,程序会报错并退出
271+
- 端口号必须在 1-65535 范围内
272+
230273
## 环境变量
231274

232275
| 变量 | 说明 | 默认值 |
233276
|------|------|--------|
234-
| PORT | 服务端口 | 57573 |
235-
| HOST | 服务主机 | 0.0.0.0 |
277+
| HOST | 服务主机地址 | 0.0.0.0 |
278+
279+
**注意**: 端口配置请使用 `-port` 命令行参数,不支持通过环境变量设置端口。
236280

237281
## 注意事项
238282

@@ -262,10 +306,10 @@ npm run test:server
262306

263307
## 开发
264308

265-
项目采用 ESM 模块化开发,主要文件:
309+
项目采用 CommonJS 模块化开发,主要文件:
266310

267-
- `sniffer.js`: 核心嗅探类
268-
- `server.js`: Fastify 服务器
311+
- `sniffer.cjs`: 核心嗅探类
312+
- `server.cjs`: Fastify 服务器
269313
- `test.js`: 测试脚本
270314
- `package.json`: 项目配置
271315

0 commit comments

Comments
 (0)