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

LocalAddr() and/or RemoteAddr() should return different values for each connection #273

Open
hansinator opened this issue Jan 31, 2023 · 0 comments

Comments

@hansinator
Copy link

I need to use LocalAddr() and/or RemoteAddr() on a pipe connection to log the client in a multiple-client setup. Unfortunately it always returns the same string for all connections on the same pipe address.

What I do now after accept is rather ugly and needs special handling for different connection types:


type fdInterface interface {
	Fd() uintptr
}
...
		c, err := l.Accept()
		if err != nil {
			return err
		}

		// create a sub-logger for each client connection
		cl := log.Logger.With().Str("client", fmt.Sprint(c.(fdInterface).Fd())).Logger()

Can you imagine a way how to remedy the situation? I'd submit a PR if we can agree on smthng.

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

No branches or pull requests

1 participant