From 563fc272a36c8be317fbe95c8308ca2dfa29c3aa Mon Sep 17 00:00:00 2001 From: Quentin Dufour Date: Wed, 7 Jul 2021 01:49:33 +0200 Subject: Vendor goldap, fix ASN.1 BER integer and length encoding - Add tests for goldap to prevent regressions - Disable reconnection for our functional tests --- ldapserver/client.go | 8 ++++++-- ldapserver/constants.go | 2 +- ldapserver/message.go | 2 +- ldapserver/packet.go | 3 ++- ldapserver/responsemessage.go | 2 +- ldapserver/route.go | 2 +- 6 files changed, 12 insertions(+), 7 deletions(-) (limited to 'ldapserver') diff --git a/ldapserver/client.go b/ldapserver/client.go index 91a5980..3674ba4 100644 --- a/ldapserver/client.go +++ b/ldapserver/client.go @@ -6,7 +6,7 @@ import ( "sync" "time" - ldap "github.com/lor00x/goldap/message" + ldap "bottin/goldap" ) type UserState interface{} @@ -206,10 +206,14 @@ func (c *client) close() { } func (c *client) writeMessage(m *ldap.LDAPMessage) { - data, _ := m.Write() + data, err := m.Write() + if err != nil { + Logger.Errorf("bottin: unable to marshal response message: %v", err) + } //Logger.Printf(">>> %d - %s - hex=%x", c.Numero, m.ProtocolOpName(), data.Bytes()) Logger.Tracef(">>> [%d] %#v", c.Numero, m) + Logger.Tracef("%v", data.Bytes()) c.bw.Write(data.Bytes()) c.bw.Flush() diff --git a/ldapserver/constants.go b/ldapserver/constants.go index de6d229..a04ca43 100644 --- a/ldapserver/constants.go +++ b/ldapserver/constants.go @@ -1,6 +1,6 @@ package ldapserver -import ldap "github.com/lor00x/goldap/message" +import ldap "bottin/goldap" // LDAP Application Codes const ( diff --git a/ldapserver/message.go b/ldapserver/message.go index f6e609f..7033e06 100644 --- a/ldapserver/message.go +++ b/ldapserver/message.go @@ -3,7 +3,7 @@ package ldapserver import ( "fmt" - ldap "github.com/lor00x/goldap/message" + ldap "bottin/goldap" ) type Message struct { diff --git a/ldapserver/packet.go b/ldapserver/packet.go index 77b4926..a60a44a 100644 --- a/ldapserver/packet.go +++ b/ldapserver/packet.go @@ -5,7 +5,7 @@ import ( "errors" "fmt" - ldap "github.com/lor00x/goldap/message" + ldap "bottin/goldap" ) type messagePacket struct { @@ -141,6 +141,7 @@ func readBytes(conn *bufio.Reader, bytes *[]byte, length int) (b byte, err error if n != length { fmt.Errorf("%d bytes read instead of %d", n, length) } else if err != nil { + fmt.Println("ooopsie an error occured here:", err) return } *bytes = append(*bytes, newbytes...) diff --git a/ldapserver/responsemessage.go b/ldapserver/responsemessage.go index 23527b9..9dc0406 100644 --- a/ldapserver/responsemessage.go +++ b/ldapserver/responsemessage.go @@ -1,6 +1,6 @@ package ldapserver -import ldap "github.com/lor00x/goldap/message" +import ldap "bottin/goldap" func NewBindResponse(resultCode int) ldap.BindResponse { r := ldap.BindResponse{} diff --git a/ldapserver/route.go b/ldapserver/route.go index dfd5240..3ba5618 100644 --- a/ldapserver/route.go +++ b/ldapserver/route.go @@ -3,7 +3,7 @@ package ldapserver import ( "strings" - ldap "github.com/lor00x/goldap/message" + ldap "bottin/goldap" ) // Constant to LDAP Request protocol Type names -- cgit v1.2.3