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

Include remote address string in Request, Call #2253

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from

Conversation

jquirke
Copy link
Contributor

@jquirke jquirke commented Mar 17, 2024

Allow peer address to be accessible to the server handler function as per #2252

This allows the server and middleware to access the underlying peer connection address in a transport agnostic way. Middleware and the server handler can then utilise this to implement audit, logging (debug), various host based rate limiting, etc.

e.g. Server RPC handler

peerAddrPort := yarpc.CallFromContext(ctx).CallerPeerAddrPort()

e.g. Middleware

peerAddrPort := request.CallerPeerAddrPort
  • Description and context for reviewers: one partner, one stranger
  • Docs (package doc)
  • Entry in CHANGELOG.md

api/encoding/call_test.go Outdated Show resolved Hide resolved
CHANGELOG.md Outdated Show resolved Hide resolved
@jquirke jquirke force-pushed the addremoteaddress branch 4 times, most recently from 762f458 to a40f5f4 Compare March 23, 2024 22:47
api/transport/request.go Outdated Show resolved Hide resolved
transport/http/handler.go Outdated Show resolved Hide resolved
transport/grpc/handler.go Outdated Show resolved Hide resolved
This allows the application to log the remote address for a connection.
It is primarily aimed at debugging and audit use cases. One can imagine
it can be injected to a logging context, for example.

e.g.
```
peerAddrPort := yarpc.CallFromContext(ctx).CallerPeerAddrPort().String()
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants