Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
cn-kali-team committed May 19, 2024
1 parent 51a313a commit b2ea056
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
15 changes: 12 additions & 3 deletions src/client.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
use crate::proxy::Proxy;
use crate::record::{HTTPRecord, InternalRequest, InternalResponse};
// use crate::redirect::{Action, Attempt, Policy};
use crate::{ConnectorBuilder, Result};
use crate::{ConnectorBuilder, redirect, Result};
use bytes::Bytes;
use http::HeaderMap;
use std::io::{BufReader, Write};
use std::sync::Arc;
use std::time::Duration;

#[derive(Clone, Debug, PartialEq)]
Expand All @@ -29,7 +30,15 @@ impl Default for Config {
}
}
}

struct ClientRef {
// cookie_store: Option<Arc<dyn cookie::CookieStore>>,
headers: HeaderMap,
redirect_policy: redirect::Policy,
referer: bool,
request_timeout: Option<Duration>,
read_timeout: Option<Duration>,
proxies: Arc<Vec<Proxy>>,
}
#[derive(Debug, Default, Clone, PartialEq)]
pub struct Client {
pub config: Config,
Expand Down Expand Up @@ -70,7 +79,7 @@ pub fn http_request(request: InternalRequest) -> Result<HTTPRecord> {
let mut record = HTTPRecord::default();
let mut socket = ConnectorBuilder::default()
.build()?
.connect_with_proxy(&request.uri)?;
.connect_with_uri(&request.uri)?;
let mut certificate = None;
if let Some(x509) = socket.peer_certificate() {
certificate = Some(x509);
Expand Down
2 changes: 1 addition & 1 deletion src/connector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ impl Connector {
}
Ok(InternalSocket::TCP(self.tcp.try_clone().unwrap()))
}
pub fn connect_with_proxy(&self, target: &http::Uri) -> Result<InternalSocket> {
pub fn connect_with_uri(&self, target: &http::Uri) -> Result<InternalSocket> {
ProxySocket::new(target, &self.proxy).conn_with_connector(self)
}
pub fn upgrade_to_tls(&self, stream: InternalSocket, domain: &str) -> Result<InternalSocket> {
Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ mod errors;
mod parser;
mod proxy;
mod record;
// mod redirect;
mod redirect;
mod socket;

pub use client::{Client, Config};
Expand Down

0 comments on commit b2ea056

Please sign in to comment.