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

30 lines
587 B
Go

// SPDX-FileCopyrightText: 2021 The NGI Pointer Secure-Scuttlebutt Team of 2020/2021
//
// SPDX-License-Identifier: MIT
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
}