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

Improve connection wrapping #2

Merged
merged 8 commits into from
Oct 24, 2017
Merged

Improve connection wrapping #2

merged 8 commits into from
Oct 24, 2017

Conversation

inkel
Copy link
Owner

@inkel inkel commented Oct 23, 2017

This pull request refactors the package extensively. The biggest changes are the addition of tests (finally) and exporting the Conn structure. This has the additional benefit that now viaproxy.Conn exports a ProxyAddr method in addition to LocalAddr and RemoteAddr that provides more information about the addresses of the connection.

It also improves reading the Proxy Protocol line. Error management is improving, though is still far from what I'd like to have.

This pull request aims to address most (if not) the issues listed in #1.

inkel added 8 commits October 17, 2017 15:36
I am still not very happy about this method, but it should be more
complaint with the Proxy Protocol than the previous version. The tests
are far from perfect, yey, but I'm getting there.

This was much easier in my head than in practice.
Allows me not to add proxies for the net.Conn interface methods that
we are not interested in implementing.
This was utterly wrong, we don't want to change this value. What we
need instead is a way to tell the user the connection was coming from
a proxy and what the remote, proxy and local addresses are. This will
be addressed in a following commit.
This won't be visible yet, as the conn struct is not exported.
The previous code didn't really work, and it lacked tests. This commit
makes several changes to the previous version and adds some necessary
tests (which are far from perfect). The first important change is that
the internal `conn` struct now is exported as `Conn`, which will allow
users to cast to `*viaproxy.Conn` and access the additional
ProxyAddr() method that returns the proxy address.

The proxied connection initialization code was also rewrote almost
from scratch, and while I'm still not very happy about it (I'm
thinking how we can get rid of the buffered connection) it's working
better than before, IMO.
@inkel inkel force-pushed the feature/improve-conn-wrap branch from 4f71974 to 9f5f4c1 Compare October 23, 2017 20:07
@inkel inkel mentioned this pull request Oct 24, 2017
7 tasks
@inkel inkel merged commit 86ce4b9 into master Oct 24, 2017
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.

1 participant