diff --git a/p2p/transport/webtransport/conn.go b/p2p/transport/webtransport/conn.go index e2ab9cd50..90ae154b8 100644 --- a/p2p/transport/webtransport/conn.go +++ b/p2p/transport/webtransport/conn.go @@ -15,7 +15,7 @@ import ( type conn struct { transport tpt.Transport - wconn *webtransport.Conn + wsess *webtransport.Session localPeer, remotePeer peer.ID local, remote ma.Multiaddr @@ -23,7 +23,7 @@ type conn struct { remotePubKey ic.PubKey } -func newConn(tr tpt.Transport, wconn *webtransport.Conn, privKey ic.PrivKey, remotePubKey ic.PubKey) (*conn, error) { +func newConn(tr tpt.Transport, wsess *webtransport.Session, privKey ic.PrivKey, remotePubKey ic.PubKey) (*conn, error) { localPeer, err := peer.IDFromPrivateKey(privKey) if err != nil { return nil, err @@ -32,17 +32,17 @@ func newConn(tr tpt.Transport, wconn *webtransport.Conn, privKey ic.PrivKey, rem if err != nil { return nil, err } - local, err := toWebtransportMultiaddr(wconn.LocalAddr()) + local, err := toWebtransportMultiaddr(wsess.LocalAddr()) if err != nil { return nil, fmt.Errorf("error determiniting local addr: %w", err) } - remote, err := toWebtransportMultiaddr(wconn.RemoteAddr()) + remote, err := toWebtransportMultiaddr(wsess.RemoteAddr()) if err != nil { return nil, fmt.Errorf("error determiniting remote addr: %w", err) } return &conn{ transport: tr, - wconn: wconn, + wsess: wsess, privKey: privKey, localPeer: localPeer, remotePeer: remotePeer, @@ -55,7 +55,7 @@ func newConn(tr tpt.Transport, wconn *webtransport.Conn, privKey ic.PrivKey, rem var _ tpt.CapableConn = &conn{} func (c *conn) Close() error { - return c.wconn.Close() + return c.wsess.Close() } func (c *conn) IsClosed() bool { @@ -63,12 +63,12 @@ func (c *conn) IsClosed() bool { } func (c *conn) OpenStream(ctx context.Context) (network.MuxedStream, error) { - str, err := c.wconn.OpenStreamSync(ctx) + str, err := c.wsess.OpenStreamSync(ctx) return &stream{str}, err } func (c *conn) AcceptStream() (network.MuxedStream, error) { - str, err := c.wconn.AcceptStream(context.Background()) + str, err := c.wsess.AcceptStream(context.Background()) return &stream{str}, err } diff --git a/p2p/transport/webtransport/listener.go b/p2p/transport/webtransport/listener.go index 993354f96..6789a7454 100644 --- a/p2p/transport/webtransport/listener.go +++ b/p2p/transport/webtransport/listener.go @@ -122,16 +122,16 @@ func (l *listener) Accept() (tpt.CapableConn, error) { } } -func (l *listener) handshake(ctx context.Context, c *webtransport.Conn) (tpt.CapableConn, error) { - str, err := c.AcceptStream(ctx) +func (l *listener) handshake(ctx context.Context, sess *webtransport.Session) (tpt.CapableConn, error) { + str, err := sess.AcceptStream(ctx) if err != nil { return nil, err } - conn, err := l.noise.SecureInbound(ctx, &webtransportStream{Stream: str, wconn: c}, "") + conn, err := l.noise.SecureInbound(ctx, &webtransportStream{Stream: str, wsess: sess}, "") if err != nil { return nil, err } - return newConn(l.transport, c, conn.LocalPrivateKey(), conn.RemotePublicKey()) + return newConn(l.transport, sess, conn.LocalPrivateKey(), conn.RemotePublicKey()) } func (l *listener) Addr() net.Addr { diff --git a/p2p/transport/webtransport/stream.go b/p2p/transport/webtransport/stream.go index fa34242b6..6aa58cb8d 100644 --- a/p2p/transport/webtransport/stream.go +++ b/p2p/transport/webtransport/stream.go @@ -15,17 +15,17 @@ const ( type webtransportStream struct { webtransport.Stream - wconn *webtransport.Conn + wsess *webtransport.Session } var _ net.Conn = &webtransportStream{} func (s *webtransportStream) LocalAddr() net.Addr { - return s.wconn.LocalAddr() + return s.wsess.LocalAddr() } func (s *webtransportStream) RemoteAddr() net.Addr { - return s.wconn.RemoteAddr() + return s.wsess.RemoteAddr() } type stream struct { diff --git a/p2p/transport/webtransport/transport.go b/p2p/transport/webtransport/transport.go index 2596ba4dc..29eb78478 100644 --- a/p2p/transport/webtransport/transport.go +++ b/p2p/transport/webtransport/transport.go @@ -16,13 +16,13 @@ import ( noise "github.com/libp2p/go-libp2p-noise" + logging "github.com/ipfs/go-log/v2" + "github.com/lucas-clemente/quic-go/http3" + "github.com/marten-seemann/webtransport-go" ma "github.com/multiformats/go-multiaddr" manet "github.com/multiformats/go-multiaddr/net" "github.com/multiformats/go-multibase" "github.com/multiformats/go-multihash" - - logging "github.com/ipfs/go-log/v2" - "github.com/marten-seemann/webtransport-go" ) var log = logging.Logger("webtransport") @@ -56,7 +56,9 @@ func New(key ic.PrivKey) (tpt.Transport, error) { pid: id, privKey: key, dialer: webtransport.Dialer{ - TLSClientConf: &tls.Config{InsecureSkipVerify: true}, // TODO: verify certificate, + RoundTripper: &http3.RoundTripper{ + TLSClientConfig: &tls.Config{InsecureSkipVerify: true}, // TODO: verify certificate, + }, }, } noise, err := noise.New(key, noise.WithEarlyDataHandler(t.checkEarlyData)) @@ -117,7 +119,7 @@ func (t *transport) Dial(ctx context.Context, raddr ma.Multiaddr, p peer.ID) (tp if err != nil { return nil, fmt.Errorf("failed to marshal WebTransport protobuf: %w", err) } - sconn, err := t.noise.SecureOutboundWithEarlyData(ctx, &webtransportStream{Stream: str, wconn: wconn}, p, msgBytes) + sconn, err := t.noise.SecureOutboundWithEarlyData(ctx, &webtransportStream{Stream: str, wsess: wconn}, p, msgBytes) if err != nil { return nil, err }