mirror of
https://github.com/onyx-and-iris/q3rcon.git
synced 2024-11-22 08:30:48 +00:00
26 lines
470 B
Go
26 lines
470 B
Go
package packet
|
|
|
|
import "fmt"
|
|
|
|
type Request struct {
|
|
magic []byte
|
|
password string
|
|
}
|
|
|
|
func NewRequest(password string) Request {
|
|
return Request{
|
|
magic: []byte{'\xff', '\xff', '\xff', '\xff'},
|
|
password: password,
|
|
}
|
|
}
|
|
|
|
func (r Request) Header() []byte {
|
|
return append(r.magic, []byte("rcon")...)
|
|
}
|
|
|
|
func (r Request) Encode(cmd string) []byte {
|
|
datagram := r.Header()
|
|
datagram = append(datagram, fmt.Sprintf(" %s %s", r.password, cmd)...)
|
|
return datagram
|
|
}
|