Skip to content

Commit

Permalink
Issue #9: Handled some expects()/unwraps() (#380)
Browse files Browse the repository at this point in the history
* Handled some expects()/unwraps()

* Box workload in variant
  • Loading branch information
briansonnenberg authored Feb 8, 2023
1 parent 3622b13 commit e2f27d6
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
3 changes: 3 additions & 0 deletions src/proxy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,9 @@ pub enum Error {

#[error("attempted recursive call to ourselves")]
SelfCall,

#[error("no gateway address: {0}")]
NoGatewayAddress(Box<crate::workload::Workload>),
}

// TLS record size max is 16k. But we also have a H2 frame header, so leave a bit of room for that.
Expand Down
7 changes: 5 additions & 2 deletions src/proxy/outbound.rs
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,9 @@ impl OutboundConnection {
request_type: RequestType::ToServerWaypoint,
});
}
if us.workload.gateway_address.is_none() {
return Err(Error::NoGatewayAddress(Box::new(us.workload.clone())));
}
// For case source client and upstream server are on the same node
if !us.workload.node.is_empty()
&& self.pi.cfg.local_node == Some(us.workload.node.clone())
Expand All @@ -387,7 +390,7 @@ impl OutboundConnection {
gateway: SocketAddr::from((
us.workload
.gateway_address
.expect("todo: refactor gateway ip handling")
.expect("gateway address confirmed")
.ip(),
15008,
)),
Expand All @@ -407,7 +410,7 @@ impl OutboundConnection {
gateway: us
.workload
.gateway_address
.expect("todo: refactor gateway ip handling"),
.expect("gateway address confirmed"),
direction: Direction::Outbound,
request_type: RequestType::Direct,
})
Expand Down
2 changes: 1 addition & 1 deletion src/tls/boring.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ impl Certs {
.cert
.not_after
.duration_since(self.cert.not_before)
.unwrap()
.unwrap_or_else(|_| std::time::Duration::from_secs(0))
/ 2;
// If now() is earlier than not_before, we need to refresh ASAP, so return 0.
let elapsed = SystemTime::now()
Expand Down

0 comments on commit e2f27d6

Please sign in to comment.