Skip to content

Commit

Permalink
add AcceptIsClose func
Browse files Browse the repository at this point in the history
  • Loading branch information
wenjy committed Mar 19, 2022
1 parent d741028 commit 70c4044
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ func ConnIsClose(err error) bool {
strings.Contains(err.Error(), "broken pipe")
}

// 根据错误来判断监听是否已关闭
func AcceptIsClose(err error) bool {
return strings.Contains(err.Error(), "use of closed network connection") ||
strings.Contains(err.Error(), "the mux has closed")
}

// NormalizeMac 规范化 MAC,去掉 `:` 再转为小写
func NormalizeMac(mac string) string {
return strings.ToLower(strings.ReplaceAll(mac, ":", ""))
Expand Down

0 comments on commit 70c4044

Please sign in to comment.