forked from quic-go/quic-go
@@ -13,6 +13,7 @@ import (
|
|||||||
|
|
||||||
"github.com/lucas-clemente/quic-go"
|
"github.com/lucas-clemente/quic-go"
|
||||||
"github.com/lucas-clemente/quic-go/protocol"
|
"github.com/lucas-clemente/quic-go/protocol"
|
||||||
|
"github.com/lucas-clemente/quic-go/qerr"
|
||||||
"github.com/lucas-clemente/quic-go/utils"
|
"github.com/lucas-clemente/quic-go/utils"
|
||||||
"golang.org/x/net/http2"
|
"golang.org/x/net/http2"
|
||||||
"golang.org/x/net/http2/hpack"
|
"golang.org/x/net/http2/hpack"
|
||||||
@@ -104,7 +105,12 @@ func (s *Server) handleStream(session streamCreator, stream utils.Stream) {
|
|||||||
var headerStreamMutex sync.Mutex // Protects concurrent calls to Write()
|
var headerStreamMutex sync.Mutex // Protects concurrent calls to Write()
|
||||||
for {
|
for {
|
||||||
if err := s.handleRequest(session, stream, &headerStreamMutex, hpackDecoder, h2framer); err != nil {
|
if err := s.handleRequest(session, stream, &headerStreamMutex, hpackDecoder, h2framer); err != nil {
|
||||||
utils.Errorf("error handling h2 request: %s", err.Error())
|
// QuicErrors must originate from stream.Read() returning an error.
|
||||||
|
// In this case, the session has already logged the error, so we don't
|
||||||
|
// need to log it again.
|
||||||
|
if _, ok := err.(*qerr.QuicError); !ok {
|
||||||
|
utils.Errorf("error handling h2 request: %s", err.Error())
|
||||||
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
13
session.go
13
session.go
@@ -417,8 +417,16 @@ func (s *Session) closeImpl(e error, remoteClose bool) error {
|
|||||||
e = qerr.PeerGoingAway
|
e = qerr.PeerGoingAway
|
||||||
}
|
}
|
||||||
|
|
||||||
utils.Errorf("Closing session with error: %s", e.Error())
|
quicErr := qerr.ToQuicError(e)
|
||||||
s.closeStreamsWithError(e)
|
|
||||||
|
// Don't log 'normal' reasons
|
||||||
|
if quicErr.ErrorCode == qerr.PeerGoingAway || quicErr.ErrorCode == qerr.NetworkIdleTimeout {
|
||||||
|
utils.Infof("Closing connection %x", s.connectionID)
|
||||||
|
} else {
|
||||||
|
utils.Errorf("Closing session with error: %s", e.Error())
|
||||||
|
}
|
||||||
|
|
||||||
|
s.closeStreamsWithError(quicErr)
|
||||||
s.closeCallback(s.connectionID)
|
s.closeCallback(s.connectionID)
|
||||||
|
|
||||||
if remoteClose {
|
if remoteClose {
|
||||||
@@ -427,7 +435,6 @@ func (s *Session) closeImpl(e error, remoteClose bool) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
quicErr := qerr.ToQuicError(e)
|
|
||||||
if quicErr.ErrorCode == qerr.DecryptionFailure {
|
if quicErr.ErrorCode == qerr.DecryptionFailure {
|
||||||
// If we send a public reset, don't send a CONNECTION_CLOSE
|
// If we send a public reset, don't send a CONNECTION_CLOSE
|
||||||
s.closeChan <- nil
|
s.closeChan <- nil
|
||||||
|
|||||||
@@ -381,10 +381,10 @@ var _ = Describe("Session", func() {
|
|||||||
Eventually(func() int { return runtime.NumGoroutine() }).Should(Equal(nGoRoutinesBefore))
|
Eventually(func() int { return runtime.NumGoroutine() }).Should(Equal(nGoRoutinesBefore))
|
||||||
n, err := s.Read([]byte{0})
|
n, err := s.Read([]byte{0})
|
||||||
Expect(n).To(BeZero())
|
Expect(n).To(BeZero())
|
||||||
Expect(err).To(MatchError(testErr))
|
Expect(err.Error()).To(ContainSubstring(testErr.Error()))
|
||||||
n, err = s.Write([]byte{0})
|
n, err = s.Write([]byte{0})
|
||||||
Expect(n).To(BeZero())
|
Expect(n).To(BeZero())
|
||||||
Expect(err).To(MatchError(testErr))
|
Expect(err.Error()).To(ContainSubstring(testErr.Error()))
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -603,7 +603,7 @@ var _ = Describe("Session", func() {
|
|||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
Eventually(func() bool { return atomic.LoadUint32(&session.closed) != 0 }).Should(BeTrue())
|
Eventually(func() bool { return atomic.LoadUint32(&session.closed) != 0 }).Should(BeTrue())
|
||||||
_, err = s.Write([]byte{})
|
_, err = s.Write([]byte{})
|
||||||
Expect(err).To(MatchError(qerr.InvalidCryptoMessageType))
|
Expect(err.(*qerr.QuicError).ErrorCode).To(Equal(qerr.InvalidCryptoMessageType))
|
||||||
})
|
})
|
||||||
|
|
||||||
It("sends public reset after too many undecryptable packets", func() {
|
It("sends public reset after too many undecryptable packets", func() {
|
||||||
|
|||||||
Reference in New Issue
Block a user