Skip to content

fix(openai): improve client IP retrieval in websocket handler#2468

Merged
luispater merged 1 commit intodevfrom
ip
Apr 1, 2026
Merged

fix(openai): improve client IP retrieval in websocket handler#2468
luispater merged 1 commit intodevfrom
ip

Conversation

@hkfires
Copy link
Copy Markdown
Collaborator

@hkfires hkfires commented Apr 1, 2026

No description provided.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a websocketClientAddress helper function to extract the client IP for logging in the OpenAI responses websocket handler. The review feedback identifies that the manual parsing of the remote address and port is redundant because the Gin framework's ClientIP method already implements this logic, and suggests a simplified implementation.

Comment thread sdk/api/handlers/openai/openai_responses_websocket.go Outdated
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: caa529c282

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

if c == nil || c.Request == nil {
return ""
}
return strings.TrimSpace(c.ClientIP())
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Avoid ClientIP without trusted proxy configuration

Switching this log field from Request.RemoteAddr to ClientIP() makes the recorded client address header-dependent; in this repo I only found SetTrustedProxies(...) in a unit test (rg "SetTrustedProxies|TrustedProxies|ForwardedByClientIP"), so production routes appear to rely on Gin defaults where X-Forwarded-For can be trusted too broadly. In that setup, a direct client can spoof X-Forwarded-For and poison websocket connection logs/audit trails with arbitrary IPs.

Useful? React with 👍 / 👎.

@luispater luispater merged commit 66cd50f into dev Apr 1, 2026
2 checks passed
@luispater luispater deleted the ip branch April 1, 2026 16:03
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