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

Add remote_addr to context #70

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions wire.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,11 +127,13 @@ func (srv *Server) Serve(listener net.Listener) error {

func (srv *Server) serve(ctx context.Context, conn net.Conn) error {
ctx = setTypeInfo(ctx, srv.types)
ctx = context.WithValue(ctx, "remote_addr", conn.RemoteAddr())
Copy link
Owner

Choose a reason for hiding this comment

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

Would you be able to create a wrapper function to fetch the remote_addr from the context? Similar as done within the conn.go: https://github.com/jeroenrinzema/psql-wire/blob/main/conn.go#L24-L31

defer conn.Close()

srv.logger.Debug("serving a new client connection")

conn, version, reader, err := srv.Handshake(conn)

if err != nil {
return err
}
Expand Down