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{
|
&cli.StringFlag{
|
||||||
Name: "target-host",
|
Name: "target-host",
|
||||||
Value: "127.0.0.1",
|
Value: "localhost",
|
||||||
Usage: "Target host address",
|
Usage: "Target host address",
|
||||||
Sources: cli.EnvVars("Q3RCON_TARGET_HOST"),
|
Sources: cli.EnvVars("Q3RCON_TARGET_HOST"),
|
||||||
},
|
},
|
||||||
@ -100,26 +100,19 @@ func main() {
|
|||||||
go launchProxy(cfg, errChan)
|
go launchProxy(cfg, errChan)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Under normal circumstances, the main goroutine will block here
|
// Under normal circumstances, the main goroutine will block here.
|
||||||
// until the server is stopped or an error occurs.
|
// If we receive an error we will log it and exit
|
||||||
for err := range errChan {
|
return <-errChan
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := cmd.Run(context.Background(), os.Args); err != nil {
|
log.Fatal(cmd.Run(context.Background(), os.Args))
|
||||||
log.Fatal(err)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// launchProxy initializes the UDP proxy server with the given configuration.
|
// 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.
|
// 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.
|
// 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]
|
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