Skip to content
This repository has been archived by the owner on May 26, 2022. It is now read-only.

Commit

Permalink
add an error check that we actually received the peer's public key
Browse files Browse the repository at this point in the history
  • Loading branch information
marten-seemann committed Aug 1, 2019
1 parent c01848a commit 971415b
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion transport.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package libp2pquic

import (
"context"
"errors"
"fmt"
"net"
"sync"
Expand All @@ -22,7 +23,7 @@ var quicConfig = &quic.Config{
MaxIncomingUniStreams: -1, // disable unidirectional streams
MaxReceiveStreamFlowControlWindow: 3 * (1 << 20), // 3 MB
MaxReceiveConnectionFlowControlWindow: 4.5 * (1 << 20), // 4.5 MB
AcceptCookie: func(clientAddr net.Addr, cookie *quic.Cookie) bool {
AcceptToken: func(_ net.Addr, _ *quic.Token) bool {
// TODO(#6): require source address validation when under load
return true
},
Expand Down Expand Up @@ -127,6 +128,9 @@ func (t *transport) Dial(ctx context.Context, raddr ma.Multiaddr, p peer.ID) (tp
case remotePubKey = <-keyCh:
default:
}
if remotePubKey == nil {
return nil, errors.New("go-libp2p-quic-transport BUG: expected remote pub key to be set")
}

return &conn{
sess: sess,
Expand Down

0 comments on commit 971415b

Please sign in to comment.