forked from quic-go/quic-go
Merge pull request #3033 from lucas-clemente/qlog-quic-go-version
qlog the quic-go version
This commit is contained in:
@@ -19,8 +19,8 @@ RUN git clone https://github.com/lucas-clemente/quic-go && \
|
||||
WORKDIR /quic-go
|
||||
|
||||
RUN git rev-parse HEAD > commit.txt
|
||||
RUN go build -o server interop/server/main.go && \
|
||||
go build -o client interop/client/main.go
|
||||
RUN go build -o server -ldflags="-X github.com/lucas-clemente/quic-go/qlog.quicGoVersion=$(git describe --always --long --dirty)" interop/server/main.go
|
||||
RUN go build -o client -ldflags="-X github.com/lucas-clemente/quic-go/qlog.quicGoVersion=$(git describe --always --long --dirty)" interop/client/main.go
|
||||
|
||||
|
||||
FROM martenseemann/quic-network-simulator-endpoint:latest
|
||||
|
||||
29
qlog/qlog.go
29
qlog/qlog.go
@@ -6,6 +6,7 @@ import (
|
||||
"io"
|
||||
"log"
|
||||
"net"
|
||||
"runtime/debug"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
@@ -17,6 +18,34 @@ import (
|
||||
"github.com/francoispqt/gojay"
|
||||
)
|
||||
|
||||
// Setting of this only works when quic-go is used as a library.
|
||||
// When building a binary from this repository, the version can be set using the following go build flag:
|
||||
// -ldflags="-X github.com/lucas-clemente/quic-go/qlog.quicGoVersion=foobar"
|
||||
var quicGoVersion = "(devel)"
|
||||
|
||||
func init() {
|
||||
if quicGoVersion != "(devel)" { // variable set by ldflags
|
||||
return
|
||||
}
|
||||
info, ok := debug.ReadBuildInfo()
|
||||
if !ok { // no build info available. This happens when quic-go is not used as a library.
|
||||
return
|
||||
}
|
||||
for _, d := range info.Deps {
|
||||
if d.Path == "github.com/lucas-clemente/quic-go" {
|
||||
quicGoVersion = d.Version
|
||||
if d.Replace != nil {
|
||||
if len(d.Replace.Version) > 0 {
|
||||
quicGoVersion = d.Version
|
||||
} else {
|
||||
quicGoVersion += " (replaced)"
|
||||
}
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const eventChanSize = 50
|
||||
|
||||
type tracer struct {
|
||||
|
||||
@@ -17,6 +17,7 @@ func (l topLevel) MarshalJSONObject(enc *gojay.Encoder) {
|
||||
enc.StringKey("qlog_format", "NDJSON")
|
||||
enc.StringKey("qlog_version", "draft-02")
|
||||
enc.StringKeyOmitEmpty("title", "quic-go qlog")
|
||||
enc.StringKey("code_version", quicGoVersion)
|
||||
enc.ObjectKey("trace", l.trace)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user