From f503663108704bbcfaa472201d62d89db2f4860d Mon Sep 17 00:00:00 2001 From: achingbrain Date: Thu, 16 May 2024 14:46:56 +0100 Subject: [PATCH] chore: ip6 --- packages/transport-webtransport/.aegir.js | 9 ++--- .../transport-webtransport/test/browser.ts | 39 ++++++------------- 2 files changed, 15 insertions(+), 33 deletions(-) diff --git a/packages/transport-webtransport/.aegir.js b/packages/transport-webtransport/.aegir.js index b23293b40f..fbd741d19f 100644 --- a/packages/transport-webtransport/.aegir.js +++ b/packages/transport-webtransport/.aegir.js @@ -13,9 +13,7 @@ export default { return { goLibp2p, env: { - GO_LIBP2P_ADDR_IP4: goLibp2p.ip4, - GO_LIBP2P_ADDR_IP6: goLibp2p.ip6, - DISABLE_IPV6: process.env.DISABLE_IPV6 + GO_LIBP2P_ADDR: goLibp2p.multiaddr } } }, @@ -34,7 +32,7 @@ async function createGoLibp2p () { const deferred = pDefer() const proc = execa(p2pd(), [ `-listen=${apiAddr.toString()}`, - '-hostAddrs=/ip4/127.0.0.1/udp/0/quic-v1/webtransport,/ip6/::1/udp/0/quic-v1/webtransport', + '-hostAddrs=/ip4/127.0.0.1/udp/0/quic-v1/webtransport', '-noise=true', '-dhtServer', '-relay', @@ -62,8 +60,7 @@ async function createGoLibp2p () { return { apiAddr, peerId: id.peerId.toString(), - ip4: id.addrs.map(ma => ma.encapsulate(`/p2p/${id.peerId}`).toString()).filter(ma => ma.startsWith('/ip4')).pop(), - ip6: id.addrs.map(ma => ma.encapsulate(`/p2p/${id.peerId}`).toString()).filter(ma => ma.startsWith('/ip6')).pop(), + multiaddr: id.addrs.map(ma => ma.encapsulate(`/p2p/${id.peerId}`).toString()).pop(), proc } } diff --git a/packages/transport-webtransport/test/browser.ts b/packages/transport-webtransport/test/browser.ts index ba34c0ee85..7da82aee05 100644 --- a/packages/transport-webtransport/test/browser.ts +++ b/packages/transport-webtransport/test/browser.ts @@ -40,11 +40,11 @@ describe('libp2p-webtransport', () => { }) it('webtransport connects to go-libp2p', async () => { - if (process.env.GO_LIBP2P_ADDR_IP4 == null) { - throw new Error('GO_LIBP2P_ADDR_IP4 not found') + if (process.env.GO_LIBP2P_ADDR == null) { + throw new Error('GO_LIBP2P_ADDR not found') } - const maStr: string = process.env.GO_LIBP2P_ADDR_IP4 + const maStr: string = process.env.GO_LIBP2P_ADDR const ma = multiaddr(maStr) // Ping many times @@ -56,11 +56,11 @@ describe('libp2p-webtransport', () => { }) it('fails to connect without certhashes', async () => { - if (process.env.GO_LIBP2P_ADDR_IP4 == null) { - throw new Error('GO_LIBP2P_ADDR_IP4 not found') + if (process.env.GO_LIBP2P_ADDR == null) { + throw new Error('GO_LIBP2P_ADDR not found') } - const maStr: string = process.env.GO_LIBP2P_ADDR_IP4 + const maStr: string = process.env.GO_LIBP2P_ADDR const maStrNoCerthash: string = maStr.split('/certhash')[0] const maStrP2p = maStr.split('/p2p/')[1] const ma = multiaddr(maStrNoCerthash + '/p2p/' + maStrP2p) @@ -70,11 +70,11 @@ describe('libp2p-webtransport', () => { }) it('fails to connect due to an aborted signal', async () => { - if (process.env.GO_LIBP2P_ADDR_IP4 == null) { - throw new Error('GO_LIBP2P_ADDR_IP4 not found') + if (process.env.GO_LIBP2P_ADDR == null) { + throw new Error('GO_LIBP2P_ADDR not found') } - const maStr: string = process.env.GO_LIBP2P_ADDR_IP4 + const maStr: string = process.env.GO_LIBP2P_ADDR const ma = multiaddr(maStr) const controller = new AbortController() @@ -86,28 +86,13 @@ describe('libp2p-webtransport', () => { expect(err.toString()).to.contain('aborted') }) - it('connects to ipv6 addresses', async function () { - if (process.env.DISABLE_IPV6 === 'true') { - return this.skip() - } - if (process.env.GO_LIBP2P_ADDR_IP6 == null) { - throw new Error('GO_LIBP2P_ADDR_IP6 not found') - } - - const ma = multiaddr(process.env.GO_LIBP2P_ADDR_IP6) - - // the address is unreachable but we can parse it correctly - const stream = await node.dialProtocol(ma, '/ipfs/ping/1.0.0') - await stream.close() - }) - it('closes writes of streams after they have sunk a source', async () => { // This is the behavior of stream muxers: (see mplex, yamux and compliance tests: https://github.com/libp2p/js-libp2p/blob/main/packages/interface-compliance-tests/src/stream-muxer/close-test.ts) - if (process.env.GO_LIBP2P_ADDR_IP4 == null) { - throw new Error('GO_LIBP2P_ADDR_IP4 not found') + if (process.env.GO_LIBP2P_ADDR == null) { + throw new Error('GO_LIBP2P_ADDR not found') } - const maStr: string = process.env.GO_LIBP2P_ADDR_IP4 + const maStr: string = process.env.GO_LIBP2P_ADDR const ma = multiaddr(maStr) const data = [