-
Notifications
You must be signed in to change notification settings - Fork 114
Add proxy protocol support #608
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
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2 issues found across 4 files
Prompt for AI agents (all 2 issues)
Check if these issues are valid — if so, understand the root cause of each and fix them.
<file name="pkg/probod/probod.go">
<violation number="1" location="pkg/probod/probod.go:586">
P3: Missing `span.RecordError(err)` before returning the error. Other error returns in this function follow the pattern of recording the error to the span for tracing purposes.</violation>
<violation number="2" location="pkg/probod/probod.go:594">
P2: The second `defer listener.Close()` is unnecessary and causes a double-close. When `proxyproto.Listener` is closed, it also closes the underlying `net.Listener`. The original defer (line 580) already handles closing the wrapped listener. Remove this defer to avoid closing the underlying listener twice.</violation>
</file>
Reply to cubic to teach it or ask questions. Re-run a review with @cubic-dev-ai review this PR
pkg/probod/probod.go
Outdated
| ReadHeaderTimeout: 10 * time.Second, | ||
| Policy: policy, | ||
| } | ||
| defer listener.Close() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
P2: The second defer listener.Close() is unnecessary and causes a double-close. When proxyproto.Listener is closed, it also closes the underlying net.Listener. The original defer (line 580) already handles closing the wrapped listener. Remove this defer to avoid closing the underlying listener twice.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At pkg/probod/probod.go, line 594:
<comment>The second `defer listener.Close()` is unnecessary and causes a double-close. When `proxyproto.Listener` is closed, it also closes the underlying `net.Listener`. The original defer (line 580) already handles closing the wrapped listener. Remove this defer to avoid closing the underlying listener twice.</comment>
<file context>
@@ -578,6 +580,22 @@ func (impl *Implm) runApiServer(
+ ReadHeaderTimeout: 10 * time.Second,
+ Policy: policy,
+ }
+ defer listener.Close()
+
+ l.Info("using proxy protocol", log.String("trusted-proxies", strings.Join(impl.cfg.Api.ProxyProtocol.TrustedProxies, ", ")))
</file context>
pkg/probod/probod.go
Outdated
| if len(impl.cfg.Api.ProxyProtocol.TrustedProxies) > 0 { | ||
| policy, err := proxyproto.StrictWhiteListPolicy(impl.cfg.Api.ProxyProtocol.TrustedProxies) | ||
| if err != nil { | ||
| return fmt.Errorf("cannot create proxy protocol policy: %w", err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
P3: Missing span.RecordError(err) before returning the error. Other error returns in this function follow the pattern of recording the error to the span for tracing purposes.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At pkg/probod/probod.go, line 586:
<comment>Missing `span.RecordError(err)` before returning the error. Other error returns in this function follow the pattern of recording the error to the span for tracing purposes.</comment>
<file context>
@@ -578,6 +580,22 @@ func (impl *Implm) runApiServer(
+ if len(impl.cfg.Api.ProxyProtocol.TrustedProxies) > 0 {
+ policy, err := proxyproto.StrictWhiteListPolicy(impl.cfg.Api.ProxyProtocol.TrustedProxies)
+ if err != nil {
+ return fmt.Errorf("cannot create proxy protocol policy: %w", err)
+ }
+
</file context>
| return fmt.Errorf("cannot create proxy protocol policy: %w", err) | |
| span.RecordError(err) | |
| return fmt.Errorf("cannot create proxy protocol policy: %w", err) |
SachaProbo
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Signed-off-by: Bryan Frimin <[email protected]>
56b8cd8 to
0bd2b11
Compare
|
@cubic-dev-ai please review |
@gearnode I have started the AI code review. It will take a few minutes to complete. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No issues found across 4 files
This is preparatory in order to change the load balancer configuration and keep the the end-user IP address available on the request (required to e-signature, cookie consent, etc.).
I've use the most maintain library. I'm not a big fan of the code of the lib tbh if we got issue with it I will write our own implementation.