38 lines
740 B
Go
38 lines
740 B
Go
package proxy
|
|
|
|
type timeoutError interface {
|
|
Timeout() bool // Is it a timeout error
|
|
}
|
|
|
|
// fundamental is an error that has a message and a stack, but no caller.
|
|
type errors struct {
|
|
msg string
|
|
}
|
|
|
|
func (e errors) Error() string {
|
|
return e.msg
|
|
}
|
|
|
|
func NewError(msg string) error {
|
|
return errors{msg: msg}
|
|
}
|
|
|
|
var (
|
|
ErrBufferFull = NewError("read: buffer full")
|
|
ErrNoAnkiProxy = NewError("anki: no client proxy connect")
|
|
)
|
|
var (
|
|
ServerAddr = ":8765"
|
|
RemoteServerAddr = "175.24.226.114" + ServerAddr
|
|
ClientAddr = "127.0.0.1:8765"
|
|
)
|
|
|
|
// IsTimeoutError checks if the error is a timeout error
|
|
func IsTimeoutError(err error) bool {
|
|
if err == nil {
|
|
return false
|
|
}
|
|
ne, ok := err.(timeoutError)
|
|
return ok && ne.Timeout()
|
|
}
|