Files
mathieuHaandClaude Opus 5.5 0ef9358b79 ⚡ build each trusted IP list once instead of once per router (#441)
* ⚡ build each trusted IP list once instead of once per router

Traefik builds an entry-point middleware once per router, and every
instance parsed forwardedHeadersTrustedIps and clientTrustedIps twice,
in ValidateParams and then for the pool strategy. NewChecker now returns
the Checker already built for the same list. A Checker is read-only once
built, so the bouncers can share it.

The cache is keyed by the comma-joined list. A list with an entry that
contains a comma is never valid, so it skips the cache and still fails
validation. The cache is emptied when it reaches 64 lists, so lists
replaced over many reloads do not pile up.

Fixes #440.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* 🐛 name the invalid entry in the trusted IPs error

net.ParseCIDR returns a nil network on failure, so the error named
<nil> instead of the entry that failed to parse.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* ⚡ keep at most 16 trusted IP lists in the cache

A configuration uses one to three lists, so 16 still leaves room, and
lists replaced over many reloads hold a quarter of the memory.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* 🐛 print the invalid entry once in the trusted IPs error

The error from net.ParseCIDR already names the entry, so naming it
again printed it twice.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-29 14:32:55 +01:00
..