Skip to content

Commit 8e35acc

Browse files
committed
fix: drop custom quic-go fork, use upstream
Signed-off-by: Christian Stewart <christian@aperture.us>
1 parent 3afe6a6 commit 8e35acc

File tree

11 files changed

+134
-72
lines changed

11 files changed

+134
-72
lines changed

doc/QUIC_GO.md

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
# quic-go in Bifrost
2+
3+
Bifrost uses [quic-go](https://github.com/quic-go/quic-go) as the underlying
4+
QUIC implementation for its peer-to-peer transport layer. QUIC provides
5+
multiplexed streams over a single connection with built-in encryption via TLS
6+
1.3, making it well-suited for bifrost's networking needs.
7+
8+
## How Bifrost Uses quic-go
9+
10+
Bifrost wraps quic-go to build authenticated P2P links between peers:
11+
12+
- **transport/common/quic**: Core QUIC transport abstraction. Wraps `quic.Conn`
13+
into bifrost `Link` objects with peer identity verification via mTLS
14+
(libp2p-tls). Handles dialing, listening, and stream multiplexing.
15+
16+
- **transport/common/pconn**: Packet-conn transport. Runs QUIC over raw UDP
17+
sockets using `quic.Transport`. Used for direct UDP-based connections.
18+
19+
- **transport/common/conn**: Ordered-conn transport. Runs QUIC over ordered
20+
byte streams (e.g. TCP) by packetizing them with a custom `PacketConn`
21+
adapter.
22+
23+
- **transport/websocket**: Runs QUIC over WebSocket connections. WebSocket
24+
frames are treated as packets for the QUIC layer.
25+
26+
- **transport/webrtc**: Runs QUIC over WebRTC data channels. Enables
27+
browser-to-browser and browser-to-native P2P connections.
28+
29+
All transports negotiate peer identity using libp2p-tls certificates. The QUIC
30+
connection provides the stream multiplexing and flow control, while the TLS
31+
layer provides mutual authentication and peer identity verification.
32+
33+
### Configuration
34+
35+
QUIC configuration is built via `BuildQuicConfig(opts)` which maps bifrost
36+
`Opts` protobuf fields to `quic.Config`:
37+
38+
- `MaxIdleTimeoutDur`: Connection idle timeout (default: 10s)
39+
- `MaxIncomingStreams`: Maximum concurrent streams (default: 100000)
40+
- `DisableDatagrams`: Disable QUIC datagram support
41+
- `DisableKeepAlive`: Disable keep-alive probes
42+
- `KeepAliveDur`: Custom keep-alive interval
43+
- `DisablePathMtuDiscovery`: Disable PMTU discovery (forced on for
44+
non-UDP transports like WebSocket, WebRTC, and ordered conns)
45+
46+
Bifrost uses QUIC Version 2 (RFC 9369) exclusively.
47+
48+
## Fork History
49+
50+
Bifrost previously used a fork at `github.com/aperturerobotics/quic-go`. The
51+
fork was created in January 2024 and maintained the following changes on top of
52+
upstream:
53+
54+
1. **Configurable logrus logger**: Added `Logger *logrus.Entry` field to
55+
`Config` and `Transport`, replacing quic-go's built-in logger (which uses
56+
Go's `log` package and `QUIC_GO_LOG_LEVEL` env var) with logrus integration.
57+
This was the primary reason for the fork.
58+
59+
2. **`CloseNoError()` method**: Added a convenience method on `Connection` that
60+
calls `closeLocal(nil)` and waits for context cancellation. Equivalent to
61+
`CloseWithError(0, "")`.
62+
63+
3. **Log level reductions**: Demoted ~9 log messages from Info/Error to Debug
64+
level to reduce noise during normal operation.
65+
66+
4. **Buffer size warning suppression**: Commented out UDP buffer size warnings
67+
that print on startup when the OS buffer cannot be increased.
68+
69+
5. **Multiplexer removal**: Removed the global connection multiplexer (upstream
70+
later removed this independently).
71+
72+
6. **Mutex deadlock fix**: Used `TryLock` pattern in `closeServer()` to avoid
73+
a potential deadlock when closing transports.
74+
75+
### Why the Fork Was Dropped
76+
77+
As of February 2026, the fork was dropped in favor of upstream quic-go v0.59.0:
78+
79+
- The `CloseNoError()` convenience method was replaced with the upstream
80+
idiomatic `CloseWithError(0, "")` (one call site in bifrost).
81+
- The configurable logger was the only feature that truly required a fork.
82+
Bifrost decided to accept upstream's default logging behavior (silent by
83+
default, configurable via `QUIC_GO_LOG_LEVEL` env var) rather than maintain
84+
a fork indefinitely.
85+
- Buffer size warnings can be suppressed via the
86+
`QUIC_GO_DISABLE_RECEIVE_BUFFER_WARNING=true` env var.
87+
- Log level reductions are less important since upstream defaults to no logging.
88+
- The multiplexer was already removed upstream.
89+
- The deadlock fix was specific to the fork's older architecture and not
90+
applicable to current upstream.
91+
92+
## Upstream Wishlist
93+
94+
Features that would benefit bifrost if added to upstream quic-go:
95+
96+
1. **Configurable logger interface**: The ability to inject a custom logger
97+
(e.g. `slog.Logger` or a simple interface) into `Config` or `Transport`
98+
instead of relying on `QUIC_GO_LOG_LEVEL` + Go's `log` package. Upstream
99+
has a TODO comment for this in `transport.go`. This was the primary reason
100+
for the fork and would eliminate the need for any future fork.
101+
102+
2. **Programmatic buffer warning control**: While
103+
`QUIC_GO_DISABLE_RECEIVE_BUFFER_WARNING` exists, a programmatic way to
104+
suppress or redirect the buffer size warning (e.g. via the logger interface
105+
above) would be cleaner for library consumers.

