From cee8c9365953b0bd7ade7eb479338805c27bc787 Mon Sep 17 00:00:00 2001 From: xenofem Date: Thu, 28 Apr 2022 01:06:39 -0400 Subject: [PATCH 1/5] Content-Security-Policy: sandbox for user-submitted files --- src/download.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/download.rs b/src/download.rs index c86d801..830e9fb 100644 --- a/src/download.rs +++ b/src/download.rs @@ -45,6 +45,7 @@ impl DownloadingFile { let mut res = HttpResponse::build(StatusCode::OK); + res.insert_header((header::CONTENT_SECURITY_POLICY, "sandbox")); res.insert_header((header::CONTENT_TYPE, mime::APPLICATION_OCTET_STREAM)); res.insert_header(( header::CONTENT_DISPOSITION, From c37fa2628963e90a6db80ebf5ab7fce092ce940f Mon Sep 17 00:00:00 2001 From: xenofem Date: Thu, 28 Apr 2022 01:29:11 -0400 Subject: [PATCH 2/5] add cargo-flamegraph to dev shell --- flake.nix | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/flake.nix b/flake.nix index b1d4057..a915975 100644 --- a/flake.nix +++ b/flake.nix @@ -51,7 +51,13 @@ packages."${name}-unwrapped" = project.rootCrate.build; devShell = pkgs.mkShell { - nativeBuildInputs = with pkgs; [ rustc cargo cargo-audit stdenv.cc ]; + nativeBuildInputs = with pkgs; [ + stdenv.cc + rustc + cargo + cargo-audit + cargo-flamegraph + ]; RUST_SRC_PATH = "${pkgs.rust.packages.stable.rustPlatform.rustLibSrc}"; }; } From 30fc8845f0b073cf49ef2ef9d5c1778c2571ffc6 Mon Sep 17 00:00:00 2001 From: xenofem Date: Thu, 28 Apr 2022 01:50:55 -0400 Subject: [PATCH 3/5] ignore flamegraph perf data --- .gitignore | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 3e42fc3..c870aac 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ /target /storage -/result \ No newline at end of file +/result +flamegraph.svg +perf.data* \ No newline at end of file From 93da22569ca1c3ab0a11e9a808d299276e72db5c Mon Sep 17 00:00:00 2001 From: xenofem Date: Thu, 28 Apr 2022 02:19:43 -0400 Subject: [PATCH 4/5] per-file progress bars --- static/transbeam.css | 6 ++++++ static/transbeam.js | 12 ++++++++++++ 2 files changed, 18 insertions(+) diff --git a/static/transbeam.css b/static/transbeam.css index 3a7402b..37d82df 100644 --- a/static/transbeam.css +++ b/static/transbeam.css @@ -31,6 +31,12 @@ table { margin: 20px auto; } +tr { + background-image: linear-gradient(0deg, #7af, #7af); + background-repeat: no-repeat; + background-size: 0; +} + tr + tr td { border-top: 1px solid #ddd; } diff --git a/static/transbeam.js b/static/transbeam.js index 340d529..e065a1c 100644 --- a/static/transbeam.js +++ b/static/transbeam.js @@ -41,6 +41,7 @@ function finishSending() { } socket.close(); progressContainer.textContent = "Upload complete!"; + fileList.style.backgroundColor = "#7af"; } function sendData() { @@ -72,6 +73,17 @@ function updateProgress() { } progress.textContent = percentage; progressBarFilled.style.width = percentage; + + const fileEntries = Array.from(fileList.children); + for (entry of fileEntries.slice(0, fileIndex)) { + entry.style.backgroundSize = "100%"; + } + if (fileIndex < files.length) { + const currentFile = files[fileIndex]; + if (currentFile.size > 0) { + fileEntries[fileIndex].style.backgroundSize = `${(byteIndex*100/currentFile.size)}%`; + } + } } function updateFiles() { From b520304a9daf9031d723820bbf689ba80cf12f6c Mon Sep 17 00:00:00 2001 From: xenofem Date: Thu, 28 Apr 2022 02:28:10 -0400 Subject: [PATCH 5/5] make overall progress bar nicer too --- static/index.html | 4 +--- static/transbeam.css | 13 +++++-------- static/transbeam.js | 6 +++--- 3 files changed, 9 insertions(+), 14 deletions(-) diff --git a/static/index.html b/static/index.html index 5728d64..c9b570e 100644 --- a/static/index.html +++ b/static/index.html @@ -21,9 +21,7 @@