Skip to content

Commit

Permalink
WAYK-2287: allow same TCP listener to route RDP and JET (#128)
Browse files Browse the repository at this point in the history
Co-authored-by: Benoît CORTIER <benoit.cortier@fried-world.eu>
  • Loading branch information
bcortier-devolutions and CBenoit authored Dec 11, 2020
1 parent 04b1062 commit 5c7580e
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -316,8 +316,17 @@ async fn start_tcp_server(
scheme => panic!("Unsupported routing URL scheme {}", scheme),
}
} else if config.is_rdp_supported() {
let rdp_client = RdpClient::new(config.clone(), tls_public_key.clone(), tls_acceptor.clone());
Box::pin(rdp_client.serve(conn))
let mut peeked = [0; 4];
let _ = conn.peek(&mut peeked).await;

if peeked == [74, 69, 84, 0] {
// four first bytes matching JET protocol
let jet_client = JetClient::new(config.clone(), jet_associations.clone());
Box::pin(jet_client.serve(JetTransport::new_tcp(conn)))
} else {
let rdp_client = RdpClient::new(config.clone(), tls_public_key.clone(), tls_acceptor.clone());
Box::pin(rdp_client.serve(conn))
}
} else {
let jet_client = JetClient::new(config.clone(), jet_associations.clone());
Box::pin(jet_client.serve(JetTransport::new_tcp(conn)))
Expand Down

0 comments on commit 5c7580e

Please sign in to comment.