com.jimuwd.xian.registry-proxy 1.0.112 → 1.0.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.
Files changed (2) hide show
  1. package/dist/index.js +11 -14
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -411,25 +411,22 @@ export async function startProxyServer(proxyConfigPath, localYarnConfigPath, glo
411
411
  socket.setTimeout(60000);
412
412
  socket.setKeepAlive(true, 30000);
413
413
  };
414
- // 嵌套的回调函数,在ipv6监听器启动之后会被回调调用
415
- const nestedListener = () => {
416
- const portFile = join(process.env.PROJECT_ROOT || process.cwd(), '.registry-proxy-port');
417
- writeFile(portFile, proxyPort.toString()).catch(e => logger.error(`Failed to write port file: ${portFile}`, e));
418
- logger.info(`Proxy server running on ${proxyInfo.https ? 'https' : 'http'}://localhost:${proxyPort}${basePathPrefixedWithSlash === '/' ? '' : basePathPrefixedWithSlash}`);
419
- resolve({ serverIpv6, serverIpv4, });
420
- };
421
- const listenerCallback = () => {
422
- const address = serverIpv6.address();
423
- proxyPort = address.port;
424
- // 前面已经监听了ipv6端口,追加监听Ipv4同端口号
425
- serverIpv4.listen(proxyPort, '0.0.0.0', nestedListener);
426
- };
427
414
  serverIpv6.on('error', errHandler);
428
415
  serverIpv4.on('error', errHandler);
429
416
  serverIpv6.on('connection', connectionHandler);
430
417
  serverIpv4.on('connection', connectionHandler);
431
418
  // 为了代理服务器的健壮性,先启动ipv6监听,然后再在其回调函数中启动ipv4监听
432
- serverIpv6.listen(port, '::', listenerCallback);
419
+ serverIpv6.listen(port, '::', () => {
420
+ const address = serverIpv6.address();
421
+ proxyPort = address.port;
422
+ logger.info(`前面已经监听了ipv6端口 ${address},追加监听Ipv4同端口号 0.0.0.0:${proxyPort}`);
423
+ serverIpv4.listen(proxyPort, '0.0.0.0', () => {
424
+ const portFile = join(process.env.PROJECT_ROOT || process.cwd(), '.registry-proxy-port');
425
+ writeFile(portFile, proxyPort.toString()).catch(e => logger.error(`Failed to write port file: ${portFile}`, e));
426
+ logger.info(`Proxy server running on ${proxyInfo.https ? 'https' : 'http'}://localhost:${proxyPort}${basePathPrefixedWithSlash === '/' ? '' : basePathPrefixedWithSlash}`);
427
+ resolve({ serverIpv6, serverIpv4, });
428
+ });
429
+ });
433
430
  });
434
431
  return promisedServer;
435
432
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "com.jimuwd.xian.registry-proxy",
3
- "version": "1.0.112",
3
+ "version": "1.0.113",
4
4
  "description": "A lightweight npm registry proxy with fallback support",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",