monkeyWie / proxyee

HTTP proxy server,support HTTPS&websocket.MITM impl,intercept and tamper HTTPS traffic.
MIT License
1.52k stars 567 forks source link

Inject a custom DNS resolver #123

Closed rzabini closed 3 years ago

rzabini commented 3 years ago

The proposed change addresses the following use case:

As a developer, I want to redirect the browser to a local server, without changing the host name in the location, to test a local instance of a production website.

This is usually achieved by changing the 'hosts' file on the local computer, however:

In this change, the proxy uses a custom resolver, configured in HttpProxyServerConfig, which resolves every name to localhost.

monkeyWie commented 3 years ago

I think this is weighty, for this case, it is recommended to refer InterceptForwardHttpProxyServer.java.

Of course, inject a custom DNS resolver is a nice feature, I will merge it.

rzabini commented 3 years ago

I think this is weighty, for this case, it is recommended to refer InterceptForwardHttpProxyServer.java.

Yes, this was my first try. However I am not sure that it is the exact same use case: I need to change the IP address, without changing the Http host header of the request. In the example you suggest, the browser asks for the baidu site, and the proxy fetches a URL from the taobao site, but in order to get a valid response the host header must be changed, am I right?

Of course, inject a custom DNS resolver is a nice feature, I will merge it.

Thank you

monkeyWie commented 3 years ago

In the example you suggest, the browser asks for the baidu site, and the proxy fetches a URL from the taobao site, but in order to get a valid response the host header must be changed, am I right?

Yes, the request host header will be changed, so it should not be suitable for your case, please remove the reviewed code and then I will merge it. Thank you~