aboutsummaryrefslogtreecommitdiff
path: root/ldapserver
diff options
context:
space:
mode:
Diffstat (limited to 'ldapserver')
-rw-r--r--ldapserver/client.go24
-rw-r--r--ldapserver/logger.go2
-rw-r--r--ldapserver/route.go9
3 files changed, 25 insertions, 10 deletions
diff --git a/ldapserver/client.go b/ldapserver/client.go
index 501af2a..085041f 100644
--- a/ldapserver/client.go
+++ b/ldapserver/client.go
@@ -134,7 +134,9 @@ func (c *client) serve() {
Logger.Printf("Error reading Message : %s\n\t%x", err.Error(), messagePacket.bytes)
continue
}
- Logger.Printf("<<< %d - %s - hex=%x", c.Numero, message.ProtocolOpName(), messagePacket)
+ if DEBUG {
+ Logger.Printf("<<< %d - %s - hex=%x", c.Numero, message.ProtocolOpName(), messagePacket)
+ }
// TODO: Use a implementation to limit runnuning request by client
// solution 1 : when the buffered output channel is full, send a busy
@@ -172,12 +174,16 @@ func (c *client) serve() {
// * close client connection
// * signal to server that client shutdown is ok
func (c *client) close() {
- Logger.Printf("client %d close()", c.Numero)
+ if DEBUG {
+ Logger.Printf("client %d close()", c.Numero)
+ }
close(c.closing)
// stop reading from client
c.rwc.SetReadDeadline(time.Now().Add(time.Millisecond))
- Logger.Printf("client %d close() - stop reading from client", c.Numero)
+ if DEBUG {
+ Logger.Printf("client %d close() - stop reading from client", c.Numero)
+ }
// signals to all currently running request processor to stop
c.mutex.Lock()
@@ -186,11 +192,15 @@ func (c *client) close() {
go request.Abandon()
}
c.mutex.Unlock()
- Logger.Printf("client %d close() - Abandon signal sent to processors", c.Numero)
+ if DEBUG {
+ Logger.Printf("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
- Logger.Printf("client [%d] request processors ended", c.Numero)
+ if DEBUG {
+ Logger.Printf("client [%d] request processors ended", c.Numero)
+ }
<-c.writeDone // Wait for the last message sent to be written
c.rwc.Close() // close client connection
@@ -201,7 +211,9 @@ func (c *client) close() {
func (c *client) writeMessage(m *ldap.LDAPMessage) {
data, _ := m.Write()
- Logger.Printf(">>> %d - %s - hex=%x", c.Numero, m.ProtocolOpName(), data.Bytes())
+ if DEBUG {
+ Logger.Printf(">>> %d - %s - hex=%x", c.Numero, m.ProtocolOpName(), data.Bytes())
+ }
c.bw.Write(data.Bytes())
c.bw.Flush()
}
diff --git a/ldapserver/logger.go b/ldapserver/logger.go
index fdac2f4..70352e3 100644
--- a/ldapserver/logger.go
+++ b/ldapserver/logger.go
@@ -8,6 +8,8 @@ import (
var Logger logger
+const DEBUG = false
+
// Logger represents log.Logger functions from the standard library
type logger interface {
Fatal(v ...interface{})
diff --git a/ldapserver/route.go b/ldapserver/route.go
index d5bd00a..ec09f7d 100644
--- a/ldapserver/route.go
+++ b/ldapserver/route.go
@@ -148,10 +148,11 @@ func (h *RouteMux) ServeLDAP(s UserState, w ResponseWriter, r *Message) {
}
if route.label != "" {
- Logger.Printf("")
- Logger.Printf(" ROUTE MATCH ; %s", route.label)
- Logger.Printf("")
- // Logger.Printf(" ROUTE MATCH ; %s", runtime.FuncForPC(reflect.ValueOf(route.handler).Pointer()).Name())
+ if DEBUG {
+ Logger.Printf("")
+ Logger.Printf(" ROUTE MATCH ; %s", route.label)
+ Logger.Printf("")
+ }
}
route.handler(s, w, r)