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

vsock_proxy: Perform DNS resolution after the expiration of the TTL #593

Merged
merged 11 commits into from
Apr 11, 2024

Conversation

meerd
Copy link
Contributor

@meerd meerd commented Mar 13, 2024

Description of changes: This PR addresses the wrong assumption that domain names are resolved to fixed static IP addresses. With these changes, vsock-proxy periodically refreshes the resolved IP address of the remote host after the Time-To-Live (TTL) expires, ensuring that the most up-to-date IP address is used.

Relevant issues: #553

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@meerd meerd changed the base branch from vsp_enable_logging to main April 9, 2024 08:45
@meerd meerd force-pushed the dns_resolve branch 3 times, most recently from a59972b to b78b6c4 Compare April 9, 2024 09:48
@meerd meerd changed the base branch from main to fix_ci April 9, 2024 12:58
meerd added 6 commits April 9, 2024 12:58
Use an enumeration type (IpAddrType) instead of boolean variables
to represent different IP address types.

Signed-off-by: Erdem Meydanli <[email protected]>
- Create a new module 'dns.rs' to encapsulate DNS-related operations.
- Move existing DNS-related functionality into the new 'dns.rs' module.
- Rename 'parse_addr' function to 'resolve' for better semantic clarity.

Signed-off-by: Erdem Meydanli <[email protected]>
Rename starter.rs module to proxy.rs to better reflect its purpose.

Signed-off-by: Erdem Meydanli <[email protected]>
Perform allowlisted hosts' check before creating a Proxy instance and
terminate the application if necessary.

Signed-off-by: Erdem Meydanli <[email protected]>
The proxy used to resolve the server hostname only once during its
startup. This behavior was creating issues where the DNS addresses changed
frequently. This commit changes the behavior to resolve DNS each time after
the TTL expires.

Signed-off-by: Erdem Meydanli <[email protected]>
This commit resolves all errors and warnings that surfaced
after upgrading from rustc v1.60 to v1.68.2.

Signed-off-by: Erdem Meydanli <[email protected]>
@meerd meerd force-pushed the dns_resolve branch 4 times, most recently from 6161520 to ae2e1e1 Compare April 10, 2024 06:32
@meerd meerd changed the title [WIP] vsock_proxy: Perform DNS resolution after the expiration of the TTL vsock_proxy: Perform DNS resolution after the expiration of the TTL Apr 10, 2024
@meerd meerd requested review from foersleo and mariusknaust April 10, 2024 06:40
Copy link
Contributor

@foersleo foersleo left a comment

Choose a reason for hiding this comment

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

Apart from the comments about the mismatch in error message and test pointed out before this looks good to me.

vsock_proxy/Cargo.toml Outdated Show resolved Hide resolved
vsock_proxy/src/dns.rs Outdated Show resolved Hide resolved
@meerd meerd requested a review from foersleo April 10, 2024 09:15
vsock_proxy/src/proxy.rs Outdated Show resolved Hide resolved
vsock_proxy/src/proxy.rs Outdated Show resolved Hide resolved
vsock_proxy/src/proxy.rs Outdated Show resolved Hide resolved
vsock_proxy/src/proxy.rs Outdated Show resolved Hide resolved
vsock_proxy/src/dns.rs Outdated Show resolved Hide resolved
vsock_proxy/src/dns.rs Outdated Show resolved Hide resolved
vsock_proxy/src/proxy.rs Outdated Show resolved Hide resolved
@meerd meerd force-pushed the dns_resolve branch 2 times, most recently from f444244 to 30e7686 Compare April 11, 2024 15:19
meerd added 4 commits April 11, 2024 15:33
Modify the signature of `dns::resolve` function to return a `DnsResolveResult`
struct instead of a plain vector of IP addresses.

Signed-off-by: Erdem Meydanli <[email protected]>
Add tests for the dns module to improve coverage.

Signed-off-by: Erdem Meydanli <[email protected]>
Replace the existing DNS lookup implementation with hickory_resolver.
This allows accessing additional information from DNS records, such as
TTL values, and enhances the functionality of the dns module.

Signed-off-by: Erdem Meydanli <[email protected]>
Replace DnsResolveResult with DnsResolutionInfo. The new type includes
utility methods and provides a better interface for DNS resolution
information, encapsulating resolved IP address, TTL value, and last
resolution time.

Signed-off-by: Erdem Meydanli <[email protected]>
This commit marks the new release of the vsock_proxy, setting the
version to 1.0.0.

Signed-off-by: Erdem Meydanli <[email protected]>
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.

3 participants