Skip to content

Commit

Permalink
log on handshake and conn.Read
Browse files Browse the repository at this point in the history
  • Loading branch information
henrod committed Nov 12, 2018
1 parent 050a0e8 commit 7b635cc
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions service/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,13 @@ func (h *HandlerService) Handle(conn net.Conn) {
return
}

logger.Log.Debug("Received data on connection")
bufStr := string(buf)
bufStr = strings.Replace(bufStr, "\n", "", -1)
bufStr = strings.Replace(bufStr, " ", "", -1)
bufStr = strings.Replace(bufStr, "\t", " ", -1)
logger.Log.Debugf("Received data: %s", bufStr)

// (warning): decoder uses slice for performance, packet data should be copied before next Decode
packets, err := h.decoder.Decode(buf[:n])
if err != nil {
Expand All @@ -211,6 +218,7 @@ func (h *HandlerService) Handle(conn net.Conn) {
func (h *HandlerService) processPacket(a *agent.Agent, p *packet.Packet) error {
switch p.Type {
case packet.Handshake:
logger.Log.Debug("Received handshake packet")
if err := a.SendHandshakeResponse(); err != nil {
return err
}
Expand All @@ -231,6 +239,8 @@ func (h *HandlerService) processPacket(a *agent.Agent, p *packet.Packet) error {
logger.Log.Warnf("failed to save ip version on session: %q\n", err)
}

logger.Log.Debug("Successfully saved handshake data")

case packet.HandshakeAck:
a.SetStatus(constants.StatusWorking)
logger.Log.Debugf("Receive handshake ACK Id=%d, Remote=%s", a.Session.ID(), a.RemoteAddr())
Expand Down

0 comments on commit 7b635cc

Please sign in to comment.