Skip to content

Commit

Permalink
Use correct(?) identities
Browse files Browse the repository at this point in the history
  • Loading branch information
Stevenjin8 committed Jan 21, 2025
1 parent cab4849 commit a8856a4
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/proxy/outbound.rs
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,7 @@ impl OutboundConnection {
intended_destination_service: Some(ServiceDescription::from(&*target_service)),
actual_destination,
upstream_sans,
final_sans: vec![],
});
}
// this was service addressed but we did not find a waypoint
Expand Down Expand Up @@ -437,6 +438,7 @@ impl OutboundConnection {
intended_destination_service: None,
actual_destination: target,
upstream_sans: vec![],
final_sans: vec![],
});
};

Expand Down Expand Up @@ -470,6 +472,7 @@ impl OutboundConnection {
intended_destination_service: us.destination_service.clone(),
actual_destination,
upstream_sans,
final_sans: vec![],
});
}
// Workload doesn't have a waypoint; send directly
Expand All @@ -486,9 +489,12 @@ impl OutboundConnection {
Protocol::HBONE | Protocol::DOUBLEHBONE => Some(us.workload_socket_addr()),
Protocol::TCP => None,
};
let (upstream_sans, final_sans) = match us.workload.protocol {
Protocol::DOUBLEHBONE => (vec![us.workload.identity()], us.service_sans()),
Protocol::TCP | Protocol::HBONE => (us.workload_and_services_san(), vec![]),
};

// For case no waypoint for both side and direct to remote node proxy
let upstream_sans = us.workload_and_services_san();
debug!("built request to workload");
Ok(Request {
protocol: us.workload.protocol,
Expand All @@ -498,6 +504,7 @@ impl OutboundConnection {
intended_destination_service: us.destination_service.clone(),
actual_destination,
upstream_sans,
final_sans,
})
}
}
Expand Down Expand Up @@ -546,6 +553,11 @@ struct Request {
// The identity we will assert for the next hop; this may not be the same as actual_destination_workload
// in the case of proxies along the path.
upstream_sans: Vec<Identity>,

// The identity of workload that will ultimately process this request.
// This field only matters if we need to know both the identity of the next hop, as well as the
// final hop (currently, this is only double HBONE).
final_sans: Vec<Identity>,
}

#[cfg(test)]
Expand Down
13 changes: 13 additions & 0 deletions src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,19 @@ impl Upstream {
.chain(std::iter::once(self.workload.identity()))
.collect()
}

pub fn service_sans(&self) -> Vec<Identity> {
self.service_sans
.iter()
.flat_map(|san| match Identity::from_str(san) {
Ok(id) => Some(id),
Err(err) => {
warn!("ignoring invalid SAN {}: {}", san, err);
None
}
})
.collect()
}
}

// Workload information that a specific proxy instance represents. This is used to cross check
Expand Down

0 comments on commit a8856a4

Please sign in to comment.