forked from cyfdecyf/cow
-
Notifications
You must be signed in to change notification settings - Fork 0
/
proxy_unix.go
47 lines (40 loc) · 825 Bytes
/
proxy_unix.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
// +build darwin freebsd linux netbsd openbsd
package main
import (
"net"
"syscall"
"strings"
)
func isErrConnReset(err error) bool {
if ne, ok := err.(*net.OpError); ok {
return strings.Contains(ne.Err.Error(), syscall.ECONNRESET.Error())
}
return false
}
func isDNSError(err error) bool {
if _, ok := err.(*net.DNSError); ok {
return true
}
return false
}
func isErrOpWrite(err error) bool {
ne, ok := err.(*net.OpError)
if !ok {
return false
}
return ne.Op == "write"
}
func isErrOpRead(err error) bool {
ne, ok := err.(*net.OpError)
if !ok {
return false
}
return ne.Op == "read"
}
func isErrTooManyOpenFd(err error) bool {
if ne, ok := err.(*net.OpError); ok && (ne.Err == syscall.EMFILE || ne.Err == syscall.ENFILE) {
errl.Println("too many open fd")
return true
}
return false
}