From 9e06d56569215b03147da940cc349624a1280b00 Mon Sep 17 00:00:00 2001 From: mapleeit <522856232@qq.com> Date: Mon, 20 Apr 2020 11:27:24 +0800 Subject: [PATCH] fix(create-server-hack): use net.isIP to detect IP format --- lib/core/runtime/create-server.hack.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/core/runtime/create-server.hack.ts b/lib/core/runtime/create-server.hack.ts index 838f2031..2286b0ea 100644 --- a/lib/core/runtime/create-server.hack.ts +++ b/lib/core/runtime/create-server.hack.ts @@ -9,8 +9,8 @@ import * as http from "http"; import * as domain from "domain"; import currentContext, { RequestLog } from "../context"; -import { address, isV4Format, isV6Format } from "ip"; -import { AddressInfo } from "net"; +import { address } from "ip"; +import { AddressInfo, isIP } from "net"; import { captureOutgoing } from "./capture/outgoing"; import { captureIncoming } from "./capture/incoming"; import { eventBus, EVENT_LIST } from "../bus"; @@ -173,7 +173,7 @@ export const httpCreateServerHack = (): void => { }); // proxy req to proxy env when hitting uid - if ((isV4Format(context.proxyIp) || isV6Format(context.proxyIp)) + if ((isIP(context.proxyIp)) && !req.headers["x-tsw-proxy"]) { console.debug("isProxyUser...");