-
Notifications
You must be signed in to change notification settings - Fork 470
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: maximum call stack size with duplicate webrtc addresses (#2980)
Ignore other instances of WebRTCPeerListener when getting listen addresses. Fixes #2539 --------- Co-authored-by: achingbrain <[email protected]>
- Loading branch information
1 parent
7718d02
commit d98cc46
Showing
2 changed files
with
57 additions
and
1 deletion.
There are no files selected for viewing
56 changes: 56 additions & 0 deletions
56
packages/integration-tests/test/webrtc-private-to-private.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/* eslint-env mocha */ | ||
/* eslint max-nested-callbacks: ['error', 6] */ | ||
|
||
import { yamux } from '@chainsafe/libp2p-yamux' | ||
import { circuitRelayTransport } from '@libp2p/circuit-relay-v2' | ||
import { identify } from '@libp2p/identify' | ||
import { plaintext } from '@libp2p/plaintext' | ||
import { webRTC } from '@libp2p/webrtc' | ||
import { webSockets } from '@libp2p/websockets' | ||
import { WebRTC } from '@multiformats/multiaddr-matcher' | ||
import { expect } from 'aegir/chai' | ||
import { createLibp2p } from 'libp2p' | ||
import type { Libp2p } from '@libp2p/interface' | ||
|
||
describe('webrtc private-to-private', () => { | ||
let local: Libp2p | ||
|
||
afterEach(async () => { | ||
await local?.stop() | ||
}) | ||
|
||
it('should listen on two webrtc addresses', async () => { | ||
local = await createLibp2p({ | ||
addresses: { | ||
listen: [ | ||
`${process.env.RELAY_MULTIADDR}/p2p-circuit`, | ||
// this is a misconfiguration, it's only necessary to specify this | ||
// once as the WebRTC transport is really just a protocol handler so | ||
// in effect it will always bind to all addresses | ||
'/webrtc', | ||
'/webrtc' | ||
] | ||
}, | ||
transports: [ | ||
circuitRelayTransport(), | ||
webSockets(), | ||
webRTC() | ||
], | ||
streamMuxers: [ | ||
yamux() | ||
], | ||
connectionEncrypters: [ | ||
plaintext() | ||
], | ||
connectionGater: { | ||
denyDialMultiaddr: () => false | ||
}, | ||
services: { | ||
identify: identify() | ||
} | ||
}) | ||
|
||
// two because the relay listens on two TCP addresses so it binds to both | ||
expect(local.getMultiaddrs().filter(WebRTC.exactMatch)).to.have.lengthOf(2) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters