mirror of
https://github.com/drakkan/sftpgo.git
synced 2025-12-07 23:00:55 +03:00
improve SFTP loop detection
This commit is contained in:
@@ -474,9 +474,10 @@ func EncodeTLSCertToPem(tlsCert *x509.Certificate) (string, error) {
|
||||
return string(pem.EncodeToMemory(&publicKeyBlock)), nil
|
||||
}
|
||||
|
||||
// CheckTCP4Port quits the app if bind to the given IPv4 port.
|
||||
// CheckTCP4Port quits the app if bind on the given IPv4 port fails.
|
||||
// This is a ugly hack to avoid to bind on an already used port.
|
||||
// It is required on Windows only.
|
||||
// It is required on Windows only. Upstream does not consider this
|
||||
// behaviour a bug:
|
||||
// https://github.com/golang/go/issues/45150
|
||||
func CheckTCP4Port(port int) {
|
||||
if runtime.GOOS != osWindows {
|
||||
@@ -484,8 +485,8 @@ func CheckTCP4Port(port int) {
|
||||
}
|
||||
listener, err := net.Listen("tcp4", fmt.Sprintf(":%d", port))
|
||||
if err != nil {
|
||||
logger.ErrorToConsole("unable to bind tcp4 address: %v", err)
|
||||
logger.Error(logSender, "", "unable to bind tcp4 address: %v", err)
|
||||
logger.ErrorToConsole("unable to bind on tcp4 address: %v", err)
|
||||
logger.Error(logSender, "", "unable to bind on tcp4 address: %v", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
listener.Close()
|
||||
|
||||
Reference in New Issue
Block a user