-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Allow to specify server IP address #1067
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@yhirose take a look. This PR for my issue |
@zhenyolka, thank you for the pull request. Could you add unit tests in @PixlRainbow, do you have any thought about this PR? |
This is similar to CURL's |
@PixlRainbow, thanks for the excellent suggestion! |
@zhenyolka, thanks for the update. Could you add a unit test in test/test.cc to verify your implementation? |
a9aceab
to
c384be0
Compare
@yhirose done. Could you check? |
@zhenyolka, thanks for the excellent contribution! |
* Allow to specify server IP address * Reimplement in set_hostname_addr_map * Add tests for set_hostname_addr_map * Fix tests after implement set_hostname_addr_map * SpecifyServerIPAddressTest.RealHostname typo
cpp-httplib uses getaddrinfo to get server IP address to connect to. However sometimes this function might not work. For example when staticially linked with musl binary running on system. that don't have /etc/resolv.conf, android for example. Also plain DNS requests may be spoofed by ISP to block access to sites. Some Russian ISPs do that and with implementing by government National System of Domain Names this problem will grow. Also it affects privacy.
One of solution is to allow projects that use this library specify IP address of server when do HTTP/HTTPS request. So we can resolve IP over DoH/DoT or any other secure way and then pass it to cpp-httplib Client class constructor.
This pull request implements this feature.