mirror of
https://github.com/onyx-and-iris/q3rcon-proxy.git
synced 2026-04-07 15:53:29 +00:00
Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 5ac3f805e2 | |||
| ab548d669a | |||
| 107f914d3b | |||
| 0fdf9d10c3 | |||
| 690fabddaf | |||
| f6f0044a84 | |||
| 725e6cfb3d | |||
| ca33a6a390 |
35
CHANGELOG.md
35
CHANGELOG.md
@@ -11,8 +11,41 @@ Before any major/minor/patch bump all unit tests will be run to verify they pass
|
|||||||
|
|
||||||
- [x]
|
- [x]
|
||||||
|
|
||||||
|
## [0.6.0] - 2024-03-21
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- new environment variable `Q3RCON_DEBUG` for enabling debug logging. Defaults to 0.
|
||||||
|
- rcon responses are now logged at debug level
|
||||||
|
- invalid responses (rcon and query) now logged
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- All packet header checking methods moved into Session struct.
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- a bug causing the proxy not to send back query responses
|
||||||
|
|
||||||
|
## [0.3.0] - 2024-03-08
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- outgoing rcon requests now logged at info level
|
||||||
|
- new environment variable `Q3RCON_HOST` for specifying which ip to bind the proxy to. Defaults to `0.0.0.0`.
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- now using [logrus][logrus] package for logging.
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- a `slice bounds out of range` error due to query packets being logged.
|
||||||
|
|
||||||
## [0.1.0] - 2024-01-27
|
## [0.1.0] - 2024-01-27
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
- only forward packets if the header matches q3 rcon/query.
|
- only forward packets if the header matches q3 rcon/query.
|
||||||
|
|
||||||
## [0.0.1] - 2024-01-27
|
## [0.0.1] - 2024-01-27
|
||||||
@@ -20,3 +53,5 @@ Before any major/minor/patch bump all unit tests will be run to verify they pass
|
|||||||
### Added
|
### Added
|
||||||
|
|
||||||
- All source files for lilproxy including full commit history.
|
- All source files for lilproxy including full commit history.
|
||||||
|
|
||||||
|
[logrus]: https://github.com/sirupsen/logrus
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ Avoid sending plaintext rcon commands to the public game server port. In general
|
|||||||
|
|
||||||
### Special Thanks
|
### Special Thanks
|
||||||
|
|
||||||
[Dylan][user_link] For writing this proxy.
|
[Dylan][user_link] For writing [lilproxy][lilproxy_url].
|
||||||
|
|
||||||
[lilproxy_url]: https://github.com/dgparker/lilproxy
|
[lilproxy_url]: https://github.com/dgparker/lilproxy
|
||||||
[user_link]: https://github.com/dgparker
|
[user_link]: https://github.com/dgparker
|
||||||
|
|||||||
18
debian/q3rcon-proxy.service
vendored
Normal file
18
debian/q3rcon-proxy.service
vendored
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=Q3Rcon Proxy Service
|
||||||
|
Wants=network.target
|
||||||
|
After=network.target
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=simple
|
||||||
|
User=gameservers
|
||||||
|
Environment="Q3RCON_PROXY=20000:28960;20001:28961;20002:28962"
|
||||||
|
Environment="Q3RCON_HOST=0.0.0.0"
|
||||||
|
Environment="Q3RCON_DEBUG=0"
|
||||||
|
|
||||||
|
ExecStart=/usr/local/bin/q3rcon-proxy
|
||||||
|
Restart=always
|
||||||
|
RestartSec=3
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
||||||
@@ -34,22 +34,30 @@ func newSession(caddr *net.UDPAddr, raddr *net.UDPAddr, proxyConn *net.UDPConn)
|
|||||||
return session, nil
|
return session, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Session) isRconPacket(buf []byte) bool {
|
func (s *Session) isRconRequestPacket(buf []byte) bool {
|
||||||
return string(buf[:8]) == "\xff\xff\xff\xffrcon"
|
return string(buf[:8]) == "\xff\xff\xff\xffrcon"
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Session) isQueryPacket(buf []byte) bool {
|
func (s *Session) isQueryRequestPacket(buf []byte) bool {
|
||||||
return string(buf[:13]) == "\xff\xff\xff\xffgetstatus" || string(buf[:11]) == "\xff\xff\xff\xffgetinfo"
|
return string(buf[:13]) == "\xff\xff\xff\xffgetstatus" || string(buf[:11]) == "\xff\xff\xff\xffgetinfo"
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Session) isValidPacket(buf []byte) bool {
|
func (s *Session) isValidRequestPacket(buf []byte) bool {
|
||||||
return s.isRconPacket(buf) || s.isQueryPacket(buf)
|
return s.isRconRequestPacket(buf) || s.isQueryRequestPacket(buf)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Session) isResponsePacket(buf []byte) bool {
|
func (s *Session) isRconResponsePacket(buf []byte) bool {
|
||||||
return string(buf[:9]) == "\xff\xff\xff\xffprint"
|
return string(buf[:9]) == "\xff\xff\xff\xffprint"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *Session) isQueryResponsePacket(buf []byte) bool {
|
||||||
|
return string(buf[:18]) == "\xff\xff\xff\xffstatusResponse" || string(buf[:16]) == "\xff\xff\xff\xffinfoResponse"
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *Session) isValidResponsePacket(buf []byte) bool {
|
||||||
|
return s.isRconResponsePacket(buf) || s.isQueryResponsePacket(buf)
|
||||||
|
}
|
||||||
|
|
||||||
func (s *Session) listen() error {
|
func (s *Session) listen() error {
|
||||||
for {
|
for {
|
||||||
buf := make([]byte, 2048)
|
buf := make([]byte, 2048)
|
||||||
@@ -64,8 +72,10 @@ func (s *Session) listen() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *Session) proxyFrom(buf []byte) error {
|
func (s *Session) proxyFrom(buf []byte) error {
|
||||||
if !s.isResponsePacket(buf) {
|
if !s.isValidResponsePacket(buf) {
|
||||||
return nil
|
err := errors.New("not a rcon or query response packet")
|
||||||
|
log.Error(err.Error())
|
||||||
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
s.updateTime = time.Now()
|
s.updateTime = time.Now()
|
||||||
@@ -75,17 +85,16 @@ func (s *Session) proxyFrom(buf []byte) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if log.GetLevel() == log.DebugLevel {
|
if s.isRconResponsePacket(buf) {
|
||||||
parts := strings.Split(string(buf[10:]), " ")
|
log.Debugf("Response: %s", string(buf[10:]))
|
||||||
log.Debugf("Response: %s", strings.Join(parts, " "))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Session) proxyTo(buf []byte) error {
|
func (s *Session) proxyTo(buf []byte) error {
|
||||||
if !s.isValidPacket(buf) {
|
if !s.isValidRequestPacket(buf) {
|
||||||
err := errors.New("not a rcon or query packet")
|
err := errors.New("not a rcon or query request packet")
|
||||||
log.Error(err.Error())
|
log.Error(err.Error())
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -97,9 +106,9 @@ func (s *Session) proxyTo(buf []byte) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if s.isRconPacket(buf) {
|
if s.isRconRequestPacket(buf) {
|
||||||
parts := strings.Split(string(buf), " ")
|
parts := strings.Split(string(buf), " ")
|
||||||
log.Infof("From [%s] To [%s] Command: %s", s.caddr.IP.String(), s.serverConn.RemoteAddr().String(), strings.Join(parts[2:], " "))
|
log.Infof("From [%s] To [%s] Command: %s", s.caddr.IP, s.serverConn.RemoteAddr(), strings.Join(parts[2:], " "))
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|||||||
Reference in New Issue
Block a user