mirror of
https://github.com/onyx-and-iris/q3rcon-proxy.git
synced 2026-02-19 18:19:11 +00:00
use net.JoinHostPort to build addresses
This commit is contained in:
parent
63cf99b217
commit
225188bb70
@ -4,6 +4,7 @@ package main
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"net"
|
||||
"os"
|
||||
"runtime/debug"
|
||||
"strconv"
|
||||
@ -158,18 +159,18 @@ func main() {
|
||||
func launchProxy(cfg proxyConfig, errChan chan<- error) {
|
||||
proxyPort, targetPort := cfg.portsMapping[0], cfg.portsMapping[1]
|
||||
|
||||
hostAddr := fmt.Sprintf("%s:%s", cfg.proxyHost, proxyPort)
|
||||
proxyAddr := fmt.Sprintf("%s:%s", cfg.targetHost, targetPort)
|
||||
proxyAddr := net.JoinHostPort(cfg.proxyHost, proxyPort)
|
||||
targetAddr := net.JoinHostPort(cfg.targetHost, targetPort)
|
||||
|
||||
server, err := udpproxy.New(
|
||||
hostAddr, proxyAddr,
|
||||
proxyAddr, targetAddr,
|
||||
udpproxy.WithSessionTimeout(time.Duration(cfg.sessionTimeout)*time.Minute))
|
||||
if err != nil {
|
||||
errChan <- fmt.Errorf("failed to create proxy: %w", err)
|
||||
return
|
||||
}
|
||||
|
||||
log.Infof("q3rcon-proxy initialised: [proxy] (%s) [target] (%s)", hostAddr, proxyAddr)
|
||||
log.Infof("q3rcon-proxy initialised: [proxy] (%s) [target] (%s)", proxyAddr, targetAddr)
|
||||
|
||||
errChan <- server.ListenAndServe()
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user