mirror of
https://github.com/taobataoma/meanTorrent.git
synced 2026-01-16 20:32:21 +01:00
32 lines
656 B
JavaScript
32 lines
656 B
JavaScript
'use strict';
|
|
|
|
/**
|
|
* Created by wei on 2017/3/23.
|
|
*/
|
|
/**
|
|
* Functions/constants needed by both the client and server.
|
|
*/
|
|
|
|
var Buffer = require('safe-buffer').Buffer;
|
|
var extend = require('xtend/mutable');
|
|
|
|
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');
|
|
extend(exports, config);
|