fetch-dht/lib/peerListFormatters/compact.js
2020-04-12 16:33:32 -05:00

15 lines
340 B
JavaScript

const bencode = require('bencode');
const string2compact = require('string2compact');
module.exports = (peers, res) => {
const response = bencode.encode({
interval: 30 * 60, // 30 minutes between requests
peers: string2compact(peers),
});
res
.set({
'Content-Length': response.length,
})
.end(response);
};