mirror of
https://github.com/onyx-and-iris/q3rcon-proxy.git
synced 2026-02-16 08:47:49 +00:00
format fixes
This commit is contained in:
parent
1c5e18294e
commit
46874f2cf5
@ -8,9 +8,10 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
udpproxy "github.com/onyx-and-iris/q3rcon-proxy"
|
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
"github.com/urfave/cli/v3"
|
"github.com/urfave/cli/v3"
|
||||||
|
|
||||||
|
udpproxy "github.com/onyx-and-iris/q3rcon-proxy"
|
||||||
)
|
)
|
||||||
|
|
||||||
// proxyConfig holds the configuration for a single UDP proxy server.
|
// 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])
|
return fmt.Errorf("invalid target port: %s", ports[1])
|
||||||
}
|
}
|
||||||
if proxyPort == targetPort {
|
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
|
return nil
|
||||||
|
|||||||
@ -13,7 +13,9 @@ type Option func(*Client)
|
|||||||
func WithSessionTimeout(timeout time.Duration) Option {
|
func WithSessionTimeout(timeout time.Duration) Option {
|
||||||
return func(c *Client) {
|
return func(c *Client) {
|
||||||
if timeout < time.Minute {
|
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
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
15
session.go
15
session.go
@ -19,7 +19,7 @@ type session struct {
|
|||||||
validator
|
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)
|
serverConn, err := net.DialUDP("udp", nil, raddr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -81,7 +81,11 @@ func (s *session) proxyTo(buf []byte) error {
|
|||||||
var err error
|
var err error
|
||||||
if s.isChallengeRequestPacket(buf) {
|
if s.isChallengeRequestPacket(buf) {
|
||||||
parts := strings.SplitN(string(buf), " ", 3)
|
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 {
|
} else {
|
||||||
err = errors.New("not a rcon or query request packet")
|
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) {
|
if s.isRconRequestPacket(buf) {
|
||||||
parts := strings.SplitN(string(buf), " ", 3)
|
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
|
return nil
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user