Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -129,4 +129,10 @@ dist
.yarn/install-state.gz
.pnp.*

bin/libp2p-relay-daemon
.DS_Store

# libp2p-relay-daemon binary
bin/libp2p-relay-daemon

# example
example/identity
44 changes: 44 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# NPM LibP2P Relay Daemon

This utility downloads and runs the [V2](https://github.com/libp2p/specs/blob/master/relay/circuit-v2.md) of the [libp2p relay daemon](https://github.com/libp2p/go-libp2p-relay-daemon).

## Usage

First, create a config.json file.

```shell
touch config.json
```

An example of a config.json file:

```json
{
"RelayV1": {
"Enabled": false
},
"RelayV2": {
"Enabled": true
},
"Network": {
"ListenAddrs": ["/ip4/127.0.0.1/tcp/24222/ws"],
"AnnounceAddrs": ["/ip4/127.0.0.1/tcp/24222/ws"]
},
"Daemon": {
"PprofPort": -1
}
}
```

Now let's run the libp2p relay deamon:

```js
const { run } = require('npm-libp2p-relay-daemon')
const os = require('os')
const path = require('path')

const configPath = 'config.json'
const identityPath = path.join(os.tmpdir(), `relayd_v2-${Math.random()}.identity`)

run(configPath, identityPath)
```
16 changes: 16 additions & 0 deletions example/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Run LibP2P Relay Daemon

This utility downloads and runs the [V2](https://github.com/libp2p/specs/blob/master/relay/circuit-v2.md) of the [libp2p relay daemon](https://github.com/libp2p/go-libp2p-relay-daemon).

## Usage

First, install dependencies.

```shell
npm i
```
Now let's run the libp2p relay deamon:

```js
node index.js
```
15 changes: 15 additions & 0 deletions example/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"RelayV1": {
"Enabled": false
},
"RelayV2": {
"Enabled": true
},
"Network": {
"ListenAddrs": ["/ip4/127.0.0.1/tcp/24222/ws"],
"AnnounceAddrs": ["/ip4/127.0.0.1/tcp/24222/ws"]
},
"Daemon": {
"PprofPort": -1
}
}
4 changes: 4 additions & 0 deletions example/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
const { run } = require('npm-libp2p-relay-daemon')
const configPath = 'config.json'

run(configPath)
Loading