Merge pull request #2799 from lucas-clemente/optional-quic-trace

only include quic-trace when the quictrace build flag is set
This commit is contained in:
Marten Seemann
2020-10-06 20:24:13 +07:00
committed by GitHub
3 changed files with 22 additions and 2 deletions

View File

@@ -256,8 +256,9 @@ type Config struct {
StatelessResetKey []byte
// KeepAlive defines whether this peer will periodically send a packet to keep the connection alive.
KeepAlive bool
// QUIC Event Tracer.
// Warning: Experimental. This API should not be considered stable and will change soon.
// QUIC Event Tracer (see https://github.com/google/quic-trace).
// Warning: Support for quic-trace will soon be dropped in favor of qlog.
// It is disabled by default. Use the "quictrace" build tag to enable (e.g. go build -tags quictrace).
QuicTracer quictrace.Tracer
Tracer logging.Tracer
}

17
quictrace/null_tracer.go Normal file
View File

@@ -0,0 +1,17 @@
// +build !quictrace
package quictrace
import "github.com/lucas-clemente/quic-go/internal/protocol"
// NewTracer returns a new Tracer that doesn't do anything.
func NewTracer() Tracer {
return &nullTracer{}
}
type nullTracer struct{}
var _ Tracer = &nullTracer{}
func (t *nullTracer) Trace(protocol.ConnectionID, Event) {}
func (t *nullTracer) GetAllTraces() map[string][]byte { return make(map[string][]byte) }

View File

@@ -1,3 +1,5 @@
// +build quictrace
package quictrace
import (