mirror of https://github.com/status-im/consul.git
28 lines
531 B
Go
28 lines
531 B
Go
package lib
|
|
|
|
import (
|
|
"io"
|
|
"strings"
|
|
|
|
"github.com/hashicorp/yamux"
|
|
)
|
|
|
|
var yamuxStreamClosed = yamux.ErrStreamClosed.Error()
|
|
var yamuxSessionShutdown = yamux.ErrSessionShutdown.Error()
|
|
|
|
// IsErrEOF returns true if we get an EOF error from the socket itself, or
|
|
// an EOF equivalent error from yamux.
|
|
func IsErrEOF(err error) bool {
|
|
if err == io.EOF {
|
|
return true
|
|
}
|
|
|
|
errStr := err.Error()
|
|
if strings.Contains(errStr, yamuxStreamClosed) ||
|
|
strings.Contains(errStr, yamuxSessionShutdown) {
|
|
return true
|
|
}
|
|
|
|
return false
|
|
}
|