2021-10-08 12:39:31 +00:00
|
|
|
// SPDX-FileCopyrightText: 2021 The NGI Pointer Secure-Scuttlebutt Team of 2020/2021
|
|
|
|
//
|
2021-02-09 11:53:33 +00:00
|
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
|
2021-01-25 12:23:03 +00:00
|
|
|
package network
|
|
|
|
|
|
|
|
import (
|
|
|
|
"errors"
|
|
|
|
"net"
|
|
|
|
"os"
|
|
|
|
"syscall"
|
|
|
|
)
|
|
|
|
|
|
|
|
func isConnBrokenErr(err error) bool {
|
|
|
|
netErr := new(net.OpError)
|
|
|
|
if errors.As(err, &netErr) {
|
|
|
|
var sysCallErr = new(os.SyscallError)
|
|
|
|
if errors.As(netErr.Err, &sysCallErr) {
|
|
|
|
action := sysCallErr.Unwrap()
|
|
|
|
if action == syscall.ECONNRESET || action == syscall.EPIPE {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if netErr.Err.Error() == "use of closed network connection" {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false
|
|
|
|
}
|