From 08266a15c076fa83244cfb0ac44732233e346151 Mon Sep 17 00:00:00 2001 From: hujiulong Date: Wed, 26 Feb 2025 11:48:42 +0800 Subject: [PATCH 1/3] Update lock file --- package-lock.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index 4ab410a..ffb161d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "http-mitm-proxy", - "version": "1.0.0", + "version": "1.1.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "http-mitm-proxy", - "version": "1.0.0", + "version": "1.1.0", "license": "MIT", "dependencies": { "async": "^3.2.5", From 3122884737b31f252e8fb4f11a5c32e5cab1f8f8 Mon Sep 17 00:00:00 2001 From: hujiulong Date: Wed, 26 Feb 2025 11:49:19 +0800 Subject: [PATCH 2/3] Add new lookup option --- lib/proxy.ts | 1 + lib/types.ts | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/lib/proxy.ts b/lib/proxy.ts index 2927a08..61b88f6 100644 --- a/lib/proxy.ts +++ b/lib/proxy.ts @@ -1150,6 +1150,7 @@ export class Proxy implements IProxy { port: hostPort.port, headers, agent: ctx.isSSL ? self.httpsAgent : self.httpAgent, + lookup: this.options.lookup, }; return self._onRequest(ctx, (err) => { if (err) { diff --git a/lib/types.ts b/lib/types.ts index 03c7ae8..6a5920d 100644 --- a/lib/types.ts +++ b/lib/types.ts @@ -4,6 +4,7 @@ import type CA from "../lib/ca"; import type WebSocket from "ws"; import type { Server } from "https"; import type { WebSocket as WebSocketType, WebSocketServer } from "ws"; +import type { LookupFunction } from 'net'; export interface IProxyStatic { (): IProxy; @@ -34,6 +35,8 @@ export interface IProxyOptions { httpsPort?: number; /** - Setting this option will remove the content-length from the proxy to server request, forcing chunked encoding */ forceChunkedRequest?: boolean; + /** - The DNS lookup function to use. This option can be used to avoid the default synchronous DNS resolution. See #314 for details. */ + lookup?: LookupFunction; } export interface IProxySSLServer { @@ -306,6 +309,7 @@ export type IContext = ICallbacks & port: string | number | null | undefined; headers: { [key: string]: string }; agent: http.Agent; + lookup: LookupFunction | undefined; }; onRequestHandlers: OnRequestParams[]; From 2791810653a599ae828b455254b57bd2234b23c3 Mon Sep 17 00:00:00 2001 From: hujiulong Date: Wed, 26 Feb 2025 11:53:03 +0800 Subject: [PATCH 3/3] Add explanation about the lookup option --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 677fef4..ebf2942 100644 --- a/README.md +++ b/README.md @@ -134,6 +134,7 @@ __Arguments__ * forceSNI - force use of [SNI](https://en.wikipedia.org/wiki/Server_Name_Indication) by the client. Allow node-http-mitm-proxy to handle all HTTPS requests with a single internal server. * httpsPort - The port or named socket for https server to listen on. _(forceSNI must be enabled)_ * forceChunkedRequest - Setting this option will remove the content-length from the proxy to server request, forcing chunked encoding. + * lookup - The DNS lookup function to use. This option can be used to avoid the default synchronous DNS resolution. See [#314](https://github.com/joeferner/node-http-mitm-proxy/issues/314) for details. __Example__