Allow manual re-resolving of server hostname #1365
Draft
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This feature is designed to solve one specific use case that I personally have: roaming the client on and off ZScaler ZPA as I move my laptop between home and the office.
The way ZPA works is that when have it enabled, all DNS lookups for ZPA-protected hostnames are intercepted and converted into IP address for ZScaler endpoints (which then proxy the packets to the actual mosh-server host).
When ZPA is disabled (when you're inside a trusted corporate network), DNS lookups for the mosh-server host resolve to the "normal" IP address.
So this looks a lot like a roaming server.
This commit adds a new "re-resolve" command to trigger a manual DNS lookup. This is just a boring call to
getaddrinfo(so no new fancy async resolver), and it's fully manual, so there's no attempts to automatically figure out when a new DNS lookup is needed.This has been working well for my use case. Note that this approach is not general enough to work for everyone. For example, it doesn't handle the case where the actual hostname is known only to your ssh_config. And I've made no attempts to test anything other than IPv4. So this PR is marked as a "Draft" and will probably never be merged in its current form. But I'm sharing it here anyway because I'm sure others will find it useful.
Most of the code in this commit was written by Gemini AI.