|
1 | 1 | package server |
2 | 2 |
|
3 | 3 | import ( |
4 | | - "bytes" |
5 | 4 | "crypto/tls" |
6 | 5 | "fmt" |
7 | 6 | "strings" |
@@ -145,12 +144,12 @@ func (ldapServer *LDAPServer) handleInteraction(uniqueID, fullID, reqString, hos |
145 | 144 | RemoteAddress: host, |
146 | 145 | Timestamp: time.Now(), |
147 | 146 | } |
148 | | - buffer := &bytes.Buffer{} |
149 | | - if err := jsoniter.NewEncoder(buffer).Encode(interaction); err != nil { |
| 147 | + data, err := jsoniter.Marshal(interaction) |
| 148 | + if err != nil { |
150 | 149 | gologger.Warning().Msgf("Could not encode ldap interaction: %s\n", err) |
151 | 150 | } else { |
152 | | - gologger.Debug().Msgf("LDAP Interaction: \n%s\n", buffer.String()) |
153 | | - if err := ldapServer.options.Storage.AddInteraction(correlationID, buffer.Bytes()); err != nil { |
| 151 | + gologger.Debug().Msgf("LDAP Interaction: \n%s\n", string(data)) |
| 152 | + if err := ldapServer.options.Storage.AddInteraction(correlationID, data); err != nil { |
154 | 153 | gologger.Warning().Msgf("Could not store ldap interaction: %s\n", err) |
155 | 154 | } |
156 | 155 | } |
@@ -411,12 +410,12 @@ func (ldapServer *LDAPServer) logInteraction(interaction Interaction) { |
411 | 410 | // Correlation id doesn't apply here, we skip encryption |
412 | 411 | interaction.Protocol = "ldap" |
413 | 412 | interaction.Timestamp = time.Now() |
414 | | - buffer := &bytes.Buffer{} |
415 | | - if err := jsoniter.NewEncoder(buffer).Encode(interaction); err != nil { |
| 413 | + data, err := jsoniter.Marshal(interaction) |
| 414 | + if err != nil { |
416 | 415 | gologger.Warning().Msgf("Could not encode ldap interaction: %s\n", err) |
417 | 416 | } else { |
418 | | - gologger.Debug().Msgf("LDAP Interaction: \n%s\n", buffer.String()) |
419 | | - if err := ldapServer.options.Storage.AddInteractionWithId(ldapServer.options.Token, buffer.Bytes()); err != nil { |
| 417 | + gologger.Debug().Msgf("LDAP Interaction: \n%s\n", string(data)) |
| 418 | + if err := ldapServer.options.Storage.AddInteractionWithId(ldapServer.options.Token, data); err != nil { |
420 | 419 | gologger.Warning().Msgf("Could not store ldap interaction: %s\n", err) |
421 | 420 | } |
422 | 421 | } |
|
0 commit comments