From 6a19acbd3361ef4c3abaea4f2631aa1b9896833a Mon Sep 17 00:00:00 2001 From: merlinz01 <158784988+merlinz01@users.noreply.github.com> Date: Fri, 3 May 2024 18:36:49 -0400 Subject: [PATCH] handle "connection reset by peer" error --- server.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/server.go b/server.go index b754932..e8632ac 100644 --- a/server.go +++ b/server.go @@ -5,6 +5,7 @@ import ( "errors" "log" "net" + "strings" "syscall" ) @@ -133,8 +134,9 @@ func (s *LDAPServer) handleConnection(c net.Conn) { msg, err := ldapConn.ReadMessage() ldapConn.tlsStarting.RUnlock() if err != nil { - if errors.Is(err, syscall.Errno(0x2746)) { // Windows: An existing connection was forcibly closed by the client - log.Println("Connection was reset by the client.") + if errors.Is(err, syscall.Errno(0x2746)) || // Windows: An existing connection was forcibly closed by the client + strings.HasSuffix(err.Error(), "connection reset by peer") { + log.Println("Connection was reset.") ldapConn.Close() return } else {