-
Notifications
You must be signed in to change notification settings - Fork 184
Fix hostname resolution for proxied connections #913
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
Open
bartosz822
wants to merge
4
commits into
nats-io:main
Choose a base branch
from
rivero-ag:fix-proxy-hostname-resolution
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 2 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
f162017
Fix hostname resolution for proxied connections
bartosz822 465b0e6
Do not use `InetSocketAddress.createUnresolved` for uris already cont…
bartosz822 8d9679d
Add unit test
bartosz822 45da71d
Add enableInetAddressCreateUnresolved option
bartosz822 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, resolution is supposed to be done before it gets here. Look in the NatsConnection line 540 and work backward. Also look in NatsServerPool, where it does resolveHostToIps.
Resolution does not belong here, it belongs further back up the call chain.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree that the resolution probably belongs further back up the call chain. However the problem is that even if it didn't happen earlier, the default constructor of InetSocketAddress will perform it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be correct to say that this is only an issue in some cases AND only when a proxy is provided?
Why can't the proxy be expected to do this work?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes it is an issue only in some cases, it only really is an issue if a proxy is doing whitelisting based on domain names, which is a common use-case in secure/enterprise environments.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So the question remains, why can't this be part of the Option.proxy's responsibility? If it can be, we can simply add documentation to that effect.
I'm suspicious how common this really is in secure/enterprise environments. Enterprises are the most common users of this client, it's been around for 7 years, and this is the first time I'm hearing about the issue.
At a minimum we need an opt in solution to ensure backward compatibility, like
isEnableInetAddressCreateUnresolvedor something like that.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bartosz822 bump
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added the suggested option.
I don't understand how it could be part of the Option.proxy responsibility? What do you mean by that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The proxy seems to have some flexibility. You test has a proxy implementation. It seems like code could just go in there. But at least there is a backward compatible way now, so I think that's fine.