Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion proto/models.proto
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ message IpAddress {
message NetworkInterface {
string name = 1;
string device = 2;
repeated IpAddress addresses = 3;
string description = 3;
repeated IpAddress addresses = 4;
}

message SSHConfig {
Expand Down
1 change: 1 addition & 0 deletions proto/service.proto
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ enum ServiceProtocol {
HTTPS = 1;
SSH = 2;
TTY = 3;
RD = 4;
}

message ServiceInfo {
Expand Down
4 changes: 3 additions & 1 deletion wallguard-common/src/protobuf/wallguard_models.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,9 @@ pub struct NetworkInterface {
pub name: ::prost::alloc::string::String,
#[prost(string, tag = "2")]
pub device: ::prost::alloc::string::String,
#[prost(message, repeated, tag = "3")]
#[prost(string, tag = "3")]
pub description: ::prost::alloc::string::String,
#[prost(message, repeated, tag = "4")]
pub addresses: ::prost::alloc::vec::Vec<IpAddress>,
}
#[derive(serde::Serialize, serde::Deserialize)]
Expand Down
3 changes: 3 additions & 0 deletions wallguard-common/src/protobuf/wallguard_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ pub enum ServiceProtocol {
Https = 1,
Ssh = 2,
Tty = 3,
Rd = 4,
}
impl ServiceProtocol {
/// String value of the enum field names used in the ProtoBuf definition.
Expand All @@ -146,6 +147,7 @@ impl ServiceProtocol {
Self::Https => "HTTPS",
Self::Ssh => "SSH",
Self::Tty => "TTY",
Self::Rd => "RD",
}
}
/// Creates an enum from field names used in the ProtoBuf definition.
Expand All @@ -155,6 +157,7 @@ impl ServiceProtocol {
"HTTPS" => Some(Self::Https),
"SSH" => Some(Self::Ssh),
"TTY" => Some(Self::Tty),
"RD" => Some(Self::Rd),
_ => None,
}
}
Expand Down
2 changes: 0 additions & 2 deletions wallguard-server/src/datastore/models/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ mod device_configuration;
mod device_instance;
mod heartbeat;
mod installation_code;
mod remote_access_session;
mod service;
mod tunnel;

Expand All @@ -14,6 +13,5 @@ pub use device_configuration::*;
pub use device_instance::*;
pub use heartbeat::*;
pub use installation_code::*;
pub use remote_access_session::*;
pub use service::*;
pub use tunnel::*;
65 changes: 0 additions & 65 deletions wallguard-server/src/datastore/models/remote_access_session.rs

This file was deleted.

3 changes: 3 additions & 0 deletions wallguard-server/src/datastore/models/tunnel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ pub enum TunnelType {
Ssh,
Http,
Https,
Rd,
}

impl TryFrom<&str> for TunnelType {
Expand All @@ -24,6 +25,7 @@ impl TryFrom<&str> for TunnelType {
"http" => Ok(TunnelType::Http),
"https" => Ok(TunnelType::Https),
"tty" => Ok(TunnelType::Tty),
"rd" => Ok(TunnelType::Rd),
other => {
Err(format!("Tunnel of type {other} is not supported")).handle_err(location!())
}
Expand All @@ -38,6 +40,7 @@ impl Display for TunnelType {
TunnelType::Ssh => "ssh",
TunnelType::Http => "http",
TunnelType::Https => "https",
TunnelType::Rd => "rd",
};

f.write_str(value)
Expand Down
1 change: 0 additions & 1 deletion wallguard-server/src/datastore/operations/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ mod obtain_device;
mod obtain_installation_code;
mod obtain_service;
mod obtain_services;
mod obtain_session;
mod obtain_tunnel;
mod redeem_installation_code;
mod register_device;
Expand Down
42 changes: 0 additions & 42 deletions wallguard-server/src/datastore/operations/obtain_session.rs

This file was deleted.

2 changes: 1 addition & 1 deletion wallguard-server/src/http_api/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use config::HttpApiConfig;

mod api;
mod config;
// mod rd_gateway;
mod rd_gateway_v2;
pub mod ssh_gateway_v2;
pub mod tty_gateway_v2;
pub mod utilities;
Expand Down
89 changes: 0 additions & 89 deletions wallguard-server/src/http_api/rd_gateway/mod.rs

This file was deleted.

76 changes: 76 additions & 0 deletions wallguard-server/src/http_api/rd_gateway_v2/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
use std::time::SystemTime;
use std::time::UNIX_EPOCH;

use super::utilities::error_json::ErrorJson;
use super::utilities::request_handling;
use crate::app_context::AppContext;
use crate::datastore::TunnelStatus;
use crate::tunneling::tunnel_common::WallguardTunnel;
use actix_web::HttpRequest;
use actix_web::HttpResponse;
use actix_web::Responder;
use actix_web::rt;
use actix_web::web::{Data, Payload};

mod websocket_relay;

pub(super) async fn open_remote_desktop_session(
request: HttpRequest,
context: Data<AppContext>,
body: Payload,
) -> impl Responder {
let tunnel_id = match request_handling::extract_session_token(&request) {
Ok(tunnel_id) => tunnel_id.to_ascii_uppercase(),
Err(response) => return response,
};

let Some(WallguardTunnel::RemoteDesktop(rd_tunnel)) = context.tunnels_manager.get(&tunnel_id).await
else {
return HttpResponse::NotFound().json(ErrorJson::from("Tunnel not found"));
};

{
let mut lock = rd_tunnel.lock().await;

let timestamp = SystemTime::now()
.duration_since(UNIX_EPOCH)
.unwrap()
.as_secs();

let (date, time) = crate::utilities::time::timestamp_to_datetime(timestamp.cast_signed());
lock.data.tunnel_data.last_access_date = Some(date);
lock.data.tunnel_data.last_access_time = Some(time);

if let Ok(token) = context.sysdev_token_provider.get().await {
let _ = context
.datastore
.update_tunnel_accessed(&token.jwt, &lock.data.tunnel_data.id, false, timestamp)
.await;

let _ = context
.datastore
.update_tunnel_status(
&token.jwt,
&lock.data.tunnel_data.id,
TunnelStatus::Active,
token.account.is_root_account,
)
.await;
}
}

let (response, ws_session, stream) = match request_handling::upgrade_to_websocket(request, body)
{
Ok(r) => r,
Err(resp) => return resp,
};

rt::spawn(websocket_relay::websocket_relay(
stream,
ws_session,
ssh_tunnel,
context.into_inner(),
));

response
}
Loading
Loading