middleware.RealIP is deprecated in this PR with pointers to the new API.
The deprecation only adds a // Deprecated: doc comment; the function keeps working for backward compatibility.
Why a new middleware (not "fix RealIP in place")
RealIP has two unfixable design choices: it mutates r.RemoteAddr, and it tries to be a one-size-fits-all default by walking a hard-coded list of headers any client can supply. Per adam-p's "The perils of the 'real' client IP" (which calls chi out by name on this), there is no safe default — the user must pick their trust source explicitly.
The new API
Four middlewares, two accessors. Pick exactly one middleware based on your
infrastructure, read the result with one of the two accessors:
// One of the four. There is no safe default — pick exactly one.funcClientIPFromHeader(trustedHeaderstring) func(http.Handler) http.HandlerfuncClientIPFromXFF(trustedIPPrefixes...string) func(http.Handler) http.HandlerfuncClientIPFromXFFTrustedProxies(numTrustedProxiesint) func(http.Handler) http.HandlerfuncClientIPFromRemoteAddr(h http.Handler) http.Handler// Read the result.funcGetClientIP(ctx context.Context) string// for logs, rate-limit keysfuncGetClientIPAddr(ctx context.Context) netip.Addr// for typed work
Example usage:
// Pick a single ClientIP middleware based on your deployment// Cloudflare.r.Use(middleware.ClientIPFromHeader("CF-Connecting-IP"))
// Nginx with ngx_http_realip_module.r.Use(middleware.ClientIPFromHeader("X-Real-IP"))
// Apache with mod_remoteip.r.Use(middleware.ClientIPFromHeader("X-Client-IP"))
// AWS CloudFront, or any proxy fleet with known CIDRs.r.Use(middleware.ClientIPFromXFF(
"13.32.0.0/15", // CloudFront IPv4"52.46.0.0/18", // CloudFront IPv4"2600:9000::/28", // CloudFront IPv6
))
// Behind exactly 2 trusted proxies with dynamic IPs (autoscaling pools,// ephemeral containers, dynamic CDN edges).r.Use(middleware.ClientIPFromXFFTrustedProxies(2))
// Server directly on the public internet, no proxy in front.r.Use(middleware.ClientIPFromRemoteAddr)
And in your handler or downstream middleware:
clientIP:=middleware.GetClientIP(r.Context())
// log it, use it as a rate-limit key, etc.
This release fixes #1785 introduced in v1.11.0 where expected argument values implementing the stringer interface (String() string) with a method which mutates their value, when passed to mock.Mock.On (m.On("Method", <expected>).Return()) or actual argument values passed to mock.Mock.Called may no longer match one another where they previously did match. The behaviour prior to v1.11.0 where the stringer is always called is restored. Future testify releases may not call the stringer method at all in this case.
What's Changed
Backport #1786 to release/1.11: mock: revert to pre-v1.11.0 argument matching behavior for mutating stringers by @brackendawson in #1788
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR contains the following updates:
Release Notes
aws/aws-lambda-go (github.com/aws/aws-lambda-go)v1.54.0
Compare Source
What's Changed
New Contributors
Full Changelog: aws/aws-lambda-go@v1.54.0...v1.53.0
v1.53.0
Compare Source
What's Changed
New Contributors
Full Changelog: aws/aws-lambda-go@v1.53.0...v1.52.0
fsnotify/fsnotify (github.com/fsnotify/fsnotify)v1.10.1
Compare Source
Changes and fixes
inotify: don't remove sibling watches sharing a path prefix (#754)
inotify, windows: don't rename sibling watches sharing a path prefix
(#755)
v1.10.0
Compare Source
This version of fsnotify needs Go 1.23.
Changes and fixes
-
-
-
-
-
-
-
go-chi/chi (github.com/go-chi/chi/v5)inotify: improve initialization error message (#731)
inotify: send Rename event if recursive watch is renamed (#696)
inotify: avoid copying event buffers when reading names (#741)
kqueue: skip dangling symlinks (ENOENT) in watchDirectoryFiles, so a bad entry no longer aborts Watcher.Add for the whole directory (#748)
kqueue: drop watches directly in Close() to fix a file descriptor leak when recycling watchers (#740)
windows: fix nil pointer dereference in remWatch (#736)
windows: lock watch field updates against concurrent WatchList to fix a race introduced in v1.9.0 (#709, #749)
v5.3.0
Compare Source
What's Changed
New Contributors
SECURITY: middleware.ClientIP, a replacement for middleware.RealIP
PR #967 introduced middleware.ClientIP, a replacement for middleware.RealIP that closes the three open spoofing advisories:
It also addresses issues outlined at:
middleware.RealIP is deprecated in this PR with pointers to the new API.
The deprecation only adds a // Deprecated: doc comment; the function keeps working for backward compatibility.
Why a new middleware (not "fix RealIP in place")
RealIP has two unfixable design choices: it mutates r.RemoteAddr, and it tries to be a one-size-fits-all default by walking a hard-coded list of headers any client can supply. Per adam-p's "The perils of the 'real' client IP" (which calls chi out by name on this), there is no safe default — the user must pick their trust source explicitly.
The new API
Four middlewares, two accessors. Pick exactly one middleware based on your
infrastructure, read the result with one of the two accessors:
Example usage:
And in your handler or downstream middleware:
Thanks to @adam-p, @c2h5oh, @rezmoss, @Saku0512, @convto, @Dirbaio, @jawnsy, @lrstanley, @mfridman, @n33pm, @pkieltyka for the prior discussions, detailed reviews, advisory reports, and test contributions that shaped this PR.
Full Changelog: go-chi/chi@v5.2.5...v5.3.0
stretchr/testify (github.com/stretchr/testify)v1.11.1
Compare Source
This release fixes #1785 introduced in v1.11.0 where expected argument values implementing the stringer interface (String() string) with a method which mutates their value, when passed to mock.Mock.On (m.On("Method", <expected>).Return()) or actual argument values passed to mock.Mock.Called may no longer match one another where they previously did match. The behaviour prior to v1.11.0 where the stringer is always called is restored. Future testify releases may not call the stringer method at all in this case.
What's Changed
Full Changelog: stretchr/testify@v1.11.0...v1.11.1
v1.11.0
Compare Source
What's Changed
Functional Changes
v1.11.0 Includes a number of performance improvements.
Fixes
Documentation, Build & CI
New Contributors
Full Changelog: stretchr/testify@v1.10.0...v1.11.0
Configuration
📅 Schedule: (UTC)
🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.
♻ Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.
👻 Immortal: This PR will be recreated if closed unmerged. Get config help if that's undesired.
This PR was generated by Mend Renovate. View the repository job log.