generated from tipragot/rust
Reconnection system using secret for the relay server #46
|
@ -149,7 +149,7 @@ impl Connection {
|
||||||
self.send_sender.send(Message::Binary(data)).ok();
|
self.send_sender.send(Message::Binary(data)).ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Receive a message from the target client.
|
/// Receive a message from the relay connection.
|
||||||
pub fn read(&self) -> Option<(Uuid, Vec<u8>)> {
|
pub fn read(&self) -> Option<(Uuid, Vec<u8>)> {
|
||||||
self.receive_receiver.try_recv().ok()
|
self.receive_receiver.try_recv().ok()
|
||||||
}
|
}
|
||||||
|
@ -208,7 +208,7 @@ impl Connection {
|
||||||
/// Start the websocket handshake.
|
/// Start the websocket handshake.
|
||||||
fn start_handshake(&mut self, stream: TcpStream) -> ConnectionState {
|
fn start_handshake(&mut self, stream: TcpStream) -> ConnectionState {
|
||||||
match tungstenite::client_tls(format!("wss://{}", self.domain), stream) {
|
match tungstenite::client_tls(format!("wss://{}", self.domain), stream) {
|
||||||
Ok((socket, _)) => ConnectionState::Active(socket),
|
Ok((socket, _)) => ConnectionState::Handshaked(socket),
|
||||||
Err(HandshakeError::Interrupted(handshake)) => ConnectionState::Handshaking(handshake),
|
Err(HandshakeError::Interrupted(handshake)) => ConnectionState::Handshaking(handshake),
|
||||||
Err(HandshakeError::Failure(e)) => {
|
Err(HandshakeError::Failure(e)) => {
|
||||||
warn!("handshake failed with the relay server: {e}");
|
warn!("handshake failed with the relay server: {e}");
|
||||||
|
|
Loading…
Reference in a new issue