Skip to content

Commit f35e889

Browse files
madeyeclaude
andcommitted
Fix formatting and clippy warnings
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent a83f619 commit f35e889

File tree

6 files changed

+30
-30
lines changed

6 files changed

+30
-30
lines changed

src/auth.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,11 @@ pub fn check_proxy_auth(req: &Request<Incoming>, users: &[UserConfig]) -> bool {
3434
};
3535

3636
match credentials {
37-
Some(cred) => cred
38-
.split_once(':')
39-
.is_some_and(|(user, pass)| users.iter().any(|u| u.username == user && u.password == pass)),
37+
Some(cred) => cred.split_once(':').is_some_and(|(user, pass)| {
38+
users
39+
.iter()
40+
.any(|u| u.username == user && u.password == pass)
41+
}),
4042
None => false,
4143
}
4244
}

src/main.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,7 @@ fn main() -> anyhow::Result<()> {
8585
async fn run_server(config_path: String) -> anyhow::Result<()> {
8686
tracing_subscriber::fmt()
8787
.with_env_filter(
88-
tracing_subscriber::EnvFilter::try_from_default_env()
89-
.unwrap_or_else(|_| "info".into()),
88+
tracing_subscriber::EnvFilter::try_from_default_env().unwrap_or_else(|_| "info".into()),
9089
)
9190
.init();
9291

src/net.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,8 +183,7 @@ fn set_tcp_fastopen_connect(socket: &Socket) -> anyhow::Result<()> {
183183
)
184184
};
185185
if ret != 0 {
186-
return Err(std::io::Error::last_os_error())
187-
.context("setsockopt TCP_FASTOPEN_CONNECT");
186+
return Err(std::io::Error::last_os_error()).context("setsockopt TCP_FASTOPEN_CONNECT");
188187
}
189188
}
190189

src/proxy.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,10 @@ use crate::net;
2020
/// that upgrades the connection and copies bytes bidirectionally between the
2121
/// client and the target host. Optionally uses TCP Fast Open for the outgoing
2222
/// connection when `fast_open` is `true`.
23-
pub async fn handle_connect(req: Request<Incoming>, fast_open: bool) -> anyhow::Result<Response<Full<Bytes>>> {
23+
pub async fn handle_connect(
24+
req: Request<Incoming>,
25+
fast_open: bool,
26+
) -> anyhow::Result<Response<Full<Bytes>>> {
2427
let authority = req
2528
.uri()
2629
.authority()
@@ -75,7 +78,10 @@ pub async fn handle_connect(req: Request<Incoming>, fast_open: bool) -> anyhow::
7578
/// path-only (`/path`), removes `Proxy-Authorization` and `Proxy-Connection`
7679
/// headers, connects to the upstream server, and relays the response back
7780
/// to the client.
78-
pub async fn handle_forward(mut req: Request<Incoming>, fast_open: bool) -> anyhow::Result<Response<Full<Bytes>>> {
81+
pub async fn handle_forward(
82+
mut req: Request<Incoming>,
83+
fast_open: bool,
84+
) -> anyhow::Result<Response<Full<Bytes>>> {
7985
let uri = req.uri().clone();
8086
let host = uri
8187
.authority()

src/service.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -94,14 +94,10 @@ pub fn uninstall_service() -> anyhow::Result<()> {
9494
let _ = run_cmd("systemctl", &["disable", SERVICE_NAME]);
9595

9696
// Remove files
97-
for path in [
98-
&unit_path,
99-
&format!("/usr/local/bin/{SERVICE_NAME}"),
100-
] {
97+
for path in [&unit_path, &format!("/usr/local/bin/{SERVICE_NAME}")] {
10198
if Path::new(path).exists() {
10299
println!("Removing {path}");
103-
fs::remove_file(path)
104-
.with_context(|| format!("failed to remove {path}"))?;
100+
fs::remove_file(path).with_context(|| format!("failed to remove {path}"))?;
105101
}
106102
}
107103

src/setup.rs

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -305,14 +305,12 @@ impl SetupApp {
305305
.split(area);
306306

307307
// Title
308-
let title = Paragraph::new(Line::from(vec![
309-
Span::raw(" HTTPS Proxy Setup").bold(),
310-
]))
311-
.block(
312-
Block::default()
313-
.borders(Borders::ALL)
314-
.border_style(Style::default().fg(Color::Cyan)),
315-
);
308+
let title = Paragraph::new(Line::from(vec![Span::raw(" HTTPS Proxy Setup").bold()]))
309+
.block(
310+
Block::default()
311+
.borders(Borders::ALL)
312+
.border_style(Style::default().fg(Color::Cyan)),
313+
);
316314
frame.render_widget(title, outer[0]);
317315

318316
// Main form
@@ -324,8 +322,7 @@ impl SetupApp {
324322
frame.render_widget(form_block, outer[1]);
325323

326324
let rows = Layout::vertical(
327-
std::iter::repeat(Constraint::Length(2))
328-
.take(FIELDS.len())
325+
std::iter::repeat_n(Constraint::Length(2), FIELDS.len())
329326
.chain(std::iter::once(Constraint::Min(0)))
330327
.collect::<Vec<_>>(),
331328
)
@@ -399,9 +396,7 @@ impl SetupApp {
399396
let status_text = match &self.status {
400397
Some(msg) => msg.clone(),
401398
None => match self.mode {
402-
Mode::Navigate => {
403-
"↑↓ navigate Enter edit d delete user s save q quit".into()
404-
}
399+
Mode::Navigate => "↑↓ navigate Enter edit d delete user s save q quit".into(),
405400
Mode::Edit => "Type to edit Enter confirm Esc cancel".into(),
406401
Mode::UserAdd => "Tab next field Enter confirm Esc cancel".into(),
407402
},
@@ -413,8 +408,11 @@ impl SetupApp {
413408
} else {
414409
Style::default().fg(Color::DarkGray)
415410
};
416-
let status = Paragraph::new(Span::styled(format!(" {status_text}"), status_style))
417-
.block(Block::default().borders(Borders::ALL).border_style(Style::default().fg(Color::Gray)));
411+
let status = Paragraph::new(Span::styled(format!(" {status_text}"), status_style)).block(
412+
Block::default()
413+
.borders(Borders::ALL)
414+
.border_style(Style::default().fg(Color::Gray)),
415+
);
418416
frame.render_widget(status, outer[2]);
419417

420418
// User add popup

0 commit comments

Comments
 (0)