cmd/ctrld: fatal loudly if listen failed

For address already in use error when listening, we have a workaround to
spawn a new listener on different port. However, if that case does not
match, we must fatal to notice the error to user.
This commit is contained in:
Cuong Manh Le
2023-02-03 22:44:27 +07:00
committed by Cuong Manh Le
parent beca95d5b9
commit 318fec27de

View File

@@ -119,6 +119,9 @@ func (p *prog) run() {
proxyLog.Fatal().Err(err).Msgf("Unable to start dns proxy on listener.%s", listenerNum)
return
}
if err == nil {
return
}
if opErr, ok := err.(*net.OpError); ok {
if sErr, ok := opErr.Err.(*os.SyscallError); ok && errors.Is(opErr.Err, syscall.EADDRINUSE) || errors.Is(sErr.Err, errWindowsAddrInUse) {
@@ -159,6 +162,7 @@ func (p *prog) run() {
}
}
}
proxyLog.Fatal().Err(err).Msgf("Unable to start dns proxy on listener.%s", listenerNum)
}(listenerNum)
}