-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathseed.js
37 lines (31 loc) · 935 Bytes
/
seed.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import WebTorrent from "webtorrent"
const client = new WebTorrent()
const filePath = process.argv[2] || './seed-file.txt'
const trackerUrls = [
'udp://127.0.0.1:8001',
'udp://[::1]:8001',
'http://127.0.0.1:9000',
'http://[::1]:9000',
]
const options = {
announce: trackerUrls,
// dht: false,
// localPeerDiscovery: false,
}
client.seed(filePath, options, (torrent) => {
console.log('seeding file: ', filePath)
console.log('magnet uri: ', torrent.magnetURI)
console.log('tracker being used: ', torrent["announce-list"])
console.log('trackers being used: ', torrent.announce)
console.log('info hash: ', torrent.infoHash)
console.log('waiting for peers to connect...')
torrent.on('wire', (_, addr) => {
console.log('peer connected: ', addr)
})
torrent.on('upload', (bytes) => {
console.log('uploaded: ', bytes)
})
})
client.on('error', (err) => {
console.error('error: ', err.message)
})