From a2957e1ca17ca95ab41cd741904cfb37c2cf9c68 Mon Sep 17 00:00:00 2001 From: Janos Guljas Date: Thu, 23 Mar 2023 13:29:34 +0100 Subject: [PATCH] Update dependencies --- .github/workflows/go.yml | 7 +++-- go.mod | 38 +++++++++++++------------- go.sum | 55 +++++++++++++++++++++++++++++--------- logging/access_log.go | 2 +- logging/logging.go | 22 +++++++++++++-- maintenance/maintenance.go | 12 ++++----- recovery/recovery.go | 7 ++--- recovery/recovery_test.go | 2 +- servers/quic/quic.go | 2 +- servers/servers.go | 10 +++---- servers/servers_test.go | 4 +-- templates/templates.go | 4 +-- 12 files changed, 107 insertions(+), 58 deletions(-) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index db14107..6158186 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -14,8 +14,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v2 with: - stable: 'false' - go-version: '1.19' + go-version: '1.20' - name: Checkout uses: actions/checkout@v1 @@ -35,7 +34,7 @@ jobs: - name: Lint uses: golangci/golangci-lint-action@v2 with: - version: v1.50.1 + version: v1.52.1 args: --timeout 10m - name: Vet @@ -48,4 +47,4 @@ jobs: run: go build -ldflags "-s -w" ./... - name: Test - run: go test -v -race ./... + run: go test -v -race ./... \ No newline at end of file diff --git a/go.mod b/go.mod index ca1aef0..142462f 100644 --- a/go.mod +++ b/go.mod @@ -5,13 +5,13 @@ go 1.19 require ( github.com/felixge/httpsnoop v1.0.3 github.com/gorilla/handlers v1.5.1 - github.com/lucas-clemente/quic-go v0.31.1 github.com/prometheus/client_golang v1.14.0 - golang.org/x/crypto v0.4.0 - golang.org/x/exp v0.0.0-20221217163422-3c43f8badb15 - golang.org/x/net v0.4.0 - google.golang.org/grpc v1.51.0 - google.golang.org/protobuf v1.28.1 + github.com/quic-go/quic-go v0.33.0 + golang.org/x/crypto v0.7.0 + golang.org/x/exp v0.0.0-20230321023759-10a507213a29 + golang.org/x/net v0.8.0 + google.golang.org/grpc v1.54.0 + google.golang.org/protobuf v1.30.0 resenje.org/email v0.1.3 resenje.org/iostuff v0.1.3 resenje.org/jsonhttp v0.2.0 @@ -24,21 +24,21 @@ require ( github.com/cespare/xxhash/v2 v2.2.0 // indirect github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0 // indirect github.com/golang/mock v1.6.0 // indirect - github.com/golang/protobuf v1.5.2 // indirect - github.com/google/pprof v0.0.0-20221219190121-3cb0bae90811 // indirect - github.com/marten-seemann/qpack v0.3.0 // indirect - github.com/marten-seemann/qtls-go1-18 v0.1.3 // indirect - github.com/marten-seemann/qtls-go1-19 v0.1.1 // indirect + github.com/golang/protobuf v1.5.3 // indirect + github.com/google/pprof v0.0.0-20230323073829-e72429f035bd // indirect github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect - github.com/onsi/ginkgo/v2 v2.6.1 // indirect + github.com/onsi/ginkgo/v2 v2.9.1 // indirect github.com/prometheus/client_model v0.3.0 // indirect - github.com/prometheus/common v0.39.0 // indirect - github.com/prometheus/procfs v0.8.0 // indirect - golang.org/x/mod v0.7.0 // indirect - golang.org/x/sys v0.3.0 // indirect - golang.org/x/text v0.5.0 // indirect - golang.org/x/tools v0.4.0 // indirect - google.golang.org/genproto v0.0.0-20221207170731-23e4bf6bdc37 // indirect + github.com/prometheus/common v0.42.0 // indirect + github.com/prometheus/procfs v0.9.0 // indirect + github.com/quic-go/qpack v0.4.0 // indirect + github.com/quic-go/qtls-go1-19 v0.3.0 // indirect + github.com/quic-go/qtls-go1-20 v0.2.0 // indirect + golang.org/x/mod v0.9.0 // indirect + golang.org/x/sys v0.6.0 // indirect + golang.org/x/text v0.8.0 // indirect + golang.org/x/tools v0.7.0 // indirect + google.golang.org/genproto v0.0.0-20230322174352-cde4c949918d // indirect gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc // indirect gopkg.in/mail.v2 v2.3.1 // indirect ) diff --git a/go.sum b/go.sum index a8be303..4aa0265 100644 --- a/go.sum +++ b/go.sum @@ -18,27 +18,24 @@ github.com/golang/protobuf v1.3.5/go.mod h1:6O5/vntMXwX2lRkT1hjjk0nAC1IDOTvTlVgj github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw= github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= +github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg= +github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= -github.com/google/pprof v0.0.0-20221212185716-aee1124e3a93 h1:D5iJJZKAi0rU4e/5E58BkrnN+xeCDjAIqcm1GGxAGSI= -github.com/google/pprof v0.0.0-20221212185716-aee1124e3a93/go.mod h1:dDKJzRmX4S37WGHujM7tX//fmj1uioxKzKxz3lo4HJo= github.com/google/pprof v0.0.0-20221219190121-3cb0bae90811 h1:wORs2YN3R3ona/CXYuTvLM31QlgoNKHvlCNuArCDDCU= github.com/google/pprof v0.0.0-20221219190121-3cb0bae90811/go.mod h1:dDKJzRmX4S37WGHujM7tX//fmj1uioxKzKxz3lo4HJo= +github.com/google/pprof v0.0.0-20230323073829-e72429f035bd h1:r8yyd+DJDmsUhGrRBxH5Pj7KeFK5l+Y3FsgT8keqKtk= +github.com/google/pprof v0.0.0-20230323073829-e72429f035bd/go.mod h1:79YE0hCXdHag9sBkw2o+N/YnZtTkXi0UT9Nnixa5eYk= github.com/gorilla/handlers v1.5.1 h1:9lRY6j8DEeeBT10CvO9hGW0gmky0BprnvDI5vfhUHH4= github.com/gorilla/handlers v1.5.1/go.mod h1:t8XrUpc4KVXb7HGyJ4/cEnwQiaxrX/hz1Zv/4g96P1Q= -github.com/lucas-clemente/quic-go v0.31.1 h1:O8Od7hfioqq0PMYHDyBkxU2aA7iZ2W9pjbrWuja2YR4= -github.com/lucas-clemente/quic-go v0.31.1/go.mod h1:0wFbizLgYzqHqtlyxyCaJKlE7bYgE6JQ+54TLd/Dq2g= -github.com/marten-seemann/qpack v0.3.0 h1:UiWstOgT8+znlkDPOg2+3rIuYXJ2CnGDkGUXN6ki6hE= -github.com/marten-seemann/qpack v0.3.0/go.mod h1:cGfKPBiP4a9EQdxCwEwI/GEeWAsjSekBvx/X8mh58+g= -github.com/marten-seemann/qtls-go1-18 v0.1.3 h1:R4H2Ks8P6pAtUagjFty2p7BVHn3XiwDAl7TTQf5h7TI= -github.com/marten-seemann/qtls-go1-18 v0.1.3/go.mod h1:mJttiymBAByA49mhlNZZGrH5u1uXYZJ+RW28Py7f4m4= -github.com/marten-seemann/qtls-go1-19 v0.1.1 h1:mnbxeq3oEyQxQXwI4ReCgW9DPoPR94sNlqWoDZnjRIE= -github.com/marten-seemann/qtls-go1-19 v0.1.1/go.mod h1:5HTDWtVudo/WFsHKRNuOhWlbdjrfs5JHrYb0wIJqGpI= github.com/matttproud/golang_protobuf_extensions v1.0.4 h1:mmDVorXM7PCGKw94cs5zkfA9PSy5pEvNWRP0ET0TIVo= github.com/matttproud/golang_protobuf_extensions v1.0.4/go.mod h1:BSXmuO+STAnVfrANrmjBb36TMTDstsz7MSK+HVaYKv4= github.com/onsi/ginkgo/v2 v2.6.1 h1:1xQPCjcqYw/J5LchOcp4/2q/jzJFjiAOc25chhnDw+Q= github.com/onsi/ginkgo/v2 v2.6.1/go.mod h1:yjiuMwPokqY1XauOgju45q3sJt6VzQ/Fict1LFVcsAo= +github.com/onsi/ginkgo/v2 v2.9.1 h1:zie5Ly042PD3bsCvsSOPvRnFwyo3rKe64TJlD6nu0mk= +github.com/onsi/ginkgo/v2 v2.9.1/go.mod h1:FEcmzVcCHl+4o9bQZVab+4dC9+j+91t2FHSzmGAPfuo= github.com/onsi/gomega v1.24.1 h1:KORJXNNTzJXzu4ScJWssJfJMnJ+2QJqhoQSRwNlze9E= +github.com/onsi/gomega v1.27.3 h1:5VwIwnBY3vbBDOJrNtA4rVdiTZCsq9B5F12pvy1Drmk= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/prometheus/client_golang v1.14.0 h1:nJdhIvne2eSX/XRAFV9PcvFFRbrjbcTUj0VP62TMhnw= @@ -47,8 +44,24 @@ github.com/prometheus/client_model v0.3.0 h1:UBgGFHqYdG/TPFD1B1ogZywDqEkwp3fBMvq github.com/prometheus/client_model v0.3.0/go.mod h1:LDGWKZIo7rky3hgvBe+caln+Dr3dPggB5dvjtD7w9+w= github.com/prometheus/common v0.39.0 h1:oOyhkDq05hPZKItWVBkJ6g6AtGxi+fy7F4JvUV8uhsI= github.com/prometheus/common v0.39.0/go.mod h1:6XBZ7lYdLCbkAVhwRsWTZn+IN5AB9F/NXd5w0BbEX0Y= +github.com/prometheus/common v0.42.0 h1:EKsfXEYo4JpWMHH5cg+KOUWeuJSov1Id8zGR8eeI1YM= +github.com/prometheus/common v0.42.0/go.mod h1:xBwqVerjNdUDjgODMpudtOMwlOwf2SaTr1yjz4b7Zbc= github.com/prometheus/procfs v0.8.0 h1:ODq8ZFEaYeCaZOJlZZdJA2AbQR98dSHSM1KW/You5mo= github.com/prometheus/procfs v0.8.0/go.mod h1:z7EfXMXOkbkqb9IINtpCn86r/to3BnA0uaxHdg830/4= +github.com/prometheus/procfs v0.9.0 h1:wzCHvIvM5SxWqYvwgVL7yJY8Lz3PKn49KQtpgMYJfhI= +github.com/prometheus/procfs v0.9.0/go.mod h1:+pB4zwohETzFnmlpe6yd2lSc+0/46IYZRB/chUwxUZY= +github.com/quic-go/qpack v0.4.0 h1:Cr9BXA1sQS2SmDUWjSofMPNKmvF6IiIfDRmgU0w1ZCo= +github.com/quic-go/qpack v0.4.0/go.mod h1:UZVnYIfi5GRk+zI9UMaCPsmZ2xKJP7XBUvVyT1Knj9A= +github.com/quic-go/qtls-go1-19 v0.2.1 h1:aJcKNMkH5ASEJB9FXNeZCyTEIHU1J7MmHyz1Q1TSG1A= +github.com/quic-go/qtls-go1-19 v0.2.1/go.mod h1:ySOI96ew8lnoKPtSqx2BlI5wCpUVPT05RMAlajtnyOI= +github.com/quic-go/qtls-go1-19 v0.3.0 h1:aUBoQdpHzUWtPw5tQZbsD2GnrWCNu7/RIX1PtqGeLYY= +github.com/quic-go/qtls-go1-19 v0.3.0/go.mod h1:ySOI96ew8lnoKPtSqx2BlI5wCpUVPT05RMAlajtnyOI= +github.com/quic-go/qtls-go1-20 v0.1.1 h1:KbChDlg82d3IHqaj2bn6GfKRj84Per2VGf5XV3wSwQk= +github.com/quic-go/qtls-go1-20 v0.1.1/go.mod h1:JKtK6mjbAVcUTN/9jZpvLbGxvdWIKS8uT7EiStoU1SM= +github.com/quic-go/qtls-go1-20 v0.2.0 h1:jUHn+obJ6WI5JudqBO0Iy1ra5Vh5vsitQ1gXQvkmN+E= +github.com/quic-go/qtls-go1-20 v0.2.0/go.mod h1:JKtK6mjbAVcUTN/9jZpvLbGxvdWIKS8uT7EiStoU1SM= +github.com/quic-go/quic-go v0.33.0 h1:ItNoTDN/Fm/zBlq769lLJc8ECe9gYaW40veHCCco7y0= +github.com/quic-go/quic-go v0.33.0/go.mod h1:YMuhaAV9/jIu0XclDXwZPAsP/2Kgr5yMYhe9oxhhOFA= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk= @@ -57,18 +70,24 @@ golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACk golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.4.0 h1:UVQgzMY87xqpKNgb+kDsll2Igd33HszWHFLmpaRMq/8= golang.org/x/crypto v0.4.0/go.mod h1:3quD/ATkf6oY+rnes5c3ExXTbLc8mueNue5/DoinL80= -golang.org/x/exp v0.0.0-20221215174704-0915cd710c24 h1:6w3iSY8IIkp5OQtbYj8NeuKG1jS9d+kYaubXqsoOiQ8= -golang.org/x/exp v0.0.0-20221215174704-0915cd710c24/go.mod h1:CxIveKay+FTh1D0yPZemJVgC/95VzuuOLq5Qi4xnoYc= +golang.org/x/crypto v0.7.0 h1:AvwMYaRytfdeVt3u6mLaxYtErKYjxA2OXjJ1HHq6t3A= +golang.org/x/crypto v0.7.0/go.mod h1:pYwdfH91IfpZVANVyUOhSIPZaFoJGxTFbZhFTx+dXZU= golang.org/x/exp v0.0.0-20221217163422-3c43f8badb15 h1:5oN1Pz/eDhCpbMbLstvIPa0b/BEQo6g6nwV3pLjfM6w= golang.org/x/exp v0.0.0-20221217163422-3c43f8badb15/go.mod h1:CxIveKay+FTh1D0yPZemJVgC/95VzuuOLq5Qi4xnoYc= +golang.org/x/exp v0.0.0-20230321023759-10a507213a29 h1:ooxPy7fPvB4kwsA2h+iBNHkAbp/4JxTSwCmvdjEYmug= +golang.org/x/exp v0.0.0-20230321023759-10a507213a29/go.mod h1:CxIveKay+FTh1D0yPZemJVgC/95VzuuOLq5Qi4xnoYc= golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.7.0 h1:LapD9S96VoQRhi/GrNTqeBJFrUjs5UHCAtTlgwA5oZA= golang.org/x/mod v0.7.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= +golang.org/x/mod v0.9.0 h1:KENHtAZL2y3NLMYZeHY9DW8HW8V+kQyJsY/V9JlKvCs= +golang.org/x/mod v0.9.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= golang.org/x/net v0.4.0 h1:Q5QPcMlvfxFTAPV0+07Xz/MpK9NTXu2VDUuy0FeMfaU= golang.org/x/net v0.4.0/go.mod h1:MBQ8lrhLObU/6UmLb4fmbmk5OcyYmqtbGd/9yIeKjEE= +golang.org/x/net v0.8.0 h1:Zrh2ngAOFYneWTAIAPethzeaQLuHwhuBkuV6ZiRnUaQ= +golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -79,28 +98,40 @@ golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.3.0 h1:w8ZOecv6NaNa/zC8944JTU3vz4u6Lagfk4RPQxv92NQ= golang.org/x/sys v0.3.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.6.0 h1:MVltZSvRTcU2ljQOhs94SXPftV6DCNnZViHeQps87pQ= +golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.5.0 h1:OLmvp0KP+FVG99Ct/qFiL/Fhk4zp4QQnZ7b2U+5piUM= golang.org/x/text v0.5.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= +golang.org/x/text v0.8.0 h1:57P1ETyNKtuIjB4SRd15iJxuhj8Gc416Y78H3qgMh68= +golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.4.0 h1:7mTAgkunk3fr4GAloyyCasadO6h9zSsQZbwvcaIciV4= golang.org/x/tools v0.4.0/go.mod h1:UE5sM2OK9E/d67R0ANs2xJizIymRP5gJU295PvKXxjQ= +golang.org/x/tools v0.7.0 h1:W4OVu8VVOaIO0yzWMNdepAulS7YfoS3Zabrm8DOXXU4= +golang.org/x/tools v0.7.0/go.mod h1:4pg6aUX35JBAogB10C9AtvVL+qowtN4pT3CGSQex14s= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= google.golang.org/genproto v0.0.0-20221207170731-23e4bf6bdc37 h1:jmIfw8+gSvXcZSgaFAGyInDXeWzUhvYH57G/5GKMn70= google.golang.org/genproto v0.0.0-20221207170731-23e4bf6bdc37/go.mod h1:RGgjbofJ8xD9Sq1VVhDM1Vok1vRONV+rg+CjzG4SZKM= +google.golang.org/genproto v0.0.0-20230322174352-cde4c949918d h1:OE8TncEeAei3Tehf/P/Jdt/K+8GnTUrRY6wzYpbCes4= +google.golang.org/genproto v0.0.0-20230322174352-cde4c949918d/go.mod h1:NWraEVixdDnqcqQ30jipen1STv2r/n24Wb7twVTGR4s= google.golang.org/grpc v1.51.0 h1:E1eGv1FTqoLIdnBCZufiSHgKjlqG6fKFf6pPWtMTh8U= google.golang.org/grpc v1.51.0/go.mod h1:wgNDFcnuBGmxLKI/qn4T+m5BtEBYXJPvibbUPsAIPww= +google.golang.org/grpc v1.54.0 h1:EhTqbhiYeixwWQtAEZAxmV9MGqcjEU2mFx52xCzNyag= +google.golang.org/grpc v1.54.0/go.mod h1:PUSEXI6iWghWaB6lXM4knEgpJNu2qUcKfDtNci3EC2g= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= google.golang.org/protobuf v1.28.1 h1:d0NfwRgPtno5B1Wa6L2DAG+KivqkdutMf1UhdNx175w= google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= +google.golang.org/protobuf v1.30.0 h1:kPPoIgf3TsEvrm0PFe15JQ+570QVxYzEvvHqChK+cng= +google.golang.org/protobuf v1.30.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc h1:2gGKlE2+asNV9m7xrywl36YYNnBG5ZQ0r/BOOxqPpmk= gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc/go.mod h1:m7x9LTH6d71AHyAX77c9yqWCCa3UKHcVEj9y7hAtKDk= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= diff --git a/logging/access_log.go b/logging/access_log.go index 9ffcec5..e0a1515 100644 --- a/logging/access_log.go +++ b/logging/access_log.go @@ -94,7 +94,7 @@ func NewAccessLogHandler(h http.Handler, logger *slog.Logger, o *AccessLogOption level = slog.LevelDebug } - logger.LogAttrs(level, logMessage, attrs...) + logger.LogAttrs(r.Context(), level, logMessage, attrs...) if o.PostHook != nil { o.PostHook(m.Code, m.Duration, m.Written) diff --git a/logging/logging.go b/logging/logging.go index 6bc9a74..b0ecef9 100644 --- a/logging/logging.go +++ b/logging/logging.go @@ -6,6 +6,7 @@ package logging import ( + "context" "fmt" "io" "net/http" @@ -77,7 +78,7 @@ func NewDailyReplaceableWriterConstructor(dir, name string) func(flag string) (f // name. func NewContextLoggerHandler(h http.Handler, l *slog.Logger) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - r = r.WithContext(slog.NewContext(r.Context(), l)) + r = r.WithContext(newSlogContext(r.Context(), l)) h.ServeHTTP(w, r) }) } @@ -88,5 +89,22 @@ const HandlerKey = "handler" // HandlerLogger provides a logger from HTTP request with attached name of the // handler. func HandlerLogger(r *http.Request, handlerName string) *slog.Logger { - return slog.FromContext(r.Context()).With(HandlerKey, handlerName) + return fromSlogContext(r.Context()).With(HandlerKey, handlerName) +} + +type contextKeySlog struct{} + +// newSlogContext returns a context that contains the given Logger. +// Use FromContext to retrieve the Logger. +func newSlogContext(ctx context.Context, l *slog.Logger) context.Context { + return context.WithValue(ctx, contextKeySlog{}, l) +} + +// fromSlogContext returns the Logger stored in ctx by NewContext, or the default +// Logger if there is none. +func fromSlogContext(ctx context.Context) *slog.Logger { + if l, ok := ctx.Value(contextKeySlog{}).(*slog.Logger); ok { + return l + } + return slog.Default() } diff --git a/maintenance/maintenance.go b/maintenance/maintenance.go index 169a8d2..244e8ec 100644 --- a/maintenance/maintenance.go +++ b/maintenance/maintenance.go @@ -196,7 +196,7 @@ func (s Service) HTMLHandler(h http.Handler) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { on, err := s.store.Status() if err != nil { - s.logger.Error("maintenance status", err) + s.logger.Error("maintenance status", "error", err) } if on || err != nil { if s.HTML.Handler != nil { @@ -218,7 +218,7 @@ func (s Service) JSONHandler(h http.Handler) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { on, err := s.store.Status() if err != nil { - s.logger.Error("maintenance status", err) + s.logger.Error("maintenance status", "error", err) } if on || err != nil { if s.JSON.Handler != nil { @@ -240,7 +240,7 @@ func (s Service) TextHandler(h http.Handler) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { on, err := s.store.Status() if err != nil { - s.logger.Error("maintenance status", err) + s.logger.Error("maintenance status", "error", err) } if on || err != nil { if s.Text.Handler != nil { @@ -266,7 +266,7 @@ func (s Service) Status() (on bool, err error) { func (s Service) StatusHandler(w http.ResponseWriter, r *http.Request) { on, err := s.store.Status() if err != nil { - s.logger.Error("maintenance status", err) + s.logger.Error("maintenance status", "error", err) jsonInternalServerErrorResponse(w) return } @@ -279,7 +279,7 @@ func (s Service) StatusHandler(w http.ResponseWriter, r *http.Request) { func (s Service) OnHandler(w http.ResponseWriter, r *http.Request) { changed, err := s.store.On() if err != nil { - s.logger.Error("maintenance on", err) + s.logger.Error("maintenance on", "error", err) jsonInternalServerErrorResponse(w) return } @@ -295,7 +295,7 @@ func (s Service) OnHandler(w http.ResponseWriter, r *http.Request) { func (s Service) OffHandler(w http.ResponseWriter, r *http.Request) { changed, err := s.store.Off() if err != nil { - s.logger.Error("maintenance off", err) + s.logger.Error("maintenance off", "error", err) jsonInternalServerErrorResponse(w) return } diff --git a/recovery/recovery.go b/recovery/recovery.go index 287935a..e2a7d96 100644 --- a/recovery/recovery.go +++ b/recovery/recovery.go @@ -76,6 +76,7 @@ func New(handler http.Handler, options ...Option) (h *Handler) { // ServeHTTP implements http.Handler interface. func (h Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) { + ctx := r.Context() defer func() { if err := recover(); err != nil { debugMsg := fmt.Sprintf( @@ -87,13 +88,13 @@ func (h Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) { if h.label != "" { debugMsg = h.label + "\n\n" + debugMsg } - h.logger.Log(slog.LevelError, "http recovery handler", "method", r.Method, "url", r.URL.String(), slog.ErrorKey, err, "debug", debugMsg) + h.logger.ErrorCtx(ctx, "http recovery handler", "method", r.Method, "url", r.URL.String(), "error", err, "debug", debugMsg) if h.notifier != nil { go func() { defer func() { if err := recover(); err != nil { - h.logger.Log(slog.LevelError, "http recovery handler: notify panic", slog.Any(slog.ErrorKey, err)) + h.logger.ErrorCtx(ctx, "http recovery handler: notify panic", slog.Any("error", err)) } }() @@ -107,7 +108,7 @@ func (h Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) { ), debugMsg, ); err != nil { - h.logger.Log(slog.LevelError, "http recovery handler: notify", slog.Any(slog.ErrorKey, err)) + h.logger.ErrorCtx(ctx, "http recovery handler: notify", slog.Any("error", err)) } }() } diff --git a/recovery/recovery_test.go b/recovery/recovery_test.go index 732561c..995eb78 100644 --- a/recovery/recovery_test.go +++ b/recovery/recovery_test.go @@ -84,7 +84,7 @@ func TestHandlerLogger(t *testing.T) { New(panicHandler, WithLogger(slog.New(slog.NewTextHandler(&buf)))).ServeHTTP(httptest.NewRecorder(), req) - want := "level=ERROR msg=\"http recovery handler\" method=GET url=/ err=\"HTTP utils panic!\" debug=" + want := "level=ERROR msg=\"http recovery handler\" method=GET url=/ error=\"HTTP utils panic!\" debug=" if !strings.Contains(buf.String(), want) { t.Errorf("got %q, expected %q", buf.String(), want) } diff --git a/servers/quic/quic.go b/servers/quic/quic.go index cd91b16..eadc1c4 100644 --- a/servers/quic/quic.go +++ b/servers/quic/quic.go @@ -11,7 +11,7 @@ import ( "net" "net/http" - "github.com/lucas-clemente/quic-go/http3" + "github.com/quic-go/quic-go/http3" "resenje.org/web/servers" ) diff --git a/servers/servers.go b/servers/servers.go index e2f65b7..db02c9a 100644 --- a/servers/servers.go +++ b/servers/servers.go @@ -127,7 +127,7 @@ func (s *Servers) Serve() (err error) { continue } if err := l.Close(); err != nil { - s.logger.Error("close tcp listener", err, "name", srv.label(), "address", srv.address) + s.logger.Error("close tcp listener", "name", srv.label(), "address", srv.address, "error", err) } } return fmt.Errorf("%s tcp listener %q: %v", srv.label(), srv.address, err) @@ -157,7 +157,7 @@ func (s *Servers) Serve() (err error) { s.logger.Info("listen tcp", "label", srv.label(), "address", srv.tcpAddr.String()) if err := tcpSrv.ServeTCP(ln); err != nil { - s.logger.Error("serve tcp", err, "name", srv.label(), "address", srv.tcpAddr.String()) + s.logger.Error("serve tcp", "name", srv.label(), "address", srv.tcpAddr.String(), "error", err) } }(srv, lns[i]) } @@ -171,7 +171,7 @@ func (s *Servers) Serve() (err error) { s.logger.Info("listen udp", "name", srv.label(), "address", srv.udpAddr.String()) if err := udpSrv.ServeUDP(conn); err != nil { - s.logger.Error("serve udp", err, "name", srv.label(), "address", srv.udpAddr.String(), err) + s.logger.Error("serve udp", "name", srv.label(), "address", srv.udpAddr.String(), "error", err) } }(srv, conns[i]) } @@ -222,7 +222,7 @@ func (s *Servers) Close() { s.logger.Info("closing server", "name", srv.label()) if err := srv.Close(); err != nil { - s.logger.Error("closing server", err, "name", srv.label()) + s.logger.Error("closing server", "name", srv.label(), "error", err) } }(srv) } @@ -240,7 +240,7 @@ func (s *Servers) Shutdown(ctx context.Context) { s.logger.Info("shutting down server", "name", srv.label()) if err := srv.Shutdown(ctx); err != nil { - s.logger.Error("shutting down server", err, "name", srv.label()) + s.logger.ErrorCtx(ctx, "shutting down server", "name", srv.label(), "error", err) } }(srv) } diff --git a/servers/servers_test.go b/servers/servers_test.go index c4fdf8b..f2500ac 100644 --- a/servers/servers_test.go +++ b/servers/servers_test.go @@ -234,7 +234,7 @@ func TestServersShutdown(t *testing.T) { s.Shutdown(context.Background()) - l = "ERROR shutting down server name=server err=\"server already shut down\"" + l = "ERROR shutting down server name=server error=\"server already shut down\"" if !strings.Contains(buf.String(), l) { t.Errorf("got %q, expected %q", buf.String(), l) } @@ -272,7 +272,7 @@ func TestServersClose(t *testing.T) { s.Close() - l = "ERROR closing server name=server err=\"server already closed\"" + l = "ERROR closing server name=server error=\"server already closed\"" if !strings.Contains(buf.String(), l) { t.Errorf("got %q, expected %q", buf.String(), l) } diff --git a/templates/templates.go b/templates/templates.go index 620ed9e..0ef3c51 100644 --- a/templates/templates.go +++ b/templates/templates.go @@ -237,7 +237,7 @@ func (t Templates) RespondTemplateWithStatus(w http.ResponseWriter, name, templa w.WriteHeader(status) } if _, err := buf.WriteTo(w); err != nil { - t.logger.Debug("templates: respond template with status", "name", name, "template", templateName, "status", status, slog.ErrorKey, err) + t.logger.Debug("templates: respond template with status", "name", name, "template", templateName, "status", status, "error", err) } } @@ -257,7 +257,7 @@ func (t Templates) RespondWithStatus(w http.ResponseWriter, name string, data an w.WriteHeader(status) } if _, err := buf.WriteTo(w); err != nil { - t.logger.Debug("templates: respond with status", "name", name, "status", status, slog.ErrorKey, err) + t.logger.Debug("templates: respond with status", "name", name, "status", status, "error", err) } }