aboutsummaryrefslogtreecommitdiff
path: root/ldapserver/client.go
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2020-01-26 19:47:38 +0100
committerAlex Auvolat <alex@adnab.me>2020-01-26 19:47:38 +0100
commit94eafa2a9ba34d2cbcd678fff5a0dcbfcfa40e7c (patch)
tree7d0ed0515b5973591c64c7c9b4579b5575ac2010 /ldapserver/client.go
parentc1f0247586c98bbdfc42c4a8db3410d34dfbc500 (diff)
downloadbottin-94eafa2a9ba34d2cbcd678fff5a0dcbfcfa40e7c.tar.gz
bottin-94eafa2a9ba34d2cbcd678fff5a0dcbfcfa40e7c.zip
Less logs but better logs
Diffstat (limited to 'ldapserver/client.go')
-rw-r--r--ldapserver/client.go24
1 files changed, 18 insertions, 6 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()
}