go-ssb-room/internal/network/errors.go

30 lines
587 B
Go
Raw Normal View History

// 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
}