mirror of
https://github.com/status-im/libp2p-test-plans.git
synced 2025-02-26 05:25:16 +00:00
35 lines
919 B
TypeScript
35 lines
919 B
TypeScript
|
import { noise } from '@chainsafe/libp2p-noise'
|
||
|
import { yamux } from '@chainsafe/libp2p-yamux'
|
||
|
import { webSockets } from '@libp2p/websockets'
|
||
|
import * as filters from '@libp2p/websockets/filters'
|
||
|
import { createLibp2p } from 'libp2p'
|
||
|
import { circuitRelayServer } from '@libp2p/circuit-relay-v2'
|
||
|
import { identify } from '@libp2p/identify'
|
||
|
import type { Libp2p } from '@libp2p/interface'
|
||
|
|
||
|
export async function createRelay (): Promise<Libp2p> {
|
||
|
const server = await createLibp2p({
|
||
|
addresses: {
|
||
|
listen: ['/ip4/0.0.0.0/tcp/0/ws']
|
||
|
},
|
||
|
transports: [
|
||
|
webSockets({
|
||
|
filter: filters.all
|
||
|
})
|
||
|
],
|
||
|
connectionEncryption: [noise()],
|
||
|
streamMuxers: [yamux()],
|
||
|
services: {
|
||
|
identify: identify(),
|
||
|
relay: circuitRelayServer({
|
||
|
reservations: {
|
||
|
maxReservations: Infinity,
|
||
|
applyDefaultLimit: false
|
||
|
}
|
||
|
})
|
||
|
}
|
||
|
})
|
||
|
|
||
|
return server
|
||
|
}
|