teleport/lib/loglimit
Vitor Enes 702a3ebd32
Deduplicate multiplexer detection errors over 1-minute windows (#20694)
* Deduplicate multiplexer detection errors over 1-minute windows

This commit deduplicates errors  returned by `Mux.detect` (which detects
the type of a new connection just established) over 1-minute windows.

This ensures that health checkers / malicious actors cannot pollute /
overpower the logs with warnings when such connections are invalid or
unknown to the multiplexer.

* Improve error message

* Fix lint

* Add `TestErrorDeduplicator`

* Multi-line Sprintf

* ErrorDeduplicator -> LogLimiter

* Improve `LogLimiter.Log` API

* Fix typo

* Remove `windowInfo`

* Improve test assertions

* Use new log limiter API

* Remove unnecessary append

Co-authored-by: Alan Parra <alan.parra@goteleport.com>

* Fix `toLogMessages`

* Start log limiter in `Mux.New`

* Use public API in tests

* Make `Config` field private

* Improve godoc

* Remove channel size from log limiter config

* Use `assert` instead of `require` for log assertions

* Revert "Start log limiter in `Mux.New`"

This reverts commit 3554daa6db.

* Use mutex instead of `entryCh`

* Start log limiter goroutine in `loglimit.New`

* Use `context.Background` as default.

Co-authored-by: Alan Parra <alan.parra@goteleport.com>

---------

Co-authored-by: Alan Parra <alan.parra@goteleport.com>
2023-03-08 20:32:44 +00:00
..
loglimit.go Deduplicate multiplexer detection errors over 1-minute windows (#20694) 2023-03-08 20:32:44 +00:00
loglimit_test.go Deduplicate multiplexer detection errors over 1-minute windows (#20694) 2023-03-08 20:32:44 +00:00