mirror of
https://github.com/onyx-and-iris/q3rcon-proxy.git
synced 2025-05-16 01:00:22 +01:00
rename initProxy to launchProxy
remove double log on error add some explanatory comments.
This commit is contained in:
parent
a00796254d
commit
d0e3f5863a
@ -13,6 +13,7 @@ import (
|
|||||||
"github.com/urfave/cli/v3"
|
"github.com/urfave/cli/v3"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// proxyConfig holds the configuration for a single UDP proxy server.
|
||||||
type proxyConfig struct {
|
type proxyConfig struct {
|
||||||
proxyHost string
|
proxyHost string
|
||||||
targetHost string
|
targetHost string
|
||||||
@ -96,13 +97,13 @@ func main() {
|
|||||||
sessionTimeout: cmd.Int("session-timeout"),
|
sessionTimeout: cmd.Int("session-timeout"),
|
||||||
}
|
}
|
||||||
|
|
||||||
go initProxy(cfg, errChan)
|
go launchProxy(cfg, errChan)
|
||||||
}
|
}
|
||||||
|
|
||||||
// We don't expect to receive any errors from the channels, but if we do, we log and return early.
|
// Under normal circumstances, the main goroutine will block here
|
||||||
|
// until the server is stopped or an error occurs.
|
||||||
for err := range errChan {
|
for err := range errChan {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Errorf("Error: %v", err)
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -115,7 +116,10 @@ func main() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func initProxy(cfg proxyConfig, errChan chan error) {
|
// launchProxy initializes the UDP proxy server with the given configuration.
|
||||||
|
// It listens on the specified proxy host and port, and forwards traffic to the target host and port.
|
||||||
|
// server.ListenAndServe blocks until the server is stopped or an error occurs.
|
||||||
|
func launchProxy(cfg proxyConfig, errChan chan error) {
|
||||||
proxyPort, targetPort := cfg.portsMapping[0], cfg.portsMapping[1]
|
proxyPort, targetPort := cfg.portsMapping[0], cfg.portsMapping[1]
|
||||||
|
|
||||||
hostAddr := fmt.Sprintf("%s:%s", cfg.proxyHost, proxyPort)
|
hostAddr := fmt.Sprintf("%s:%s", cfg.proxyHost, proxyPort)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user