Commit 81b76447 authored by Elena's avatar Elena 🤷‍♀️ Committed by Pier Angelo Vendrame
Browse files

fixup! TB 44806: Implement the tor integration in Rust.

TB 44930: Implement the commands on the Rust control port

Remove ambiguity on the connection closed error.
parent 8a46afe3
Loading
Loading
Loading
Loading
Loading
+10 −4
Original line number Diff line number Diff line
@@ -85,8 +85,8 @@ impl ControlPortInner {
        handler: Box<dyn FnOnce(Result<Reply, ControlPortError>)>,
    ) {
        if self.closed.get() {
            handler(Err(ControlPortError::ConnectionError(
                ControlSocketError::ConnectionClosed,
            handler(Err(ControlPortError::ProtocolError(
                ReplyError::ConnectionClosed,
            )));
            return;
        }
@@ -115,8 +115,14 @@ impl ControlPortInner {
                            handler(r.map_err(|e| ControlPortError::ProtocolError(e)));
                        }));
                    }
                    Err(e) => {
                        handler(Err(ControlPortError::from(e)));
                    Err(ControlSocketError::ConnectionClosed) => {
                        handler(Err(ControlPortError::ProtocolError(
                            ReplyError::ConnectionClosed,
                        )));
                        this.async_failure();
                    }
                    Err(ControlSocketError::ImplementationError(rv)) => {
                        handler(Err(ControlPortError::ConnectionError(rv)));
                        this.async_failure();
                    }
                }
+4 −6
Original line number Diff line number Diff line
@@ -5,14 +5,12 @@

use thiserror::Error;

use super::super::{ControlSocketError, ReplyError};
use crate::ctor::ReplyError;

#[derive(Error, Debug, Clone, PartialEq, Eq)]
pub enum ControlPortError {
    #[error("connection error")]
    ConnectionError(#[from] ControlSocketError),
    #[error("protocol violation")]
    #[error("connection error: {0:#x}")]
    ConnectionError(u32),
    #[error("protocol violation: {0}")]
    ProtocolError(#[from] ReplyError),
    #[error("unsuccessful command ({code}): {message}")]
    TorError { code: u16, message: String },
}