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

proxyproto: PROXY protocol net.Conn and net.Listener impl #919

Closed
wants to merge 1 commit into from

Conversation

mmatczuk
Copy link
Contributor

Use github.com/pires/go-proxyproto header parsing and provide better (safer) net.Conn and net.Listener implementations.

Use github.com/pires/go-proxyproto header parsing and provide better (safer) net.Conn and net.Listener implementations.
The Conn type is designed after tls.Conn.

We never read more than header bytes from connection.
This allows to eliminate any 3rd party readers,
and to use the connection ReadFrom() and WriteTo() functions if provided.
The underlying connection is available via Conn.NetConn().

On context cancellation the connection is closed to terminate the paring go routine,
and to avoid unspecified behaviour caused by double reads from header parsing and user code.
panic("proxy protocol header read: unexpected data after header")
}

resCh <- r
Copy link
Contributor

Choose a reason for hiding this comment

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

It may leak.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Let's make buffered chanel.

@mmatczuk mmatczuk closed this Sep 23, 2024
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