mirror of
https://github.com/webtorrent/bittorrent-tracker.git
synced 2025-01-08 23:31:36 +00:00
26 lines
558 B
JavaScript
26 lines
558 B
JavaScript
/**
|
|
* Functions/constants needed by both the client and server.
|
|
*/
|
|
|
|
var Buffer = require('safe-buffer').Buffer
|
|
|
|
exports.DEFAULT_ANNOUNCE_PEERS = 50
|
|
exports.MAX_ANNOUNCE_PEERS = 82
|
|
|
|
exports.binaryToHex = function (str) {
|
|
if (typeof str !== 'string') {
|
|
str = String(str)
|
|
}
|
|
return Buffer.from(str, 'binary').toString('hex')
|
|
}
|
|
|
|
exports.hexToBinary = function (str) {
|
|
if (typeof str !== 'string') {
|
|
str = String(str)
|
|
}
|
|
return Buffer.from(str, 'hex').toString('binary')
|
|
}
|
|
|
|
var config = require('./common-node')
|
|
Object.assign(exports, config)
|