Skip to content

Commit

Permalink
fix(dgw): typo in TLS forward route (#510)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
CBenoit authored Aug 15, 2023
1 parent 31d5a5c commit 7cea3c0
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions devolutions-gateway/src/api/fwd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ use crate::{utils, DgwState};
pub fn make_router<S>(state: DgwState) -> Router<S> {
Router::new()
.route("/tcp/:id", get(fwd_tcp))
.route("/fwd/:id", get(fwd_tls))
.route("/tls/:id", get(fwd_tls))
.with_state(state)
}

Expand Down Expand Up @@ -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))
Expand Down Expand Up @@ -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))
Expand All @@ -129,23 +131,22 @@ async fn handle_fwd_tls(
}

#[derive(TypedBuilder)]
pub struct PlainForward<S> {
struct Forward<S> {
conf: Arc<Conf>,
claims: AssociationTokenClaims,
client_stream: S,
client_addr: SocketAddr,
sessions: SessionMessageSender,
subscriber_tx: SubscriberSender,
#[builder(default = false)]
with_tls: bool,
}

impl<S> PlainForward<S>
impl<S> Forward<S>
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,
Expand Down

0 comments on commit 7cea3c0

Please sign in to comment.