@tedbrain/vlink 0.1.160 → 0.1.161
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 +9 -3
- package/binaries.json +22 -22
- package/install.js +20 -10
- package/npm-payload.js +45 -4
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -203,9 +203,15 @@ V1 的版本查询、安装、自更新和七平台二进制统一由 npm 承载
|
|
|
203
203
|
| Windows arm64 | `@tedbrain/vlink-windows-aarch64` |
|
|
204
204
|
|
|
205
205
|
安装器使用 npm 已安装的平台包,缺失时从 registry 获取精确版本。Linux x64 依现有 glibc 检测选择兼容载荷。
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
206
|
+
安装器、`vlink update` 和 SSH 远端载荷下载默认先访问 `https://registry.npmjs.org`,
|
|
207
|
+
遇到连接失败、超时、限流或服务端故障时自动改用 `https://registry.npmmirror.com`。
|
|
208
|
+
下载继续使用已选版本,并校验归档完整性和二进制 SHA256。
|
|
209
|
+
安装器使用 npm 解析并传入的 `registry` 配置,包括 `.npmrc` 中的 `registry=` 和 npm 的 `--registry`。
|
|
210
|
+
直接运行 `vlink update` 或 `vlink ssh connect` 时,可以设置 `npm_config_registry` 或
|
|
211
|
+
`NPM_CONFIG_REGISTRY`。两项都设置时小写优先。下载器沿用 HTTP(S)_PROXY / NO_PROXY 配置。
|
|
212
|
+
`vlink update` 查询最新正式版,`vlink ssh connect` 下载与本机同版本的远端平台载荷并通过 SSH 上传。两者无需安装 Node/npm。
|
|
213
|
+
`npx` 首次获取安装包时由 npm 选择 registry。如果 npmjs 无法访问,运行
|
|
214
|
+
`npx --registry=https://registry.npmmirror.com -y @tedbrain/vlink@latest install --no-setup`。
|
|
209
215
|
|
|
210
216
|
### 薄包模式(直链数据包)
|
|
211
217
|
|
package/binaries.json
CHANGED
|
@@ -1,40 +1,40 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "0.1.
|
|
2
|
+
"version": "0.1.161",
|
|
3
3
|
"binaries": {
|
|
4
4
|
"linux-x86_64": {
|
|
5
|
-
"url": "https://cloud.tsinghua.edu.cn/f/
|
|
6
|
-
"sha256": "
|
|
7
|
-
"size":
|
|
5
|
+
"url": "https://cloud.tsinghua.edu.cn/f/4b824ceb5a6141709ccd/?dl=1",
|
|
6
|
+
"sha256": "cd85e516e29f1f754d4721468140caff0222aff5903cb80a480e60d9d0ff90d7",
|
|
7
|
+
"size": 24877437
|
|
8
8
|
},
|
|
9
9
|
"linux-x86_64-glibc2.17": {
|
|
10
|
-
"url": "https://cloud.tsinghua.edu.cn/f/
|
|
11
|
-
"sha256": "
|
|
12
|
-
"size":
|
|
10
|
+
"url": "https://cloud.tsinghua.edu.cn/f/1620d41fbbd0405fb684/?dl=1",
|
|
11
|
+
"sha256": "ac36a5ae4510917b80442804f608ea66f2f72dea8be301f4add8aafeca14619a",
|
|
12
|
+
"size": 25603249
|
|
13
13
|
},
|
|
14
14
|
"linux-aarch64": {
|
|
15
|
-
"url": "https://cloud.tsinghua.edu.cn/f/
|
|
16
|
-
"sha256": "
|
|
17
|
-
"size":
|
|
15
|
+
"url": "https://cloud.tsinghua.edu.cn/f/0754e59860cd4a1a86ef/?dl=1",
|
|
16
|
+
"sha256": "6d65f88f0f7e1b8167e6568674680a5bfa6f3e5568e3f994088d97570a3d776c",
|
|
17
|
+
"size": 21179301
|
|
18
18
|
},
|
|
19
19
|
"macos-x86_64": {
|
|
20
|
-
"url": "https://cloud.tsinghua.edu.cn/f/
|
|
21
|
-
"sha256": "
|
|
22
|
-
"size":
|
|
20
|
+
"url": "https://cloud.tsinghua.edu.cn/f/30983e728c7041858932/?dl=1",
|
|
21
|
+
"sha256": "d2fff46ccfeb3b150b4888bcad364c5c1160f8397d45c38d34ec020866be1408",
|
|
22
|
+
"size": 22247233
|
|
23
23
|
},
|
|
24
24
|
"macos-aarch64": {
|
|
25
|
-
"url": "https://cloud.tsinghua.edu.cn/f/
|
|
26
|
-
"sha256": "
|
|
27
|
-
"size":
|
|
25
|
+
"url": "https://cloud.tsinghua.edu.cn/f/151b437c7bcd4df7846d/?dl=1",
|
|
26
|
+
"sha256": "362a30090ccd57ffa18eaf9cd32f42ad3b63e89785aab2f9add802ddb0d9004a",
|
|
27
|
+
"size": 18022389
|
|
28
28
|
},
|
|
29
29
|
"windows-x86_64.exe": {
|
|
30
|
-
"url": "https://cloud.tsinghua.edu.cn/f/
|
|
31
|
-
"sha256": "
|
|
32
|
-
"size":
|
|
30
|
+
"url": "https://cloud.tsinghua.edu.cn/f/2c23d16117a84a8abe60/?dl=1",
|
|
31
|
+
"sha256": "035b5b6b006ebc30c6e1460e0ff4e271f499dc51fd84b27919acc8934c58859c",
|
|
32
|
+
"size": 9781029
|
|
33
33
|
},
|
|
34
34
|
"windows-aarch64.exe": {
|
|
35
|
-
"url": "https://cloud.tsinghua.edu.cn/f/
|
|
36
|
-
"sha256": "
|
|
37
|
-
"size":
|
|
35
|
+
"url": "https://cloud.tsinghua.edu.cn/f/6a586869ac0f4329b75b/?dl=1",
|
|
36
|
+
"sha256": "99e52099ae5e1b77939670d75ae3bf0ebac5e76783d96352b5e9a8b1cc14d598",
|
|
37
|
+
"size": 11281193
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
40
|
}
|
package/install.js
CHANGED
|
@@ -8,6 +8,7 @@ const https = require('https');
|
|
|
8
8
|
const os = require('os');
|
|
9
9
|
const path = require('path');
|
|
10
10
|
const { spawnSync } = require('child_process');
|
|
11
|
+
const { pipeline } = require('stream/promises');
|
|
11
12
|
const { HttpProxyAgent } = require('http-proxy-agent');
|
|
12
13
|
const { HttpsProxyAgent } = require('https-proxy-agent');
|
|
13
14
|
|
|
@@ -251,7 +252,7 @@ function fallbackDownloadUrl(spec, suffix = spec.suffix) {
|
|
|
251
252
|
return `${DOWNLOAD_BASE}/${CHANNEL}/vlink/${VERSION}/vlink-${suffix}`;
|
|
252
253
|
}
|
|
253
254
|
|
|
254
|
-
function
|
|
255
|
+
function httpResponse(url, timeout, options) {
|
|
255
256
|
return new Promise((resolve, reject) => {
|
|
256
257
|
const request = (target, redirects) => {
|
|
257
258
|
const transport = target.startsWith('https:') ? https : http;
|
|
@@ -274,25 +275,33 @@ function httpGetText(url, options = {}) {
|
|
|
274
275
|
}
|
|
275
276
|
if (res.statusCode !== 200) {
|
|
276
277
|
res.resume();
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
);
|
|
278
|
+
const error = new VlinkInstallError(`HTTP ${res.statusCode} from ${displayUrl(target)}`);
|
|
279
|
+
error.statusCode = res.statusCode;
|
|
280
|
+
return reject(error);
|
|
280
281
|
}
|
|
281
|
-
|
|
282
|
-
const chunks = [];
|
|
283
|
-
res.on('data', (chunk) => chunks.push(chunk));
|
|
284
|
-
res.on('end', () => resolve(Buffer.concat(chunks).toString('utf8')));
|
|
282
|
+
resolve(res);
|
|
285
283
|
}
|
|
286
284
|
);
|
|
287
285
|
|
|
288
286
|
req.on('error', reject);
|
|
289
|
-
req.setTimeout(
|
|
287
|
+
req.setTimeout(timeout, () => {
|
|
288
|
+
const error = new VlinkInstallError('request timed out');
|
|
289
|
+
error.code = 'ETIMEDOUT';
|
|
290
|
+
req.destroy(error);
|
|
291
|
+
});
|
|
290
292
|
};
|
|
291
293
|
|
|
292
294
|
request(url, 0);
|
|
293
295
|
});
|
|
294
296
|
}
|
|
295
297
|
|
|
298
|
+
async function httpGetText(url, options = {}) {
|
|
299
|
+
const response = await httpResponse(url, 30000, options);
|
|
300
|
+
const chunks = [];
|
|
301
|
+
for await (const chunk of response) chunks.push(chunk);
|
|
302
|
+
return Buffer.concat(chunks).toString('utf8');
|
|
303
|
+
}
|
|
304
|
+
|
|
296
305
|
function parseJson(text, url) {
|
|
297
306
|
try {
|
|
298
307
|
return JSON.parse(text);
|
|
@@ -347,7 +356,8 @@ function buildDownloadSources(spec, suffix = spec.suffix, options = {}) {
|
|
|
347
356
|
resolve: () => Promise.resolve(`npm:${require('./npm-payload').packageName(suffix)}@${VERSION}`),
|
|
348
357
|
fetchTo: (destination) => require('./npm-payload').installPayload(
|
|
349
358
|
suffix, VERSION, expectedChecksum(spec, suffix), destination,
|
|
350
|
-
{ text: url => httpGetText(url, options), download: (url, dest) => downloadFile(url, dest, options) }
|
|
359
|
+
{ text: url => httpGetText(url, options), download: (url, dest) => downloadFile(url, dest, options) },
|
|
360
|
+
options.env || process.env
|
|
351
361
|
)
|
|
352
362
|
}];
|
|
353
363
|
}
|
package/npm-payload.js
CHANGED
|
@@ -11,6 +11,12 @@ const SUFFIXES = [
|
|
|
11
11
|
'macos-x86_64', 'macos-aarch64', 'windows-x86_64.exe', 'windows-aarch64.exe'
|
|
12
12
|
];
|
|
13
13
|
const MAX_PAYLOAD = 128 * 1024 * 1024;
|
|
14
|
+
const DEFAULT_REGISTRY = 'https://registry.npmjs.org';
|
|
15
|
+
const MIRROR_REGISTRY = 'https://registry.npmmirror.com';
|
|
16
|
+
const NETWORK_ERRORS = new Set([
|
|
17
|
+
'EAI_AGAIN', 'ENOTFOUND', 'ETIMEDOUT', 'EHOSTUNREACH', 'ENETUNREACH',
|
|
18
|
+
'ECONNABORTED', 'ECONNREFUSED', 'ECONNRESET', 'EPIPE', 'ERR_STREAM_PREMATURE_CLOSE'
|
|
19
|
+
]);
|
|
14
20
|
|
|
15
21
|
function packageName(suffix) {
|
|
16
22
|
if (!SUFFIXES.includes(suffix)) throw new Error(`unsupported platform: ${suffix}`);
|
|
@@ -65,7 +71,16 @@ function verify(data, expected, algorithm) {
|
|
|
65
71
|
if (!expected || actual !== expected) throw new Error(`${algorithm} integrity mismatch`);
|
|
66
72
|
}
|
|
67
73
|
|
|
68
|
-
|
|
74
|
+
function registryUnavailable(error) {
|
|
75
|
+
const { statusCode, code } = error;
|
|
76
|
+
if (statusCode !== undefined) {
|
|
77
|
+
return [403, 408, 429].includes(statusCode) || (statusCode >= 500 && statusCode < 600);
|
|
78
|
+
}
|
|
79
|
+
return NETWORK_ERRORS.has(code) ||
|
|
80
|
+
/^(ERR_TLS_|ERR_SSL_|CERT_|UNABLE_TO_|DEPTH_ZERO_|SELF_SIGNED_)/.test(code);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
async function installPayload(suffix, version, checksum, destination, transport, env = process.env) {
|
|
69
84
|
const name = packageName(suffix);
|
|
70
85
|
const contentVersion = packageVersion(suffix, version);
|
|
71
86
|
const binaryName = suffix.endsWith('.exe') ? 'vlink.exe' : 'vlink';
|
|
@@ -79,15 +94,41 @@ async function installPayload(suffix, version, checksum, destination, transport)
|
|
|
79
94
|
fs.writeFileSync(destination, data, { mode: 0o755 });
|
|
80
95
|
return;
|
|
81
96
|
}
|
|
82
|
-
|
|
83
|
-
|
|
97
|
+
let registry = (env.npm_config_registry || env.NPM_CONFIG_REGISTRY || DEFAULT_REGISTRY)
|
|
98
|
+
.replace(/\/+$/, '');
|
|
99
|
+
async function fromRegistry(request) {
|
|
100
|
+
try {
|
|
101
|
+
return await request(registry);
|
|
102
|
+
} catch (error) {
|
|
103
|
+
if (registry !== DEFAULT_REGISTRY || !registryUnavailable(error)) throw error;
|
|
104
|
+
registry = MIRROR_REGISTRY;
|
|
105
|
+
console.error(`[vlink] npmjs request failed, retrying via ${registry}`);
|
|
106
|
+
try {
|
|
107
|
+
return await request(registry);
|
|
108
|
+
} catch (mirrorError) {
|
|
109
|
+
throw new Error(`npmjs request failed (${error.message}), mirror request failed (${mirrorError.message})`);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
const text = await fromRegistry(origin => transport.text(
|
|
114
|
+
`${origin}/${encodeURIComponent(name)}/${contentVersion}`
|
|
115
|
+
));
|
|
116
|
+
const metadata = JSON.parse(text);
|
|
84
117
|
if (metadata.name !== name || metadata.version !== contentVersion || !metadata.dist ||
|
|
118
|
+
typeof metadata.dist.tarball !== 'string' ||
|
|
85
119
|
!/^sha512-[A-Za-z0-9+/]+={0,2}$/.test(metadata.dist.integrity || '')) {
|
|
86
120
|
throw new Error('invalid npm platform metadata');
|
|
87
121
|
}
|
|
88
122
|
const tarball = `${destination}.tgz`;
|
|
89
123
|
try {
|
|
90
|
-
|
|
124
|
+
const url = metadata.dist.tarball;
|
|
125
|
+
const upstreamPrefix = `${DEFAULT_REGISTRY}/`;
|
|
126
|
+
if ([DEFAULT_REGISTRY, MIRROR_REGISTRY].includes(registry) && url.startsWith(upstreamPrefix)) {
|
|
127
|
+
const tarballPath = url.slice(upstreamPrefix.length);
|
|
128
|
+
await fromRegistry(origin => transport.download(`${origin}/${tarballPath}`, tarball));
|
|
129
|
+
} else {
|
|
130
|
+
await transport.download(url, tarball);
|
|
131
|
+
}
|
|
91
132
|
if (fs.statSync(tarball).size > MAX_PAYLOAD) throw new Error('platform package too large');
|
|
92
133
|
const data = fs.readFileSync(tarball);
|
|
93
134
|
verify(data, metadata.dist.integrity.slice(7), 'sha512');
|
package/package.json
CHANGED