From ab91c219b92fae0b153ca3995c095155f35c6e72 Mon Sep 17 00:00:00 2001 From: onyx-and-iris Date: Sat, 27 Jan 2024 14:48:39 +0000 Subject: [PATCH] add isValidPacket ignore packets that don't match q3 rcon/query --- pkg/udpproxy/udpproxy.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/pkg/udpproxy/udpproxy.go b/pkg/udpproxy/udpproxy.go index 03dc739..f574749 100644 --- a/pkg/udpproxy/udpproxy.go +++ b/pkg/udpproxy/udpproxy.go @@ -36,6 +36,10 @@ func New(port, target string) (*Client, error) { }, nil } +func (c *Client) isValidPacket(header []byte) bool { + return string(header[:8]) == "\xff\xff\xff\xffrcon" || string(header[:13]) == "\xff\xff\xff\xffgetstatus" || string(header[:11]) == "\xff\xff\xff\xffgetinfo" +} + func (c *Client) ListenAndServe() error { var err error c.proxyConn, err = net.ListenUDP("udp", c.laddr) @@ -52,6 +56,10 @@ func (c *Client) ListenAndServe() error { log.Println(err) } + if !c.isValidPacket(buf[:16]) { + continue + } + session, found := c.sessions[caddr.String()] if !found { session, err = createSession(caddr, c.raddr, c.proxyConn)