dsh-sub2api 0.2.10 → 0.2.12
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/CHANGELOG.md +17 -0
- package/README.md +14 -0
- package/lib/adapter.js +28 -3
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.2.12
|
|
4
|
+
|
|
5
|
+
- Stop dropping `<private-host>`-style placeholders while stripping HTML from an
|
|
6
|
+
upstream error body. A blanket `<[^>]+>` removed exactly the part that says
|
|
7
|
+
where the failure happened; only real HTML element names are stripped now.
|
|
8
|
+
- The proxy-timeout message no longer asserts an internal network unless the
|
|
9
|
+
body actually names one. It otherwise says the error is the upstream's own
|
|
10
|
+
text, passed through, and points at the gateway log for the account id.
|
|
11
|
+
|
|
12
|
+
## 0.2.11
|
|
13
|
+
|
|
14
|
+
- Recognize a 5xx whose body is a proxy's network failure
|
|
15
|
+
(`connect-timeout`, `UND_ERR_CONNECT_TIMEOUT`, `acp-proxy`, …) and say what it
|
|
16
|
+
means: an upstream proxy could not reach its target, which for an internal
|
|
17
|
+
address points at the VPN/overlay rather than the plugin.
|
|
18
|
+
- README breaks down the three usual causes and how to check each.
|
|
19
|
+
|
|
3
20
|
## 0.2.10
|
|
4
21
|
|
|
5
22
|
- Recognize sub2api's own "Upstream service temporarily unavailable" 502 and say
|
package/README.md
CHANGED
|
@@ -302,6 +302,20 @@ ssh pskh 'docker logs --since 1h sub2api | grep account_select_failed | tail -5'
|
|
|
302
302
|
|
|
303
303
|
插件会把这句话翻译成中文并说明「不是插件本身的问题」,但真正的修复在网关。
|
|
304
304
|
|
|
305
|
+
### `502 Bad Gateway: acp-proxy failure: connect-timeout UND_ERR_CONNECT_TIMEOUT <private-host>`
|
|
306
|
+
|
|
307
|
+
这是**某个走内网的代理**返回的原文,被网关透传了出来:它连不上目标主机,超时了。`<private-host>` 是内网地址被打码后的样子。
|
|
308
|
+
|
|
309
|
+
常见成因:
|
|
310
|
+
|
|
311
|
+
| 现象 | 原因 | 查法 |
|
|
312
|
+
|---|---|---|
|
|
313
|
+
| 时好时坏,多机互联 | VPN / overlay(如 EasyTier)peer 在抖 | `docker logs --since 2h easytier \| grep -i "connection error"` |
|
|
314
|
+
| 一直失败 | 目标服务没起,或端口不通 | 在代理所在机器 `curl -m 5 http://<内网IP>:<端口>/` |
|
|
315
|
+
| 只有个别模型 | 那个模型绑的账号指向内网 | 网关日志看该请求用了哪个 `account_id` |
|
|
316
|
+
|
|
317
|
+
插件会把它翻译成「上游代理连不上它的目标(连接超时)」,并说明不是插件本身的问题。
|
|
318
|
+
|
|
305
319
|
### `the endpoint answered 502 Bad Gateway: <html>...openresty</html>`
|
|
306
320
|
|
|
307
321
|
这是**网关前面的 openresty 返回的**,不是模型的问题:sub2api 的 Go 后端当时不可用(重启中),或者上游账号被判定不可用正在切换。
|
package/lib/adapter.js
CHANGED
|
@@ -292,12 +292,21 @@ export function isRetryableFailure(error) {
|
|
|
292
292
|
return /answered 5\d\d|Bad Gateway|Service Unavailable|Gateway Timeout/i.test(message);
|
|
293
293
|
}
|
|
294
294
|
|
|
295
|
-
/**
|
|
295
|
+
/**
|
|
296
|
+
* Strip the tags a gateway puts around an HTML error page.
|
|
297
|
+
*
|
|
298
|
+
* Only real HTML element names are removed: a blanket `<[^>]+>` also eats
|
|
299
|
+
* placeholders like `<private-host>`, which is exactly the part of an upstream
|
|
300
|
+
* message that says where the failure happened.
|
|
301
|
+
*/
|
|
302
|
+
const HTML_TAGS =
|
|
303
|
+
/<\/?(?:html|head|body|title|meta|link|script|style|div|span|p|br|hr|center|h[1-6]|ul|ol|li|table|thead|tbody|tr|td|th|pre|code|strong|em|b|i|a|img|form|input|button)\b[^>]*>/gi;
|
|
304
|
+
|
|
296
305
|
export function plainText(value) {
|
|
297
306
|
return String(value ?? "")
|
|
298
307
|
.replace(/<script[\s\S]*?<\/script>/gi, " ")
|
|
299
308
|
.replace(/<style[\s\S]*?<\/style>/gi, " ")
|
|
300
|
-
.replace(
|
|
309
|
+
.replace(HTML_TAGS, " ")
|
|
301
310
|
.replace(/\s+/g, " ")
|
|
302
311
|
.trim();
|
|
303
312
|
}
|
|
@@ -319,8 +328,24 @@ export function describeStreamFailure(error, emitted, attempts) {
|
|
|
319
328
|
// sub2api answers this exact sentence for "my upstream failed", which in
|
|
320
329
|
// practice means the account pool has nothing usable for this model — a
|
|
321
330
|
// gateway-side condition the user can only act on by waiting or switching.
|
|
331
|
+
// A 5xx whose body is a network failure from something upstream: a proxy
|
|
332
|
+
// that could not reach an internal host, for instance. The host is usually
|
|
333
|
+
// redacted by whoever produced the message, so only the class is usable.
|
|
334
|
+
const upstreamNetwork = /connect-timeout|UND_ERR_CONNECT_TIMEOUT|ECONNREFUSED|EHOSTUNREACH|ENETUNREACH|acp-proxy/i.test(
|
|
335
|
+
said,
|
|
336
|
+
);
|
|
322
337
|
const upstreamDown = /Upstream service temporarily unavailable/i.test(said);
|
|
323
|
-
|
|
338
|
+
// Only claim "internal network" when the text says so: the body is passed
|
|
339
|
+
// through from whatever produced it, and guessing the cause from a timeout
|
|
340
|
+
// alone sends people looking in the wrong place.
|
|
341
|
+
const mentionsPrivate = /<private-host>|\b(?:10|127)\.\d+\.\d+\.\d+\b|\b192\.168\.\d+\.\d+\b|\b172\.(?:1[6-9]|2\d|3[01])\.\d+\.\d+\b/i.test(
|
|
342
|
+
said,
|
|
343
|
+
);
|
|
344
|
+
const what = upstreamNetwork
|
|
345
|
+
? mentionsPrivate
|
|
346
|
+
? "中转站上游的某个代理连不上它的目标(连接超时),目标看起来是内网地址;这通常是 VPN / 内网链路或对端服务的问题,不是插件本身"
|
|
347
|
+
: "中转站上游的某个代理连不上它的目标(连接超时);这条错误是上游原文透传,具体是哪个组件要看网关日志里该请求的 account_id"
|
|
348
|
+
: upstreamDown
|
|
324
349
|
? "中转站的上游暂时不可用(502);这通常是该模型此刻没有可用账号,或上游账号返回了 5xx,不是插件本身的问题"
|
|
325
350
|
: status === 502
|
|
326
351
|
? "中转站的网关返回 502,后端当时不可用(重启或上游账号异常)"
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-sub2api",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.12",
|
|
4
4
|
"description": "Sub2API provider for DeepSeek Harness: zero-friction signup, auto-provisioned API key, upstream model sync, balance and recharge",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "GPL-3.0-only",
|