Skip to content

Commit ab50118

Browse files
committed
http_proxy: Add upstream proxy configuration
Second of the stack. Adds `UpstreamProxy`: parsing of an upstream HTTP proxy from the environment (`HTTPS_PROXY` / `HTTP_PROXY` / `ALL_PROXY` and lowercase forms) with `NO_PROXY` bypass matching delegated to the `proxyvars` crate, basic-auth credentials (kept out of `Debug`/`Display`), and IPv6/default-port normalization. Used by the proxy server in the next PR to chain outbound connections through a corporate proxy when one is configured. Release Notes: - N/A
1 parent 9d36dc0 commit ab50118

6 files changed

Lines changed: 366 additions & 2 deletions

File tree

Cargo.lock

Lines changed: 14 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -697,6 +697,7 @@ profiling = "1"
697697
# replace this with main when #635 is merged
698698
proptest = { git = "https://github.com/proptest-rs/proptest", rev = "3dca198a8fef1b32e3a66f1e1897c955b4dc5b5b", features = ["attr-macro"] }
699699
proptest-derive = "0.8.0"
700+
proxyvars = "0.2"
700701
prost = "0.9"
701702
prost-build = "0.9"
702703
prost-types = "0.9"

crates/http_proxy/Cargo.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,9 @@ workspace = true
1212
path = "src/http_proxy.rs"
1313

1414
[dependencies]
15+
anyhow.workspace = true
1516
idna.workspace = true
17+
percent-encoding.workspace = true
18+
proxyvars.workspace = true
1619
thiserror.workspace = true
20+
url.workspace = true

crates/http_proxy/src/http_proxy.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,14 @@
44
//!
55
//! - [`allowlist`]: the policy types ([`HostPattern`], [`Allowlist`]) that
66
//! decide which hosts a sandboxed command may reach.
7-
//! - `upstream` (next): parsing an upstream HTTP proxy from the environment.
8-
//! - the proxy server itself (last): an in-process HTTP/HTTPS proxy that
7+
//! - [`UpstreamProxy`]: parsing an upstream HTTP proxy from the environment
8+
//! (`HTTPS_PROXY` / `NO_PROXY` etc.) to chain through.
9+
//! - the proxy server itself (next): an in-process HTTP/HTTPS proxy that
910
//! enforces an [`Allowlist`] and is the only network egress a sandboxed
1011
//! command is permitted.
1112
1213
mod allowlist;
14+
mod proxy;
1315

1416
pub use allowlist::{Allowlist, HostPattern, HostPatternError};
17+
pub use proxy::UpstreamProxy;

crates/http_proxy/src/proxy.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
//! The proxy module. For now it holds only the upstream-proxy configuration
2+
//! type; the proxy server (listener, connection handling) lands in a later
3+
//! PR.
4+
5+
mod upstream;
6+
7+
pub use upstream::UpstreamProxy;

0 commit comments

Comments
 (0)