pub(crate) struct Forward {
unique_id: UniqId,
outbound: Option<Outbound>,
crypto_out: Box<dyn OutboundRelayLayer + Send>,
relay_early_count: usize,
extend_handler: ExtendRequestHandler,
}Expand description
Relay-specific state for the forward reactor.
Fields§
§unique_id: UniqIdAn identifier for logging about this reactor’s circuit.
outbound: Option<Outbound>The outbound view of this circuit, if we are not the last hop.
Delivers cells towards the exit.
Only set for middle relays.
crypto_out: Box<dyn OutboundRelayLayer + Send>The cryptographic state for this circuit for inbound cells.
relay_early_count: usizeThe number of RELAY_EARLY cells we have seen so far on this circuit.
If we see more than MAX_RELAY_EARLY_CELLS_PER_CIRCUIT RELAY_EARLY cells, we tear down the circuit.
extend_handler: ExtendRequestHandlerHelper for handling circuit extension requests.
Used for validating EXTEND2 cells.
Implementations§
Source§impl Forward
impl Forward
Sourcepub(crate) fn new(
inbound_chan: &Arc<Channel>,
unique_id: UniqId,
crypto_out: Box<dyn OutboundRelayLayer + Send>,
chan_provider: Arc<dyn ChannelProvider<BuildSpec = OwnedChanTarget> + Send + Sync>,
event_tx: Sender<CircEvent>,
memquota: CircuitAccount,
) -> Self
pub(crate) fn new( inbound_chan: &Arc<Channel>, unique_id: UniqId, crypto_out: Box<dyn OutboundRelayLayer + Send>, chan_provider: Arc<dyn ChannelProvider<BuildSpec = OwnedChanTarget> + Send + Sync>, event_tx: Sender<CircEvent>, memquota: CircuitAccount, ) -> Self
Create a new Forward.
Sourcefn decode_relay_cell<R: Runtime>(
&mut self,
hop_mgr: &mut HopMgr<R>,
cell: Relay,
) -> Result<(Option<HopNum>, CellDecodeResult)>
fn decode_relay_cell<R: Runtime>( &mut self, hop_mgr: &mut HopMgr<R>, cell: Relay, ) -> Result<(Option<HopNum>, CellDecodeResult)>
Decode cell, returning its corresponding hop number, tag and decoded body.
Sourcefn handle_drop(&mut self) -> StdResult<(), ReactorError>
fn handle_drop(&mut self) -> StdResult<(), ReactorError>
Handle a DROP message.
Sourcefn handle_extend_result(
&mut self,
res: StdResult<ExtendResult, ReactorError>,
) -> StdResult<Option<BackwardReactorCmd>, ReactorError>
fn handle_extend_result( &mut self, res: StdResult<ExtendResult, ReactorError>, ) -> StdResult<Option<BackwardReactorCmd>, ReactorError>
Handle the outcome of handling an EXTEND2.
Sourcefn handle_relay_cell<R: Runtime>(
&mut self,
hop_mgr: &mut HopMgr<R>,
cell: Relay,
early: bool,
) -> StdResult<Option<ForwardCellDisposition>, ReactorError>
fn handle_relay_cell<R: Runtime>( &mut self, hop_mgr: &mut HopMgr<R>, cell: Relay, early: bool, ) -> StdResult<Option<ForwardCellDisposition>, ReactorError>
Handle a RELAY or RELAY_EARLY cell.
Sourcefn handle_unrecognized_cell(
&mut self,
body: RelayCellBody,
info: Option<QueuedCellPaddingInfo>,
early: bool,
) -> StdResult<(), ReactorError>
fn handle_unrecognized_cell( &mut self, body: RelayCellBody, info: Option<QueuedCellPaddingInfo>, early: bool, ) -> StdResult<(), ReactorError>
Handle a forward cell that we could not decrypt.
Sourceasync fn handle_truncate(&mut self) -> StdResult<(), ReactorError>
async fn handle_truncate(&mut self) -> StdResult<(), ReactorError>
Handle a TRUNCATE cell.
Sourcefn handle_destroy_cell(&mut self, _cell: Destroy) -> StdResult<(), ReactorError>
fn handle_destroy_cell(&mut self, _cell: Destroy) -> StdResult<(), ReactorError>
Handle a DESTROY cell originating from the client.
Sourcefn handle_padding_negotiate(
&mut self,
_cell: PaddingNegotiate,
) -> StdResult<(), ReactorError>
fn handle_padding_negotiate( &mut self, _cell: PaddingNegotiate, ) -> StdResult<(), ReactorError>
Handle a PADDING_NEGOTIATE cell originating from the client.
Trait Implementations§
Source§impl ControlHandler for Forward
impl ControlHandler for Forward
Source§fn handle_cmd(&mut self, cmd: Self::CtrlCmd) -> StdResult<(), ReactorError>
fn handle_cmd(&mut self, cmd: Self::CtrlCmd) -> StdResult<(), ReactorError>
Source§fn handle_msg(&mut self, msg: Self::CtrlMsg) -> StdResult<(), ReactorError>
fn handle_msg(&mut self, msg: Self::CtrlMsg) -> StdResult<(), ReactorError>
Source§impl ForwardHandler for Forward
impl ForwardHandler for Forward
Source§type BuildSpec = OwnedChanTarget
type BuildSpec = OwnedChanTarget
Source§type CircChanMsg = RelayCircChanMsg
type CircChanMsg = RelayCircChanMsg
Source§async fn handle_meta_msg<R: Runtime>(
&mut self,
runtime: &R,
early: bool,
_hopnum: Option<HopNum>,
msg: UnparsedRelayMsg,
_relay_cell_format: RelayCellFormat,
) -> StdResult<(), ReactorError>
async fn handle_meta_msg<R: Runtime>( &mut self, runtime: &R, early: bool, _hopnum: Option<HopNum>, msg: UnparsedRelayMsg, _relay_cell_format: RelayCellFormat, ) -> StdResult<(), ReactorError>
Source§async fn handle_forward_cell<R: Runtime>(
&mut self,
hop_mgr: &mut HopMgr<R>,
cell: RelayCircChanMsg,
) -> StdResult<Option<ForwardCellDisposition>, ReactorError>
async fn handle_forward_cell<R: Runtime>( &mut self, hop_mgr: &mut HopMgr<R>, cell: RelayCircChanMsg, ) -> StdResult<Option<ForwardCellDisposition>, ReactorError>
Source§fn handle_event(
&mut self,
event: Self::CircEvent,
) -> StdResult<Option<BackwardReactorCmd>, ReactorError>
fn handle_event( &mut self, event: Self::CircEvent, ) -> StdResult<Option<BackwardReactorCmd>, ReactorError>
Auto Trait Implementations§
impl Freeze for Forward
impl !RefUnwindSafe for Forward
impl Send for Forward
impl !Sync for Forward
impl Unpin for Forward
impl UnsafeUnpin for Forward
impl !UnwindSafe for Forward
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSend for T
impl<T> DowncastSend for T
Source§impl<T> FmtForward for T
impl<T> FmtForward for T
Source§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self to use its Binary implementation when Debug-formatted.Source§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self to use its Display implementation when
Debug-formatted.Source§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self to use its LowerExp implementation when
Debug-formatted.Source§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self to use its LowerHex implementation when
Debug-formatted.Source§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self to use its Octal implementation when Debug-formatted.Source§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self to use its Pointer implementation when
Debug-formatted.Source§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self to use its UpperExp implementation when
Debug-formatted.Source§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self to use its UpperHex implementation when
Debug-formatted.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
Source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
Source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
Source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self, then passes self.as_ref() into the pipe function.Source§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self, then passes self.as_mut() into the pipe
function.Source§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.Source§impl<T> PossiblyOption<T> for T
impl<T> PossiblyOption<T> for T
Source§impl<T> Tap for T
impl<T> Tap for T
Source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read moreSource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read moreSource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read moreSource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read moreSource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.Source§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut() only in debug builds, and is erased in release
builds.Source§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref() only in debug builds, and is erased in release
builds.Source§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut() only in debug builds, and is erased in release
builds.Source§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.