Skip to content

quicreuse: make it possible to use an application-constructed quic.Transport - #3122

Merged
MarcoPolo merged 10 commits into
libp2p:masterfrom
marten-seemann:raw-quic-conn
Jan 10, 2025
Merged

MarcoPolo merged 10 commits into
libp2p:masterfrom
marten-seemann:raw-quic-conn

Conversation

@marten-seemann

Copy link
Copy Markdown
Contributor

It would be nice if the application was able to construct its own quic.Transport, and have that transport used by libp2p.

This would allow an application:

  • on the listener side: inject its own tls.Config on the Listen call, and Accept (a subset of) QUIC connections returned by the listener
  • on the client side: dial QUIC connections without going through libp2p at all

This would make it possible to run a vanilla HTTP/3 server behind a NAT / firewall and use libp2p's NAT hole punching mechanism to create the NAT bindings.

We shouldn't create the listener entry. This happens once the libp2p
QUIC transport starts listening.
Comment thread p2p/transport/quicreuse/connmgr.go Outdated
refCountedTr := &refcountedTransport{
QUICTransport: tr,
packetConn: conn,
isExternal: true,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does the actual owner of this transport want to know when libp2p will be done with it? My guess is yes.

Any preference for how this looks? We could accept a callback or we could return a done channel. Either way, we'd signal done when we otherwise would have closed this transport (in the case of a non "external" transport). This allows the actual owner to know when it is safe to free the transport.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure there's a lot of value in that. The only reason why libp2p would be done with this transport is when the host is closed, which is something that the owner of the transport initiated himself (by calling Host.Close). Or am I missing something?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's fair, but I think it would be a bit simpler if this package doesn't have to consider a Host for managing the lifecycle of this resource. Users could still simply ignore this signal and free after they've closed the host.

Without this, you may be closing the transport before the connmgr is actually done with it.

@MarcoPolo MarcoPolo Jan 10, 2025 •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done in d8cc67d. Has the nice side-effect of removing the conditional branches around isExternal.

@MarcoPolo MarcoPolo left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excited to see this used. Please report back

@MarcoPolo
MarcoPolo merged commit 4651a0d into libp2p:master Jan 10, 2025
@lidel lidel mentioned this pull request Jan 13, 2025
51 of 60 tasks
2color added a commit that referenced this pull request Jan 24, 2025
โ€ฆbug-nat-port-mapping

* origin/marco/bring-go-nat-home: (75 commits)
  go mod tidy
  reference internal package for mockgen
  mod tidy test-plans
  Make changes to internal nat library
  ci: move to actions/upload-artifact@v4 (#3152)
  tcpreuse: fix rcmgr accounting when tcp metrics are enabled (#3142)
  fix(net/nat): data race problem of `extAddr` (#3140)
  test: fix failing test (#3141)
  quicreuse: make it possible to use an application-constructed quic.Transport (#3122)
  nat: ignore mapping if external port is 0 (#3094)
  tcpreuse: error on using tcpreuse with pnet (#3129)
  chore: Update contribution guidelines (#3134)
  tcp: fix metrics test build directive (#3052)
  webrtc: upgrade pion/webrtc to v4 (#3098)
  ci: get back on the main release track of release checker (#3117)
  webtransport: fix docstring comment for getCurrentBucketStartTime
  chore: release v0.38.1 (#3114)
  fix(httpauth): Correctly handle concurrent requests on server (#3111)
  ci: Install specific protoc version when generating protobufs (#3112)
  fix(autorelay): Move relayFinder peer disconnect cleanup to separate goroutine (#3105)
  ...
@MarcoPolo MarcoPolo mentioned this pull request Jan 29, 2025
10 of 20 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants