Skip to content

Commit

Permalink
Add sent/received packages into debug log
Browse files Browse the repository at this point in the history
  • Loading branch information
cavus700 committed May 10, 2022
1 parent 9ef89d9 commit c805f90
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
5 changes: 4 additions & 1 deletion pkg/tftp/rrq_response.go
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,8 @@ func (r *rrqResponse) sendError(code ErrorCode, occurredError error) (err error)
errorbuffer[len(errorbuffer)-1] = 0

_, err = r.connection.Write(errorbuffer)
r.logger.Debug("Error sent",
zap.ByteString("bytes", errorbuffer))
return
}

Expand All @@ -286,7 +288,8 @@ func (r *rrqResponse) sendBufferWithRetransmissionOnTimeout(buffer []byte, tries
}

r.logger.Debug("Package sent",
zap.Int("Bytes", numBytes))
zap.Int("Bytes", numBytes),
zap.ByteString("bytes", buffer))

_ = r.connection.SetReadDeadline(time.Now().Add(r.config.ReadTimeoutOrDefault()))
numBytes, _, err = r.connection.ReadFromUDP(r.ack)
Expand Down
3 changes: 3 additions & 0 deletions pkg/tftp/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,9 @@ func (s *server) accept(listenSocket udp.Connection) (err error) {
s.logger.Info("Received request",
zap.Any("Addr", addr))

s.logger.Debug("Parse request",
zap.ByteString("bytes", requestBuffer[:written]))

var request *Request
request, err = parseRequest(requestBuffer[:written])
if err != nil {
Expand Down

0 comments on commit c805f90

Please sign in to comment.