Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proxy: Add TLS client infrastructure. #1158

Merged
merged 9 commits into from
Jun 20, 2018
7 changes: 2 additions & 5 deletions proxy/src/connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -184,15 +184,15 @@ impl Future for Connecting {

fn poll(&mut self) -> Poll<Self::Item, Self::Error> {
loop {
let new_state = match self {
*self = match self {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Incidentally, I really don't like that we have this explicit Future implementation. I would prefer it to be rewritten in terms of combinators but I couldn't get that to work after spending some time spent on it. Also, since we're going to implement some "fall back to non-secure if TLS failed" logic, we should probably do that fallback logic first and then see if we can simplify things.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I think that sounds like the right approach.

Connecting::Plaintext { connect, tls } => {
let plaintext_stream = try_ready!(connect.poll());
set_nodelay_or_warn(&plaintext_stream);
match tls.take().expect("Polled after ready") {
Conditional::Some(config) => {
let upgrade_to_tls = tls::Connection::connect(
plaintext_stream, &config.identity, config.config);
Some(Connecting::UpgradeToTls(upgrade_to_tls))
Connecting::UpgradeToTls(upgrade_to_tls)
},
Conditional::None(why) => {
return Ok(Async::Ready(Connection::plain(plaintext_stream, why)));
Expand All @@ -204,9 +204,6 @@ impl Future for Connecting {
return Ok(Async::Ready(Connection::tls(tls_stream)));
},
};
if let Some(s) = new_state {
std::mem::replace(self, s);
}
}
}
}
Expand Down