go.mod

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ replace (
2323
github.com/libp2p/go-msgio => github.com/aperturerobotics/go-libp2p-msgio v0.0.0-20240511033615-1b69178aa5c8 // aperture
2424
github.com/multiformats/go-multiaddr => github.com/aperturerobotics/go-multiaddr v0.12.4-0.20240407071906-6f0354cc6755 // aperture
2525
github.com/multiformats/go-multihash => github.com/aperturerobotics/go-multihash v0.2.3 // aperture
26-
github.com/quic-go/quic-go => github.com/aperturerobotics/quic-go v0.48.2-0.20241029082227-fa76c393ee89 // aperture
2726
github.com/sirupsen/logrus => github.com/aperturerobotics/logrus v1.9.4-0.20240119050608-13332fb58195 // aperture
2827
)
2928

@@ -56,8 +55,6 @@ require (
5655
github.com/bwesterb/go-ristretto v1.2.3 // indirect
5756
github.com/davidlazar/go-crypto v0.0.0-20200604182044-b73af7476f6c // indirect
5857
github.com/ghodss/yaml v1.0.0 // indirect
59-
github.com/go-task/slim-sprig/v3 v3.0.0 // indirect
60-
github.com/google/pprof v0.0.0-20241017200806-017d972448fc // indirect
6158
github.com/google/uuid v1.6.0 // indirect
6259
github.com/ipfs/go-cid v0.4.1 // indirect
6360
github.com/ipfs/go-log/v2 v2.5.1 // indirect
@@ -71,7 +68,6 @@ require (
7168
github.com/multiformats/go-multihash v0.2.3 // indirect
7269
github.com/multiformats/go-multistream v0.5.0 // indirect
7370
github.com/multiformats/go-varint v0.0.7 // indirect
74-
github.com/onsi/ginkgo/v2 v2.20.2 // indirect
7571
github.com/petermattis/goid v0.0.0-20250813065127-a731cc31b4fe // indirect
7672
github.com/pion/dtls/v3 v3.0.10 // indirect
7773
github.com/pion/ice/v4 v4.2.0 // indirect
@@ -90,14 +86,10 @@ require (
9086
github.com/tetratelabs/wazero v1.11.0 // indirect
9187
github.com/wlynxg/anet v0.0.5 // indirect
9288
github.com/xrash/smetrics v0.0.0-20250705151800-55b8f293f342 // indirect
93-
go.uber.org/mock v0.5.0 // indirect
9489
golang.org/x/mod v0.32.0 // indirect
9590
golang.org/x/net v0.49.0 // indirect
96-
golang.org/x/sync v0.19.0 // indirect
9791
golang.org/x/sys v0.40.0 // indirect
9892
golang.org/x/time v0.12.0 // indirect
99-
golang.org/x/tools v0.41.0 // indirect
100-
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect
10193
gopkg.in/yaml.v2 v2.4.0 // indirect
10294
lukechampine.com/blake3 v1.3.0 // indirect
10395
)

go.sum

Lines changed: 8 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,6 @@ github.com/aperturerobotics/protobuf v0.0.0-20260203024654-8201686529c4 h1:4Dy3B
3030
github.com/aperturerobotics/protobuf v0.0.0-20260203024654-8201686529c4/go.mod h1:tMgO7y6SJo/d9ZcvrpNqIQtdYT9de+QmYaHOZ4KnhOg=
3131
github.com/aperturerobotics/protobuf-go-lite v0.12.1 h1:o9of87F/LFS2p5xfq32CrU99dvfqIAalTP7ZzoZK6Kg=
3232
github.com/aperturerobotics/protobuf-go-lite v0.12.1/go.mod h1:lGH3s5ArCTXKI4wJdlNpaybUtwSjfAG0vdWjxOfMcF8=
33-
github.com/aperturerobotics/quic-go v0.48.2-0.20241029082227-fa76c393ee89 h1:MUXLrLDjCw36dx8OeBwF/B7YP5akyoU6Ps+v50qR5Lo=
34-
github.com/aperturerobotics/quic-go v0.48.2-0.20241029082227-fa76c393ee89/go.mod h1:vhhkHYq2i9lb0bOllqKhOdtg/3i7r4o/7zc8XI/T4lo=
3533
github.com/aperturerobotics/starpc v0.46.1 h1:RdyPA1UsU4WNj0ISzNQRcQvDk9hkwBrmRzpCrJD2XP0=
3634
github.com/aperturerobotics/starpc v0.46.1/go.mod h1:x1CyVEdQz1N90KtpEF6hv9Bn0gWSqoEx090mpnyPZIk=
3735
github.com/aperturerobotics/util v1.32.3 h1:wBc6L2guYMgLEzFwORH3CLMoMpfEqbV6pDqYervo3S0=
@@ -51,14 +49,8 @@ github.com/davidlazar/go-crypto v0.0.0-20200604182044-b73af7476f6c h1:pFUpOrbxDR
5149
github.com/davidlazar/go-crypto v0.0.0-20200604182044-b73af7476f6c/go.mod h1:6UhI8N9EjYm1c2odKpFpAYeR8dsBeM7PtzQhRgxRr9U=
5250
github.com/ghodss/yaml v1.0.0 h1:wQHKEahhL6wmXdzwWG11gIVCkOv05bNOh+Rxn0yngAk=
5351
github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
54-
github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY=
55-
github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
56-
github.com/go-task/slim-sprig/v3 v3.0.0 h1:sUs3vkvUymDpBKi3qH1YSqBQk9+9D/8M2mN1vB6EwHI=
57-
github.com/go-task/slim-sprig/v3 v3.0.0/go.mod h1:W848ghGpv3Qj3dhTPRyJypKRiqCdHZiAzKg9hl15HA8=
5852
github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
5953
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
60-
github.com/google/pprof v0.0.0-20241017200806-017d972448fc h1:NGyrhhFhwvRAZg02jnYVg3GBQy0qGBKmFQJwaPmpmxs=
61-
github.com/google/pprof v0.0.0-20241017200806-017d972448fc/go.mod h1:vavhavw2zAxS5dIdcRluK6cSGGPlZynqzFM8NdvU144=
6254
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
6355
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
6456
github.com/ipfs/go-cid v0.4.1 h1:A/T3qGvxi4kpKWWcPC/PgbvDA2bjVLO7n4UeVwnbs/s=
@@ -69,10 +61,8 @@ github.com/klauspost/compress v1.18.3 h1:9PJRvfbmTabkOX8moIpXPbMMbYN60bWImDDU7L+
6961
github.com/klauspost/compress v1.18.3/go.mod h1:R0h/fSBs8DE4ENlcrlib3PsXS61voFxhIs2DeRhCvJ4=
7062
github.com/klauspost/cpuid/v2 v2.2.8 h1:+StwCXwm9PdpiEkPyzBXIy+M9KUb4ODm0Zarf1kS5BM=
7163
github.com/klauspost/cpuid/v2 v2.2.8/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZYpaMropDUws=
72-
github.com/kr/pretty v0.2.1 h1:Fmg33tUaq4/8ym9TJN1x7sLJnHVwhP33CNkpYV/7rwI=
73-
github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
74-
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
75-
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
64+
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
65+
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
7666
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
7767
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
7868
github.com/libp2p/go-buffer-pool v0.1.0 h1:oK4mSFcQz7cTQIfqbe4MIj9gLW+mnanjyFtc6cdF0Y8=
@@ -93,10 +83,6 @@ github.com/multiformats/go-multistream v0.5.0 h1:5htLSLl7lvJk3xx3qT/8Zm9J4K8vEOf
9383
github.com/multiformats/go-multistream v0.5.0/go.mod h1:n6tMZiwiP2wUsR8DgfDWw1dydlEqV3l6N3/GBsX6ILA=
9484
github.com/multiformats/go-varint v0.0.7 h1:sWSGR+f/eu5ABZA2ZpYKBILXTTs9JWpdEM/nEGOHFS8=
9585
github.com/multiformats/go-varint v0.0.7/go.mod h1:r8PUYw/fD/SjBCiKOoDlGF6QawOELpZAu9eioSos/OU=
96-
github.com/onsi/ginkgo/v2 v2.20.2 h1:7NVCeyIWROIAheY21RLS+3j2bb52W0W82tkberYytp4=
97-
github.com/onsi/ginkgo/v2 v2.20.2/go.mod h1:K9gyxPIlb+aIvnZ8bd9Ak+YP18w3APlR+5coaZoE2ag=
98-
github.com/onsi/gomega v1.34.1 h1:EUMJIKUjM8sKjYbtxQI9A4z2o+rruxnzNvpknOXie6k=
99-
github.com/onsi/gomega v1.34.1/go.mod h1:kU1QgUvBDLXBJq618Xvm2LUX6rSAfRaFRTcdOeDLwwY=
10086
github.com/paralin/ipfs-go-logrus v0.0.0-20240410105224-e24cb05f9e98 h1:8VijFMz4qJ70+ObyaByu6XZctKPhjllz/XfEoVZDQGo=
10187
github.com/paralin/ipfs-go-logrus v0.0.0-20240410105224-e24cb05f9e98/go.mod h1:8oFwKpIFewIJ9LrnO8dib4kQjKQQx7Ukq9sNZ+k50QU=
10288
github.com/patrickmn/go-cache v2.1.0+incompatible h1:HRMgzkcYKYpi3C8ajMPV8OFXaaRUnok+kx1WdO15EQc=
@@ -141,6 +127,10 @@ github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
141127
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
142128
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
143129
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
130+
github.com/quic-go/quic-go v0.59.0 h1:OLJkp1Mlm/aS7dpKgTc6cnpynnD2Xg7C1pwL6vy/SAw=
131+
github.com/quic-go/quic-go v0.59.0/go.mod h1:upnsH4Ju1YkqpLXC305eW3yDZ4NfnNbmQRCMWS58IKU=
132+
github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ=
133+
github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncjaFoBhdsK/akog=
144134
github.com/sasha-s/go-deadlock v0.3.6 h1:TR7sfOnZ7x00tWPfD397Peodt57KzMDo+9Ae9rMiUmw=
145135
github.com/sasha-s/go-deadlock v0.3.6/go.mod h1:CUqNyyvMxTyjFqDT7MRg9mb4Dv/btmGTqSR+rky/UXo=
146136
github.com/spaolacci/murmur3 v1.1.1-0.20190317074736-539464a789e9 h1:7/iCYp2ii4GgbLhsT4uA8+vNHYYlSY5I5CS6/8e57hE=
@@ -161,8 +151,8 @@ github.com/zeebo/blake3 v0.2.4 h1:KYQPkhpRtcqh0ssGYcKLG1JYvddkEA8QwCM/yBqhaZI=
161151
github.com/zeebo/blake3 v0.2.4/go.mod h1:7eeQ6d2iXWRGF6npfaxl2CU+xy2Fjo2gxeyZGCRUjcE=
162152
github.com/zeebo/pcg v1.0.1 h1:lyqfGeWiv4ahac6ttHs+I5hwtH/+1mrhlCtVNQM2kHo=
163153
github.com/zeebo/pcg v1.0.1/go.mod h1:09F0S9iiKrwn9rlI5yjLkmrug154/YRW6KnnXVDM/l4=
164-
go.uber.org/mock v0.5.0 h1:KAMbZvZPyBPWgD14IrIQ38QCyjwpvVVV6K/bHl1IwQU=
165-
go.uber.org/mock v0.5.0/go.mod h1:ge71pBPLYDk7QIi1LupWxdAykm7KIEFchiOqd6z7qMM=
154+
go.uber.org/mock v0.5.2 h1:LbtPTcP8A5k9WPXj54PPPbjcI4Y6lhyOZXn+VS7wNko=
155+
go.uber.org/mock v0.5.2/go.mod h1:wLlUxC2vVTPTaE3UD51E0BGOAElKrILxhVSDYQLld5o=
166156
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
167157
golang.org/x/crypto v0.0.0-20200602180216-279210d13fed/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
168158
golang.org/x/crypto v0.47.0 h1:V6e3FRj+n4dbpw86FJ8Fv7XVOql7TEwpHapKoMJ/GO8=
@@ -174,8 +164,6 @@ golang.org/x/mod v0.32.0/go.mod h1:SgipZ/3h2Ci89DlEtEXWUk/HteuRin+HHhN+WbNhguU=
174164
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
175165
golang.org/x/net v0.49.0 h1:eeHFmOGUTtaaPSGNmjBKpbng9MulQsJURQUAfUwY++o=
176166
golang.org/x/net v0.49.0/go.mod h1:/ysNB2EvaqvesRkuLAyjI1ycPZlQHM3q01F02UY/MV8=
177-
golang.org/x/sync v0.19.0 h1:vV+1eWNmZ5geRlYjzm2adRgW2/mcpevXNg50YZtPCE4=
178-
golang.org/x/sync v0.19.0/go.mod h1:9KTHXmSnoGruLpwFjVSX0lNNA75CykiMECbovNTZqGI=
179167
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
180168
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
181169
golang.org/x/sys v0.0.0-20200602225109-6fdc65e7d980/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
@@ -186,12 +174,8 @@ golang.org/x/sys v0.40.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
186174
golang.org/x/term v0.39.0 h1:RclSuaJf32jOqZz74CkPA9qFuVTX7vhLlpfj/IGWlqY=
187175
golang.org/x/term v0.39.0/go.mod h1:yxzUCTP/U+FzoxfdKmLaA0RV1WgE0VY7hXBwKtY/4ww=
188176
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
189-
golang.org/x/text v0.33.0 h1:B3njUFyqtHDUI5jMn1YIr5B0IE2U0qck04r6d4KPAxE=
190-
golang.org/x/text v0.33.0/go.mod h1:LuMebE6+rBincTi9+xWTY8TztLzKHc/9C1uBCG27+q8=
191177
golang.org/x/time v0.12.0 h1:ScB/8o8olJvc+CQPWrK3fPZNfh7qgwCrY0zJmoEQLSE=
192178
golang.org/x/time v0.12.0/go.mod h1:CDIdPxbZBQxdj6cxyCIdrNogrJKMJ7pr37NYpMcMDSg=
193-
golang.org/x/tools v0.41.0 h1:a9b8iMweWG+S0OBnlU36rzLp20z1Rp10w+IY2czHTQc=
194-
golang.org/x/tools v0.41.0/go.mod h1:XSY6eDqxVNiYgezAVqqCeihT4j1U2CCsqvH3WhQpnlg=
195179
gonum.org/v1/gonum v0.17.0 h1:VbpOemQlsSMrYmn7T2OUvQ4dqxQXU+ouZFQsZOx50z4=
196180
gonum.org/v1/gonum v0.17.0/go.mod h1:El3tOrEuMpv2UdMrbNlKEh9vd86bmQ6vqIcDwxEOc1E=
197181
google.golang.org/protobuf v1.36.11 h1:fV6ZwhNocDyBLK0dj+fg8ektcVegBBuEolpbTQyBNVE=

transport/common/conn/conn.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ func NewTransport(
9292

9393
var dialFn transport_quic.DialFunc
9494
if addrDialer != nil {
95-
dialFn = func(dctx context.Context, addr string) (quic.Connection, net.Addr, error) {
95+
dialFn = func(dctx context.Context, addr string) (*quic.Conn, net.Addr, error) {
9696
c, na, err := addrDialer(dctx, addr)
9797
if err != nil {
9898
return nil, nil, err

transport/common/pconn/pconn.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ func NewTransport(
8686

8787
var dialFn transport_quic.DialFunc
8888
if addrParser != nil {
89-
dialFn = func(ctx context.Context, addr string) (quic.Connection, net.Addr, error) {
89+
dialFn = func(ctx context.Context, addr string) (*quic.Conn, net.Addr, error) {
9090
// parse the addr to a net.Addr
9191
na, err := addrParser(addr)
9292
if err != nil {
@@ -125,7 +125,7 @@ func NewTransport(
125125
return nil, err
126126
}
127127

128-
tpt.quicConfig = transport_quic.BuildQuicConfig(le, opts.GetQuic())
128+
tpt.quicConfig = transport_quic.BuildQuicConfig(opts.GetQuic())
129129
tpt.quicTpt = &quic.Transport{Conn: pc}
130130

131131
return tpt, nil

transport/common/quic/config.go

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,15 @@ import (
77
"github.com/aperturerobotics/bifrost/peer"
88
p2ptls "github.com/libp2p/go-libp2p/p2p/security/tls"
99
quic "github.com/quic-go/quic-go"
10-
"github.com/sirupsen/logrus"
1110
)
1211

1312
// BuildQuicConfig constructs the quic config.
14-
func BuildQuicConfig(le *logrus.Entry, opts *Opts) *quic.Config {
15-
// var enableMaxIdleTimeout bool
13+
func BuildQuicConfig(opts *Opts) *quic.Config {
1614
maxIdleTimeout := time.Second * 10
1715
if ntDur := opts.GetMaxIdleTimeoutDur(); ntDur != "" {
1816
nt, err := time.ParseDuration(ntDur)
1917
if err == nil && nt > time.Duration(0) && nt < time.Hour*2 {
2018
maxIdleTimeout = nt
21-
// enableMaxIdleTimeout = true
2219
}
2320
}
2421

@@ -27,14 +24,6 @@ func BuildQuicConfig(le *logrus.Entry, opts *Opts) *quic.Config {
2724
maxIncStreams = int(mis)
2825
}
2926

30-
// copy the logger
31-
le = &logrus.Entry{Logger: le.Logger, Context: le.Context}
32-
if opts.GetVerbose() {
33-
le.Level = logrus.DebugLevel
34-
} else {
35-
le.Level = logrus.InfoLevel
36-
}
37-
3827
keepAlivePeriod := maxIdleTimeout / 2
3928
if opts.GetDisableKeepAlive() {
4029
keepAlivePeriod = 0
@@ -45,24 +34,17 @@ func BuildQuicConfig(le *logrus.Entry, opts *Opts) *quic.Config {
4534
}
4635
}
4736

48-
// _ = enableMaxIdleTimeout
4937
return &quic.Config{
50-
Logger: le,
51-
5238
// We don't use datagrams (yet), but this is necessary for WebTransport
5339
EnableDatagrams: !opts.GetDisableDatagrams(),
5440
KeepAlivePeriod: keepAlivePeriod,
5541
DisablePathMTUDiscovery: opts.GetDisablePathMtuDiscovery(),
5642

57-
MaxIdleTimeout: maxIdleTimeout,
58-
// DisableIdleTimeout: !enableMaxIdleTimeout,
43+
MaxIdleTimeout: maxIdleTimeout,
5944
MaxIncomingStreams: int64(maxIncStreams),
6045
MaxIncomingUniStreams: -1, // disable unidirectional streams
6146

62-
// MaxStreamReceiveWindow: 10 * (1 << 20), // 10 MB
63-
// MaxConnectionReceiveWindow: 15 * (1 << 20), // 15 MB
64-
65-
Versions: []quic.Version{quic.Version2}, // {quic.Version1},
47+
Versions: []quic.Version{quic.Version2},
6648
}
6749
}
6850

transport/common/quic/link.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ type Link struct {
2727
// localAddr is the local address
2828
localAddr net.Addr
2929
// sess is the quic session
30-
sess quic.Connection
30+
sess *quic.Conn
3131
// remotePeerID is the remote peer id
3232
remotePeerID peer.ID
3333
// remotePubKey is the remote public key
@@ -54,7 +54,7 @@ func NewLink(
5454
localTransportUUID uint64,
5555
localPeerID peer.ID,
5656
localAddr net.Addr,
57-
sess quic.Connection,
57+
sess *quic.Conn,
5858
closed func(),
5959
) (*Link, error) {
6060
remotePeerID, remotePubKey, err := DetermineSessionIdentity(sess)
@@ -167,13 +167,12 @@ func (l *Link) AcceptStream() (stream.Stream, stream.OpenOpts, error) {
167167
// Close closes the connection.
168168
func (l *Link) Close() error {
169169
l.closedOnce.Do(func() {
170-
// _ = l.sess.CloseWithError(quic.ApplicationErrorCode(0), "goodbye")
171170
l.ctxCancel()
172171
if closed := l.closed; closed != nil {
173172
closed()
174173
}
175174
if l.sess != nil {
176-
l.sess.CloseNoError()
175+
_ = l.sess.CloseWithError(0, "")
177176
}
178177
})
179178
return nil

transport/common/quic/quic.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ type Transport struct {
5353

5454
// DialFunc is a function to dial a peer with a string address.
5555
// The function should parse the addr to a net.Addr.
56-
type DialFunc func(ctx context.Context, addr string) (quic.Connection, net.Addr, error)
56+
type DialFunc func(ctx context.Context, addr string) (*quic.Conn, net.Addr, error)
5757

5858
// NewTransport constructs a new quic-backed based transport.
5959
func NewTransport(
@@ -201,7 +201,7 @@ func (t *Transport) HandleConn(ctx context.Context, dial bool, pc net.PacketConn
201201
raddr = peer.NewNetAddr(peerID)
202202
}
203203

204-
var sess quic.Connection
204+
var sess *quic.Conn
205205
var err error
206206

207207
t.le.Debugf("negotiating quic session with: %s", raddr.String())
@@ -240,7 +240,7 @@ func (t *Transport) HandleConn(ctx context.Context, dial bool, pc net.PacketConn
240240
}
241241

242242
// HandleSession handles a new Quic session, creating & registering a link.
243-
func (t *Transport) HandleSession(ctx context.Context, sess quic.Connection) (*Link, error) {
243+
func (t *Transport) HandleSession(ctx context.Context, sess *quic.Conn) (*Link, error) {
244244
t.mtx.Lock()
245245
sessID := t.sessionCounter
246246
t.sessionCounter++

0 commit comments

Comments
 (0)