From 3e039824de4980c435d2e562c78411b9888c214b Mon Sep 17 00:00:00 2001 From: onyx-and-iris Date: Wed, 3 Apr 2024 20:54:10 +0100 Subject: [PATCH] log bad rcon requests at info level include client ip in log --- pkg/udpproxy/session.go | 6 +++++- pkg/udpproxy/validator.go | 4 ++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/pkg/udpproxy/session.go b/pkg/udpproxy/session.go index 9121c58..9e31d10 100644 --- a/pkg/udpproxy/session.go +++ b/pkg/udpproxy/session.go @@ -64,7 +64,11 @@ func (s *session) proxyFrom(buf []byte) error { } if s.isRconResponsePacket(buf) { - log.Debugf("Response: %s", string(buf[10:])) + if s.isBadRconRequest(buf) { + log.Infof("Response: Bad rcon from %s", s.caddr.IP) + } else { + log.Debugf("Response: %s", string(buf[10:])) + } } return nil diff --git a/pkg/udpproxy/validator.go b/pkg/udpproxy/validator.go index 631a504..0ff8370 100644 --- a/pkg/udpproxy/validator.go +++ b/pkg/udpproxy/validator.go @@ -26,3 +26,7 @@ func (v *validator) isQueryResponsePacket(buf []byte) bool { func (v *validator) isValidResponsePacket(buf []byte) bool { return v.isRconResponsePacket(buf) || v.isQueryResponsePacket(buf) } + +func (v *validator) isBadRconRequest(buf []byte) bool { + return string(buf[10:18]) == "Bad rcon" +}