Skip to content
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

Allow overriding of DNS resolution to specified IP addresses(#561) #1277

Merged
merged 1 commit into from Jun 16, 2021

Conversation

campbellC
Copy link
Contributor

@campbellC campbellC commented Jun 1, 2021

This change allows users to bypass the selected DNS resolver for
specific domains. The allows, for example, to make calls to a local TLS
server by rerouting a given domain to 127.0.0.1.

The approach I've taken for the design is to wrap the resolver in an
outer service. This leads to a fair amount of boilerplate code mainly to
be able to explain the typing to the compiler. The actual business logic
is very simple for the number of lines involved.

One alternative option I considered was using an inline tower_service instead of a struct. This is possible at the cost of making reqwest's HttpConnector generic, because I could not find a way to state the type of this inlined struct. This was a bigger change than I wanted to make but happy to reconsider, it would reduce the boilerplate for sure.

NB: this change adds a new dependency (itertools). This is simply to use one struct (itertools::Either) which would be simple to implement directly. If keeping the dependency tree short is needed this is a small change I believe.

Closes #561

Copy link
Owner

@seanmonstar seanmonstar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is really good work, thank you! Just some small suggestions inline.

Cargo.toml Outdated Show resolved Hide resolved
src/async_impl/client.rs Outdated Show resolved Hide resolved
@campbellC
Copy link
Contributor Author

New version with the requested changes. I'm afraid I'm not great with the Github PR process so I did a force push and this may have made inter-version comparison more difficult. The only changes are:

  • Remove itertools as a depdendency
  • Introduce a module in src/connect.rs itertools that implements an Either iterator type
  • Into<SocketAddr> -> SocketAddr

campbellC added a commit to campbellC/third-wheel that referenced this pull request Jun 3, 2021
src/connect.rs Outdated Show resolved Hide resolved
@campbellC
Copy link
Contributor Author

Are there any more changes requested for this patch? Cheers.

Copy link
Owner

@seanmonstar seanmonstar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, what a helpful feature, finally in! ❤️

@seanmonstar
Copy link
Owner

Ah, to make the older Rust version work, you could use futures_util::future::ready instead of from std.

@campbellC
Copy link
Contributor Author

I have switched to futures_util and tested locally that it builds on 1.46. No other changes made so I expect workflows will work now. Thanks!

…tar#561)

This change allows users to bypass the selected DNS resolver for
specific domains. The allows, for example, to make calls to a local TLS
server by rerouting a given domain to 127.0.0.1.

The approach I've taken for the design is to wrap the resolver in an
outer service. This leads to a fair amount of boilerplate code mainly to
be able to explain the typing to the compiler. The actual business logic
is very simple for the number of lines involved.

Closes seanmonstar#561
@campbellC
Copy link
Contributor Author

I rebased onto the new changes and no conflicts there either so merge should be simple.

@seanmonstar seanmonstar merged commit 8e5af45 into seanmonstar:master Jun 16, 2021
pfernie added a commit to pfernie/reqwest that referenced this pull request Jun 25, 2021
* master:
  add option to disable http2 upgrade (seanmonstar#1292)
  Fix documentation of http1_title_case_headers() (seanmonstar#1294)
  CI: make a single final job that depends on all others (seanmonstar#1291)
  Fix bare url warnings in `multipart` docs (seanmonstar#1289)
  v0.11.4
  Allow overriding of DNS resolution to specified IP addresses(seanmonstar#561) (seanmonstar#1277)
  WASM: Add `try_clone` implementations to `Request` and `RequestBuilder` (seanmonstar#1286)
  Add native-tls-alpn feature (seanmonstar#1283)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

DNS bypass
2 participants