Skip to content

Commit

Permalink
Rename always_use_connect to proxytunnel
Browse files Browse the repository at this point in the history
  • Loading branch information
kiron1 committed Dec 20, 2024
1 parent 43a3d7d commit fab8f22
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion proxydetox/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ async fn run(config: Arc<Options>) -> Result<(), proxydetoxlib::Error> {
let context = proxydetoxlib::Context::builder()
.pac_file(config.pac_file.clone())
.authenticator_factory(Some(auth))
.always_use_connect(config.always_use_connect)
.proxytunnel(config.proxytunnel)
.connect_timeout(config.connect_timeout)
.direct_fallback(config.direct_fallback)
.client_tcp_keepalive(config.client_tcp_keepalive.clone())
Expand Down
10 changes: 5 additions & 5 deletions proxydetox/src/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ pub struct Options {
pub authorization: Authorization,
pub connect_timeout: Duration,
pub direct_fallback: bool,
pub always_use_connect: bool,
pub proxytunnel: bool,
pub activate_socket: Option<String>,
pub listen: Vec<SocketAddr>,
pub client_tcp_keepalive: TcpKeepAlive,
Expand Down Expand Up @@ -173,7 +173,7 @@ impl Options {
)
.arg(netrc_arg)
.arg(
Arg::new("always_use_connect")
Arg::new("proxytunnel")
.short('C')
.long("always-use-connect")
.help("Always use CONNECT method even for http:// resources")
Expand Down Expand Up @@ -326,7 +326,7 @@ impl From<ArgMatches> for Options {
.cloned()
.or_else(|| which_pac_file().map(PathOrUri::Path)),
authorization,
always_use_connect: m.get_flag("always_use_connect"),
proxytunnel: m.get_flag("proxytunnel"),
direct_fallback: m.get_flag("direct_fallback"),
connect_timeout: m
.get_one::<f64>("connect_timeout")
Expand Down Expand Up @@ -439,7 +439,7 @@ mod tests {
fn test_default() {
let args = Options::parse_args(&["proxydetox".into()]);
assert!(!args.direct_fallback);
assert!(!args.always_use_connect);
assert!(!args.proxytunnel);
}

#[test]
Expand All @@ -450,7 +450,7 @@ mod tests {
"--always-use-connect".into(),
]);
assert!(args.direct_fallback);
assert!(args.always_use_connect);
assert!(args.proxytunnel);
}

#[test]
Expand Down
4 changes: 2 additions & 2 deletions proxydetoxlib/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ pub enum Error {
pub struct Context {
pub(super) eval: paclib::Evaluator,
pub(super) auth: AuthenticatorFactory,
pub(super) always_use_connect: bool,
pub(super) proxytunnel: bool,
pub(super) race_connect: bool,
pub(super) parallel_connect: usize,
pub(super) direct_fallback: bool,
Expand Down Expand Up @@ -119,7 +119,7 @@ impl Context {
uri: http::Uri,
) -> Result<Connection, Error> {
let dst = HostAndPort::try_from_uri(&uri)?;
let tunnel = method == hyper::Method::CONNECT || self.always_use_connect;
let tunnel = method == hyper::Method::CONNECT || self.proxytunnel;
let tls_config = self.tls_config.clone();
let auth = self.auth.clone();
let connect_timeout = self.connect_timeout;
Expand Down
8 changes: 4 additions & 4 deletions proxydetoxlib/src/context/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ pub struct Builder {
pac_file: Option<PathOrUri>,
pac_script: Option<String>,
auth: Option<AuthenticatorFactory>,
always_use_connect: bool,
proxytunnel: bool,
direct_fallback: bool,
tls_config: Option<Arc<rustls::ClientConfig>>,
connect_timeout: Option<Duration>,
Expand Down Expand Up @@ -40,8 +40,8 @@ impl Builder {
}

/// use the CONNECT method even for HTTP requests.
pub fn always_use_connect(mut self, yesno: bool) -> Self {
self.always_use_connect = yesno;
pub fn proxytunnel(mut self, yesno: bool) -> Self {
self.proxytunnel = yesno;
self
}

Expand Down Expand Up @@ -91,7 +91,7 @@ impl Builder {
let context = Context {
eval,
auth,
always_use_connect: self.always_use_connect,
proxytunnel: self.proxytunnel,
race_connect: false, // TODO: make it a config option
parallel_connect: 1, // TODO: make it a config option
direct_fallback: self.direct_fallback,
Expand Down
4 changes: 2 additions & 2 deletions proxydetoxlib/tests/environment/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ impl Environment {
pub(crate) struct Builder {
pac_script: Option<String>,
netrc_content: Option<String>,
always_use_connect: bool,
proxytunnel: bool,
}

impl Builder {
Expand All @@ -139,7 +139,7 @@ impl Builder {
.unwrap_or_else(|| proxydetoxlib::DEFAULT_PAC_SCRIPT.to_string()),
)
.authenticator_factory(auth)
.always_use_connect(self.always_use_connect)
.proxytunnel(self.proxytunnel)
.build();

let listener = TcpListener::bind(SocketAddr::from(([127, 0, 0, 1], 0)))
Expand Down

0 comments on commit fab8f22

Please sign in to comment.