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

allow RemoteAddrHandler to include addresses which have no port #347

Merged
merged 3 commits into from Aug 19, 2021
Merged

allow RemoteAddrHandler to include addresses which have no port #347

merged 3 commits into from Aug 19, 2021

Conversation

Vivalldi
Copy link
Contributor

@Vivalldi Vivalldi commented Aug 19, 2021

Many HTTP servers end up being placed behind reverse proxies. As a result, many devs use middleware to map reverse-proxy headers to the request RemoteAddr. Many of these headers don't include ports, causing an otherwise valid RemoteAddrHandler to not set the field.

@rs
Copy link
Owner

rs commented Aug 19, 2021

We should probably not remove the port anyway. I would accept a PR with plain remote addr copied to the field.

@Vivalldi
Copy link
Contributor Author

Vivalldi commented Aug 19, 2021

Just for clarification, are you suggesting

A. Update RemoteAddrHandler to only use the r.RemoteAddr in it's pure state (unless empty, then don't add)

if r.RemoteAddr != "" {
    // Add to log
}

B. Create a new Handler that does the above, but leaves RemoteAddrHandler intact

@rs
Copy link
Owner

rs commented Aug 19, 2021

I mean A. This is a change of behavior, but thinking about it, current behavior is misleading.

@Vivalldi
Copy link
Contributor Author

Updated! Would you like to keep or remove the additional tests? (They don't really assert anything special anymore due to the change in logic)

@rs
Copy link
Owner

rs commented Aug 19, 2021

You can remove the non relevant ones.

@Vivalldi
Copy link
Contributor Author

Done! Thanks for the feedback

@rs rs merged commit fe93100 into rs:master Aug 19, 2021
@Vivalldi Vivalldi deleted the remote-addr-no-port branch August 23, 2021 14:55
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.

None yet

2 participants