1
1
# bittorrent-lsd [ ![ ci] [ ci-image ]] [ ci-url ] [ ![ npm] [ npm-image ]] [ npm-url ] [ ![ downloads] [ downloads-image ]] [ downloads-url ] [ ![ javascript style guide] [ standard-image ]] [ standard-url ]
2
2
3
3
[ ci-image ] : https://github.com/webtorrent/bittorrent-lsd/actions/workflows/ci.yml/badge.svg?branch=master
4
+
4
5
[ ci-url ] : https://github.com/webtorrent/bittorrent-lsd/actions/workflows/ci.yml
6
+
5
7
[ npm-image ] : https://img.shields.io/npm/v/bittorrent-lsd.svg
8
+
6
9
[ npm-url ] : https://npmjs.org/package/bittorrent-lsd
10
+
7
11
[ downloads-image ] : https://img.shields.io/npm/dm/bittorrent-lsd.svg
12
+
8
13
[ downloads-url ] : https://npmjs.org/package/bittorrent-lsd
14
+
9
15
[ standard-image ] : https://img.shields.io/badge/code_style-standard-brightgreen.svg
16
+
10
17
[ standard-url ] : https://standardjs.com
11
18
12
19
### Local Service Discovery (BEP14) implementation.
@@ -27,7 +34,8 @@ npm install bittorrent-lsd
27
34
const opts = {
28
35
peerId: new Buffer('01234567890123456789'), // hex string or Buffer
29
36
infoHash: new Buffer('01234567890123456789'), // hex string or Buffer
30
- port: common.randomPort() // torrent client port
37
+ port: common.randomPort(), // torrent client port
38
+ host: '0.0.0.0' // torrent client host or network interface to bind to
31
39
}
32
40
33
41
const lsd = new LSD(opts)
@@ -45,23 +53,29 @@ lsd.destroy()
45
53
## api
46
54
47
55
### ` lsd = new LSD([opts]) `
56
+
48
57
Create a new ` lsd ` instance.
49
58
50
59
### ` lsd.start() `
60
+
51
61
Start listening and sending (every 5 minutes) for local network announces.
52
62
53
63
### ` lsd.destroy([callback]) `
64
+
54
65
Destroy the LSD. Closes the socket and cleans up resources.
55
66
56
67
## events
57
68
58
69
### ` lsd.on('peer', (peerAddress, infoHash) => { ... }) `
70
+
59
71
Emitted when a potential peer is found. ` peerAddress ` is of the form ` host:port ` . ` infoHash ` is the torrent info hash.
60
72
61
73
### ` lsd.on('warning', (err) => { ... }) `
74
+
62
75
Emitted when the LSD gets an unexpected message.
63
76
64
77
### ` lsd.on('error', (err) => { ... }) `
78
+
65
79
Emitted when the LSD has a fatal error.
66
80
67
81
## license
0 commit comments