Advertisement
EXTREMEXPLOIT

ratio 4 me

Nov 20th, 2022
912
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import { createLibp2p } from 'libp2p'
  2. import { webSockets } from '@libp2p/websockets'
  3. import { noise } from '@chainsafe/libp2p-noise'
  4. import { mplex } from '@libp2p/mplex'
  5.  
  6. /*
  7. This file is used to configure and run the relay node.
  8. The relay node is used to listen/accept incoming connections.
  9. This relay does not use the HOP feture, because it is used to advertise the relay address.
  10.  */
  11.  
  12. async function main ()
  13. {
  14.     const myNode = await createLibp2p({
  15.         addresses: { listen: ['/ip4/0.0.0.0/tcp/0/ws'] },
  16.         transports: [ webSockets() ],
  17.         connectionEncryption: [ noise() ],
  18.         streamMuxers: [ mplex() ]
  19.     })
  20.  
  21.     await myNode.start()
  22.         .then(() => console.log("Node ID: " + myNode.peerId.toString())) // Display the Node ID
  23.         .then(() =>
  24.         {
  25.             console.log("Listening:") // Display the listening addresses.
  26.             myNode.getMultiaddrs().forEach((ma) => console.log("\t" + ma.toString()))
  27.         })
  28.         .catch((err) => console.error(err))
  29.  
  30.     /*
  31.     let ID = "12D3KooWCMpg35Foh1JMKgZrTWJeja5ojrHxtNgcjZYKf3CovSjj";
  32.     let addr = "/ip4/192.168.65.103/tcp/4001/ws/p2p/" + ID;
  33.     const conn = await myNode.dial(addr)
  34.         .then(() => console.log("Connected to " + ID))
  35.         .catch((err) => console.error(err))
  36.  
  37.      */
  38. }
  39.  
  40. main().then(r => console.log(r)).catch(e => console.error(e))
  41.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement