mirror of
https://github.com/onyx-and-iris/q3rcon-proxy.git
synced 2025-01-18 08:40:53 +00:00
add isValidPacket
ignore packets that don't match q3 rcon/query
This commit is contained in:
parent
270f993cbc
commit
ab91c219b9
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user