format fixes

This commit is contained in:
onyx-and-iris 2026-02-15 15:54:02 +00:00
parent 1c5e18294e
commit 46874f2cf5
3 changed files with 21 additions and 6 deletions

View File

@ -8,9 +8,10 @@ import (
"strings"
"time"
udpproxy "github.com/onyx-and-iris/q3rcon-proxy"
log "github.com/sirupsen/logrus"
"github.com/urfave/cli/v3"
udpproxy "github.com/onyx-and-iris/q3rcon-proxy"
)
// proxyConfig holds the configuration for a single UDP proxy server.
@ -59,7 +60,10 @@ func main() {
return fmt.Errorf("invalid target port: %s", ports[1])
}
if proxyPort == targetPort {
return fmt.Errorf("proxy and target ports cannot be the same: %s", mapping)
return fmt.Errorf(
"proxy and target ports cannot be the same: %s",
mapping,
)
}
}
return nil

View File

@ -13,7 +13,9 @@ type Option func(*Client)
func WithSessionTimeout(timeout time.Duration) Option {
return func(c *Client) {
if timeout < time.Minute {
log.Warnf("cannot set stale session timeout to less than 1 minute.. defaulting to 20 minutes")
log.Warnf(
"cannot set stale session timeout to less than 1 minute.. defaulting to 20 minutes",
)
return
}

View File

@ -19,7 +19,7 @@ type session struct {
validator
}
func newSession(caddr *net.UDPAddr, raddr *net.UDPAddr, proxyConn *net.UDPConn) (*session, error) {
func newSession(caddr, raddr *net.UDPAddr, proxyConn *net.UDPConn) (*session, error) {
serverConn, err := net.DialUDP("udp", nil, raddr)
if err != nil {
return nil, err
@ -81,7 +81,11 @@ func (s *session) proxyTo(buf []byte) error {
var err error
if s.isChallengeRequestPacket(buf) {
parts := strings.SplitN(string(buf), " ", 3)
err = fmt.Errorf("invalid challenge from %s with GUID: %s", s.caddr.IP, parts[len(parts)-1])
err = fmt.Errorf(
"invalid challenge from %s with GUID: %s",
s.caddr.IP,
parts[len(parts)-1],
)
} else {
err = errors.New("not a rcon or query request packet")
}
@ -98,7 +102,12 @@ func (s *session) proxyTo(buf []byte) error {
if s.isRconRequestPacket(buf) {
parts := strings.SplitN(string(buf), " ", 3)
log.Infof("From [%s] To [%s] Command: %s", s.caddr.IP, s.serverConn.RemoteAddr(), parts[len(parts)-1])
log.Infof(
"From [%s] To [%s] Command: %s",
s.caddr.IP,
s.serverConn.RemoteAddr(),
parts[len(parts)-1],
)
}
return nil