Skip to content

Support for PROXY protocol v1 and v2#920

Merged
mmatczuk merged 12 commits intomainfrom
mmt/proxyproto_v4
Sep 24, 2024
Merged

Support for PROXY protocol v1 and v2#920
mmatczuk merged 12 commits intomainfrom
mmt/proxyproto_v4

Conversation

@mmatczuk
Copy link
Contributor

No description provided.

It is ingested because go mod failed

$ go mod tidy
go: finding module for package github.com/mailgun/influx/proxyproto
go: github.com/saucelabs/forwarder/proxyproto imports
        github.com/mailgun/proxyproto tested by
        github.com/mailgun/proxyproto.test imports
        github.com/mailgun/influx/proxyproto: cannot find module providing package github.com/mailgun/influx/proxyproto: module github.com/mailgun/influx/proxyproto: git ls-remote -q origin in /Users/michal/go/pkg/mod/cache/vcs/305ad51dbd40a25626bb1b1b54a6123e638813e336c601d6c4da5bb43e5b0e43: exit status 128:
        fatal: could not read Username for 'https://github.com': terminal prompts disabled
Confirm the import path was entered correctly.
If this is a private repository, see https://golang.org/doc/faq#git_https for additional information.
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.
    --proxy-protocol-enabled <value> (default false) (env FORWARDER_PROXY_PROTOCOL_ENABLED)
        The PROXY protocol is used to correctly read the client's IP address. When enabled the proxy will expect the
        client to send the PROXY protocol header before the actual request. It is still possible to connect to the
        proxy without the PROXY protocol header when this flag is enabled.

    --proxy-protocol-read-header-timeout <duration> (default 10s) (env FORWARDER_PROXY_PROTOCOL_READ_HEADER_TIMEOUT)
        The amount of time to wait for PROXY protocol header. Zero means no limit.
Enable proxy protocol by default in tests.
Add tests to check if XFF header is properly updated.
@mmatczuk mmatczuk requested a review from Choraden as a code owner September 23, 2024 14:17
Comment on lines +179 to +182
ll = &proxyproto.Listener{
Listener: ll,
ReadHeaderTimeout: l.ProxyProtocolConfig.ReadHeaderTimeout,
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Use constructor? It's from different package.

Copy link
Contributor

Choose a reason for hiding this comment

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

On the other hand, this is handy

@Choraden
Copy link
Contributor

LGTM

@mmatczuk mmatczuk merged commit 1564447 into main Sep 24, 2024
@mmatczuk mmatczuk deleted the mmt/proxyproto_v4 branch September 24, 2024 09:57
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