Add an insecure_disable_tls_host_verification command line option

When set, this disables the host verification of all HTTP requests. Available
for both the fetch and serve mode.

Also introduced an App.Config, for future command line options which need to
be passed more deeply into the code.
This commit is contained in:
Karl Seguin
2025-03-27 18:02:30 +08:00
parent 3a1a582013
commit c6538e1038
7 changed files with 81 additions and 30 deletions

View File

@@ -17,11 +17,18 @@ pub const App = struct {
app_dir_path: ?[]const u8,
pub const RunMode = enum {
serve,
help,
fetch,
serve,
version,
};
pub fn init(allocator: Allocator, run_mode: RunMode) !*App {
pub const Config = struct {
tls_verify_host: bool = true,
run_mode: RunMode,
};
pub fn init(allocator: Allocator, config: Config) !*App {
const app = try allocator.create(App);
errdefer allocator.destroy(app);
@@ -38,9 +45,11 @@ pub const App = struct {
.allocator = allocator,
.telemetry = undefined,
.app_dir_path = app_dir_path,
.http_client = try HttpClient.init(allocator, 5),
.http_client = try HttpClient.init(allocator, 5, .{
.tls_verify_host = config.tls_verify_host,
}),
};
app.telemetry = Telemetry.init(app, run_mode);
app.telemetry = Telemetry.init(app, config.run_mode);
return app;
}