Skip to content

Commit

Permalink
fix: use quic.Version instead of the deprecated quic.VersionNumber (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
wlynxg authored and sukunrt committed Sep 24, 2024
1 parent 11f1ffc commit 2d8f05f
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 14 deletions.
4 changes: 2 additions & 2 deletions p2p/transport/quic/listener.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ type listener struct {
rcmgr network.ResourceManager
privKey ic.PrivKey
localPeer peer.ID
localMultiaddrs map[quic.VersionNumber]ma.Multiaddr
localMultiaddrs map[quic.Version]ma.Multiaddr
}

func newListener(ln quicreuse.Listener, t *transport, localPeer peer.ID, key ic.PrivKey, rcmgr network.ResourceManager) (listener, error) {
localMultiaddrs := make(map[quic.VersionNumber]ma.Multiaddr)
localMultiaddrs := make(map[quic.Version]ma.Multiaddr)
for _, addr := range ln.Multiaddrs() {
if _, err := addr.ValueForProtocol(ma.P_QUIC_V1); err == nil {
localMultiaddrs[quic.Version1] = addr
Expand Down
2 changes: 1 addition & 1 deletion p2p/transport/quic/transport.go
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ func (t *transport) Listen(addr ma.Multiaddr) (tpt.Listener, error) {

acceptRunner = &acceptLoopRunner{
acceptSem: make(chan struct{}, 1),
muxer: make(map[quic.VersionNumber]chan acceptVal),
muxer: make(map[quic.Version]chan acceptVal),
}
}

Expand Down
12 changes: 6 additions & 6 deletions p2p/transport/quic/virtuallistener.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const acceptBufferPerVersion = 4
type virtualListener struct {
*listener
udpAddr string
version quic.VersionNumber
version quic.Version
t *transport
acceptRunnner *acceptLoopRunner
acceptChan chan acceptVal
Expand Down Expand Up @@ -46,11 +46,11 @@ type acceptLoopRunner struct {
acceptSem chan struct{}

muxerMu sync.Mutex
muxer map[quic.VersionNumber]chan acceptVal
muxer map[quic.Version]chan acceptVal
muxerClosed bool
}

func (r *acceptLoopRunner) AcceptForVersion(v quic.VersionNumber) chan acceptVal {
func (r *acceptLoopRunner) AcceptForVersion(v quic.Version) chan acceptVal {
r.muxerMu.Lock()
defer r.muxerMu.Unlock()

Expand All @@ -64,7 +64,7 @@ func (r *acceptLoopRunner) AcceptForVersion(v quic.VersionNumber) chan acceptVal
return ch
}

func (r *acceptLoopRunner) RmAcceptForVersion(v quic.VersionNumber, err error) {
func (r *acceptLoopRunner) RmAcceptForVersion(v quic.Version, err error) {
r.muxerMu.Lock()
defer r.muxerMu.Unlock()

Expand Down Expand Up @@ -98,7 +98,7 @@ func (r *acceptLoopRunner) sendErrAndClose(err error) {
// innerAccept is the inner logic of the Accept loop. Assume caller holds the
// acceptSemaphore. May return both a nil conn and nil error if it didn't find a
// conn with the expected version
func (r *acceptLoopRunner) innerAccept(l *listener, expectedVersion quic.VersionNumber, bufferedConnChan chan acceptVal) (tpt.CapableConn, error) {
func (r *acceptLoopRunner) innerAccept(l *listener, expectedVersion quic.Version, bufferedConnChan chan acceptVal) (tpt.CapableConn, error) {
select {
// Check if we have a buffered connection first from an earlier Accept call
case v, ok := <-bufferedConnChan:
Expand Down Expand Up @@ -150,7 +150,7 @@ func (r *acceptLoopRunner) innerAccept(l *listener, expectedVersion quic.Version
return nil, nil
}

func (r *acceptLoopRunner) Accept(l *listener, expectedVersion quic.VersionNumber, bufferedConnChan chan acceptVal) (tpt.CapableConn, error) {
func (r *acceptLoopRunner) Accept(l *listener, expectedVersion quic.Version, bufferedConnChan chan acceptVal) (tpt.CapableConn, error) {
for {
var conn tpt.CapableConn
var err error
Expand Down
2 changes: 1 addition & 1 deletion p2p/transport/quicreuse/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ var quicConfig = &quic.Config{
MaxStreamReceiveWindow: 10 * (1 << 20), // 10 MB
MaxConnectionReceiveWindow: 15 * (1 << 20), // 15 MB
KeepAlivePeriod: 15 * time.Second,
Versions: []quic.VersionNumber{quic.Version1},
Versions: []quic.Version{quic.Version1},
// We don't use datagrams (yet), but this is necessary for WebTransport
EnableDatagrams: true,
}
2 changes: 1 addition & 1 deletion p2p/transport/quicreuse/connmgr.go
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ func (c *ConnManager) DialQUIC(ctx context.Context, raddr ma.Multiaddr, tlsConf

if v == quic.Version1 {
// The endpoint has explicit support for QUIC v1, so we'll only use that version.
quicConf.Versions = []quic.VersionNumber{quic.Version1}
quicConf.Versions = []quic.Version{quic.Version1}
} else {
return nil, errors.New("unknown QUIC version")
}
Expand Down
6 changes: 3 additions & 3 deletions p2p/transport/quicreuse/quic_multiaddr.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ var (
quicV1MA = ma.StringCast("/quic-v1")
)

func ToQuicMultiaddr(na net.Addr, version quic.VersionNumber) (ma.Multiaddr, error) {
func ToQuicMultiaddr(na net.Addr, version quic.Version) (ma.Multiaddr, error) {
udpMA, err := manet.FromNetAddr(na)
if err != nil {
return nil, err
Expand All @@ -26,8 +26,8 @@ func ToQuicMultiaddr(na net.Addr, version quic.VersionNumber) (ma.Multiaddr, err
}
}

func FromQuicMultiaddr(addr ma.Multiaddr) (*net.UDPAddr, quic.VersionNumber, error) {
var version quic.VersionNumber
func FromQuicMultiaddr(addr ma.Multiaddr) (*net.UDPAddr, quic.Version, error) {
var version quic.Version
var partsBeforeQUIC []ma.Multiaddr
ma.ForEach(addr, func(c ma.Component) bool {
switch c.Protocol().Code {
Expand Down

0 comments on commit 2d8f05f

Please sign in to comment.