mirror of
https://github.com/SagerNet/sing.git
synced 2025-04-01 19:07:38 +03:00
Minor fixes
This commit is contained in:
parent
26511a251f
commit
0acb36c118
2 changed files with 8 additions and 7 deletions
|
@ -8,10 +8,6 @@ linters:
|
||||||
- paralleltest
|
- paralleltest
|
||||||
- ineffassign
|
- ineffassign
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
linters-settings:
|
linters-settings:
|
||||||
gci:
|
gci:
|
||||||
custom-order: true
|
custom-order: true
|
||||||
|
|
|
@ -1,17 +1,22 @@
|
||||||
package exceptions
|
package exceptions
|
||||||
|
|
||||||
import "net"
|
import (
|
||||||
|
"errors"
|
||||||
|
"net"
|
||||||
|
)
|
||||||
|
|
||||||
type TimeoutError interface {
|
type TimeoutError interface {
|
||||||
Timeout() bool
|
Timeout() bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func IsTimeout(err error) bool {
|
func IsTimeout(err error) bool {
|
||||||
if netErr, isNetErr := err.(net.Error); isNetErr {
|
var netErr net.Error
|
||||||
|
if errors.As(err, &netErr) {
|
||||||
//goland:noinspection GoDeprecation
|
//goland:noinspection GoDeprecation
|
||||||
//nolint:staticcheck
|
//nolint:staticcheck
|
||||||
return netErr.Temporary() && netErr.Timeout()
|
return netErr.Temporary() && netErr.Timeout()
|
||||||
} else if timeoutErr, isTimeout := Cast[TimeoutError](err); isTimeout {
|
}
|
||||||
|
if timeoutErr, isTimeout := Cast[TimeoutError](err); isTimeout {
|
||||||
return timeoutErr.Timeout()
|
return timeoutErr.Timeout()
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue