Skip to content

Commit

Permalink
feat: reenable webtransport support removed in libp2p/pull/1927
Browse files Browse the repository at this point in the history
  • Loading branch information
zvolin committed Nov 10, 2023
1 parent 1b0df37 commit 25cb621
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions p2p/transport/webtransport/transport.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,16 @@ func WithClock(cl clock.Clock) Option {
}
}

// WithTLSConfig sets a tls.Config used for listening.
// When used, the certificate from that config will be used, and no /certhash will be added to the listener's multiaddr.
// This is most useful when running a listener that has a valid (CA-signed) certificate.
func WithTLSConfig(c *tls.Config) Option {
return func(t *transport) error {
t.staticTLSConf = c
return nil
}
}

// WithTLSClientConfig sets a custom tls.Config used for dialing.
// This option is most useful for setting a custom tls.Config.RootCAs certificate pool.
// When dialing a multiaddr that contains a /certhash component, this library will set InsecureSkipVerify and
Expand Down Expand Up @@ -147,9 +157,9 @@ func (t *transport) dialWithScope(ctx context.Context, raddr ma.Multiaddr, p pee
return nil, err
}

if len(certHashes) == 0 {
return nil, errors.New("can't dial webtransport without certhashes")
}
// if len(certHashes) == 0 {
// return nil, errors.New("can't dial webtransport without certhashes")
// }

sni, _ := extractSNI(raddr)

Expand Down Expand Up @@ -305,8 +315,8 @@ func (t *transport) Listen(laddr ma.Multiaddr) (tpt.Listener, error) {
if t.listenOnceErr != nil {
return nil, t.listenOnceErr
}
} else {
return nil, errors.New("static TLS config not supported on WebTransport")
// } else {
// return nil, errors.New("static TLS config not supported on WebTransport")
}
tlsConf := t.staticTLSConf.Clone()
if tlsConf == nil {
Expand Down

0 comments on commit 25cb621

Please sign in to comment.