feat(config): Add support for HTTP proxies on outgoing requests

This commit is contained in:
Jesse Wierzbinski 2024-06-25 17:13:40 -10:00
parent 0ecb65de29
commit b8b822e553
No known key found for this signature in database
13 changed files with 225 additions and 136 deletions

View file

@ -123,21 +123,16 @@ export const configValidator = z.object({
proxy: z
.object({
enabled: z.boolean().default(false),
host: z.string().min(1).default("localhost"),
port: z
.number()
.int()
.min(1)
.max(2 ** 16 - 1)
.default(9050),
type: z.enum(["socks4", "socks4a", "socks5"]).default("socks5"),
address: zUrl,
})
.default({
enabled: false,
host: "localhost",
port: 9050,
type: "socks5",
}),
address: "",
})
.transform((arg) => ({
...arg,
address: arg.enabled ? arg.address : undefined,
})),
tls: z
.object({
enabled: z.boolean().default(false),

View file

@ -595,6 +595,7 @@ export class Note extends BaseInterface<typeof Notes, StatusWithRelations> {
headers: {
Accept: "application/json",
},
proxy: config.http.proxy.address,
});
note = await new EntityValidator().Note(await response.json());

View file

@ -253,6 +253,7 @@ export class User extends BaseInterface<typeof Users, UserWithRelations> {
headers: {
Accept: "application/json",
},
proxy: config.http.proxy.address,
});
const json = (await response.json()) as Partial<LysandUser>;
@ -551,7 +552,9 @@ export class User extends BaseInterface<typeof Users, UserWithRelations> {
);
// FIXME: Add to new queue system when it's implemented
fetch(federationRequest);
fetch(federationRequest, {
proxy: config.http.proxy.address,
});
}
}