Skip to content

Commit

Permalink
fix(rust): treat a relay as a terminal address
Browse files Browse the repository at this point in the history
  • Loading branch information
davide-baldo committed Feb 5, 2025
1 parent 65ca76c commit a9e0cac
Showing 1 changed file with 24 additions and 4 deletions.
28 changes: 24 additions & 4 deletions implementations/rust/ockam/ockam/src/relay_service/relay.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ pub(super) struct Relay {

impl Relay {
pub(super) fn create(
ctx: &Context,
context: &Context,
address: Address,
forward_route: Route,
registration_payload: Vec<u8>,
Expand All @@ -35,16 +35,36 @@ impl Relay {
Arc::new(AllowOnwardAddress(next_hop))
};

// Copying metadata from the forward route
let metadata = if let Some((_address, metadata)) =
context.find_terminal_address(forward_route.iter())?
{
Some(metadata)
} else {
None
};

let relay = Self {
forward_route,
payload: Some(registration_payload.clone()),
};

WorkerBuilder::new(relay)
let builder = WorkerBuilder::new(relay)
.with_address(address)
.with_incoming_access_control_arc(incoming_access_control)
.with_outgoing_access_control_arc(outgoing_access_control)
.start(ctx)?;
.with_outgoing_access_control_arc(outgoing_access_control);

let builder = if let Some(metadata) = metadata {
let mut builder = builder;
for (key, value) in metadata.attributes {
builder = builder.with_metadata_attribute(key, value);
}
builder.terminal()
} else {
builder
};

builder.start(context)?;

Ok(())
}
Expand Down

0 comments on commit a9e0cac

Please sign in to comment.