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

Refactor + Caching #404

Open
wants to merge 95 commits into
base: master
Choose a base branch
from
Open

Refactor + Caching #404

wants to merge 95 commits into from

Conversation

hazcod
Copy link

@hazcod hazcod commented Sep 28, 2020

Up for discussion, it's a collection of refactors/prs & bugfixes.
Some tests are broken.

oec added 30 commits November 28, 2018 20:29
Important changes:

Fixes elazarl#256:  connections are closed after usage, so FD-count remains
congruent with the actual amount of open connections.

Added ProxyHttpServer.Signer of type
	type Signer func(ca *tls.Certificate, hostname []string) (*tls.Certificate, error)
If ProxyHttpServer.Signer is set, the goproxy uses that function to
retrieve Certificates for TLS-interception.  This allows consumers of
goproxy to implement f.e. caching of certificates.

Minor changes:

- adjusted import-path to github.com/oec/goproxy
- go fmt on all files
UrlHasPrefix did not add "://" between the url.Scheme and the url.Host
so that the comparison against the given prefix would fail, if that
starts with the usual URL syntax "scheme://host..."
oec and others added 29 commits September 18, 2019 09:10
After successful handshake in a HTTPS MITM scenario, it is not
sufficient call http.ReadRequest(clientTLS).  The body -or parts of it-
might still be in the bufio.Buffer and not processed yet.  The
subsequent call to http.ReadRequest will than fail because it doesn't
find a proper request-line in the buffer.

This patch reads the complete body from the request and resets the
bufio.Buffer so that the next call to http.ReadRequest() can work with a
clean plate.

[Unfortunately I haven't managed to create an test case for it as the
http.Client seems to open new CONNECTs to access the test-TLS-server.
Still working on it.]
When intercepting a CONNECT, we read the request from the client in a
loop and create another request object.  Before this commit, we had set
the .Host of this new request with the .Host from the original
CONNECT-request, which might contain a port number.  Such a request to
the outgoing server failed with 500.

With this commit, the proxy does not set .Host anymore on the outgoing
request (but still sets .URL.Host).
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.

2 participants