Advertisement
EXTREMEXPLOIT

em vull morir no es cap broma

Nov 20th, 2022
858
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2. This file is used to configure and run a public node.
  3. The public node is used to listen/accept incoming connections.
  4. This public node can be reached by other nodes behind a NAT.
  5.  */
  6.  
  7. import { createLibp2p } from 'libp2p'
  8. import { webSockets } from '@libp2p/websockets'
  9. import { noise } from '@chainsafe/libp2p-noise'
  10. import { mplex } from '@libp2p/mplex'
  11.  
  12. async function main ()
  13. {
  14.     const myNode = await createLibp2p({
  15.         addresses: { listen: ['/ip4/92.185.24.206/tcp/0/ws', '/ip4/127.0.0.1/tcp/0/ws'] },
  16.         transports: [ webSockets() ],
  17.         connectionEncryption: [ noise() ],
  18.         streamMuxers: [ mplex() ]
  19.     })
  20.  
  21.     function connectToNode(addr)
  22.     {
  23.         // Try to connect to the node and return if the connection was successful.
  24.         try
  25.         {
  26.             myNode.dial(addr)
  27.             console.log("Connected to " + addr)
  28.         }
  29.         catch (e)
  30.         {
  31.             console.log("Failed to connect to " + addr)
  32.             console.error(e)
  33.             return false
  34.         }
  35.     }
  36.  
  37. await myNode.start()
  38.         .then(() => console.log("Node ID: " + myNode.peerId.toString())) // Display the Node ID
  39.         .then(() =>
  40.         {
  41.             console.log("Listening:") // Display the listening addresses.
  42.             myNode.getMultiaddrs().forEach((ma) => console.log("\t" + ma.toString()))
  43.         })
  44.         .then(() =>
  45.         {
  46.             connectToNode("/ip4/92.185.24.206/tcp/38353/ws/p2p/12D3KooWJiv6N9wSGaXnHj9wjJvd3S6aD9khijubpfoFBHGgo6B9")
  47.         })
  48.         .catch((err) => console.error(err))
  49. }
  50.  
  51. main().then(r => console.log(r)).catch(e => console.error(e))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement