add proxy support to Cloudflare
This commit is contained in:
parent
02df7a1c75
commit
878f62ef0a
|
@ -55,6 +55,19 @@ fn make(step: *std.Build.Step, prog_node: *std.Progress.Node) !void {
|
||||||
|
|
||||||
var client = std.http.Client{ .allocator = b.allocator };
|
var client = std.http.Client{ .allocator = b.allocator };
|
||||||
defer client.deinit();
|
defer client.deinit();
|
||||||
|
var proxy_text = std.os.getenv("https_proxy") orelse std.os.getenv("HTTPS_PROXY");
|
||||||
|
if (proxy_text) |p| {
|
||||||
|
client.deinit();
|
||||||
|
const proxy = try std.Uri.parse(p);
|
||||||
|
client = std.http.Client{
|
||||||
|
.allocator = b.allocator,
|
||||||
|
.proxy = .{
|
||||||
|
.protocol = if (std.ascii.eqlIgnoreCase(proxy.scheme, "http")) .plain else .tls,
|
||||||
|
.host = proxy.host.?,
|
||||||
|
.port = proxy.port,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
const script = self.options.primary_file_data orelse
|
const script = self.options.primary_file_data orelse
|
||||||
try std.fs.cwd().readFileAlloc(b.allocator, self.primary_javascript_file.path, std.math.maxInt(usize));
|
try std.fs.cwd().readFileAlloc(b.allocator, self.primary_javascript_file.path, std.math.maxInt(usize));
|
||||||
|
|
|
@ -13,13 +13,19 @@ pub fn main() !u8 {
|
||||||
const allocator = arena.allocator();
|
const allocator = arena.allocator();
|
||||||
var client = std.http.Client{ .allocator = allocator };
|
var client = std.http.Client{ .allocator = allocator };
|
||||||
defer client.deinit();
|
defer client.deinit();
|
||||||
// .allocator = allocator,
|
var proxy_text = std.os.getenv("https_proxy") orelse std.os.getenv("HTTPS_PROXY");
|
||||||
// .proxy = .{
|
if (proxy_text) |p| {
|
||||||
// .protocol = .plain,
|
client.deinit();
|
||||||
// .host = "localhost",
|
const proxy = try std.Uri.parse(p);
|
||||||
// .port = 8080,
|
client = std.http.Client{
|
||||||
// },
|
.allocator = allocator,
|
||||||
// };
|
.proxy = .{
|
||||||
|
.protocol = if (std.ascii.eqlIgnoreCase(proxy.scheme, "http")) .plain else .tls,
|
||||||
|
.host = proxy.host.?,
|
||||||
|
.port = proxy.port,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
const stdout_file = std.io.getStdOut().writer();
|
const stdout_file = std.io.getStdOut().writer();
|
||||||
var bw = std.io.bufferedWriter(stdout_file);
|
var bw = std.io.bufferedWriter(stdout_file);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user