2 Commits

Author SHA1 Message Date
2c8ae43303 split 3 times, log last part 2024-04-03 23:58:58 +01:00
0935fc1190 rename isBadRconRequest to isBadRconResponse 2024-04-03 20:59:37 +01:00
2 changed files with 4 additions and 4 deletions

View File

@@ -64,7 +64,7 @@ func (s *session) proxyFrom(buf []byte) error {
} }
if s.isRconResponsePacket(buf) { if s.isRconResponsePacket(buf) {
if s.isBadRconRequest(buf) { if s.isBadRconResponse(buf) {
log.Infof("Response: Bad rcon from %s", s.caddr.IP) log.Infof("Response: Bad rcon from %s", s.caddr.IP)
} else { } else {
log.Debugf("Response: %s", string(buf[10:])) log.Debugf("Response: %s", string(buf[10:]))
@@ -89,8 +89,8 @@ func (s *session) proxyTo(buf []byte) error {
} }
if s.isRconRequestPacket(buf) { if s.isRconRequestPacket(buf) {
parts := strings.Split(string(buf), " ") parts := strings.SplitN(string(buf), " ", 3)
log.Infof("From [%s] To [%s] Command: %s", s.caddr.IP, s.serverConn.RemoteAddr(), strings.Join(parts[2:], " ")) log.Infof("From [%s] To [%s] Command: %s", s.caddr.IP, s.serverConn.RemoteAddr(), parts[len(parts)-1])
} }
return nil return nil

View File

@@ -27,6 +27,6 @@ func (v *validator) isValidResponsePacket(buf []byte) bool {
return v.isRconResponsePacket(buf) || v.isQueryResponsePacket(buf) return v.isRconResponsePacket(buf) || v.isQueryResponsePacket(buf)
} }
func (v *validator) isBadRconRequest(buf []byte) bool { func (v *validator) isBadRconResponse(buf []byte) bool {
return string(buf[10:18]) == "Bad rcon" return string(buf[10:18]) == "Bad rcon"
} }