From 7cea3c055ade2a86aaa76ac6fe534d9fe0ecd1a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Cortier?= Date: Tue, 15 Aug 2023 10:42:55 -0400 Subject: [PATCH] fix(dgw): typo in TLS forward route (#510) The name of the endpoint was wrong, and thus /jet/fwd/tls was returning the 404 Not Found status. Furthermore, the `with_tls` option was not properly set. Issue: DGW-102 --- devolutions-gateway/src/api/fwd.rs | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/devolutions-gateway/src/api/fwd.rs b/devolutions-gateway/src/api/fwd.rs index 7173a2b09..634ed05e9 100644 --- a/devolutions-gateway/src/api/fwd.rs +++ b/devolutions-gateway/src/api/fwd.rs @@ -24,7 +24,7 @@ use crate::{utils, DgwState}; pub fn make_router(state: DgwState) -> Router { Router::new() .route("/tcp/:id", get(fwd_tcp)) - .route("/fwd/:id", get(fwd_tls)) + .route("/tls/:id", get(fwd_tls)) .with_state(state) } @@ -61,13 +61,14 @@ async fn handle_fwd_tcp( ) { let stream = crate::ws::websocket_compat(ws); - let result = PlainForward::builder() + let result = Forward::builder() .client_addr(source_addr) .client_stream(stream) .conf(conf) .claims(claims) .sessions(sessions) .subscriber_tx(subscriber_tx) + .with_tls(false) .build() .run() .instrument(info_span!("tcp", client = %source_addr)) @@ -111,13 +112,14 @@ async fn handle_fwd_tls( ) { let stream = crate::ws::websocket_compat(ws); - let result = PlainForward::builder() + let result = Forward::builder() .client_addr(source_addr) .client_stream(stream) .conf(conf) .claims(claims) .sessions(sessions) .subscriber_tx(subscriber_tx) + .with_tls(true) .build() .run() .instrument(info_span!("tls", client = %source_addr)) @@ -129,23 +131,22 @@ async fn handle_fwd_tls( } #[derive(TypedBuilder)] -pub struct PlainForward { +struct Forward { conf: Arc, claims: AssociationTokenClaims, client_stream: S, client_addr: SocketAddr, sessions: SessionMessageSender, subscriber_tx: SubscriberSender, - #[builder(default = false)] with_tls: bool, } -impl PlainForward +impl Forward where S: AsyncRead + AsyncWrite + Unpin + Send + 'static, { #[instrument(skip_all)] - pub async fn run(self) -> anyhow::Result<()> { + async fn run(self) -> anyhow::Result<()> { let Self { conf, claims,