Comments (13)
Few questions:
What version of Windows are you using?
What version of Chrome are you using?
Are you running the log example on the main branch? If so, could you also try the latest tagged version (https://github.com/omjadas/hudsucker/tree/v0.21.0)?
from hudsucker.
@omjadas thanks so much for the quick response.
I'm running the log example from the stable v0.21.0 (from crate)
Windows: 11
Chrome: Version 122.0.6261.112 (Official Build) (64-bit)
Cargo.toml
[package]
name = "huduse"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
hudsucker = { version = "0.21.0", features = ["default"] }
rcgen = "0.12.1"
reqwest = "0.11.10"
rustls-pemfile = "2.0.0"
tokio = { version = "1.24.2", features = ["full"] }
tracing = { version = "0.1.40", features = ["log"] }
tracing-subscriber = "0.3.8"
main.rs
use hudsucker::{
async_trait::async_trait,
certificate_authority::RcgenAuthority,
hyper::{Body, Request, Response},
*,
};
use rustls_pemfile as pemfile;
use std::net::SocketAddr;
use tracing::*;
async fn shutdown_signal() {
tokio::signal::ctrl_c()
.await
.expect("Failed to install CTRL+C signal handler");
}
#[derive(Clone)]
struct LogHandler;
#[async_trait]
impl HttpHandler for LogHandler {
async fn handle_request(
&mut self,
_ctx: &HttpContext,
req: Request<Body>,
) -> RequestOrResponse {
println!(" {:?}", req);
req.into()
}
async fn handle_response(&mut self, _ctx: &HttpContext, res: Response<Body>) -> Response<Body> {
println!("RES::: {:?}", res);
res
}
}
#[tokio::main]
async fn main() {
tracing_subscriber::fmt::init();
let mut private_key_bytes: &[u8] = include_bytes!("ca/rpai.key");
let mut ca_cert_bytes: &[u8] = include_bytes!("ca/rpai.pem");
let private_key = rustls::PrivateKey(
pemfile::pkcs8_private_keys(&mut private_key_bytes)
.next()
.unwrap()
.expect("Failed to parse private key")
.secret_pkcs8_der()
.to_vec(),
);
let ca_cert = rustls::Certificate(
pemfile::certs(&mut ca_cert_bytes)
.next()
.unwrap()
.expect("Failed to parse CA certificate")
.to_vec(),
);
let ca = RcgenAuthority::new(private_key, ca_cert, 1_000)
.expect("Failed to create Certificate Authority");
let proxy = Proxy::builder()
.with_addr(SocketAddr::from(([127, 0, 0, 1], 6070)))
.with_rustls_client()
.with_ca(ca)
.with_http_handler(LogHandler)
.build();
if let Err(e) = proxy.start(shutdown_signal()).await {
error!("{}", e);
}
}
from hudsucker.
What site are you navigating to in Chrome that causes the error?
from hudsucker.
I tried different websites. Few of them are:
Also, I tried proxy url itself
from hudsucker.
I'm using this Proxy Extension on chrome browser
from hudsucker.
I am having trouble reproducing the issue. Using the Cargo.toml
and main.rs
files you provided with the same Chrome extension on Windows, everything seems to be working for me. Could you let me know what version of Rust you are using to build your project? Would you also be able to try the same thing with Firefox? And just to confirm, you are using those exact same Cargo.toml
and main.rs
files yourself?
from hudsucker.
Rust Version : rustup 1.26.0 (5af9b9484 2023-04-05)
Yes, using the same files. It worked in Firefox. Not sure, what's with Chrome. Let me try again. Thanks for the help.
Aside:
I was trying to intercept a particular URL and write the response to file and post the same response to some other API. Can we do this ?
from hudsucker.
Would you be able to share a list of all the other Chrome extensions you have installed? Also, have you enabled/disabled any Chrome flags?
In regards to your query, that should definitely be possible.
from hudsucker.
In regards to your query, that should definitely be possible.
Great! I will try to do it.
Would you be able to share a list of all the other Chrome extensions you have installed? Also, have you enabled/disabled any Chrome flags?
I tried to open the chrome browser with Proxy server argument, may be this is the issue.
"C:\Program Files\Google\Chrome\Application\chrome.exe" --profile-directory="Profile1" --proxy-server="127.0.0.1:6070"
Thanks for the help
from hudsucker.
Just to confirm, are you saying that it worked when using the --proxy-server
argument?
from hudsucker.
With --proxy-server
argument, the traffic is not intercepted, I might be doing something wrong. If I use extension with latest Rust version, proxy chrome extension and with latest stable hudsucker crate, it's working.
from hudsucker.
When you specify --proxy-server
, do you also have the extension enabled? If so, they may be conflicting with each other.
When I use the --proxy-server
argument myself, I can see traffic coming through.
from hudsucker.
Yes, that's the root cause. I tried to use only Proxy chrome extension. It worked. Thanks for the help
from hudsucker.
Related Issues (20)
- How to do something after streaming body? HOT 4
- gui implementation HOT 1
- How can I use this without TLS? HOT 3
- [Feature Request] Upstream Proxy HOT 9
- Access to the open websockets HOT 3
- transfer-encoding:chunked HOT 4
- Cargo bech does not build HOT 1
- How to obtain the request URI address in `HttpHandler::handle_response`? HOT 1
- Handle Specific Response? HOT 1
- Failed to establish TLS connection: HOT 2
- How to get the original data of Response body? HOT 2
- Cargo audit failure due to tungstenite dependency HOT 3
- How to serliaize hudsucker::Body to bytes? HOT 2
- `WebSocketContext` is wrong in `WebSocketHandler` HOT 2
- WebSocket TLS not support ? HOT 5
- How to set whitelist url not proxy by hudsucker ? HOT 10
- Seems not work with Proxifier HOT 4
- when I visit a download link , I got the error "connection closed before message completed" HOT 2
- I found that "text/event-stream;" type not send one by one, It send when all the content down HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from hudsucker.