mirror of
https://github.com/onyx-and-iris/q3rcon-proxy.git
synced 2025-05-15 16:50:23 +01:00
return value straight from errChan
This commit is contained in:
parent
d0e3f5863a
commit
6489d1e556
@ -34,7 +34,7 @@ func main() {
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "target-host",
|
||||
Value: "127.0.0.1",
|
||||
Value: "localhost",
|
||||
Usage: "Target host address",
|
||||
Sources: cli.EnvVars("Q3RCON_TARGET_HOST"),
|
||||
},
|
||||
@ -100,26 +100,19 @@ func main() {
|
||||
go launchProxy(cfg, errChan)
|
||||
}
|
||||
|
||||
// Under normal circumstances, the main goroutine will block here
|
||||
// until the server is stopped or an error occurs.
|
||||
for err := range errChan {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
// Under normal circumstances, the main goroutine will block here.
|
||||
// If we receive an error we will log it and exit
|
||||
return <-errChan
|
||||
},
|
||||
}
|
||||
|
||||
if err := cmd.Run(context.Background(), os.Args); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
log.Fatal(cmd.Run(context.Background(), os.Args))
|
||||
}
|
||||
|
||||
// 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) {
|
||||
func launchProxy(cfg proxyConfig, errChan chan<- error) {
|
||||
proxyPort, targetPort := cfg.portsMapping[0], cfg.portsMapping[1]
|
||||
|
||||
hostAddr := fmt.Sprintf("%s:%s", cfg.proxyHost, proxyPort)
|
||||
|
Loading…
x
Reference in New Issue
Block a user