aboutsummaryrefslogtreecommitdiff
path: root/ldapserver/client.go
diff options
context:
space:
mode:
Diffstat (limited to 'ldapserver/client.go')
-rw-r--r--ldapserver/client.go37
1 files changed, 16 insertions, 21 deletions
diff --git a/ldapserver/client.go b/ldapserver/client.go
index 681aa76..7ab043d 100644
--- a/ldapserver/client.go
+++ b/ldapserver/client.go
@@ -134,9 +134,12 @@ func (c *client) serve() {
Logger.Printf("Error reading Message : %s\n\t%x", err.Error(), messagePacket.bytes)
continue
}
- if TRACE {
- //Logger.Printf("<<< %d - %s - hex=%x", c.Numero, message.ProtocolOpName(), messagePacket)
- Logger.Printf("<<< %d - %#v", c.Numero, message)
+
+ //Logger.Printf("<<< %d - %s - hex=%x", c.Numero, message.ProtocolOpName(), messagePacket)
+ if br, ok := message.ProtocolOp().(ldap.BindRequest); ok {
+ Logger.Debugf("<<< [%d] (bind request for %s)", c.Numero, br.Name())
+ } else {
+ Logger.Debugf("<<< [%d] %#v", c.Numero, message)
}
// TODO: Use a implementation to limit runnuning request by client
@@ -175,47 +178,39 @@ func (c *client) serve() {
// * close client connection
// * signal to server that client shutdown is ok
func (c *client) close() {
- if DEBUG {
- Logger.Printf("client %d close()", c.Numero)
- }
+ Logger.Tracef("client %d close()", c.Numero)
close(c.closing)
// stop reading from client
c.rwc.SetReadDeadline(time.Now().Add(time.Millisecond))
- if DEBUG {
- Logger.Printf("client %d close() - stop reading from client", c.Numero)
- }
+ Logger.Tracef("client %d close() - stop reading from client", c.Numero)
// signals to all currently running request processor to stop
c.mutex.Lock()
for messageID, request := range c.requestList {
- Logger.Printf("Client %d close() - sent abandon signal to request[messageID = %d]", c.Numero, messageID)
+ Logger.Debugf("Client %d close() - sent abandon signal to request[messageID = %d]", c.Numero, messageID)
go request.Abandon()
}
c.mutex.Unlock()
- if DEBUG {
- Logger.Printf("client %d close() - Abandon signal sent to processors", c.Numero)
- }
+ Logger.Tracef("client %d close() - Abandon signal sent to processors", c.Numero)
c.wg.Wait() // wait for all current running request processor to end
close(c.chanOut) // No more message will be sent to client, close chanOUT
- if DEBUG {
- Logger.Printf("client [%d] request processors ended", c.Numero)
- }
+ Logger.Tracef("client [%d] request processors ended", c.Numero)
<-c.writeDone // Wait for the last message sent to be written
c.rwc.Close() // close client connection
- Logger.Printf("client [%d] connection closed", c.Numero)
+ Logger.Debugf("client [%d] connection closed", c.Numero)
c.srv.wg.Done() // signal to server that client shutdown is ok
}
func (c *client) writeMessage(m *ldap.LDAPMessage) {
data, _ := m.Write()
- if TRACE {
- //Logger.Printf(">>> %d - %s - hex=%x", c.Numero, m.ProtocolOpName(), data.Bytes())
- Logger.Printf(">>> %d - %#v", c.Numero, m)
- }
+
+ //Logger.Printf(">>> %d - %s - hex=%x", c.Numero, m.ProtocolOpName(), data.Bytes())
+ Logger.Tracef(">>> [%d] %#v", c.Numero, m)
+
c.bw.Write(data.Bytes())
c.bw.Flush()
}