Skip to content

Commit

Permalink
Async crates upgrade (#124)
Browse files Browse the repository at this point in the history
* Commented out all modules/function which require futures/tokio upgrade; Updated Cargo.toml

* async-upgrade: Updated utils.rs; Implemented async dns resolution function

* Performed refactoring on JetSink/JetStream

* Upgraded tcp transport logic to tokio 0.3

* Upgraded WebSockets transport module

* Finished JetTransport upgrade

* Managed to completely port transport module

* Upgraded proxy module to the newest tokio/futures

* Draft sequence feature futures 0.3 port

* Performed refactoring on sequence future

* Ported negotiation sequence future

* Upgraded dvc_capabilities, finalization, mcs and post_mcst sequence futures

* Upgraded nla sequence future

* Upgraded connection sequence future

* Upgraded accept_connection future

* Upgraded rdp.rs

* Upgraded http middleware, health controller and session controller

* Upgraded utils::association, http::controllers::jet

* Upgraded http module

* cargo fmt

* routing client upgrade

* Upgraded jet_client.rs to use async/await

* update websocket_client to the newest futures

* minor warnings fixes

* Fixed buildability

* async upgrade on start_websocket_server

* finished upgrade of service

* General refactoring

* Updated rustls repo

* async update on main

* build fixes

* fix tests releated bugs

* refactoring

* Updated Cargo.lock

* Fixed jet transport sink

* Fixed jet sink

* runnning gateway with a few rdp clients parallelly bugfix

* Fixed issue with ws forwarding

* Fixed AsyncWrite trait implimentation for WsStream;Fixed missing WebSocket client request processing via Saphir

* Implemented graceful shutdown for http server

* Added jetsocat to ci script, added env-dependent integration tests to
ignore

* Fixed WebSockets Jet client deadlock

* Fixed typos, removed commented code

* Applied cargo fmt:
  • Loading branch information
pacmancoder authored Dec 9, 2020
1 parent d9f4bb1 commit 27b0821
Show file tree
Hide file tree
Showing 41 changed files with 3,324 additions and 2,616 deletions.
2,213 changes: 1,389 additions & 824 deletions Cargo.lock

Large diffs are not rendered by default.

37 changes: 24 additions & 13 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,19 @@ url = "1.7.1"
url_serde = "0.2.0"
hostname = "^0.3"
lazy_static = "1.2.0"
futures = "0.1"
futures_03 = { version = "0.3", package = "futures", features = ["compat"] }
tokio = "0.1"
tokio-signal = "0.2"
rustls = { git = "https://github.com/vaffeine/rustls.git", branch = "sni_jet_workaround", features = ["dangerous_configuration"] }
tokio-rustls = "0.10.2"
tokio = { version = "0.3.4", features = ["signal", "net", "io-util", "time", "rt", "rt-multi-thread", "sync", "macros"]}
tokio_02 = {version = "0.2", package = "tokio", features = ["rt-core", "time"]}
tokio-util = { version = "0.4", features = ["codec"] }
tokio-tungstenite = { git = "https://github.com/snapview/tokio-tungstenite", rev = "3c6d4280d77fdff3e25f68ad703d94e89f38dae2", features = [ "tls" ] }
tokio-compat-02 = "0.1"
futures = "0.3"
webpki = "0.21.0"
native-tls = "0.2"
byteorder = "1.2.7"
bytes = "0.4"
bytes = "0.5"
uuid = { version = "0.7.1", features = ["v4", "serde"] }
pcap-file = "0.10.0"
packet = { git = "https://github.com/fdubois1/rust-packet.git" }
saphir = { version = "1.0.0", default-features = false, features = ["https", "request_handler"] }
serde = "1.0"
serde_derive = "1.0"
serde_json = "1.0"
Expand All @@ -48,21 +47,33 @@ failure = "0.1"
x509-parser = "0.6.0"
sspi = "0.3.0"
ironrdp = { version = "0.4.1", git = "https://github.com/Devolutions/IronRDP", rev = "ca53209c84c55b41" }
hyper = "0.12.32"
tungstenite = "0.10"
hyper = "0.13"
sha1 = "0.6.0"
base64 = "0.9.1"
slog-stdlog = "4.0"
ring = "0.16.0"
spsc-bip-buffer = { git = "https://github.com/Devolutions/spsc-bip-buffer.git", branch = "master" }
indexmap = "1.0"

[dependencies.saphir]
git = "https://github.com/Devolutions/saphir.git"
branch = "graceful-shutdown-fix"
default-features = false
features = ["https", "json", "macro", "form"]

[dependencies.tokio-rustls]
git = "https://github.com/tokio-rs/tls.git"
rev = "a517e1d0a636359c4e54b0735d7f4e73b786d2c0"
features = ["dangerous_configuration"]

[patch.crates-io.rustls]
git = "https://github.com/Devolutions/rustls.git"
branch = "v0.18.1-patched"
features = ["dangerous_configuration"]

[target.'cfg(windows)'.dependencies]
winapi = { version = "0.3", features = ["winbase", "winuser", "winsvc", "libloaderapi", "errhandlingapi", "winerror"] }

[patch.crates-io]
rustls = { git = "https://github.com/vaffeine/rustls.git", branch = "sni_jet_workaround", features = ["dangerous_configuration"] }

[target.'cfg(windows)'.build-dependencies]
embed-resource = "1.3"

Expand Down
4 changes: 4 additions & 0 deletions ci/test.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
set -ex

# Jet
cargo fmt --all -- --check
cargo clippy --all-targets --all-features -- -D warnings

Expand All @@ -9,3 +10,6 @@ cargo build --examples

cargo test -p jet-proto -p devolutions-gateway
cargo test -p jet-proto -p devolutions-gateway --release

# Jetsocat
cargo build --release --manifest-path jetsocat/Cargo.toml
10 changes: 3 additions & 7 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ impl GatewayListener {
}

Some(ListenerConfig {
internal_url: internal_url,
internal_url,
external_url,
})
}
Expand Down Expand Up @@ -276,7 +276,7 @@ fn get_default_hostname() -> Option<String> {

impl Config {
pub fn init() -> Self {
let mut config = Config::load_from_file(get_config_file_path()).unwrap_or_else(|| Config::default());
let mut config = Config::load_from_file(get_config_file_path()).unwrap_or_default();

let cli_app = App::new(crate_name!())
.author("Devolutions Inc.")
Expand Down Expand Up @@ -712,11 +712,7 @@ impl Config {

let http_listeners: Vec<ListenerConfig> = listeners
.iter()
.filter(|listener| match listener.internal_url.scheme() {
"http" => true,
"https" => true,
_ => false,
})
.filter(|listener| matches!(listener.internal_url.scheme(), "http" | "https"))
.cloned()
.collect();

Expand Down
40 changes: 16 additions & 24 deletions src/http/controllers/health.rs
Original file line number Diff line number Diff line change
@@ -1,39 +1,31 @@
use crate::config::Config;
use saphir::{Method, *};
use saphir::{
controller::Controller,
http::{Method, StatusCode},
macros::controller,
};
use std::sync::Arc;

struct ControllerData {
config: Arc<Config>,
}

pub struct HealthController {
dispatch: ControllerDispatch<ControllerData>,
config: Arc<Config>,
}

impl HealthController {
pub fn new(config: Arc<Config>) -> Self {
let dispatch = ControllerDispatch::new(ControllerData { config });
dispatch.add(Method::GET, "/", health);

HealthController { dispatch }
Self { config }
}
}

impl Controller for HealthController {
fn handle(&self, req: &mut SyncRequest, res: &mut SyncResponse) {
self.dispatch.dispatch(req, res);
}

fn base_path(&self) -> &str {
"/health"
#[controller(name = "health")]
impl HealthController {
#[get("/")]
async fn get_health(&self) -> (u16, String) {
build_health_response(&self.config)
}
}

fn health(controller: &ControllerData, _req: &SyncRequest, res: &mut SyncResponse) {
build_health_response(res, &controller.config.hostname);
}

pub fn build_health_response(res: &mut SyncResponse, hostname: &str) {
res.status(StatusCode::OK)
.body(format!("Devolutions Gateway \"{}\" is alive and healthy.", hostname));
pub fn build_health_response(config: &Config) -> (u16, String) {
let hostname = &config.hostname;
let response_body = format!("Devolutions Gateway \"{}\" is alive and healthy.", hostname);
(StatusCode::OK.as_u16(), response_body)
}
Loading

0 comments on commit 27b0821

Please sign in to comment.