From 8e677a46dfc67382e27dac8215288f1bde10601a Mon Sep 17 00:00:00 2001 From: Eugene Pankov Date: Fri, 2 Jun 2023 09:26:52 +0200 Subject: [PATCH] lint --- warpgate-core/src/recordings/terminal.rs | 9 ++------- warpgate-protocol-http/src/proxy.rs | 7 +++---- warpgate-web/src/admin/CreateTarget.svelte | 2 +- .../src/admin/player/TerminalRecordingPlayer.svelte | 4 ++-- 4 files changed, 8 insertions(+), 14 deletions(-) diff --git a/warpgate-core/src/recordings/terminal.rs b/warpgate-core/src/recordings/terminal.rs index ec1535c..7fad959 100644 --- a/warpgate-core/src/recordings/terminal.rs +++ b/warpgate-core/src/recordings/terminal.rs @@ -19,19 +19,14 @@ pub enum AsciiCast { Output(f32, String, String), } -#[derive(Serialize, Deserialize, Debug)] +#[derive(Serialize, Deserialize, Debug, Default)] pub enum TerminalRecordingStreamId { Input, + #[default] Output, Error, } -impl Default for TerminalRecordingStreamId { - fn default() -> Self { - TerminalRecordingStreamId::Output - } -} - #[derive(Serialize, Deserialize, Debug)] #[serde(untagged)] pub enum TerminalRecordingItem { diff --git a/warpgate-protocol-http/src/proxy.rs b/warpgate-protocol-http/src/proxy.rs index 127d6fe..1811488 100644 --- a/warpgate-protocol-http/src/proxy.rs +++ b/warpgate-protocol-http/src/proxy.rs @@ -207,10 +207,9 @@ fn copy_server_request(req: &Request, mut target: B) -> B fn inject_forwarding_headers(req: &Request, mut target: B) -> Result { if let Some(host) = req.headers().get(http::header::HOST) { - target = target.header( - X_FORWARDED_HOST.clone(), - host.to_str()?.split(':').next().unwrap().to_string(), - ); + if let Some(host) = host.to_str()?.split(':').next() { + target = target.header(X_FORWARDED_HOST.clone(), host.to_string()); + } } target = target.header(X_FORWARDED_PROTO.clone(), req.scheme().as_str().to_owned()); if let Some(addr) = req.remote_addr().as_socket_addr() { diff --git a/warpgate-web/src/admin/CreateTarget.svelte b/warpgate-web/src/admin/CreateTarget.svelte index 3d43b21..9155288 100644 --- a/warpgate-web/src/admin/CreateTarget.svelte +++ b/warpgate-web/src/admin/CreateTarget.svelte @@ -6,7 +6,7 @@ import { Alert, FormGroup } from 'sveltestrap' let error: Error|null = null let name = '' -let type: 'Ssh'|'MySql'|'Http' = 'Ssh' +let type: 'Http' | 'MySql' | 'Ssh' = 'Ssh' async function create () { if (!name || !type) { diff --git a/warpgate-web/src/admin/player/TerminalRecordingPlayer.svelte b/warpgate-web/src/admin/player/TerminalRecordingPlayer.svelte index 43e4c18..13633ed 100644 --- a/warpgate-web/src/admin/player/TerminalRecordingPlayer.svelte +++ b/warpgate-web/src/admin/player/TerminalRecordingPlayer.svelte @@ -17,7 +17,7 @@ let seekInputValue = 0 let duration = 0 let resizeObserver: ResizeObserver|undefined - let events: (SizeEvent | DataEvent | SnapshotEvent)[] = [] + let events: (DataEvent | SizeEvent | SnapshotEvent)[] = [] let playing = false let loading = true let sessionIsLive: boolean|null = null @@ -67,7 +67,7 @@ } // eslint-disable-next-line @typescript-eslint/no-type-alias type AsciiCastData = [number, 'o', string] - type AsciiCastItem = AsciiCastHeader | AsciiCastData + type AsciiCastItem = AsciiCastData | AsciiCastHeader function isAsciiCastHeader (data: AsciiCastItem): data is AsciiCastHeader { return 'version' in data