Respect bind setting for all outgoing requests

So far the bind config only impacted the IRC connections.
However, nothing in our doc comment says that this is intentional.

> ### bind
> Set the local IP to bind to for outgoing connections.

This commit fixes the leak and uses it for all outgoing requests
as described by the docstring.
This commit is contained in:
Reto Brunner 2023-06-25 10:44:14 +02:00
parent 79fae26f39
commit 3af4ad1076
2 changed files with 3 additions and 0 deletions

View File

@ -3,6 +3,7 @@ import colors from "chalk";
import log from "../log"; import log from "../log";
import pkg from "../../package.json"; import pkg from "../../package.json";
import ClientManager from "../clientManager"; import ClientManager from "../clientManager";
import Config from "../config";
const TIME_TO_LIVE = 15 * 60 * 1000; // 15 minutes, in milliseconds const TIME_TO_LIVE = 15 * 60 * 1000; // 15 minutes, in milliseconds
@ -51,6 +52,7 @@ async function fetch() {
Accept: "application/vnd.github.v3.html", // Request rendered markdown Accept: "application/vnd.github.v3.html", // Request rendered markdown
"User-Agent": pkg.name + "; +" + pkg.repository.url, // Identify the client "User-Agent": pkg.name + "; +" + pkg.repository.url, // Identify the client
}, },
localAddress: Config.values.bind,
}); });
if (response.statusCode !== 200) { if (response.statusCode !== 200) {

View File

@ -437,6 +437,7 @@ function fetch(uri: string, headers: Record<string, string>) {
retry: 0, retry: 0,
timeout: prefetchTimeout || 5000, // milliseconds timeout: prefetchTimeout || 5000, // milliseconds
headers: getRequestHeaders(headers), headers: getRequestHeaders(headers),
localAddress: Config.values.bind,
}); });
gotStream gotStream