~ knotless Search/
↑↓ move↵ open⇧↵ all results

zat.dev/stream

jetstream v2 in zig · mirror of https://tangled.org/zat.dev/stream

0
0
23 lines · 1.0 KB Raw History
const std = @import("std");
const fetched_car = @import("internal/ingest/backfill/fetched_car.zig");

pub fn main(init: std.process.Init) !void {
    const allocator = init.gpa;
    const io = init.io;
    for ([_][]const u8{
        "https://dv-g3b-emudhra.we-have-a-problem.com",
        "https://dv-g3b-aaa-emudhra.we-have-a-problem.com",
        "https://emudhra.divy.zone",
        "https://atproto.com",
    }, 0..) |url, index| {
        var host: fetched_car.FinalHost = .{};
        var outcome = fetched_car.fetchOnce(allocator, io, "/tmp/stream-tls-probe", url, "did:plc:tlsprobe", &host) catch |err| {
            if (index == 3 or (err != error.TlsCertificateNotVerified and err != error.TlsInitializationFailed)) return err;
            std.debug.print("{s}: TLS rejected ({s})\n", .{ url, @errorName(err) });
            continue;
        };
        if (outcome == .ok) outcome.ok.deinit(io);
        if (index != 3) return error.CompromisedCertificateAccepted;
        std.debug.print("{s}: valid control accepted\n", .{url});
    }
}