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)