Discovery: Automatically bypass sockets for non-HTTP
Opened this issue · 1 comments
ianwsperber commented
Mitm will intercept any socket. Currently we require the user to provide ports they would like to ignore. It'd be nice if YesNo could implement some heuristic to detect sockets for HTTP requests and only intercept those. Hard because I'm not sure whether we can guarantee that the options object passed to Mitm's .on("connect"
callback will have certain properties on all HTTP requests. If it's possible that'd be a good way of doing this.
mscottx88 commented
@ianwsperber maybe we can look at the options:
private mitmOnConnect(socket: Mitm.BypassableSocket, options: ProxyRequestOptions): void { }
If options contains url
, then it will also have protocol
and we can look to see if it is http
or https
. Would that work?
JSON.stringify(options.uri, null, 2)
"{
"protocol": "http:",
"slashes": true,
"auth": null,
"host": "localhost:3001",
"port": "3001",
"hostname": "localhost",
"hash": null,
"search": "?fiz=baz",
"query": "fiz=baz",
"pathname": "/get",
"path": "/get?fiz=baz",
"href": "http://localhost:3001/get?fiz=baz"
}"