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

NO_PROXY port support + special case for proxying via localhost #11403

Merged
merged 54 commits into from
Apr 4, 2022

Conversation

atburke
Copy link
Contributor

@atburke atburke commented Mar 23, 2022

This PR updates NO_PROXY handling to allow blocking specific host:port combinations, rather than just the host. It also adds a special case for downgrading requests to plain HTTP when the following conditions are met:

  • --insecure is true
  • The request goes through a plain HTTP proxy at localhost (i.e. HTTP_PROXY=http://localhost)

Resolves #10175.

@r0mant r0mant removed the request for review from zmb3 March 28, 2022 18:32
@r0mant
Copy link
Collaborator

r0mant commented Mar 28, 2022

@jimbishopp Can you please take a look too?

api/client/proxy/proxy.go Outdated Show resolved Hide resolved
api/client/proxy/proxy.go Outdated Show resolved Hide resolved
api/client/proxy/proxy.go Show resolved Hide resolved
api/client/proxy/proxy.go Outdated Show resolved Hide resolved
Copy link
Contributor

@jimbishopp jimbishopp left a comment

Choose a reason for hiding this comment

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

LGTM

api/client/proxy/proxy_test.go Show resolved Hide resolved

// parse parses a URL. If the address does not have a scheme, it will prepend "http" and try.
func parse(addr string) (*url.URL, error) {
proxyurl, err := url.Parse(addr)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Some things about this function are still unclear to me:

  • proxyurl is still confusing because this function doesn't actually deal with proxy addresses now.
  • In which case addr will not have a scheme in it?
  • Shouldn't we default to https if the scheme is empty? That would be a more secure default, no?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Whether or not addr has a scheme depends on the caller; the existing proxy tests didn't have schemes, so I'm assuming that's a common and expected scenario.

The extra http:// is only there to help parse the url; parse doesn't assume http. GetProxyAddress handles the scheme-less URLs by checking https first, then http.

api/client/proxy/proxy.go Show resolved Hide resolved
lib/client/https_client.go Outdated Show resolved Hide resolved
api/client/webclient/webclient.go Outdated Show resolved Hide resolved
@atburke atburke requested a review from r0mant March 31, 2022 22:54
api/client/proxy/proxy.go Outdated Show resolved Hide resolved
api/client/proxy/proxy.go Outdated Show resolved Hide resolved
@atburke atburke enabled auto-merge (squash) April 1, 2022 22:46
@atburke atburke disabled auto-merge April 4, 2022 17:52
@atburke atburke merged commit e3a8fb7 into master Apr 4, 2022
@atburke atburke deleted the atburke/tsh-http-fallback branch April 4, 2022 21:23
atburke added a commit that referenced this pull request Apr 5, 2022
This change updates NO_PROXY handling to allow blocking specific host:port combinations, rather than just the host. It also adds a special case for downgrading requests to plain HTTP when --insecure is true and the request goes through a plain HTTP proxy at localhost (i.e. HTTP_PROXY=http://localhost).
atburke added a commit that referenced this pull request Apr 12, 2022
This change updates NO_PROXY handling to allow blocking specific host:port combinations, rather than just the host. It also adds a special case for downgrading requests to plain HTTP when --insecure is true and the request goes through a plain HTTP proxy at localhost (i.e. HTTP_PROXY=http://localhost).
@webvictim webvictim mentioned this pull request Apr 19, 2022
@webvictim webvictim mentioned this pull request Jun 8, 2022
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.

HTTP fallback for tsh
4 participants