From 0ecb65de296bba710d179c29063419b6ddd789c8 Mon Sep 17 00:00:00 2001 From: Jesse Wierzbinski Date: Tue, 25 Jun 2024 16:30:51 -1000 Subject: [PATCH] refactor: :recycle: Move config checker code into its own file --- config/config.example.toml | 9 +++++++++ packages/config-manager/config.type.ts | 18 ++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/config/config.example.toml b/config/config.example.toml index 0b001920..a69a338b 100644 --- a/config/config.example.toml +++ b/config/config.example.toml @@ -83,6 +83,15 @@ banned_user_agents = [ # "wget\/1.20.3", ] +[http.proxy] +# For SOCKS proxies (e.g. Tor) +# Will be used for all outgoing requests +enabled = false +host = "127.0.0.1" +port = 9050 +# Can be socks4, socks4a or socks5 +type = "socks5" + [http.tls] # If these values are set, Lysand will use these files for TLS enabled = false diff --git a/packages/config-manager/config.type.ts b/packages/config-manager/config.type.ts index 829d732a..0f6da297 100644 --- a/packages/config-manager/config.type.ts +++ b/packages/config-manager/config.type.ts @@ -120,6 +120,24 @@ export const configValidator = z.object({ // Not using .ip() because we allow CIDR ranges and wildcards and such banned_ips: z.array(z.string()).default([]), banned_user_agents: z.array(z.string()).default([]), + 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"), + }) + .default({ + enabled: false, + host: "localhost", + port: 9050, + type: "socks5", + }), tls: z .object({ enabled: z.boolean().default(false),