Merge pull request #681 from lucas-clemente/session-logging

add some more logging to the session
This commit is contained in:
Marten Seemann
2017-06-16 21:01:13 +02:00
committed by GitHub
4 changed files with 9 additions and 4 deletions

View File

@@ -93,7 +93,7 @@ func DialNonFWSecure(pconn net.PacketConn, remoteAddr net.Addr, host string, con
return nil, err
}
utils.Infof("Starting new connection to %s (%s), connectionID %x, version %d", hostname, c.conn.RemoteAddr().String(), c.connectionID, c.version)
utils.Infof("Starting new connection to %s (%s -> %s), connectionID %x, version %d", hostname, c.conn.LocalAddr().String(), c.conn.RemoteAddr().String(), c.connectionID, c.version)
return c.session.(NonFWSession), c.establishSecureConnection()
}

View File

@@ -29,7 +29,7 @@ var _ = Describe("Client", func() {
Eventually(areSessionsRunning).Should(BeFalse())
msess, _, _ := newMockSession(nil, 0, 0, nil, nil)
sess = msess.(*mockSession)
packetConn = &mockPacketConn{}
packetConn = &mockPacketConn{addr: &net.UDPAddr{IP: net.IPv4(127, 0, 0, 1), Port: 1234}}
config = &Config{
Versions: []protocol.VersionNumber{protocol.SupportedVersions[0], 77, 78},
}

View File

@@ -690,7 +690,7 @@ func (s *session) logPacket(packet *packedPacket) {
return
}
if utils.Debug() {
utils.Debugf("-> Sending packet 0x%x (%d bytes), %s", packet.number, len(packet.raw), packet.encryptionLevel)
utils.Debugf("-> Sending packet 0x%x (%d bytes) for connection %x, %s", packet.number, len(packet.raw), s.connectionID, packet.encryptionLevel)
for _, frame := range packet.frames {
frames.LogFrame(frame, true)
}
@@ -775,6 +775,7 @@ func (s *session) scheduleSending() {
func (s *session) tryQueueingUndecryptablePacket(p *receivedPacket) {
if s.handshakeComplete {
utils.Debugf("Received undecryptable packet from %s after the handshake: %#v, %d bytes data", p.remoteAddr.String(), p.publicHeader, len(p.data))
return
}
if len(s.undecryptablePackets)+1 > protocol.MaxUndecryptablePackets {

View File

@@ -1290,7 +1290,11 @@ var _ = Describe("Session", func() {
hdr := &PublicHeader{
PacketNumber: protocol.PacketNumber(i + 1),
}
sess.handlePacket(&receivedPacket{publicHeader: hdr, data: []byte("foobar")})
sess.handlePacket(&receivedPacket{
publicHeader: hdr,
remoteAddr: &net.UDPAddr{IP: net.IPv4(127, 0, 0, 1), Port: 1234},
data: []byte("foobar"),
})
}
}