gemini-proxy-client 1.0.13 → 1.0.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +158 -101
- package/dist/cli.js +16 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -4,160 +4,212 @@
|
|
|
4
4
|
|
|
5
5
|
## 特性
|
|
6
6
|
|
|
7
|
-
- **反指纹检测**: 使用 Camoufox (基于 Firefox)
|
|
8
|
-
-
|
|
7
|
+
- **反指纹检测**: 使用 Camoufox (基于 Firefox) 防止浏览器指纹识别
|
|
8
|
+
- **随机指纹**: 每个账号自动生成独立的浏览器指纹(分辨率、语言、时区)
|
|
9
|
+
- **多账号支持**: 可同时运行多个客户端连接不同 Google 账号
|
|
10
|
+
- **自动登录管理**: 首次需要手动登录,之后自动切换到无头模式
|
|
9
11
|
- **自动连接**: 自动点击 "Continue to the app" 和 "Connect WS" 按钮
|
|
10
|
-
- **连接验证**: 自动检测 WebSocket
|
|
12
|
+
- **连接验证**: 自动检测 WebSocket 连接是否成功
|
|
11
13
|
- **自动保活**: 每 2 小时检查登录状态,断线自动重连
|
|
12
|
-
- **无头运行**: 登录后可在后台无头运行,节省资源
|
|
13
14
|
|
|
14
|
-
##
|
|
15
|
+
## 快速开始
|
|
16
|
+
|
|
17
|
+
### 1. 安装
|
|
15
18
|
|
|
16
19
|
```bash
|
|
17
20
|
npm install -g gemini-proxy-client
|
|
18
21
|
```
|
|
19
22
|
|
|
20
|
-
|
|
23
|
+
### 2. 安装 Camoufox 浏览器
|
|
21
24
|
|
|
22
25
|
```bash
|
|
23
|
-
|
|
26
|
+
gemini-client setup
|
|
24
27
|
```
|
|
25
28
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
### 启动客户端
|
|
29
|
+
这会下载 Camoufox 浏览器(约 200MB)。如果网络有问题,可以设置代理:
|
|
29
30
|
|
|
30
31
|
```bash
|
|
31
|
-
|
|
32
|
-
gemini-client
|
|
33
|
-
|
|
34
|
-
# 或使用简写
|
|
35
|
-
gemini-client start -s wss://your-server.com/v1/ws
|
|
32
|
+
export https_proxy=http://127.0.0.1:7890
|
|
33
|
+
gemini-client setup
|
|
36
34
|
```
|
|
37
35
|
|
|
38
|
-
|
|
36
|
+
### 3. 启动客户端
|
|
39
37
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
```
|
|
43
|
-
✅ 点击了 "Continue to the app" 按钮
|
|
44
|
-
✅ 点击了连接按钮
|
|
45
|
-
检测按钮文字: "Disconnect WS"
|
|
46
|
-
✅ WebSocket 连接成功!
|
|
38
|
+
```bash
|
|
39
|
+
gemini-client start --server ws://your-server:5345/v1/ws
|
|
47
40
|
```
|
|
48
41
|
|
|
49
|
-
|
|
42
|
+
**首次运行**会:
|
|
43
|
+
1. 打开浏览器窗口
|
|
44
|
+
2. 等待您登录 Google 账号
|
|
45
|
+
3. 登录成功后自动保存 cookies
|
|
46
|
+
4. 关闭浏览器,以无头模式重新启动
|
|
47
|
+
5. 自动连接到代理服务器
|
|
48
|
+
|
|
49
|
+
**之后运行**会直接以无头模式启动,无需再登录。
|
|
50
50
|
|
|
51
|
-
|
|
51
|
+
### 4. 后台运行
|
|
52
52
|
|
|
53
53
|
```bash
|
|
54
|
-
|
|
54
|
+
# 使用 nohup 后台运行
|
|
55
|
+
nohup gemini-client start -s ws://your-server:5345/v1/ws > gemini-client.log 2>&1 &
|
|
55
56
|
|
|
56
57
|
# 查看日志
|
|
57
58
|
tail -f gemini-client.log
|
|
58
59
|
|
|
59
60
|
# 停止
|
|
60
|
-
|
|
61
|
+
pkill -f gemini-client
|
|
61
62
|
```
|
|
62
63
|
|
|
63
|
-
|
|
64
|
+
## 多账号配置
|
|
65
|
+
|
|
66
|
+
可以在同一台机器上同时运行多个客户端,连接不同的 Google 账号:
|
|
64
67
|
|
|
65
68
|
```bash
|
|
66
|
-
#
|
|
67
|
-
|
|
68
|
-
|
|
69
|
+
# 账号 1 - 首次运行会弹出浏览器登录
|
|
70
|
+
nohup gemini-client start \
|
|
71
|
+
--data-dir ~/.gemini-client/account1 \
|
|
72
|
+
-s ws://your-server:5345/v1/ws \
|
|
73
|
+
> account1.log 2>&1 &
|
|
74
|
+
|
|
75
|
+
# 账号 2 - 使用不同的 data-dir
|
|
76
|
+
nohup gemini-client start \
|
|
77
|
+
--data-dir ~/.gemini-client/account2 \
|
|
78
|
+
-s ws://your-server:5345/v1/ws \
|
|
79
|
+
> account2.log 2>&1 &
|
|
80
|
+
|
|
81
|
+
# 账号 3
|
|
82
|
+
nohup gemini-client start \
|
|
83
|
+
--data-dir ~/.gemini-client/account3 \
|
|
84
|
+
-s ws://your-server:5345/v1/ws \
|
|
85
|
+
> account3.log 2>&1 &
|
|
86
|
+
```
|
|
69
87
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
88
|
+
每个 `--data-dir` 会独立保存:
|
|
89
|
+
- `cookies.json` - Google 登录状态
|
|
90
|
+
- `fingerprint.json` - 浏览器指纹配置
|
|
91
|
+
- `config.json` - 其他配置
|
|
73
92
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
93
|
+
### 随机指纹
|
|
94
|
+
|
|
95
|
+
每个账号首次启动时会自动生成随机的浏览器指纹:
|
|
96
|
+
|
|
97
|
+
| 项目 | 随机化范围 |
|
|
98
|
+
|------|-----------|
|
|
99
|
+
| 分辨率 | 1920x1080, 1366x768, 1440x900 等 10 种 |
|
|
100
|
+
| 语言 | en-US, zh-CN, ja-JP 等 10 种 |
|
|
101
|
+
| 时区 | America/New_York, Asia/Shanghai 等 10 种 |
|
|
78
102
|
|
|
79
|
-
|
|
103
|
+
指纹保存后会保持一致,避免同一账号频繁变化被检测。
|
|
104
|
+
|
|
105
|
+
## 命令参考
|
|
106
|
+
|
|
107
|
+
### start - 启动客户端
|
|
80
108
|
|
|
81
109
|
```bash
|
|
82
|
-
|
|
83
|
-
|
|
110
|
+
gemini-client start [options]
|
|
111
|
+
```
|
|
84
112
|
|
|
85
|
-
|
|
86
|
-
|
|
113
|
+
| 选项 | 说明 | 默认值 |
|
|
114
|
+
|------|------|--------|
|
|
115
|
+
| `-s, --server <url>` | 代理服务器 WebSocket 地址 | `ws://localhost:5345/v1/ws` |
|
|
116
|
+
| `-t, --token <token>` | 客户端认证令牌 | 自动生成 |
|
|
117
|
+
| `-d, --daemon` | 后台运行模式 | false |
|
|
118
|
+
| `--headless` | 强制无头模式 | 自动判断 |
|
|
119
|
+
| `--data-dir <path>` | 数据目录路径 | `~/.gemini-client` |
|
|
87
120
|
|
|
88
|
-
|
|
89
|
-
pm2 logs gemini-client
|
|
121
|
+
### setup - 安装 Camoufox 浏览器
|
|
90
122
|
|
|
91
|
-
|
|
92
|
-
|
|
123
|
+
```bash
|
|
124
|
+
gemini-client setup
|
|
125
|
+
```
|
|
93
126
|
|
|
94
|
-
|
|
95
|
-
pm2 restart gemini-client
|
|
127
|
+
下载并安装 Camoufox 浏览器,首次使用前必须执行。
|
|
96
128
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
129
|
+
### login - 登录 Google 账号
|
|
130
|
+
|
|
131
|
+
```bash
|
|
132
|
+
gemini-client login [--data-dir <path>]
|
|
100
133
|
```
|
|
101
134
|
|
|
102
|
-
|
|
135
|
+
单独执行登录操作,会打开浏览器让您登录 Google 账号。
|
|
103
136
|
|
|
104
|
-
|
|
137
|
+
### logout - 清除登录状态
|
|
105
138
|
|
|
106
139
|
```bash
|
|
107
|
-
|
|
108
|
-
|
|
140
|
+
gemini-client logout [--data-dir <path>]
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
删除保存的 cookies,下次启动需要重新登录。
|
|
144
|
+
|
|
145
|
+
### status - 查看状态
|
|
109
146
|
|
|
110
|
-
|
|
111
|
-
|
|
147
|
+
```bash
|
|
148
|
+
gemini-client status [--data-dir <path>]
|
|
112
149
|
```
|
|
113
150
|
|
|
114
|
-
|
|
151
|
+
查看当前登录状态和配置信息。
|
|
152
|
+
|
|
153
|
+
## 使用 PM2 管理(推荐)
|
|
154
|
+
|
|
155
|
+
使用 PM2 可以更方便地管理多个客户端:
|
|
115
156
|
|
|
116
157
|
```bash
|
|
117
|
-
#
|
|
118
|
-
|
|
158
|
+
# 安装 PM2
|
|
159
|
+
npm install -g pm2
|
|
160
|
+
|
|
161
|
+
# 启动多个账号
|
|
162
|
+
pm2 start "gemini-client start --data-dir ~/.gemini-client/account1 -s ws://server:5345/v1/ws" --name account1
|
|
163
|
+
pm2 start "gemini-client start --data-dir ~/.gemini-client/account2 -s ws://server:5345/v1/ws" --name account2
|
|
164
|
+
pm2 start "gemini-client start --data-dir ~/.gemini-client/account3 -s ws://server:5345/v1/ws" --name account3
|
|
119
165
|
|
|
120
166
|
# 查看状态
|
|
121
|
-
|
|
167
|
+
pm2 status
|
|
122
168
|
|
|
123
|
-
#
|
|
124
|
-
|
|
169
|
+
# 查看日志
|
|
170
|
+
pm2 logs
|
|
125
171
|
|
|
126
|
-
#
|
|
127
|
-
|
|
128
|
-
```
|
|
172
|
+
# 停止所有
|
|
173
|
+
pm2 stop all
|
|
129
174
|
|
|
130
|
-
|
|
175
|
+
# 开机自启
|
|
176
|
+
pm2 startup
|
|
177
|
+
pm2 save
|
|
178
|
+
```
|
|
131
179
|
|
|
132
|
-
|
|
180
|
+
## 无图形界面服务器
|
|
133
181
|
|
|
134
|
-
|
|
135
|
-
|------|------|--------|
|
|
136
|
-
| `-s, --server <url>` | 代理服务器 WebSocket 地址 | `ws://localhost:5345/v1/ws` |
|
|
137
|
-
| `-t, --token <token>` | 客户端认证令牌 | 自动生成 `gp_client_YYYY_MM_DD_HH_mm_ss` |
|
|
138
|
-
| `-d, --daemon` | 后台运行模式 | false |
|
|
139
|
-
| `--headless` | 强制无头模式 | 自动判断 |
|
|
140
|
-
| `--data-dir <path>` | 数据目录路径 | `~/.gemini-client` |
|
|
182
|
+
如果是纯命令行服务器(无桌面环境),需要安装虚拟显示:
|
|
141
183
|
|
|
142
|
-
|
|
184
|
+
```bash
|
|
185
|
+
# Ubuntu/Debian
|
|
186
|
+
sudo apt-get install xvfb
|
|
143
187
|
|
|
144
|
-
|
|
188
|
+
# 使用 xvfb-run 运行(首次登录时需要)
|
|
189
|
+
xvfb-run gemini-client start --data-dir ~/.gemini-client/account1 -s ws://server:5345/v1/ws
|
|
190
|
+
```
|
|
145
191
|
|
|
146
|
-
|
|
147
|
-
|------|------|
|
|
148
|
-
| `cookies.json` | Google 登录 cookies |
|
|
149
|
-
| `config.json` | 配置信息 |
|
|
192
|
+
注意:首次登录需要在有图形界面的环境中完成(或使用 VNC/远程桌面)。
|
|
150
193
|
|
|
151
194
|
## 工作流程
|
|
152
195
|
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
196
|
+
```
|
|
197
|
+
首次启动
|
|
198
|
+
↓
|
|
199
|
+
打开浏览器 UI → 用户登录 Google
|
|
200
|
+
↓
|
|
201
|
+
保存 cookies 和 fingerprint
|
|
202
|
+
↓
|
|
203
|
+
关闭浏览器 → 以无头模式重新启动
|
|
204
|
+
↓
|
|
205
|
+
自动点击 "Continue to the app"
|
|
206
|
+
↓
|
|
207
|
+
自动点击 "Connect WS" 按钮
|
|
208
|
+
↓
|
|
209
|
+
验证连接成功 → 后台运行
|
|
210
|
+
↓
|
|
211
|
+
定期检查登录状态(每 2 小时)
|
|
212
|
+
```
|
|
161
213
|
|
|
162
214
|
## 保活机制
|
|
163
215
|
|
|
@@ -170,14 +222,14 @@ gemini-client --help
|
|
|
170
222
|
|
|
171
223
|
- Node.js >= 18.0.0
|
|
172
224
|
- 能够访问 GitHub(下载 Camoufox 浏览器)
|
|
173
|
-
- 能够访问 Google AI Studio
|
|
174
|
-
- 图形界面或 Xvfb
|
|
225
|
+
- 能够访问 Google AI Studio
|
|
226
|
+
- 图形界面或 Xvfb(首次登录需要)
|
|
175
227
|
|
|
176
228
|
## 常见问题
|
|
177
229
|
|
|
178
230
|
### Q: Camoufox 下载失败怎么办?
|
|
179
231
|
|
|
180
|
-
|
|
232
|
+
设置代理后重试:
|
|
181
233
|
|
|
182
234
|
```bash
|
|
183
235
|
export https_proxy=http://127.0.0.1:7890
|
|
@@ -188,18 +240,23 @@ npx camoufox-js fetch
|
|
|
188
240
|
|
|
189
241
|
通常 1-2 周,但可能因 IP 变化、长时间无活动或 Google 安全检测而提前失效。
|
|
190
242
|
|
|
191
|
-
### Q:
|
|
243
|
+
### Q: 多账号会被检测到吗?
|
|
192
244
|
|
|
193
|
-
|
|
245
|
+
Camoufox + 随机指纹可以降低检测风险,但同一 IP 运行过多账号仍有风险。建议:
|
|
246
|
+
- 同一 IP 不超过 2-3 个账号
|
|
247
|
+
- 使用代理让不同账号走不同 IP(效果更好)
|
|
194
248
|
|
|
195
|
-
|
|
196
|
-
gemini-client start -s wss://server.com/v1/ws --data-dir ~/.gemini-client-1
|
|
197
|
-
gemini-client start -s wss://server.com/v1/ws --data-dir ~/.gemini-client-2
|
|
198
|
-
```
|
|
249
|
+
### Q: 如何确认连接成功?
|
|
199
250
|
|
|
200
|
-
|
|
251
|
+
查看日志,成功连接会显示:
|
|
201
252
|
|
|
202
|
-
|
|
253
|
+
```
|
|
254
|
+
✅ 点击了 "Continue to the app" 按钮
|
|
255
|
+
✅ 点击了连接按钮
|
|
256
|
+
检测按钮文字: "Disconnect WS"
|
|
257
|
+
✅ WebSocket 连接成功!
|
|
258
|
+
✅ 客户端已启动 (无头模式)
|
|
259
|
+
```
|
|
203
260
|
|
|
204
261
|
## License
|
|
205
262
|
|
package/dist/cli.js
CHANGED
|
@@ -12,7 +12,7 @@ const program = new Command();
|
|
|
12
12
|
program
|
|
13
13
|
.name('gemini-client')
|
|
14
14
|
.description('Gemini Proxy Build App 客户端 - 使用 Camoufox 自动保持连接')
|
|
15
|
-
.version('1.0.
|
|
15
|
+
.version('1.0.15');
|
|
16
16
|
program
|
|
17
17
|
.command('start')
|
|
18
18
|
.description('启动客户端,连接到代理服务器')
|
|
@@ -70,4 +70,19 @@ program
|
|
|
70
70
|
console.log(chalk.yellow('⚠️ 没有保存的登录状态'));
|
|
71
71
|
}
|
|
72
72
|
});
|
|
73
|
+
program
|
|
74
|
+
.command('setup')
|
|
75
|
+
.description('安装 Camoufox 浏览器')
|
|
76
|
+
.action(async () => {
|
|
77
|
+
console.log(chalk.cyan('📦 安装 Camoufox 浏览器...'));
|
|
78
|
+
const { execSync } = await import('child_process');
|
|
79
|
+
try {
|
|
80
|
+
execSync('npx camoufox-js fetch', { stdio: 'inherit' });
|
|
81
|
+
console.log(chalk.green('✅ Camoufox 安装成功!'));
|
|
82
|
+
}
|
|
83
|
+
catch (error) {
|
|
84
|
+
console.error(chalk.red('❌ 安装失败,请检查网络连接'));
|
|
85
|
+
process.exit(1);
|
|
86
|
+
}
|
|
87
|
+
});
|
|
73
88
|
program.parse();
|