-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8f5f0c8
commit a64a500
Showing
3 changed files
with
248 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import { noise } from '@chainsafe/libp2p-noise' | ||
import { yamux } from '@chainsafe/libp2p-yamux' | ||
import { mplex } from '@libp2p/mplex' | ||
import { webSockets } from '@libp2p/websockets' | ||
import { createLibp2p } from 'libp2p' | ||
import { circuitRelayServer } from 'libp2p/circuit-relay' | ||
import { identifyService } from 'libp2p/identify' | ||
import { createFromJSON } from '@libp2p/peer-id-factory' | ||
|
||
async function main () { | ||
const id = await createFromJSON({id : "12D3KooWShh9qmeS1UEgwWpjAsrjsigu8UGh8DRKyx1UG6HeHzjf", | ||
privKey : "CAESQEQ7HBed1HEMpRHdhDmsJOlzHsVNBEWVc7DjEzuQtElv+uET7jQtZlGNKpltf2w4P7UqMdSYm4cYAGzjHcGcSj4="}); | ||
const node = await createLibp2p({ | ||
peerId : id, | ||
addresses: { | ||
listen: ['/ip4/0.0.0.0/tcp/5555/ws'] | ||
// TODO check "What is next?" section | ||
// announce: ['/dns4/auto-relay.libp2p.io/tcp/443/wss/p2p/QmWDn2LY8nannvSWJzruUYoLZ4vV83vfCBwd8DipvdgQc3'] | ||
}, | ||
transports: [ | ||
webSockets() | ||
], | ||
connectionEncryption: [ | ||
noise() | ||
], | ||
streamMuxers: [ | ||
yamux(), | ||
mplex() | ||
], | ||
services: { | ||
identify: identifyService(), | ||
relay: circuitRelayServer() | ||
} | ||
}) | ||
|
||
await node.handle("/trouperelay/keepalive", async ({ connection, stream }) => { | ||
console.log(`Relay handling protocol, id: ${connection.remotePeer}`) | ||
//setupConnection(connection.remotePeer, stream) | ||
}) | ||
|
||
console.log(`Node started with id ${node.peerId.toString()}`) | ||
console.log('Listening on:') | ||
node.getMultiaddrs().forEach((ma) => console.log(ma.toString())) | ||
} | ||
|
||
main() |
Oops, something went wrong.