go-libp2p-dntls

module
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 2, 2026 License: Apache-2.0, MIT

README

go-libp2p-dntls

DNTLS security seams and the QUIC, WebTransport, and WebRTC transports that consume them. The module imports upstream github.com/libp2p/go-libp2p v0.49.0 unmodified. All core/* types stay upstream, so stock ecosystem modules such as pubsub remain usable.

The code is derived from go-libp2p v0.49.0. Lineage of the DNTLS surgery is the Sakura-Industries-LLC/go-libp2p tag v0.49.0-dntls.2.

Layout

  • security/dntls — DNTLS-Noise seam used by WebTransport and WebRTC.
  • security/dntlscfg — TLS provider used by QUIC.
  • transport/quic — QUIC transport with DNTLS provider injection.
  • transport/webtransport — WebTransport with a DNTLS-Noise seam.
  • transport/webrtc — WebRTC with a DNTLS-Noise seam.

Unchanged subpackages are imported from upstream, not copied: github.com/libp2p/go-libp2p/p2p/transport/webrtc/pb, github.com/libp2p/go-libp2p/p2p/transport/webrtc/udpmux. The upstream QUIC example under p2p/transport/quic/cmd is not part of this module.

Install

go get github.com/Sakura-Industries-LLC/go-libp2p-dntls@v0.1.0

Usage

TCP and WebSocket transports need nothing from this module. Use the constructors below only for QUIC, WebTransport, and WebRTC.

import (
	"github.com/libp2p/go-libp2p"
	"github.com/Sakura-Industries-LLC/go-libp2p-dntls/security/dntls"
	"github.com/Sakura-Industries-LLC/go-libp2p-dntls/security/dntlscfg"
	"github.com/Sakura-Industries-LLC/go-libp2p-dntls/transport/quic"
	"github.com/Sakura-Industries-LLC/go-libp2p-dntls/transport/webrtc"
	"github.com/Sakura-Industries-LLC/go-libp2p-dntls/transport/webtransport"
)

// QUIC: inject a dntlscfg.Provider. NewStockTLSProvider reproduces upstream TLS
// identity checks; production hosts inject the SDK provider.
provider, err := dntlscfg.NewStockTLSProvider(priv)
if err != nil {
	return err
}
h, err := libp2p.New(
	libp2p.Transport(quic.NewTransport, quic.WithDNTLSProvider(provider)),
)

// WebTransport / WebRTC: inject a dntls.Transport.
h, err = libp2p.New(
	libp2p.Transport(webtransport.New, webtransport.WithDNTLSNoise(sec)),
	libp2p.Transport(webrtc.New, webrtc.WithDNTLSNoise(sec)),
)

sec is a dntls.Transport. Tests in this repository use security/dntls/noisewrap, which wraps stock Noise with no DNTLS verification.

Tracking upstream

When go-libp2p cuts a new tag:

  1. Re-copy only the files that carry DNTLS surgery: p2p/security/dntls, p2p/security/dntlscfg, p2p/transport/quic (not cmd/), p2p/transport/webtransport, and p2p/transport/webrtc (not pb/ or udpmux/) from that tag.
  2. Re-apply the DNTLS surgery (provider/Noise seams and the DntlsClaims field names hash / fqdn / selectors).
  3. Rewrite copied-package imports to this module path. Leave every other github.com/libp2p/go-libp2p/... import on the new upstream version, including p2p/transport/webrtc/pb and p2p/transport/webrtc/udpmux.
  4. Bump require github.com/libp2p/go-libp2p in go.mod, run go mod tidy, then go test -race ./....

License

Derived from go-libp2p, which is available under MIT or Apache-2.0. See LICENSE-MIT and LICENSE-APACHE.

Directories

Path Synopsis
security
dntls
Package dntls defines the contract between go-libp2p's transports and an externally provided DNTLS-Noise security transport.
Package dntls defines the contract between go-libp2p's transports and an externally provided DNTLS-Noise security transport.
dntls/noisewrap
Package noisewrap adapts the stock Noise security transport to the dntls.Transport seam.
Package noisewrap adapts the stock Noise security transport to the dntls.Transport seam.
dntls/pb
Package pb contains the protobuf types carried in DNTLS-Noise payloads.
Package pb contains the protobuf types carried in DNTLS-Noise payloads.
dntlscfg
Package dntlscfg defines the TLS configuration seam used by DNTLS-aware QUIC transports.
Package dntlscfg defines the TLS configuration seam used by DNTLS-aware QUIC transports.
transport
quic
Package libp2pquic implements the libp2p QUIC transport with an optional DNTLS TLS provider.
Package libp2pquic implements the libp2p QUIC transport with an optional DNTLS TLS provider.
webrtc
Package libp2pwebrtc implements the WebRTC transport for go-libp2p, as described in https://github.com/libp2p/specs/tree/master/webrtc.
Package libp2pwebrtc implements the WebRTC transport for go-libp2p, as described in https://github.com/libp2p/specs/tree/master/webrtc.
webtransport
Package libp2pwebtransport implements the libp2p WebTransport transport with a DNTLS-Noise seam.
Package libp2pwebtransport implements the libp2p WebTransport transport with a DNTLS-Noise seam.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL