com.jimuwd.xian.registry-proxy 1.0.121 → 1.0.124
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/dist/index.js +5 -4
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -299,7 +299,7 @@ function getDownstreamClientIp(req) {
|
|
|
299
299
|
// 直接连接时,取 socket.remoteAddress
|
|
300
300
|
return req.socket.remoteAddress;
|
|
301
301
|
}
|
|
302
|
-
//
|
|
302
|
+
// deprecated 出于安全考虑只监听::1地址,废弃本注释:同时启动ipv6,ipv4监听,比如当客户端访问http://localhost:port时,无论客户端DNS解析到IPV4-127.0.0.1还是IPV6-::1地址,咱server都能轻松应对!
|
|
303
303
|
export async function startProxyServer(proxyConfigPath, localYarnConfigPath, globalYarnConfigPath, port = 0) {
|
|
304
304
|
const proxyInfo = await loadProxyInfo(proxyConfigPath, localYarnConfigPath, globalYarnConfigPath);
|
|
305
305
|
const registryInfos = proxyInfo.registries;
|
|
@@ -358,7 +358,7 @@ export async function startProxyServer(proxyConfigPath, localYarnConfigPath, glo
|
|
|
358
358
|
resToDownstreamClient.writeHead(404).end('All upstream registries failed');
|
|
359
359
|
}
|
|
360
360
|
};
|
|
361
|
-
//
|
|
361
|
+
// deprecated 废弃本注释:需要同时启动ipv6,ipv4监听,比如当客户端访问http://localhost:port时,无论客户端DNS解析到IPV4-127.0.0.1还是IPV6-::1地址,咱server都能轻松应对!
|
|
362
362
|
let server;
|
|
363
363
|
if (proxyInfo.https) {
|
|
364
364
|
const { key, cert } = proxyInfo.https;
|
|
@@ -406,8 +406,9 @@ export async function startProxyServer(proxyConfigPath, localYarnConfigPath, glo
|
|
|
406
406
|
};
|
|
407
407
|
server.on('error', errHandler /*this handler will call 'reject'*/);
|
|
408
408
|
server.on('connection', connectionHandler);
|
|
409
|
-
//
|
|
410
|
-
|
|
409
|
+
// 为了代理服务器的安全性,暂时只监听本机ipv6地址【::1】,不能对本机之外暴露本代理服务地址避免造成安全隐患
|
|
410
|
+
// 注意:截止目前yarn客户端如果通过localhost:<port>来访问本服务,可能会报错ECONNREFUSED错误码,原因是yarn客户端环境解析“localhost”至多个地址,它会尝试轮询每个地址。
|
|
411
|
+
const listenOptions = { port, host: '::1', ipv6Only: true };
|
|
411
412
|
server.listen(listenOptions, () => {
|
|
412
413
|
const addressInfo = server.address();
|
|
413
414
|
port = addressInfo.port; // 回写上层局部变量
|