This commit is contained in:
McToel 2025-02-17 15:46:01 +01:00
parent c908705167
commit f943e50cbd

View file

@ -3,56 +3,6 @@ import {Request, fetch} from 'cross-fetch';
import {parse as parseContentType} from 'content-type'; import {parse as parseContentType} from 'content-type';
import {HafasError} from './errors.js'; import {HafasError} from './errors.js';
// const proxyAddress = process.env.HTTPS_PROXY || process.env.HTTP_PROXY || null;
// const localAddresses = process.env.LOCAL_ADDRESS || null;
// if (proxyAddress && localAddresses) {
// console.error('Both env vars HTTPS_PROXY/HTTP_PROXY and LOCAL_ADDRESS are not supported.');
// process.exit(1);
// }
// const plainAgent = new HttpsAgent({
// keepAlive: true,
// });
// let getAgent = () => plainAgent;
// if (proxyAddress) {
// const agent = new ProxyAgent(proxyAddress, {
// keepAlive: true,
// keepAliveMsecs: 10 * 1000, // 10s
// });
// getAgent = () => agent;
// } else if (localAddresses) {
// const agents = process.env.LOCAL_ADDRESS.split(',')
// .map((addr) => {
// const family = isIP(addr);
// if (family === 0) {
// throw new Error('invalid local address:' + addr);
// }
// return new HttpsAgent({
// localAddress: addr, family,
// keepAlive: true,
// });
// });
// const pool = roundRobin(agents);
// getAgent = () => pool.get();
// }
// const id = randomBytes(3)
// .toString('hex');
// const randomizeUserAgent = (userAgent) => {
// let ua = userAgent;
// for (
// let i = Math.round(5 + Math.random() * 5);
// i < ua.length;
// i += Math.round(5 + Math.random() * 5)
// ) {
// ua = ua.slice(0, i) + id + ua.slice(i);
// i += id.length;
// }
// return ua;
// };
const randomBytesHex = (nBytes = 8) => { const randomBytesHex = (nBytes = 8) => {
const array = new Uint8Array(nBytes); const array = new Uint8Array(nBytes);
crypto.getRandomValues(array); crypto.getRandomValues(array);