Advertisement
Guest User

Here's my latest configuration after bruteforcing for a full day more

a guest
Jul 17th, 2024
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.   const libp2p = await createLibp2p({
  2.     datastore,
  3.     ...(savedPeerId ? { peerId: savedPeerId } : {}),
  4.     addresses: {
  5.       listen: [
  6.         '/ip4/0.0.0.0/tcp/4001',
  7.         '/ip4/0.0.0.0/tcp/9001/ws',       
  8.         ...relayListenAddrs,
  9.       ],
  10.       announce: [
  11.         `/ip4/${myPublicIP}/tcp/4001`,
  12.         `/ip4/${myPublicIP}/tcp/9001/ws`,
  13.         ...relayListenAddrs, // I have no idea what I'm doing
  14.       ],
  15.     },    transports: [tcp(), webSockets()],
  16.     connectionManager: {
  17.       maxConnections: 300,
  18.       minConnections: 50,
  19.     },
  20.     connectionGater: {
  21.       denyDialMultiaddr: async () => false,
  22.     },
  23.     connectionEncryption: [noise()],
  24.     streamMuxers: [yamux(), mplex()],
  25.     peerDiscovery: [
  26.       // mdns({
  27.       //   interval: 2000,
  28.       // }),
  29.       bootstrap({
  30.         list: [
  31.           '/ip4/104.131.131.82/tcp/4001/p2p/QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLuvuJ',
  32.           ...bootstrapAddrs,
  33.         ],
  34.       }),
  35.     ],
  36.     services: {
  37.       identify: identify(),
  38.       dcutr: dcutr(),
  39.       //autoNAT: autoNAT(),
  40.       //pubsub: gossipsub(),
  41.       //delegatedRouting: () => delegatedClient,
  42.       aminoDHT: kadDHT({
  43.         protocol: '/ipfs/kad/1.0.0',
  44.         //pingTimeout: 10000,
  45.         //pingConcurrency: 10,
  46.         //kBucketSize: 20,
  47.         peerInfoMapper: removePrivateAddressesMapper,
  48.         //clientMode: true,
  49.         validators: {
  50.           ipns: ipnsValidator,
  51.         },
  52.         selectors: {
  53.           ipns: ipnsSelector,
  54.         },
  55.       }),
  56.     },
  57.   })
  58.  
  59.   libp2p.addEventListener('peer:connect', (evt) => {
  60.     const peerId = evt.detail
  61.     //console.log(`Connected to ${peerId.toString()}`)
  62.   })
  63.  
  64.   libp2p.addEventListener('peer:disconnect', (evt) => {
  65.     const peerId = evt.detail
  66.     //console.log(`Disconnected from ${peerId.toString()}`)
  67.   })
  68.  
  69.   libp2p.addEventListener('peer:discovery', (evt) => {
  70.     const peerInfo = evt.detail
  71.     console.log('Discovered:', peerInfo.id.toString())
  72.   })
  73.  
  74.   console.log('PeerId:', JSON.stringify(libp2p.peerId, null, 2))
  75.  
  76.   await writePeerId(libp2p.peerId)
  77.  
  78.   return await createHelia({
  79.     libp2p,
  80.     datastore,
  81.     blockstore,
  82.   })
  83. }
  84.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement