Skip to content

Commit

Permalink
feat: torrentHost, interface binding
Browse files Browse the repository at this point in the history
  • Loading branch information
ThaUnknown committed Nov 16, 2024
1 parent 527b34a commit ccb7969
Show file tree
Hide file tree
Showing 2 changed files with 4,120 additions and 2 deletions.
7 changes: 5 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class Discovery extends EventEmitter {
? opts.infoHash.toLowerCase()
: opts.infoHash.toString('hex')
this._port = opts.port // torrent port
this._host = opts.host || '::'
this._userAgent = opts.userAgent // User-Agent header for http requests

this.destroyed = false
Expand Down Expand Up @@ -58,7 +59,7 @@ class Discovery extends EventEmitter {
const dht = new DHT(opts)
dht.on('warning', this._onWarning)
dht.on('error', this._onError)
dht.listen(port)
dht.listen(port, this._host)
this._internalDHT = true
return dht
}
Expand Down Expand Up @@ -169,6 +170,7 @@ class Discovery extends EventEmitter {
announce: this._announce,
peerId: this.peerId,
port: this._port,
host: this._host,
userAgent: this._userAgent
})

Expand Down Expand Up @@ -209,7 +211,8 @@ class Discovery extends EventEmitter {
const opts = Object.assign({}, {
infoHash: this.infoHash,
peerId: this.peerId,
port: this._port
port: this._port,
host: this._host
})

const lsd = new LSD(opts)
Expand Down
Loading

0 comments on commit ccb7969

Please sign in to comment.