mirror of
https://github.com/0xJacky/nginx-ui.git
synced 2025-05-12 10:55:51 +02:00
refactor: nodes analytics (#847)
* refactor: nodes analytics * feat(debug): add pprof in debug mode * refactor: websocket error handler
This commit is contained in:
parent
b1ba719cb1
commit
cb4977e5ab
17 changed files with 276 additions and 155 deletions
|
@ -1,24 +1,21 @@
|
|||
package helper
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"github.com/gorilla/websocket"
|
||||
"errors"
|
||||
"github.com/gorilla/websocket"
|
||||
"strings"
|
||||
"syscall"
|
||||
)
|
||||
|
||||
// IsUnexpectedWebsocketError checks if the error is an unexpected websocket error
|
||||
func IsUnexpectedWebsocketError(err error) bool {
|
||||
// nil error is an expected error
|
||||
if err == nil {
|
||||
return false
|
||||
}
|
||||
// ignore: write: broken pipe
|
||||
if errors.Is(err, syscall.EPIPE) {
|
||||
return false
|
||||
}
|
||||
// client closed error: *net.OpErr
|
||||
if strings.Contains(err.Error(), "An existing connection was forcibly closed by the remote host") {
|
||||
return true
|
||||
return false
|
||||
}
|
||||
|
||||
return websocket.IsUnexpectedCloseError(err,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue