Skip to content

Commit

Permalink
Fixed handling rejection in intproxy
Browse files Browse the repository at this point in the history
  • Loading branch information
Razz4780 committed Jan 2, 2025
1 parent 9917374 commit 7043c68
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions mirrord/intproxy/src/proxies/incoming/subscriptions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,7 @@ impl SubscriptionsManager {

Ok(subscription.confirm())
}

Err(ResponseError::PortAlreadyStolen(port)) => {
let Some(subscription) = self.subscriptions.remove(&port) else {
return Ok(vec![]);
Expand All @@ -255,23 +256,26 @@ impl SubscriptionsManager {
}
}
}
Err(
ref response_err @ ResponseError::Forbidden {
blocked_action: BlockedAction::Steal(ref steal_type),
..
},
) => {
tracing::warn!("Port subscribe blocked by policy: {response_err}");
let Some(subscription) = self.subscriptions.remove(&steal_type.get_port()) else {

Err(ref response_error @ ResponseError::Forbidden { ref blocked_action, .. }) => {
tracing::warn!(%response_error, "Port subscribe blocked by policy");

let port = match blocked_action {
BlockedAction::Steal(steal_type) => steal_type.get_port(),
BlockedAction::Mirror(port) => *port,
};
let Some(subscription) = self.subscriptions.remove(&port) else {
return Ok(vec![]);
};

subscription
.reject(response_err.clone())
.map_err(|sub|{
tracing::error!("Subscription {sub:?} was confirmed before, then requested again and blocked by a policy.");
IncomingProxyError::SubscriptionFailed(response_err.clone())
.reject(response_error.clone())
.map_err(|subscription|{
tracing::error!(?subscription, "Subscription was confirmed before, then requested again and blocked by a policy.");
IncomingProxyError::SubscriptionFailed(response_error.clone())
})
}

Err(err) => Err(IncomingProxyError::SubscriptionFailed(err)),
}
}
Expand Down

0 comments on commit 7043c68

Please sign in to comment.