justcoding121 / titanium-web-proxy

A cross-platform asynchronous HTTP(S) proxy server in C#.
MIT License
1.92k stars 598 forks source link

Getting the remote server ip #949

Open Eonasdan opened 1 year ago

Eonasdan commented 1 year ago

Is there a way to get the remote server's ip address? E.g. google.com => 64.233.177.100

Thank you

trontronicent commented 1 year ago

Well, how does a system connect to "google.com" ? Actually by doing a DNS resolution and getting it's 'physical' address, which is the IP address. If there can't be any IP found, no connection is made - that's how the internet works. Of course, when you are using forward proxies, probably including proxying of DNS, then you won't know what the endpoint will be. Different DNS-servers and (in case of DNS like 8.8.8.8) - also your geolocation affects the resolution. And due to the fact, that there is even more proxyfication included, which is probably also outside your scope (in case it's external proxies not under your control).

In a strict way - environment. The endpoint you connect to, is the resolved IP address(es) from the DNS lookup. By default, Titanium.WebProxy is using the DNS servers of the machine where your proxy is running on. So using the default dotnet DnsClient to resolve the name, will yield the same result(s).

Eonasdan commented 1 year ago

I know how the internet works. My question was if Titanium.WebProxy provided this as part of the request object.