Struct Tunnel
pub struct Tunnel {
pub(crate) client_mode: ClientMode,
pub(crate) web_socket: WebSocketStream<MaybeTlsStream<TcpStream>>,
}Fields§
§client_mode: ClientMode§web_socket: WebSocketStream<MaybeTlsStream<TcpStream>>Implementations§
§impl Tunnel
impl Tunnel
pub async fn new(notify: &Notify) -> Result<Self>
pub async fn new(notify: &Notify) -> Result<Self>
Creates a new Tunnel instance from the provided payload.
The payload contains the necessary information to establish a secure tunnel connection with AWS IoT Secure Tunneling.
The function performs the following checks:
- Ensures the
client_modeis “destination” - Ensures the
serviceslist contains the “SSH” service
If the checks pass, the function creates a new WebSocket connection to
the AWS IoT Secure Tunneling endpoint and returns a Tunnel
instance.
pub async fn start<S>(self, service: S) -> Result<()>where
S: Service,
pub async fn start<S>(self, service: S) -> Result<()>where
S: Service,
Starts the Tunnel service, handling incoming and outgoing
messages.
This function is responsible for managing the WebSocket connection, processing received data, and forwarding messages to the underlying service.
The function takes a Service instance as a parameter, which is
responsible for handling the actual processing of the messages. The
Service trait defines the interface for this processing, including
methods for connecting to the service, handling incoming messages,
and closing the connection.