@simonyea/holysheep-cli 1.7.111 → 1.7.113
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@simonyea/holysheep-cli",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.113",
|
|
4
4
|
"description": "Claude Code/Cursor/Cline API relay for China — ¥1=$1, WeChat/Alipay payment, no credit card, no VPN. One command setup for all AI coding tools.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"openai-china",
|
|
@@ -181,6 +181,7 @@ function createConnectTunnel(proxyUrl, target, headers) {
|
|
|
181
181
|
method: 'CONNECT',
|
|
182
182
|
path: target,
|
|
183
183
|
headers,
|
|
184
|
+
timeout: 15000, // CONNECT 握手 15 秒超时
|
|
184
185
|
})
|
|
185
186
|
|
|
186
187
|
request.once('connect', (response, socket, head) => {
|
|
@@ -191,6 +192,9 @@ function createConnectTunnel(proxyUrl, target, headers) {
|
|
|
191
192
|
if (head?.length) socket.unshift(head)
|
|
192
193
|
resolve(socket)
|
|
193
194
|
})
|
|
195
|
+
request.once('timeout', () => {
|
|
196
|
+
request.destroy(new Error('CONNECT tunnel handshake timeout'))
|
|
197
|
+
})
|
|
194
198
|
request.once('error', reject)
|
|
195
199
|
request.end()
|
|
196
200
|
})
|
|
@@ -201,23 +205,33 @@ function pipeWithCleanup(a, b) {
|
|
|
201
205
|
if (typeof sock.setKeepAlive === 'function') sock.setKeepAlive(true, 10000)
|
|
202
206
|
}
|
|
203
207
|
|
|
204
|
-
//
|
|
205
|
-
//
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
208
|
+
// 单向响应超时:a 发了数据给 b,但 b 那边 30 秒没回任何数据 → 断开
|
|
209
|
+
// 解决 node proxy 进程挂了但 TCP 还 ESTABLISHED 的问题
|
|
210
|
+
// 不影响 extended thinking:thinking 时 a(客户端)没发新数据,不触发计时
|
|
211
|
+
let responseTimer = null
|
|
212
|
+
let bHasResponded = false
|
|
213
|
+
a.on('data', () => {
|
|
214
|
+
// 客户端发了数据(请求),开始等上游响应
|
|
215
|
+
if (!bHasResponded) {
|
|
216
|
+
if (responseTimer) clearTimeout(responseTimer)
|
|
217
|
+
responseTimer = setTimeout(() => {
|
|
218
|
+
if (!bHasResponded) {
|
|
219
|
+
a.destroy(new Error('upstream response timeout'))
|
|
220
|
+
b.destroy(new Error('upstream response timeout'))
|
|
221
|
+
}
|
|
222
|
+
}, 30000)
|
|
223
|
+
}
|
|
224
|
+
})
|
|
225
|
+
b.on('data', () => {
|
|
226
|
+
// 上游回数据了,清掉超时
|
|
227
|
+
bHasResponded = true
|
|
228
|
+
if (responseTimer) { clearTimeout(responseTimer); responseTimer = null }
|
|
229
|
+
})
|
|
216
230
|
|
|
217
231
|
a.pipe(b)
|
|
218
232
|
b.pipe(a)
|
|
219
233
|
const close = () => {
|
|
220
|
-
if (
|
|
234
|
+
if (responseTimer) clearTimeout(responseTimer)
|
|
221
235
|
a.destroy()
|
|
222
236
|
b.destroy()
|
|
223
237
|
}
|