Skip to content

Commit

Permalink
chore: remove commented out code in launch.json and http_client.rs
Browse files Browse the repository at this point in the history
  • Loading branch information
arloor committed Sep 4, 2024
1 parent 9a5b136 commit bda227b
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 14 deletions.
4 changes: 2 additions & 2 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
"aes-256-gcm",
"-s",
"us.arloor.dev:444",
"--protocol",
"http",
// "--protocol",
// "http",
"--use-http-tunnel=true"
],
"cwd": "${workspaceFolder}",
Expand Down
20 changes: 12 additions & 8 deletions crates/shadowsocks-service/src/local/http/http_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,11 @@ use pin_project::pin_project;
use shadowsocks::relay::Address;
use tokio::sync::Mutex;

use crate::local::{context::ServiceContext, loadbalancing::PingBalancer, net::AutoProxyClientStream};
use crate::local::{
context::ServiceContext,
loadbalancing::PingBalancer,
net::{tcp::auto_proxy_stream::BasicAuth, AutoProxyClientStream},
};

use super::{
http_stream::ProxyHttpStream,
Expand Down Expand Up @@ -195,7 +199,7 @@ where
&self,
host: Address,
mut c: HttpConnection<B>,
mut req: Request<B>,
req: Request<B>,
) -> hyper::Result<Response<body::Incoming>> {
trace!("HTTP making request to host: {}, request: {:?}", host, req);
let response = c.send_request(req).await?;
Expand All @@ -221,8 +225,8 @@ where
}

enum HttpConnection<B> {
Http1(http1::SendRequest<B>, Option<String>),
Http2(http2::SendRequest<B>, Option<String>),
Http1(http1::SendRequest<B>, Option<BasicAuth>),
Http2(http2::SendRequest<B>, Option<BasicAuth>),
}

impl<B> HttpConnection<B>
Expand Down Expand Up @@ -343,14 +347,14 @@ where
pub async fn send_request(&mut self, mut req: Request<B>) -> hyper::Result<Response<body::Incoming>> {
match self {
HttpConnection::Http1(r, auth) => {
if let Some(auth) = auth {
req.headers_mut().insert("Proxy-Authorization", auth.parse().unwrap());
if let Some(auth) = &auth {
req.headers_mut().insert("Proxy-Authorization", auth.0.parse().unwrap());
}
r.send_request(req).await
}
HttpConnection::Http2(r, auth) => {
if let Some(auth) = auth {
req.headers_mut().insert("Proxy-Authorization", auth.parse().unwrap());
if let Some(auth) = &auth {
req.headers_mut().insert("Proxy-Authorization", auth.0.parse().unwrap());
}
r.send_request(req).await
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
use std::{
io::{self, ErrorKind, IoSlice},
net::SocketAddr,
ops::Add,
pin::{self, Pin},

Check warning on line 6 in crates/shadowsocks-service/src/local/net/tcp/auto_proxy_stream.rs

View workflow job for this annotation

GitHub Actions / clippy macos-latest

unused import: `self`

warning: unused import: `self` --> crates/shadowsocks-service/src/local/net/tcp/auto_proxy_stream.rs:6:11 | 6 | pin::{self, Pin}, | ^^^^

Check warning on line 6 in crates/shadowsocks-service/src/local/net/tcp/auto_proxy_stream.rs

View workflow job for this annotation

GitHub Actions / clippy ubuntu-latest

unused import: `self`

warning: unused import: `self` --> crates/shadowsocks-service/src/local/net/tcp/auto_proxy_stream.rs:6:11 | 6 | pin::{self, Pin}, | ^^^^
sync::{Arc, LazyLock},
task::{self, Poll},
Expand All @@ -28,7 +27,7 @@ use crate::{
local::{context::ServiceContext, loadbalancing::ServerIdent},
net::MonProxyStream,
};

pub struct BasicAuth(pub String);
use super::auto_proxy_io::AutoProxyIo;

/// Unified stream for bypassed and proxied connections
Expand Down Expand Up @@ -111,10 +110,10 @@ impl AutoProxyClientStream {
AutoProxyClientStream::Bypassed(_) => Ok(()),
}
}
pub fn auth(&self) -> Option<String> {
pub fn auth(&self) -> Option<BasicAuth> {
match self {
AutoProxyClientStream::Proxied(_) => None,
AutoProxyClientStream::HttpTunnel(tunnel_stream) => Some(tunnel_stream.auth.clone()),
AutoProxyClientStream::HttpTunnel(tunnel_stream) => Some(BasicAuth(tunnel_stream.auth.clone())),
AutoProxyClientStream::Bypassed(_) => None,
}
}
Expand Down

0 comments on commit bda227b

Please sign in to comment.