Skip to content

Commit

Permalink
libp2p: use rcmgr for autonat dials (#2842)
Browse files Browse the repository at this point in the history
  • Loading branch information
sukunrt committed Jun 26, 2024
1 parent d8bb57c commit 6c178d4
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
1 change: 1 addition & 0 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -579,6 +579,7 @@ func (cfg *Config) addAutoNAT(h *bhost.BasicHost) error {
PeerKey: autonatPrivKey,
Peerstore: ps,
DialRanker: swarm.NoDelayDialRanker,
ResourceManager: cfg.ResourceManager,
SwarmOpts: []swarm.Option{
swarm.WithUDPBlackHoleSuccessCounter(nil),
swarm.WithIPv6BlackHoleSuccessCounter(nil),
Expand Down
21 changes: 21 additions & 0 deletions p2p/transport/webrtc/transport_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,27 @@ func getTransport(t *testing.T, opts ...Option) (*WebRTCTransport, peer.ID) {
return transport, peerID
}

func TestNullRcmgrTransport(t *testing.T) {
privKey, _, err := crypto.GenerateKeyPair(crypto.Ed25519, -1)
require.NoError(t, err)
transport, err := New(privKey, nil, nil, nil)
require.NoError(t, err)

listenTransport, pid := getTransport(t)
ln, err := listenTransport.Listen(ma.StringCast("/ip4/127.0.0.1/udp/0/webrtc-direct"))
require.NoError(t, err)
go func() {
c, err := ln.Accept()
if !assert.NoError(t, err) {
t.Error(err)
}
t.Cleanup(func() { c.Close() })
}()
c, err := transport.Dial(context.Background(), ln.Multiaddr(), pid)
require.NoError(t, err)
c.Close()
}

func TestIsWebRTCDirectMultiaddr(t *testing.T) {
invalid := []string{
"/ip4/1.2.3.4/tcp/10/",
Expand Down

0 comments on commit 6c178d4

Please sign in to comment.