From dc499e402e2ba02e63a160ea9bb1b60ec2c0d21a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Orhun=20Parmaks=C4=B1z?= Date: Thu, 11 May 2023 00:29:11 +0300 Subject: [PATCH 01/30] chore(docker): optimize docker build workflow --- .github/workflows/docker.yml | 29 +++++++++++++++++++++-------- Dockerfile | 4 +--- 2 files changed, 22 insertions(+), 11 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index a732212..2426283 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -15,14 +15,14 @@ on: jobs: docker: name: Docker Build and Push - runs-on: ubuntu-20.04 + runs-on: ubuntu-22.04 steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Docker meta id: meta - uses: docker/metadata-action@v3 + uses: docker/metadata-action@v4 with: images: | orhunp/rustypaste @@ -35,12 +35,17 @@ jobs: type=raw,value=latest type=semver,pattern={{version}} + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + with: + platforms: arm64 + - name: Set up Docker Buildx id: buildx - uses: docker/setup-buildx-action@v1 + uses: docker/setup-buildx-action@v2 - name: Cache Docker layers - uses: actions/cache@v2 + uses: actions/cache@v3 with: path: /tmp/.buildx-cache key: ${{ runner.os }}-buildx-${{ github.sha }} @@ -49,14 +54,14 @@ jobs: - name: Login to Docker Hub if: github.event_name != 'pull_request' - uses: docker/login-action@v1 + uses: docker/login-action@v2 with: username: orhunp password: ${{ secrets.DOCKER_TOKEN }} - name: Login to GHCR if: github.event_name != 'pull_request' - uses: docker/login-action@v1 + uses: docker/login-action@v2 with: registry: ghcr.io username: ${{ github.repository_owner }} @@ -64,16 +69,24 @@ jobs: - name: Build and push id: docker_build - uses: docker/build-push-action@v2 + uses: docker/build-push-action@v4 with: context: ./ file: ./Dockerfile + platforms: linux/amd64,linux/arm64 builder: ${{ steps.buildx.outputs.name }} push: ${{ github.event_name != 'pull_request' }} tags: ${{ steps.meta.outputs.tags }} + sbom: true + provenance: true labels: ${{ steps.meta.outputs.labels }} cache-from: type=local,src=/tmp/.buildx-cache cache-to: type=local,dest=/tmp/.buildx-cache + - name: Scan the image + uses: anchore/sbom-action@v0 + with: + image: ghcr.io/${{ github.repository_owner }}/rustypaste/rustypaste + - name: Image digest run: echo ${{ steps.docker_build.outputs.digest }} diff --git a/Dockerfile b/Dockerfile index a1bf304..b15eb8b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -14,9 +14,7 @@ RUN cp target/release/rustypaste build-out/ FROM scratch WORKDIR /app -COPY --from=builder \ - /app/build-out/rustypaste \ - /app/config.toml ./ +COPY --from=builder /app/build-out/rustypaste . ENV SERVER__ADDRESS=0.0.0.0:8000 EXPOSE 8000 USER 1000:1000 From d82e99c1288fece69b18c6bc5d78517a670fa1ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Orhun=20Parmaks=C4=B1z?= Date: Thu, 11 May 2023 00:39:04 +0300 Subject: [PATCH 02/30] chore(deps): upgrade dependencies --- Cargo.lock | 639 ++++++++++++++++++++++++++++++++++++----------------- Cargo.toml | 22 +- 2 files changed, 443 insertions(+), 218 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 634eec6..f243b31 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -44,16 +44,16 @@ dependencies = [ [[package]] name = "actix-http" -version = "3.3.0" +version = "3.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0070905b2c4a98d184c4e81025253cb192aa8a73827553f38e9410801ceb35bb" +checksum = "c2079246596c18b4a33e274ae10c0e50613f4d32a4198e09c7b93771013fed74" dependencies = [ "actix-codec", "actix-rt", "actix-service", "actix-tls", "actix-utils", - "ahash", + "ahash 0.8.3", "base64", "bitflags", "brotli", @@ -89,25 +89,45 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "465a6172cf69b960917811022d8f29bc0b7fa1398bc4f78b3c466673db1213b6" dependencies = [ "quote", - "syn", + "syn 1.0.109", ] [[package]] name = "actix-multipart" -version = "0.5.0" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5011f5be460e35a5b82e1745c0ea0c6293e8f8d38bbaa1f0455afcff5b454ad6" +checksum = "dee489e3c01eae4d1c35b03c4493f71cb40d93f66b14558feb1b1a807671cc4e" dependencies = [ + "actix-multipart-derive", "actix-utils", "actix-web", "bytes", "derive_more", "futures-core", + "futures-util", "httparse", "local-waker", "log", "memchr", "mime", + "serde", + "serde_json", + "serde_plain", + "tempfile", + "tokio", +] + +[[package]] +name = "actix-multipart-derive" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2ec592f234db8a253cf80531246a4407c8a70530423eea80688a6c5a44a110e7" +dependencies = [ + "darling", + "parse-size", + "proc-macro2", + "quote", + "syn 1.0.109", ] [[package]] @@ -145,7 +165,7 @@ dependencies = [ "actix-utils", "futures-core", "futures-util", - "mio 0.8.5", + "mio 0.8.6", "num_cpus", "socket2", "tokio", @@ -194,9 +214,9 @@ dependencies = [ [[package]] name = "actix-web" -version = "4.3.0" +version = "4.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "464e0fddc668ede5f26ec1f9557a8d44eda948732f40c6b0ad79126930eb775f" +checksum = "cd3cb42f9566ab176e1ef0b8b3a896529062b4efc6be0123046095914c4c1c96" dependencies = [ "actix-codec", "actix-http", @@ -208,7 +228,7 @@ dependencies = [ "actix-tls", "actix-utils", "actix-web-codegen", - "ahash", + "ahash 0.7.6", "bytes", "bytestring", "cfg-if 1.0.0", @@ -236,14 +256,14 @@ dependencies = [ [[package]] name = "actix-web-codegen" -version = "4.1.0" +version = "4.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1fa9362663c8643d67b2d5eafba49e4cb2c8a053a29ed00a0bea121f17c76b13" +checksum = "2262160a7ae29e3415554a3f1fc04c764b1540c116aa524683208078b7a75bc9" dependencies = [ "actix-router", "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -264,10 +284,22 @@ dependencies = [ ] [[package]] -name = "aho-corasick" -version = "0.7.20" +name = "ahash" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc936419f96fa211c1b9166887b38e5e40b19958e5b895be7c1f93adec7071ac" +checksum = "2c99f64d1e06488f620f932677e24bc6e2897582980441ae90a671415bd7ec2f" +dependencies = [ + "cfg-if 1.0.0", + "getrandom", + "once_cell", + "version_check", +] + +[[package]] +name = "aho-corasick" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67fc08ce920c31afb70f013dcce1bfc3a3195de6a228474e45e1f145b36f8d04" dependencies = [ "memchr", ] @@ -295,13 +327,13 @@ checksum = "619743e34b5ba4e9703bba34deac3427c72507c7159f5fd030aea8cac0cfe341" [[package]] name = "async-trait" -version = "0.1.64" +version = "0.1.68" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1cd7fce9ba8c3c042128ce72d8b2ddbf3a05747efb67ea0313c635e10bda47a2" +checksum = "b9ccdd8f2a161be9bd5c023df56f1b2a0bd1d83872ae53b71a84a12c9bf6e842" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.15", ] [[package]] @@ -312,9 +344,9 @@ checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" [[package]] name = "awc" -version = "3.1.0" +version = "3.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0dff3fc64a176e0d4398c71b0f2c2679ff4a723c6ed8fcc68dfe5baa00665388" +checksum = "87ef547a81796eb2dfe9b345aba34c2e08391a0502493711395b36dd64052b69" dependencies = [ "actix-codec", "actix-http", @@ -322,7 +354,7 @@ dependencies = [ "actix-service", "actix-tls", "actix-utils", - "ahash", + "ahash 0.7.6", "base64", "bytes", "cfg-if 1.0.0", @@ -359,9 +391,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "block-buffer" -version = "0.10.3" +version = "0.10.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "69cce20737498f97b993470a6e536b8523f0af7892a4f928cceb1ac5e52ebe7e" +checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" dependencies = [ "generic-array", ] @@ -389,15 +421,15 @@ dependencies = [ [[package]] name = "bumpalo" -version = "3.12.0" +version = "3.12.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d261e256854913907f67ed06efbc3338dfe6179796deefc1ff763fc1aee5535" +checksum = "3c6ed94e98ecff0c12dd1b04c15ec0d7d9458ca8fe806cea6f12954efe74c63b" [[package]] name = "byte-unit" -version = "4.0.18" +version = "4.0.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3348673602e04848647fffaa8e9a861e7b5d5cae6570727b41bde0f722514484" +checksum = "da78b32057b8fdfc352504708feeba7216dcd65a2c9ab02978cbd288d1279b6c" dependencies = [ "serde", "utf8-width", @@ -405,15 +437,15 @@ dependencies = [ [[package]] name = "bytes" -version = "1.3.0" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dfb24e866b15a1af2a1b663f10c6b6b8f397a84aadb828f12e5b289ec23a3a3c" +checksum = "89b2fd2a0dcf38d7971e2194b6b6eebab45ae01067456a7fd93d5547a61b70be" [[package]] name = "bytestring" -version = "1.2.0" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7f83e57d9154148e355404702e2694463241880b939570d7c97c014da7a69a1" +checksum = "238e4886760d98c4f899360c834fa93e62cf7f721ac3c2da375cbdf4b8679aae" dependencies = [ "bytes", ] @@ -473,9 +505,9 @@ dependencies = [ [[package]] name = "cpufeatures" -version = "0.2.5" +version = "0.2.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28d997bd5e24a5928dd43e46dc529867e207907fe0b239c3477d924f7f2ca320" +checksum = "3e4c1eaa2012c47becbbad2ab175484c2a84d1185b566fb2cc5b8707343dfe58" dependencies = [ "libc", ] @@ -499,6 +531,41 @@ dependencies = [ "typenum", ] +[[package]] +name = "darling" +version = "0.14.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b750cb3417fd1b327431a470f388520309479ab0bf5e323505daf0290cd3850" +dependencies = [ + "darling_core", + "darling_macro", +] + +[[package]] +name = "darling_core" +version = "0.14.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "109c1ca6e6b7f82cc233a97004ea8ed7ca123a9af07a8230878fcfda9b158bf0" +dependencies = [ + "fnv", + "ident_case", + "proc-macro2", + "quote", + "strsim", + "syn 1.0.109", +] + +[[package]] +name = "darling_macro" +version = "0.14.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4aab4dbc9f7611d8b55048a3a16d2d010c2c8334e46304b40ac1cc14bf3b48e" +dependencies = [ + "darling_core", + "quote", + "syn 1.0.109", +] + [[package]] name = "derive_more" version = "0.99.17" @@ -509,7 +576,7 @@ dependencies = [ "proc-macro2", "quote", "rustc_version", - "syn", + "syn 1.0.109", ] [[package]] @@ -524,9 +591,9 @@ dependencies = [ [[package]] name = "dotenvy" -version = "0.15.6" +version = "0.15.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03d8c417d7a8cb362e0c37e5d815f5eb7c37f79ff93707329d5a194e42e54ca0" +checksum = "1aaf95b3e5c8f23aa320147307562d361db0ae0d51242340f558153b4eb2439b" [[package]] name = "either" @@ -536,9 +603,9 @@ checksum = "7fcaabb2fef8c910e7f4c7ce9f67a1283a1715879a7c230ca9d6d1ae31f16d91" [[package]] name = "encoding_rs" -version = "0.8.31" +version = "0.8.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9852635589dc9f9ea1b6fe9f05b50ef208c85c834a562f0c6abb1c475736ec2b" +checksum = "071a31f4ee85403370b58aca746f01041ede6f0da2730960ad001edc2b71b394" dependencies = [ "cfg-if 1.0.0", ] @@ -558,13 +625,13 @@ dependencies = [ [[package]] name = "errno" -version = "0.2.8" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f639046355ee4f37944e44f60642c6f3a7efa3cf6b78c78a0d989a8ce6c396a1" +checksum = "4bcfec3a70f97c962c307b2d2c56e358cf1d00b558d74262b5f929ee8cc7e73a" dependencies = [ "errno-dragonfly", "libc", - "winapi 0.3.9", + "windows-sys 0.48.0", ] [[package]] @@ -578,22 +645,31 @@ dependencies = [ ] [[package]] -name = "filetime" -version = "0.2.19" +name = "fastrand" +version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e884668cd0c7480504233e951174ddc3b382f7c2666e3b7310b5c4e7b0c37f9" +checksum = "e51093e27b0797c359783294ca4f0a911c270184cb10f85783b118614a1501be" +dependencies = [ + "instant", +] + +[[package]] +name = "filetime" +version = "0.2.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5cbc844cecaee9d4443931972e1289c8ff485cb4cc2767cb03ca139ed6885153" dependencies = [ "cfg-if 1.0.0", "libc", - "redox_syscall", - "windows-sys", + "redox_syscall 0.2.16", + "windows-sys 0.48.0", ] [[package]] name = "flate2" -version = "1.0.25" +version = "1.0.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8a2db397cb1c8772f31494cb8917e48cd1e64f0fa7efac59fbd741a0a8ce841" +checksum = "3b9429470923de8e8cbd4d2dc513535400b4b3fef0319fb5c4e1f520a7bef743" dependencies = [ "crc32fast", "miniz_oxide", @@ -651,38 +727,38 @@ checksum = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7" [[package]] name = "futures-core" -version = "0.3.26" +version = "0.3.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec90ff4d0fe1f57d600049061dc6bb68ed03c7d2fbd697274c41805dcb3f8608" +checksum = "4bca583b7e26f571124fe5b7561d49cb2868d79116cfa0eefce955557c6fee8c" [[package]] name = "futures-macro" -version = "0.3.26" +version = "0.3.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95a73af87da33b5acf53acfebdc339fe592ecf5357ac7c0a7734ab9d8c876a70" +checksum = "89ca545a94061b6365f2c7355b4b32bd20df3ff95f02da9329b34ccc3bd6ee72" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.15", ] [[package]] name = "futures-sink" -version = "0.3.26" +version = "0.3.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f310820bb3e8cfd46c80db4d7fb8353e15dfff853a127158425f31e0be6c8364" +checksum = "f43be4fe21a13b9781a69afa4985b0f6ee0e1afab2c6f454a8cf30e2b2237b6e" [[package]] name = "futures-task" -version = "0.3.26" +version = "0.3.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dcf79a1bf610b10f42aea489289c5a2c478a786509693b80cd39c44ccd936366" +checksum = "76d3d132be6c0e6aa1534069c705a74a5997a356c0dc2f86a47765e5617c5b65" [[package]] name = "futures-util" -version = "0.3.26" +version = "0.3.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c1d6de3acfef38d2be4b1f543f553131788603495be83da675e180c8d6b7bd1" +checksum = "26b01e40b772d54cf6c6d721c1d1abd0647a0106a12ecaa1c186273392a69533" dependencies = [ "futures-core", "futures-macro", @@ -695,9 +771,9 @@ dependencies = [ [[package]] name = "generic-array" -version = "0.14.6" +version = "0.14.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bff49e947297f3312447abdca79f45f4738097cc82b06e72054d2223f601f1b9" +checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" dependencies = [ "typenum", "version_check", @@ -705,9 +781,9 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.8" +version = "0.2.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c05aeb6a22b8f62540c194aac980f2115af067bfe15a0734d7277a768d396b31" +checksum = "c85e1d9ab2eadba7e5040d4e09cbd6d072b76a557ad64e797c2cb9d4da21d7e4" dependencies = [ "cfg-if 1.0.0", "libc", @@ -722,9 +798,9 @@ checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" [[package]] name = "h2" -version = "0.3.15" +version = "0.3.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f9f29bc9dda355256b2916cf526ab02ce0aeaaaf2bad60d65ef3f12f11dd0f4" +checksum = "17f8a914c2987b688368b5138aa05321db91f4090cf26118185672ad588bce21" dependencies = [ "bytes", "fnv", @@ -754,6 +830,12 @@ dependencies = [ "libc", ] +[[package]] +name = "hermit-abi" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fed44880c466736ef9a5c5b5facefb5ed0785676d0c02d612db14e54f0d84286" + [[package]] name = "hotwatch" version = "0.4.6" @@ -766,9 +848,9 @@ dependencies = [ [[package]] name = "http" -version = "0.2.8" +version = "0.2.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75f43d41e26995c17e71ee126451dd3941010b0514a81a9d11f3b341debc2399" +checksum = "bd6effc99afb63425aff9b05836f029929e345a6148a14b7ecd5ab67af944482" dependencies = [ "bytes", "fnv", @@ -809,6 +891,12 @@ dependencies = [ "serde", ] +[[package]] +name = "ident_case" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" + [[package]] name = "idna" version = "0.3.0" @@ -821,9 +909,9 @@ dependencies = [ [[package]] name = "indexmap" -version = "1.9.2" +version = "1.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1885e79c1fc4b10f0e172c475f458b7f7b93061064d98c3293e98c5ba0c8b399" +checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99" dependencies = [ "autocfg", "hashbrown", @@ -831,9 +919,9 @@ dependencies = [ [[package]] name = "infer" -version = "0.12.0" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a898e4b7951673fce96614ce5751d13c40fc5674bc2d759288e46c3ab62598b3" +checksum = "f551f8c3a39f68f986517db0d1759de85881894fdc7db798bd2a9df9cb04b7fc" [[package]] name = "inotify" @@ -856,13 +944,23 @@ dependencies = [ ] [[package]] -name = "io-lifetimes" -version = "1.0.4" +name = "instant" +version = "0.1.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7d6c6f8c91b4b9ed43484ad1a938e393caf35960fce7f82a040497207bd8e9e" +checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c" dependencies = [ + "cfg-if 1.0.0", +] + +[[package]] +name = "io-lifetimes" +version = "1.0.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c66c74d2ae7e79a5a8f7ac924adbe38ee42a859c6539ad869eb51f0b52dc220" +dependencies = [ + "hermit-abi 0.3.1", "libc", - "windows-sys", + "windows-sys 0.48.0", ] [[package]] @@ -876,14 +974,14 @@ dependencies = [ [[package]] name = "is-terminal" -version = "0.4.2" +version = "0.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28dfb6c8100ccc63462345b67d1bbc3679177c75ee4bf59bf29c8b1d110b8189" +checksum = "adcf93614601c8129ddf72e2d5633df827ba6551541c6d8c59520a371475be1f" dependencies = [ - "hermit-abi", + "hermit-abi 0.3.1", "io-lifetimes", "rustix", - "windows-sys", + "windows-sys 0.48.0", ] [[package]] @@ -897,24 +995,24 @@ dependencies = [ [[package]] name = "itoa" -version = "1.0.5" +version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fad582f4b9e86b6caa621cabeb0963332d92eea04729ab12892c2533951e6440" +checksum = "453ad9f582a441959e5f0d088b02ce04cfe8d51a8eaf077f12ac6d3e94164ca6" [[package]] name = "jobserver" -version = "0.1.25" +version = "0.1.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "068b1ee6743e4d11fb9c6a1e6064b3693a1b600e7f5f5988047d98b3dc9fb90b" +checksum = "936cfd212a0155903bcbc060e316fb6cc7cbf2e1907329391ebadc1fe0ce77c2" dependencies = [ "libc", ] [[package]] name = "js-sys" -version = "0.3.60" +version = "0.3.62" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49409df3e3bf0856b916e2ceaca09ee28e6871cf7d9ce97a692cacfdb2a25a47" +checksum = "68c16e1bfd491478ab155fd8b4896b86f9ede344949b641e61501e07c2b8b4d5" dependencies = [ "wasm-bindgen", ] @@ -937,9 +1035,9 @@ checksum = "d4345964bb142484797b161f473a503a434de77149dd8c7427788c6e13379388" [[package]] name = "lazy-regex" -version = "2.4.1" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a505da2f89befd87ab425d252795f0f285e100b43e7d22d29528df3d9a576793" +checksum = "ff63c423c68ea6814b7da9e88ce585f793c87ddd9e78f646970891769c8235d4" dependencies = [ "lazy-regex-proc_macros", "once_cell", @@ -955,7 +1053,7 @@ dependencies = [ "proc-macro2", "quote", "regex", - "syn", + "syn 1.0.109", ] [[package]] @@ -972,9 +1070,9 @@ checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" [[package]] name = "libc" -version = "0.2.139" +version = "0.2.144" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "201de327520df007757c1f0adce6e827fe8562fbc28bfd9c15571c66ca1f5f79" +checksum = "2b00cc1c228a6782d0f076e7b232802e0c5689d41bb5df366f2a6b6621cfdfe1" [[package]] name = "linked-hash-map" @@ -984,9 +1082,9 @@ checksum = "0717cef1bc8b636c6e1c1bbdefc09e6322da8a9321966e8928ef80d20f7f770f" [[package]] name = "linux-raw-sys" -version = "0.1.4" +version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f051f77a7c8e6957c0696eac88f26b0117e54f52d3fc682ab19397a8812846a4" +checksum = "ece97ea872ece730aed82664c424eb4c8291e1ff2480247ccf7409044bc6479f" [[package]] name = "local-channel" @@ -1033,9 +1131,9 @@ checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" [[package]] name = "mime" -version = "0.3.16" +version = "0.3.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a60c7ce501c71e03a9c9c0d35b861413ae925bd979cc7a4e30d060069aaac8d" +checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" [[package]] name = "mime_guess" @@ -1055,9 +1153,9 @@ checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" [[package]] name = "miniz_oxide" -version = "0.6.2" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b275950c28b37e794e8c55d88aeb5e139d0ce23fdbbeda68f8d7174abdf9e8fa" +checksum = "e7810e0be55b428ada41041c41f32c9f1a42817901b4ccf45fa3d4b6561e74c7" dependencies = [ "adler", ] @@ -1083,14 +1181,14 @@ dependencies = [ [[package]] name = "mio" -version = "0.8.5" +version = "0.8.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5d732bc30207a6423068df043e3d02e0735b155ad7ce1a6f76fe2baa5b158de" +checksum = "5b9d9a46eff5b4ff64b45a9e316a6d1e0bc719ef429cbec4dc630684212bfdf9" dependencies = [ "libc", "log", "wasi", - "windows-sys", + "windows-sys 0.45.0", ] [[package]] @@ -1162,15 +1260,15 @@ version = "1.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0fac9e2da13b5eb447a6ce3d392f23a29d8694bff781bf03a16cd9ac8697593b" dependencies = [ - "hermit-abi", + "hermit-abi 0.2.6", "libc", ] [[package]] name = "once_cell" -version = "1.17.0" +version = "1.17.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f61fba1741ea2b3d6a1e3178721804bb716a68a6aeba1149b5d52e3d464ea66" +checksum = "b7e5500299e16ebb147ae15a00a942af264cf3688f47923b8fc2cd5858f23ad3" [[package]] name = "parking_lot" @@ -1184,22 +1282,28 @@ dependencies = [ [[package]] name = "parking_lot_core" -version = "0.9.6" +version = "0.9.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba1ef8814b5c993410bb3adfad7a5ed269563e4a2f90c41f5d85be7fb47133bf" +checksum = "9069cbb9f99e3a5083476ccb29ceb1de18b9118cafa53e90c9551235de2b9521" dependencies = [ "cfg-if 1.0.0", "libc", - "redox_syscall", + "redox_syscall 0.2.16", "smallvec", - "windows-sys", + "windows-sys 0.45.0", ] [[package]] -name = "paste" -version = "1.0.11" +name = "parse-size" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d01a5bd0424d00070b0098dd17ebca6f961a959dead1dbcbbbc1d1cd8d3deeba" +checksum = "944553dd59c802559559161f9816429058b869003836120e262e8caec061b7ae" + +[[package]] +name = "paste" +version = "1.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9f746c4065a8fa3fe23974dd82f15431cc8d40779821001404d10d2e79ca7d79" [[package]] name = "pathdiff" @@ -1237,9 +1341,9 @@ checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" [[package]] name = "pkg-config" -version = "0.3.26" +version = "0.3.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ac9a59f73473f1b8d852421e59e64809f025994837ef743615c6d0c5b305160" +checksum = "26072860ba924cbfa98ea39c8c19b4dd6a4a25423dbdf219c1eca91aa0cf6964" [[package]] name = "ppv-lite86" @@ -1249,18 +1353,18 @@ checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" [[package]] name = "proc-macro2" -version = "1.0.50" +version = "1.0.56" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ef7d57beacfaf2d8aee5937dab7b7f28de3cb8b1828479bb5de2a7106f2bae2" +checksum = "2b63bdb0cd06f1f4dedf69b254734f9b45af66e4a031e42a7480257d9898b435" dependencies = [ "unicode-ident", ] [[package]] name = "quote" -version = "1.0.23" +version = "1.0.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8856d8364d252a14d474036ea1358d63c9e6965c8e5c1885c18f73d70bff9c7b" +checksum = "8f4f29d145265ec1c483c7c654450edde0bfe043d3938d6972630663356d9500" dependencies = [ "proc-macro2", ] @@ -1305,10 +1409,19 @@ dependencies = [ ] [[package]] -name = "regex" -version = "1.7.1" +name = "redox_syscall" +version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "48aaa5748ba571fb95cd2c85c09f629215d3a6ece942baa100950af03a34f733" +checksum = "567664f262709473930a4bf9e51bf2ebf3348f2e748ccc50dea20646858f8f29" +dependencies = [ + "bitflags", +] + +[[package]] +name = "regex" +version = "1.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "af83e617f331cc6ae2da5443c602dfa5af81e517212d9d611a5b3ba1777b5370" dependencies = [ "aho-corasick", "memchr", @@ -1317,9 +1430,9 @@ dependencies = [ [[package]] name = "regex-syntax" -version = "0.6.28" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "456c603be3e8d448b072f410900c09faf164fbce2d480456f50eea6e25f9c848" +checksum = "a5996294f19bd3aae0453a862ad728f60e6600695733dd5df01da90c54363a3c" [[package]] name = "ring" @@ -1347,16 +1460,16 @@ dependencies = [ [[package]] name = "rustix" -version = "0.36.7" +version = "0.37.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d4fdebc4b395b7fbb9ab11e462e20ed9051e7b16e42d24042c776eca0ac81b03" +checksum = "acf8729d8542766f1b2cf77eb034d52f40d375bb8b615d0b147089946e16613d" dependencies = [ "bitflags", "errno", "io-lifetimes", "libc", "linux-raw-sys", - "windows-sys", + "windows-sys 0.48.0", ] [[package]] @@ -1404,9 +1517,9 @@ dependencies = [ [[package]] name = "ryu" -version = "1.0.12" +version = "1.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b4b9743ed687d4b4bcedf9ff5eaa7398495ae14e61cba0a295704edbc7decde" +checksum = "f91339c0467de62360649f8d3e185ca8de4224ff281f66000de5eb2a77a79041" [[package]] name = "same-file" @@ -1435,41 +1548,50 @@ dependencies = [ [[package]] name = "semver" -version = "1.0.16" +version = "1.0.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "58bc9567378fc7690d6b2addae4e60ac2eeea07becb2c64b9f218b53865cba2a" +checksum = "bebd363326d05ec3e2f532ab7660680f3b02130d780c299bca73469d521bc0ed" [[package]] name = "serde" -version = "1.0.152" +version = "1.0.162" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb7d1f0d3021d347a83e556fc4683dea2ea09d87bccdf88ff5c12545d89d5efb" +checksum = "71b2f6e1ab5c2b98c05f0f35b236b22e8df7ead6ffbf51d7808da7f8817e7ab6" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.152" +version = "1.0.162" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af487d118eecd09402d70a5d72551860e788df87b464af30e5ea6a38c75c541e" +checksum = "a2a0814352fd64b58489904a44ea8d90cb1a91dcb6b4f5ebabc32c8318e93cb6" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.15", ] [[package]] name = "serde_json" -version = "1.0.91" +version = "1.0.96" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "877c235533714907a8c2464236f5c4b2a17262ef1bd71f38f35ea592c8da6883" +checksum = "057d394a50403bcac12672b2b18fb387ab6d289d957dab67dd201875391e52f1" dependencies = [ "itoa", "ryu", "serde", ] +[[package]] +name = "serde_plain" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d6018081315db179d0ce57b1fe4b62a12a0028c9cf9bbef868c9cf477b3c34ae" +dependencies = [ + "serde", +] + [[package]] name = "serde_regex" version = "1.1.0" @@ -1505,18 +1627,18 @@ dependencies = [ [[package]] name = "signal-hook-registry" -version = "1.4.0" +version = "1.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e51e73328dc4ac0c7ccbda3a494dfa03df1de2f46018127f60c693f2648455b0" +checksum = "d8229b473baa5980ac72ef434c4415e70c4b5e71b423043adb4ba059f89c99a1" dependencies = [ "libc", ] [[package]] name = "slab" -version = "0.4.7" +version = "0.4.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4614a76b2a8be0058caa9dbbaf66d988527d86d003c11a94fbd335d7661edcef" +checksum = "6528351c9bc8ab22353f9d776db39a20288e8d6c37ef8cfe3317cf875eecfc2d" dependencies = [ "autocfg", ] @@ -1529,9 +1651,9 @@ checksum = "a507befe795404456341dfab10cef66ead4c041f62b8b11bbb92bffe5d0953e0" [[package]] name = "socket2" -version = "0.4.7" +version = "0.4.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02e2d2db9033d13a1567121ddd7a095ee144db4e1ca1b1bda3419bc0da294ebd" +checksum = "64a4a911eed85daf18834cfaa86a79b7d266ff93ff5ba14005426219480ed662" dependencies = [ "libc", "winapi 0.3.9", @@ -1544,16 +1666,46 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d" [[package]] -name = "syn" -version = "1.0.107" +name = "strsim" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f4064b5b16e03ae50984a5a8ed5d4f8803e6bc1fd170a3cda91a1be4b18e3f5" +checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" + +[[package]] +name = "syn" +version = "1.0.109" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" dependencies = [ "proc-macro2", "quote", "unicode-ident", ] +[[package]] +name = "syn" +version = "2.0.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a34fcf3e8b60f57e6a14301a2e916d323af98b0ea63c599441eec8558660c822" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "tempfile" +version = "3.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9fbec84f381d5795b08656e4912bec604d162bff9291d6189a78f4c8ab87998" +dependencies = [ + "cfg-if 1.0.0", + "fastrand", + "redox_syscall 0.3.5", + "rustix", + "windows-sys 0.45.0", +] + [[package]] name = "termcolor" version = "1.2.0" @@ -1565,9 +1717,9 @@ dependencies = [ [[package]] name = "time" -version = "0.3.17" +version = "0.3.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a561bf4617eebd33bca6434b988f39ed798e527f51a1e797d0ee4f61c0a38376" +checksum = "8f3403384eaacbca9923fa06940178ac13e4edb725486d70e8e15881d0c836cc" dependencies = [ "itoa", "serde", @@ -1577,15 +1729,15 @@ dependencies = [ [[package]] name = "time-core" -version = "0.1.0" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2e153e1f1acaef8acc537e68b44906d2db6436e2b35ac2c6b42640fff91f00fd" +checksum = "7300fbefb4dadc1af235a9cef3737cea692a9d97e1b9cbcd4ebdae6f8868e6fb" [[package]] name = "time-macros" -version = "0.2.6" +version = "0.2.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d967f99f534ca7e495c575c62638eebc2898a8c84c119b89e250477bc4ba16b2" +checksum = "372950940a5f07bf38dbe211d7283c9e6d7327df53794992d293e534c733d09b" dependencies = [ "time-core", ] @@ -1601,26 +1753,25 @@ dependencies = [ [[package]] name = "tinyvec_macros" -version = "0.1.0" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c" +checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.25.0" +version = "1.28.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8e00990ebabbe4c14c08aca901caed183ecd5c09562a12c824bb53d3c3fd3af" +checksum = "0aa32867d44e6f2ce3385e89dceb990188b8bb0fb25b0cf576647a6f98ac5105" dependencies = [ "autocfg", "bytes", "libc", - "memchr", - "mio 0.8.5", + "mio 0.8.6", "parking_lot", "pin-project-lite", "signal-hook-registry", "socket2", - "windows-sys", + "windows-sys 0.48.0", ] [[package]] @@ -1636,9 +1787,9 @@ dependencies = [ [[package]] name = "tokio-util" -version = "0.7.4" +version = "0.7.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0bb2e075f03b3d66d8d8785356224ba688d2906a371015e225beeb65ca92c740" +checksum = "806fe8c2c87eccc8b3267cbae29ed3ab2d0bd37fca70ab622e46aaa9375ddb7d" dependencies = [ "bytes", "futures-core", @@ -1695,15 +1846,15 @@ dependencies = [ [[package]] name = "unicode-bidi" -version = "0.3.10" +version = "0.3.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d54675592c1dbefd78cbd98db9bacd89886e1ca50692a0692baefffdeb92dd58" +checksum = "92888ba5573ff080736b3648696b70cafad7d250551175acbaa4e0385b3e1460" [[package]] name = "unicode-ident" -version = "1.0.6" +version = "1.0.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "84a22b9f218b40614adcb3f4ff08b703773ad44fa9423e4e0d346d5db86e4ebc" +checksum = "e5464a87b239f13a63a501f2701565754bae92d243d4bb7eb12f6d57d2269bf4" [[package]] name = "unicode-normalization" @@ -1745,12 +1896,11 @@ checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" [[package]] name = "walkdir" -version = "2.3.2" +version = "2.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "808cf2735cd4b6866113f648b791c6adc5714537bc222d9347bb203386ffda56" +checksum = "36df944cda56c7d8d8b7496af378e6b16de9284591917d307c9b4d313c44e698" dependencies = [ "same-file", - "winapi 0.3.9", "winapi-util", ] @@ -1762,9 +1912,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm-bindgen" -version = "0.2.83" +version = "0.2.85" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eaf9f5aceeec8be17c128b2e93e031fb8a4d469bb9c4ae2d7dc1888b26887268" +checksum = "5b6cb788c4e39112fbe1822277ef6fb3c55cd86b95cb3d3c4c1c9597e4ac74b4" dependencies = [ "cfg-if 1.0.0", "wasm-bindgen-macro", @@ -1772,24 +1922,24 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.83" +version = "0.2.85" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c8ffb332579b0557b52d268b91feab8df3615f265d5270fec2a8c95b17c1142" +checksum = "35e522ed4105a9d626d885b35d62501b30d9666283a5c8be12c14a8bdafe7822" dependencies = [ "bumpalo", "log", "once_cell", "proc-macro2", "quote", - "syn", + "syn 2.0.15", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-macro" -version = "0.2.83" +version = "0.2.85" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "052be0f94026e6cbc75cdefc9bae13fd6052cdcaf532fa6c45e7ae33a1e6c810" +checksum = "358a79a0cb89d21db8120cbfb91392335913e4890665b1a7981d9e956903b434" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -1797,28 +1947,28 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.83" +version = "0.2.85" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07bc0c051dc5f23e307b13285f9d75df86bfdf816c5721e573dec1f9b8aa193c" +checksum = "4783ce29f09b9d93134d41297aded3a712b7b979e9c6f28c32cb88c973a94869" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.15", "wasm-bindgen-backend", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-shared" -version = "0.2.83" +version = "0.2.85" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c38c045535d93ec4f0b4defec448e4291638ee608530863b1e2ba115d4fff7f" +checksum = "a901d592cafaa4d711bc324edfaff879ac700b19c3dfd60058d2b445be2691eb" [[package]] name = "web-sys" -version = "0.3.60" +version = "0.3.62" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bcda906d8be16e728fd5adc5b729afad4e444e106ab28cd1c7256e54fa61510f" +checksum = "16b5f940c7edfdc6d12126d98c9ef4d1b3d470011c47c76a6581df47ad9ba721" dependencies = [ "js-sys", "wasm-bindgen", @@ -1888,60 +2038,135 @@ checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" [[package]] name = "windows-sys" -version = "0.42.0" +version = "0.45.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a3e1820f08b8513f676f7ab6c1f99ff312fb97b553d30ff4dd86f9f15728aa7" +checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0" dependencies = [ - "windows_aarch64_gnullvm", - "windows_aarch64_msvc", - "windows_i686_gnu", - "windows_i686_msvc", - "windows_x86_64_gnu", - "windows_x86_64_gnullvm", - "windows_x86_64_msvc", + "windows-targets 0.42.2", +] + +[[package]] +name = "windows-sys" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" +dependencies = [ + "windows-targets 0.48.0", +] + +[[package]] +name = "windows-targets" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e5180c00cd44c9b1c88adb3693291f1cd93605ded80c250a75d472756b4d071" +dependencies = [ + "windows_aarch64_gnullvm 0.42.2", + "windows_aarch64_msvc 0.42.2", + "windows_i686_gnu 0.42.2", + "windows_i686_msvc 0.42.2", + "windows_x86_64_gnu 0.42.2", + "windows_x86_64_gnullvm 0.42.2", + "windows_x86_64_msvc 0.42.2", +] + +[[package]] +name = "windows-targets" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b1eb6f0cd7c80c79759c929114ef071b87354ce476d9d94271031c0497adfd5" +dependencies = [ + "windows_aarch64_gnullvm 0.48.0", + "windows_aarch64_msvc 0.48.0", + "windows_i686_gnu 0.48.0", + "windows_i686_msvc 0.48.0", + "windows_x86_64_gnu 0.48.0", + "windows_x86_64_gnullvm 0.48.0", + "windows_x86_64_msvc 0.48.0", ] [[package]] name = "windows_aarch64_gnullvm" -version = "0.42.1" +version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c9864e83243fdec7fc9c5444389dcbbfd258f745e7853198f365e3c4968a608" +checksum = "597a5118570b68bc08d8d59125332c54f1ba9d9adeedeef5b99b02ba2b0698f8" + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91ae572e1b79dba883e0d315474df7305d12f569b400fcf90581b06062f7e1bc" [[package]] name = "windows_aarch64_msvc" -version = "0.42.1" +version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c8b1b673ffc16c47a9ff48570a9d85e25d265735c503681332589af6253c6c7" +checksum = "e08e8864a60f06ef0d0ff4ba04124db8b0fb3be5776a5cd47641e942e58c4d43" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2ef27e0d7bdfcfc7b868b317c1d32c641a6fe4629c171b8928c7b08d98d7cf3" [[package]] name = "windows_i686_gnu" -version = "0.42.1" +version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "de3887528ad530ba7bdbb1faa8275ec7a1155a45ffa57c37993960277145d640" +checksum = "c61d927d8da41da96a81f029489353e68739737d3beca43145c8afec9a31a84f" + +[[package]] +name = "windows_i686_gnu" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "622a1962a7db830d6fd0a69683c80a18fda201879f0f447f065a3b7467daa241" [[package]] name = "windows_i686_msvc" -version = "0.42.1" +version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf4d1122317eddd6ff351aa852118a2418ad4214e6613a50e0191f7004372605" +checksum = "44d840b6ec649f480a41c8d80f9c65108b92d89345dd94027bfe06ac444d1060" + +[[package]] +name = "windows_i686_msvc" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4542c6e364ce21bf45d69fdd2a8e455fa38d316158cfd43b3ac1c5b1b19f8e00" [[package]] name = "windows_x86_64_gnu" -version = "0.42.1" +version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1040f221285e17ebccbc2591ffdc2d44ee1f9186324dd3e84e99ac68d699c45" +checksum = "8de912b8b8feb55c064867cf047dda097f92d51efad5b491dfb98f6bbb70cb36" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca2b8a661f7628cbd23440e50b05d705db3686f894fc9580820623656af974b1" [[package]] name = "windows_x86_64_gnullvm" -version = "0.42.1" +version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "628bfdf232daa22b0d64fdb62b09fcc36bb01f05a3939e20ab73aaf9470d0463" +checksum = "26d41b46a36d453748aedef1486d5c7a85db22e56aff34643984ea85514e94a3" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7896dbc1f41e08872e9d5e8f8baa8fdd2677f29468c4e156210174edc7f7b953" [[package]] name = "windows_x86_64_msvc" -version = "0.42.1" +version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "447660ad36a13288b1db4d4248e857b510e8c3a225c822ba4fb748c0aafecffd" +checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a515f5799fe4961cb532f983ce2b23082366b898e52ffbce459c86f67c8378a" [[package]] name = "ws2_32-sys" @@ -1973,9 +2198,9 @@ dependencies = [ [[package]] name = "zstd-safe" -version = "6.0.3+zstd.1.5.2" +version = "6.0.5+zstd.1.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68e4a3f57d13d0ab7e478665c60f35e2a613dcd527851c2c7287ce5c787e134a" +checksum = "d56d9e60b4b1758206c238a10165fbcae3ca37b01744e394c463463f6529d23b" dependencies = [ "libc", "zstd-sys", @@ -1983,9 +2208,9 @@ dependencies = [ [[package]] name = "zstd-sys" -version = "2.0.6+zstd.1.5.2" +version = "2.0.8+zstd.1.5.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68a3f9792c0c3dc6c165840a75f47ae1f4da402c2d006881129579f6597e801b" +checksum = "5556e6ee25d32df2586c098bbfa278803692a20d0ab9565e049480d52707ec8c" dependencies = [ "cc", "libc", diff --git a/Cargo.toml b/Cargo.toml index 565b496..12a47a7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,22 +13,22 @@ categories = ["web-programming::http-server"] include = ["src/**/*", "Cargo.*", "LICENSE", "README.md", "CHANGELOG.md"] [dependencies] -actix-web = { version = "4.3.0", features = ["rustls"] } -actix-multipart = "0.5.0" +actix-web = { version = "4.3.1", features = ["rustls"] } +actix-multipart = "0.6.0" actix-files = "0.6.2" -awc = { version = "3.1.0", features = ["rustls"] } +awc = { version = "3.1.1", features = ["rustls"] } env_logger = "0.10.0" log = "0.4.17" -serde = "1.0.152" -futures-util = "0.3.26" +serde = "1.0.162" +futures-util = "0.3.28" petname = { version = "1.1.3", default-features = false, features = ["std_rng", "default_dictionary"] } rand = "0.8.5" -dotenvy = "0.15.6" +dotenvy = "0.15.7" url = "2.3.1" -mime = "0.3.16" -regex = "1.6.0" +mime = "0.3.17" +regex = "1.8.1" serde_regex = "1.1.0" -lazy-regex = "2.4.1" +lazy-regex = "2.5.0" humantime = "2.1.0" humantime-serde = "1.1.1" glob = "0.3.1" @@ -41,11 +41,11 @@ default-features = false features = ["toml", "yaml"] [dependencies.byte-unit] -version = "4.0.18" +version = "4.0.19" features = ["serde"] [dependencies.infer] -version = "0.12.0" +version = "0.13.0" default-features = false [dev-dependencies] From 70085f3ad0a309692365575f445b5b4824312f4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Orhun=20Parmaks=C4=B1z?= Date: Thu, 11 May 2023 00:40:08 +0300 Subject: [PATCH 03/30] chore(ci): update runners to Ubuntu 22.04 --- .github/workflows/audit.yml | 2 +- .github/workflows/cd.yml | 4 ++-- .github/workflows/ci.yml | 12 ++++++------ 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/.github/workflows/audit.yml b/.github/workflows/audit.yml index e2f9ae8..1976d87 100644 --- a/.github/workflows/audit.yml +++ b/.github/workflows/audit.yml @@ -7,7 +7,7 @@ on: jobs: audit: name: Audit - runs-on: ubuntu-20.04 + runs-on: ubuntu-22.04 steps: - name: Checkout the repository uses: actions/checkout@master diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index a5cc924..b52ebec 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -8,7 +8,7 @@ on: jobs: publish-github: name: Publish on GitHub - runs-on: ubuntu-20.04 + runs-on: ubuntu-22.04 strategy: matrix: TARGET: [x86_64-unknown-linux-gnu, x86_64-unknown-linux-musl] @@ -57,7 +57,7 @@ jobs: publish-crates-io: name: Publish on crates.io needs: publish-github - runs-on: ubuntu-20.04 + runs-on: ubuntu-22.04 steps: - name: Checkout the repository uses: actions/checkout@master diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6277d87..1981958 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,7 +13,7 @@ on: jobs: check: name: Check - runs-on: ubuntu-20.04 + runs-on: ubuntu-22.04 steps: - name: Install Rust toolchain uses: actions-rs/toolchain@v1 @@ -31,7 +31,7 @@ jobs: test: name: Test suite - runs-on: ubuntu-20.04 + runs-on: ubuntu-22.04 steps: - name: Install Rust toolchain uses: actions-rs/toolchain@v1 @@ -60,7 +60,7 @@ jobs: fixtures: name: Test fixtures - runs-on: ubuntu-20.04 + runs-on: ubuntu-22.04 steps: - name: Install Rust toolchain uses: actions-rs/toolchain@v1 @@ -84,7 +84,7 @@ jobs: clippy: name: Lints - runs-on: ubuntu-20.04 + runs-on: ubuntu-22.04 steps: - name: Install Rust toolchain uses: actions-rs/toolchain@v1 @@ -103,7 +103,7 @@ jobs: rustfmt: name: Formatting - runs-on: ubuntu-20.04 + runs-on: ubuntu-22.04 steps: - name: Install Rust toolchain uses: actions-rs/toolchain@v1 @@ -122,7 +122,7 @@ jobs: lychee: name: Links - runs-on: ubuntu-20.04 + runs-on: ubuntu-22.04 steps: - name: Checkout the repository uses: actions/checkout@master From 5e8ea66256a90049da0199d36586132eebb5c3c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Orhun=20Parmaks=C4=B1z?= Date: Thu, 11 May 2023 00:41:03 +0300 Subject: [PATCH 04/30] chore(ci): integrate dependabot --- .github/dependabot.yml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 .github/dependabot.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..0b4dd78 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,15 @@ +version: 2 +updates: + # Maintain dependencies for Cargo + - package-ecosystem: cargo + directory: "/" + schedule: + interval: daily + open-pull-requests-limit: 10 + + # Maintain dependencies for GitHub Actions + - package-ecosystem: github-actions + directory: "/" + schedule: + interval: daily + open-pull-requests-limit: 10 From 18ba29e04a66c30bc94717ccbd9b7bbeff1e973f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Orhun=20Parmaks=C4=B1z?= Date: Thu, 11 May 2023 00:41:41 +0300 Subject: [PATCH 05/30] chore(github): update funding options --- .github/FUNDING.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml index bc76e00..32a8a38 100644 --- a/.github/FUNDING.yml +++ b/.github/FUNDING.yml @@ -1,2 +1,3 @@ github: orhun patreon: orhunp +custom: ["https://www.buymeacoffee.com/orhun"] From ad4c990b132a7e8ceb196e78c26f094da3d5f82d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 10 May 2023 23:43:07 +0200 Subject: [PATCH 06/30] chore(deps): bump codecov/codecov-action from 1 to 3 (#34) Bumps [codecov/codecov-action](https://github.com/codecov/codecov-action) from 1 to 3. - [Release notes](https://github.com/codecov/codecov-action/releases) - [Changelog](https://github.com/codecov/codecov-action/blob/main/CHANGELOG.md) - [Commits](https://github.com/codecov/codecov-action/compare/v1...v3) --- updated-dependencies: - dependency-name: codecov/codecov-action dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1981958..08926be 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -49,7 +49,7 @@ jobs: - name: Run tests run: cargo tarpaulin --out Xml --verbose -- --test-threads 1 - name: Upload reports to codecov - uses: codecov/codecov-action@v1 + uses: codecov/codecov-action@v3 with: name: code-coverage-report file: cobertura.xml From 85e0c410d4b0e18fa12ea45c5ea693f202f4a7dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Orhun=20Parmaks=C4=B1z?= Date: Thu, 11 May 2023 00:44:41 +0300 Subject: [PATCH 07/30] fix(docker): remove target directory from excluded files for proper caching --- .dockerignore | 1 - 1 file changed, 1 deletion(-) diff --git a/.dockerignore b/.dockerignore index c49d10b..35ba224 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,7 +1,6 @@ # Directories /.git/ /.github/ -/target/ /upload/ # Files From 9fcbb1dfb0778eb4134bc69305b970da7d9d4113 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 11 May 2023 18:21:20 +0200 Subject: [PATCH 08/30] chore(deps): bump serde from 1.0.162 to 1.0.163 (#35) Bumps [serde](https://github.com/serde-rs/serde) from 1.0.162 to 1.0.163. - [Release notes](https://github.com/serde-rs/serde/releases) - [Commits](https://github.com/serde-rs/serde/compare/v1.0.162...v1.0.163) --- updated-dependencies: - dependency-name: serde dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Cargo.lock | 8 ++++---- Cargo.toml | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f243b31..67f4bc8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1554,18 +1554,18 @@ checksum = "bebd363326d05ec3e2f532ab7660680f3b02130d780c299bca73469d521bc0ed" [[package]] name = "serde" -version = "1.0.162" +version = "1.0.163" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "71b2f6e1ab5c2b98c05f0f35b236b22e8df7ead6ffbf51d7808da7f8817e7ab6" +checksum = "2113ab51b87a539ae008b5c6c02dc020ffa39afd2d83cffcb3f4eb2722cebec2" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.162" +version = "1.0.163" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2a0814352fd64b58489904a44ea8d90cb1a91dcb6b4f5ebabc32c8318e93cb6" +checksum = "8c805777e3930c8883389c602315a24224bcc738b63905ef87cd1420353ea93e" dependencies = [ "proc-macro2", "quote", diff --git a/Cargo.toml b/Cargo.toml index 12a47a7..cd59455 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -19,7 +19,7 @@ actix-files = "0.6.2" awc = { version = "3.1.1", features = ["rustls"] } env_logger = "0.10.0" log = "0.4.17" -serde = "1.0.162" +serde = "1.0.163" futures-util = "0.3.28" petname = { version = "1.1.3", default-features = false, features = ["std_rng", "default_dictionary"] } rand = "0.8.5" From 4e45b6a20d9b1d6f38db3966d1e82a58e731c228 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Orhun=20Parmaks=C4=B1z?= Date: Sat, 13 May 2023 22:50:39 +0300 Subject: [PATCH 09/30] style(config): format the config --- config.toml | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/config.toml b/config.toml index a21a040..536e592 100644 --- a/config.toml +++ b/config.toml @@ -1,14 +1,14 @@ [config] -refresh_rate="1s" +refresh_rate = "1s" [server] -address="127.0.0.1:8000" +address = "127.0.0.1:8000" #workers=4 -max_content_length="10MB" -upload_path="./upload" -timeout="30s" -expose_version=false -landing_page="""Submit files via HTTP POST here: +max_content_length = "10MB" +upload_path = "./upload" +timeout = "30s" +expose_version = false +landing_page = """Submit files via HTTP POST here: curl -F 'file=@example.txt' " This will return the finished URL. @@ -35,12 +35,12 @@ mime_override = [ { mime = "video/webm", regex = "^.*\\.webm$" }, { mime = "video/x-matroska", regex = "^.*\\.mkv$" }, { mime = "application/octet-stream", regex = "^.*\\.bin$" }, - { mime = "text/plain", regex = "^.*\\.(log|txt|diff)$" }, + { mime = "text/plain", regex = "^.*\\.(log|txt|diff|sh|rs|toml)$" }, ] mime_blacklist = [ "application/x-dosexec", "application/java-archive", - "application/java-vm" + "application/java-vm", ] duplicate_files = true delete_expired_files = { enabled = true, interval = "1h" } From 9ea7d5de8a17edaab85734612bbe035decacbd15 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Orhun=20Parmaks=C4=B1z?= Date: Sat, 13 May 2023 23:20:52 +0300 Subject: [PATCH 10/30] feat(config): support overriding the server URL --- src/config.rs | 2 ++ src/server.rs | 24 +++++++++++++++--------- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/src/config.rs b/src/config.rs index ca0aec0..9fe9455 100644 --- a/src/config.rs +++ b/src/config.rs @@ -30,6 +30,8 @@ pub struct Settings { pub struct ServerConfig { /// The socket address to bind. pub address: String, + /// URL that can be used to access the server externally. + pub url: Option, /// Number of workers to start. pub workers: Option, /// Maximum content length. diff --git a/src/server.rs b/src/server.rs index 7993562..39a2c2f 100644 --- a/src/server.rs +++ b/src/server.rs @@ -137,6 +137,18 @@ async fn upload( ) -> Result { let connection = request.connection_info().clone(); let host = connection.peer_addr().unwrap_or("unknown host"); + let server_url = match config + .read() + .map_err(|_| error::ErrorInternalServerError("cannot acquire config"))? + .server + .url + .clone() + { + Some(v) => v, + None => { + format!("{}://{}", connection.scheme(), connection.host(),) + } + }; auth::check( host, request.headers(), @@ -187,9 +199,8 @@ async fn upload( .get_file(bytes_checksum) { urls.push(format!( - "{}://{}/{}\n", - connection.scheme(), - connection.host(), + "{}/{}\n", + server_url, file.path .file_name() .map(|v| v.to_string_lossy()) @@ -227,12 +238,7 @@ async fn upload( Byte::from_bytes(paste.data.len() as u128).get_appropriate_unit(false), host ); - urls.push(format!( - "{}://{}/{}\n", - connection.scheme(), - connection.host(), - file_name - )); + urls.push(format!("{}/{}\n", server_url, file_name)); } else { log::warn!("{} sent an invalid form field", host); return Err(error::ErrorBadRequest("invalid form field")); From 607f07b6e189485d51c9f805d67a23d205077456 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Orhun=20Parmaks=C4=B1z?= Date: Sun, 14 May 2023 01:30:35 +0300 Subject: [PATCH 11/30] feat(server): support server-side default expiry time --- config.toml | 1 + src/config.rs | 5 ++++- src/header.rs | 12 ++++++------ src/server.rs | 11 ++++++++++- 4 files changed, 21 insertions(+), 8 deletions(-) diff --git a/config.toml b/config.toml index 536e592..19fad3a 100644 --- a/config.toml +++ b/config.toml @@ -43,4 +43,5 @@ mime_blacklist = [ "application/java-vm", ] duplicate_files = true +# default_expiry = "1h" delete_expired_files = { enabled = true, interval = "1h" } diff --git a/src/config.rs b/src/config.rs index 9fe9455..6bad254 100644 --- a/src/config.rs +++ b/src/config.rs @@ -62,8 +62,11 @@ pub struct PasteConfig { /// Media type blacklist. #[serde(default)] pub mime_blacklist: Vec, - /// Allow duplicate uploads + /// Allow duplicate uploads. pub duplicate_files: Option, + /// Default expiry time. + #[serde(default, with = "humantime_serde")] + pub default_expiry: Option, /// Delete expired files. pub delete_expired_files: Option, } diff --git a/src/header.rs b/src/header.rs index 6277dbd..3d78e55 100644 --- a/src/header.rs +++ b/src/header.rs @@ -1,19 +1,18 @@ -use crate::util; use actix_web::http::header::{ ContentDisposition as ActixContentDisposition, DispositionParam, DispositionType, HeaderMap, }; use actix_web::{error, Error as ActixError}; +use std::time::Duration; /// Custom HTTP header for expiry dates. pub const EXPIRE: &str = "expire"; /// Parses the expiry date from the [`custom HTTP header`](EXPIRE). -pub fn parse_expiry_date(headers: &HeaderMap) -> Result, ActixError> { +pub fn parse_expiry_date(headers: &HeaderMap, time: Duration) -> Result, ActixError> { if let Some(expire_time) = headers.get(EXPIRE).and_then(|v| v.to_str().ok()) { - let timestamp = util::get_system_time()?; let expire_time = humantime::parse_duration(expire_time).map_err(error::ErrorInternalServerError)?; - Ok(timestamp.checked_add(expire_time).map(|t| t.as_millis())) + Ok(time.checked_add(expire_time).map(|t| t.as_millis())) } else { Ok(None) } @@ -62,9 +61,9 @@ impl ContentDisposition { #[cfg(test)] mod tests { use super::*; + use crate::util; use actix_web::http::header::{HeaderName, HeaderValue}; use std::thread; - use std::time::Duration; #[test] fn test_content_disposition() -> Result<(), ActixError> { @@ -97,7 +96,8 @@ mod tests { HeaderName::from_static(EXPIRE), HeaderValue::from_static("5ms"), ); - let expiry_time = parse_expiry_date(&headers)?.unwrap_or_default(); + let time = util::get_system_time()?; + let expiry_time = parse_expiry_date(&headers, time)?.unwrap_or_default(); assert!(expiry_time > util::get_system_time()?.as_millis()); thread::sleep(Duration::from_millis(10)); assert!(expiry_time < util::get_system_time()?.as_millis()); diff --git a/src/server.rs b/src/server.rs index 39a2c2f..317c3b4 100644 --- a/src/server.rs +++ b/src/server.rs @@ -160,7 +160,16 @@ async fn upload( .as_ref() .cloned()), )?; - let expiry_date = header::parse_expiry_date(request.headers())?; + let time = util::get_system_time()?; + let mut expiry_date = header::parse_expiry_date(request.headers(), time)?; + if expiry_date.is_none() { + expiry_date = config + .read() + .map_err(|_| error::ErrorInternalServerError("cannot acquire config"))? + .paste + .default_expiry + .and_then(|v| time.checked_add(v).map(|t| t.as_millis())); + } let mut urls: Vec = Vec::new(); while let Some(item) = payload.next().await { let mut field = item?; From 4a4301ee72c4f1e8b2287befd05d90e4fc5140fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Orhun=20Parmaks=C4=B1z?= Date: Sun, 14 May 2023 01:54:58 +0300 Subject: [PATCH 12/30] style(server): make the default landing page fancier --- config.toml | 19 +++++++++++++------ src/server.rs | 4 +++- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/config.toml b/config.toml index 19fad3a..ac7be17 100644 --- a/config.toml +++ b/config.toml @@ -8,9 +8,14 @@ max_content_length = "10MB" upload_path = "./upload" timeout = "30s" expose_version = false -landing_page = """Submit files via HTTP POST here: - curl -F 'file=@example.txt' " -This will return the finished URL. +landing_page = """ +┬─┐┬ ┬┌─┐┌┬┐┬ ┬┌─┐┌─┐┌─┐┌┬┐┌─┐ +├┬┘│ │└─┐ │ └┬┘├─┘├─┤└─┐ │ ├┤ +┴└─└─┘└─┘ ┴ ┴ ┴ ┴ ┴└─┘ ┴ └─┘ + +Submit files via HTTP POST here: + curl -F 'file=@example.txt' +This will return the URL of the uploaded file. The server administrator might remove any pastes that they do not personally want to host. @@ -19,10 +24,12 @@ If you are the server administrator and want to change this page, just go into your config file and change it! If you change the expiry time, it is recommended that you do. -Check out the GitHub repository at https://github.com/orhun/rustypaste - By default, pastes expire every hour. The server admin may or may not have -changed this.""" +changed this. + +Check out the GitHub repository at https://github.com/orhun/rustypaste +Command line tool is available at https://github.com/orhun/rustypaste-cli +""" [paste] random_url = { enabled = true, type = "petname", words = 2, separator = "-" } diff --git a/src/server.rs b/src/server.rs index 317c3b4..6d2f0b7 100644 --- a/src/server.rs +++ b/src/server.rs @@ -25,7 +25,9 @@ async fn index(config: web::Data>) -> Result .read() .map_err(|_| error::ErrorInternalServerError("cannot acquire config"))?; match &config.server.landing_page { - Some(page) => Ok(HttpResponse::Ok().body(page.clone())), + Some(page) => Ok(HttpResponse::Ok() + .content_type("text/plain; charset=\"UTF-8\"") + .body(page.clone())), None => Ok(HttpResponse::Found() .append_header(("Location", env!("CARGO_PKG_HOMEPAGE"))) .finish()), From ab5e153a4ea989692a45ed62821d5d7f0f18232b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Orhun=20Parmaks=C4=B1z?= Date: Sun, 14 May 2023 13:38:34 +0300 Subject: [PATCH 13/30] style(config): format the default config --- config.toml | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/config.toml b/config.toml index ac7be17..a2a9064 100644 --- a/config.toml +++ b/config.toml @@ -36,18 +36,18 @@ random_url = { enabled = true, type = "petname", words = 2, separator = "-" } #random_url = { enabled = true, type = "alphanumeric", length = 8 } default_extension = "txt" mime_override = [ - { mime = "image/jpeg", regex = "^.*\\.jpg$" }, - { mime = "image/png", regex = "^.*\\.png$" }, - { mime = "image/svg+xml", regex = "^.*\\.svg$" }, - { mime = "video/webm", regex = "^.*\\.webm$" }, - { mime = "video/x-matroska", regex = "^.*\\.mkv$" }, - { mime = "application/octet-stream", regex = "^.*\\.bin$" }, - { mime = "text/plain", regex = "^.*\\.(log|txt|diff|sh|rs|toml)$" }, + { mime = "image/jpeg", regex = "^.*\\.jpg$" }, + { mime = "image/png", regex = "^.*\\.png$" }, + { mime = "image/svg+xml", regex = "^.*\\.svg$" }, + { mime = "video/webm", regex = "^.*\\.webm$" }, + { mime = "video/x-matroska", regex = "^.*\\.mkv$" }, + { mime = "application/octet-stream", regex = "^.*\\.bin$" }, + { mime = "text/plain", regex = "^.*\\.(log|txt|diff|sh|rs|toml)$" }, ] mime_blacklist = [ - "application/x-dosexec", - "application/java-archive", - "application/java-vm", + "application/x-dosexec", + "application/java-archive", + "application/java-vm", ] duplicate_files = true # default_expiry = "1h" From 019d1556da0fc80bf9e928db2da7b89f7846a24c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Orhun=20Parmaks=C4=B1z?= Date: Sun, 14 May 2023 13:48:39 +0300 Subject: [PATCH 14/30] chore(ci): use the stable version for checkout action --- .github/workflows/audit.yml | 2 +- .github/workflows/cd.yml | 4 ++-- .github/workflows/ci.yml | 14 +++++++------- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/.github/workflows/audit.yml b/.github/workflows/audit.yml index 1976d87..4d55ff3 100644 --- a/.github/workflows/audit.yml +++ b/.github/workflows/audit.yml @@ -10,7 +10,7 @@ jobs: runs-on: ubuntu-22.04 steps: - name: Checkout the repository - uses: actions/checkout@master + uses: actions/checkout@v3 - name: Install Rust uses: actions-rs/toolchain@v1 with: diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index b52ebec..8698201 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -14,7 +14,7 @@ jobs: TARGET: [x86_64-unknown-linux-gnu, x86_64-unknown-linux-musl] steps: - name: Checkout the repository - uses: actions/checkout@master + uses: actions/checkout@v3 - name: Set the release version run: echo "RELEASE_VERSION=${GITHUB_REF:11}" >> $GITHUB_ENV - name: Install musl-tools @@ -60,7 +60,7 @@ jobs: runs-on: ubuntu-22.04 steps: - name: Checkout the repository - uses: actions/checkout@master + uses: actions/checkout@v3 - name: Publish uses: actions-rs/cargo@v1 with: diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 08926be..9a84517 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,7 +8,7 @@ on: branches: - master schedule: - - cron: '0 0 * * 0' + - cron: "0 0 * * 0" jobs: check: @@ -22,7 +22,7 @@ jobs: profile: minimal override: true - name: Checkout the repository - uses: actions/checkout@master + uses: actions/checkout@v3 - name: Check the project files uses: actions-rs/cargo@v1 with: @@ -39,7 +39,7 @@ jobs: toolchain: stable override: true - name: Checkout the repository - uses: actions/checkout@master + uses: actions/checkout@v3 - name: Setup cargo-tarpaulin run: | curl -s https://api.github.com/repos/xd009642/tarpaulin/releases/latest | \ @@ -69,7 +69,7 @@ jobs: profile: minimal override: true - name: Checkout the repository - uses: actions/checkout@master + uses: actions/checkout@v3 - name: Build the project uses: actions-rs/cargo@v1 with: @@ -94,7 +94,7 @@ jobs: components: clippy override: true - name: Checkout the repository - uses: actions/checkout@master + uses: actions/checkout@v3 - name: Check the lints uses: actions-rs/cargo@v1 with: @@ -113,7 +113,7 @@ jobs: components: rustfmt override: true - name: Checkout the repository - uses: actions/checkout@master + uses: actions/checkout@v3 - name: Check the formatting uses: actions-rs/cargo@v1 with: @@ -125,7 +125,7 @@ jobs: runs-on: ubuntu-22.04 steps: - name: Checkout the repository - uses: actions/checkout@master + uses: actions/checkout@v3 - name: Check the links uses: lycheeverse/lychee-action@v1 with: From 29ddef8df0bb38ec4bd77281836105b7c7797d71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Orhun=20Parmaks=C4=B1z?= Date: Sun, 14 May 2023 18:03:53 +0200 Subject: [PATCH 15/30] feat(deploy): deploy on shuttle.rs (#36) * feat(deploy): deploy on shuttle.rs * chore(deploy): add automated shuttle deploy workflow * style(readme): update the formatting in README.md * chore(deploy): optimize shuttle workflow * fix(deploy): start the project * fix(deploy): remove start step This reverts commit 4f25921aeb2a064952dd9bc88895e446cac134e6. * chore(deploy): expose the version for the public instance * docs(lib): update the comment for shuttle entry-point * chore(deploy): run the shuttle deployment on new tag --- .dockerignore | 1 + .github/workflows/shuttle.yml | 31 + Cargo.lock | 1306 ++++++++++++++++++++++++++++++++- Cargo.toml | 19 +- README.md | 2 + config.toml | 1 + shuttle/config.toml | 53 ++ src/main.rs | 64 +- 8 files changed, 1466 insertions(+), 11 deletions(-) create mode 100644 .github/workflows/shuttle.yml create mode 100644 shuttle/config.toml diff --git a/.dockerignore b/.dockerignore index 35ba224..73269dd 100644 --- a/.dockerignore +++ b/.dockerignore @@ -2,6 +2,7 @@ /.git/ /.github/ /upload/ +/shuttle/ # Files .gitignore diff --git a/.github/workflows/shuttle.yml b/.github/workflows/shuttle.yml new file mode 100644 index 0000000..51af971 --- /dev/null +++ b/.github/workflows/shuttle.yml @@ -0,0 +1,31 @@ +name: Deploy on Shuttle + +on: + push: + tags: + - "v*.*.*" + +jobs: + deploy: + name: Deploy + runs-on: ubuntu-22.04 + steps: + - name: Checkout the repository + uses: actions/checkout@v3 + - name: Install Rust + uses: actions-rs/toolchain@v1 + with: + toolchain: stable + profile: minimal + override: true + - name: Install cargo-binstall + uses: taiki-e/install-action@cargo-binstall + - name: Install cargo-shuttle + run: cargo binstall -y cargo-shuttle + - name: Prepare for deployment + shell: bash + run: sed -i 's|default = \[\]|default = \["shuttle"\]|g' Cargo.toml + - name: Login + run: cargo shuttle login --api-key ${{ secrets.SHUTTLE_TOKEN }} + - name: Deploy + run: cargo shuttle deploy --allow-dirty --no-test diff --git a/Cargo.lock b/Cargo.lock index 67f4bc8..15ff787 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -54,7 +54,7 @@ dependencies = [ "actix-tls", "actix-utils", "ahash 0.8.3", - "base64", + "base64 0.21.0", "bitflags", "brotli", "bytes", @@ -319,12 +319,104 @@ dependencies = [ "alloc-no-stdlib", ] +[[package]] +name = "android_system_properties" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311" +dependencies = [ + "libc", +] + +[[package]] +name = "anstream" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ca84f3628370c59db74ee214b3263d58f9aadd9b4fe7e711fd87dc452b7f163" +dependencies = [ + "anstyle", + "anstyle-parse", + "anstyle-query", + "anstyle-wincon", + "colorchoice", + "is-terminal", + "utf8parse", +] + +[[package]] +name = "anstyle" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41ed9a86bf92ae6580e0a31281f65a1b1d867c0cc68d5346e2ae128dddfa6a7d" + +[[package]] +name = "anstyle-parse" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e765fd216e48e067936442276d1d57399e37bce53c264d6fefbe298080cb57ee" +dependencies = [ + "utf8parse", +] + +[[package]] +name = "anstyle-query" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5ca11d4be1bab0c8bc8734a9aa7bf4ee8316d462a08c6ac5052f888fef5b494b" +dependencies = [ + "windows-sys 0.48.0", +] + +[[package]] +name = "anstyle-wincon" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "180abfa45703aebe0093f79badacc01b8fd4ea2e35118747e5811127f926e188" +dependencies = [ + "anstyle", + "windows-sys 0.48.0", +] + +[[package]] +name = "anyhow" +version = "1.0.71" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c7d0618f0e0b7e8ff11427422b64564d5fb0be1940354bfe2e0529b18a9d9b8" + +[[package]] +name = "arrayvec" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8da52d66c7071e2e3fa2a1e5c6d088fec47b593032b254f5e980de8ea54454d6" + [[package]] name = "askama_escape" version = "0.10.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "619743e34b5ba4e9703bba34deac3427c72507c7159f5fd030aea8cac0cfe341" +[[package]] +name = "async-stream" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd56dd203fef61ac097dd65721a419ddccb106b2d2b70ba60a6b529f03961a51" +dependencies = [ + "async-stream-impl", + "futures-core", + "pin-project-lite", +] + +[[package]] +name = "async-stream-impl" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "16e62a023e7c117e27523144c5d2459f4397fcc3cab0085af8e2224f643a0193" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.15", +] + [[package]] name = "async-trait" version = "0.1.68" @@ -355,7 +447,7 @@ dependencies = [ "actix-tls", "actix-utils", "ahash 0.7.6", - "base64", + "base64 0.21.0", "bytes", "cfg-if 1.0.0", "cookie", @@ -377,6 +469,57 @@ dependencies = [ "tokio", ] +[[package]] +name = "axum" +version = "0.6.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8175979259124331c1d7bf6586ee7e0da434155e4b2d48ec2c8386281d8df39" +dependencies = [ + "async-trait", + "axum-core", + "bitflags", + "bytes", + "futures-util", + "http", + "http-body", + "hyper", + "itoa", + "matchit", + "memchr", + "mime", + "percent-encoding", + "pin-project-lite", + "rustversion", + "serde", + "sync_wrapper", + "tower", + "tower-layer", + "tower-service", +] + +[[package]] +name = "axum-core" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "759fa577a247914fd3f7f76d62972792636412fbfd634cd452f6a385a74d2d2c" +dependencies = [ + "async-trait", + "bytes", + "futures-util", + "http", + "http-body", + "mime", + "rustversion", + "tower-layer", + "tower-service", +] + +[[package]] +name = "base64" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" + [[package]] name = "base64" version = "0.21.0" @@ -435,6 +578,12 @@ dependencies = [ "utf8-width", ] +[[package]] +name = "byteorder" +version = "1.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" + [[package]] name = "bytes" version = "1.4.0" @@ -471,6 +620,67 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" +[[package]] +name = "chrono" +version = "0.4.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4e3c5919066adf22df73762e50cffcde3a758f2a848b113b586d1f86728b673b" +dependencies = [ + "iana-time-zone", + "num-integer", + "num-traits", + "serde", + "winapi 0.3.9", +] + +[[package]] +name = "clap" +version = "4.2.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34d21f9bf1b425d2968943631ec91202fe5e837264063503708b83013f8fc938" +dependencies = [ + "clap_builder", + "clap_derive", + "once_cell", +] + +[[package]] +name = "clap_builder" +version = "4.2.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "914c8c79fb560f238ef6429439a30023c862f7a28e688c58f7203f12b29970bd" +dependencies = [ + "anstream", + "anstyle", + "bitflags", + "clap_lex", + "strsim", +] + +[[package]] +name = "clap_derive" +version = "4.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f9644cd56d6b87dbe899ef8b053e331c0637664e9e21a33dfcdc36093f5c5c4" +dependencies = [ + "heck", + "proc-macro2", + "quote", + "syn 2.0.15", +] + +[[package]] +name = "clap_lex" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a2dd5a6fe8c6e3502f568a6353e5273bbb15193ad9a89e457b9970798efbea1" + +[[package]] +name = "colorchoice" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7" + [[package]] name = "config" version = "0.13.3" @@ -503,6 +713,12 @@ dependencies = [ "version_check", ] +[[package]] +name = "core-foundation-sys" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e496a50fda8aacccc86d7529e2c1e0892dbd0f898a6b5645b5561b89c3210efa" + [[package]] name = "cpufeatures" version = "0.2.7" @@ -521,6 +737,25 @@ dependencies = [ "cfg-if 1.0.0", ] +[[package]] +name = "crossbeam-channel" +version = "0.5.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a33c2bf77f2df06183c3aa30d1e96c0695a313d4f9c453cc3762a6db39f99200" +dependencies = [ + "cfg-if 1.0.0", + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-utils" +version = "0.8.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c063cd8cc95f5c377ed0d4b49a4b21f632396ff690e8470c29b3359b346984b" +dependencies = [ + "cfg-if 1.0.0", +] + [[package]] name = "crypto-common" version = "0.1.6" @@ -566,6 +801,19 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "dashmap" +version = "5.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "907076dfda823b0b36d2a1bb5f90c96660a5bbcd7729e10727f07858f22c4edc" +dependencies = [ + "cfg-if 1.0.0", + "hashbrown", + "lock_api", + "once_cell", + "parking_lot_core", +] + [[package]] name = "derive_more" version = "0.99.17" @@ -589,12 +837,24 @@ dependencies = [ "crypto-common", ] +[[package]] +name = "doc-comment" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fea41bba32d969b513997752735605054bc0dfa92b4c56bf1189f2e174be7a10" + [[package]] name = "dotenvy" version = "0.15.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1aaf95b3e5c8f23aa320147307562d361db0ae0d51242340f558153b4eb2439b" +[[package]] +name = "dunce" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56ce8c6da7551ec6c462cbaf3bfbc75131ebbfa1c944aeaa9dab51ca1c5f0c3b" + [[package]] name = "either" version = "1.8.1" @@ -665,6 +925,18 @@ dependencies = [ "windows-sys 0.48.0", ] +[[package]] +name = "finl_unicode" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8fcfdc7a0362c9f4444381a9e697c79d435fe65b52a37466fc2c1184cee9edc6" + +[[package]] +name = "fixedbitset" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ce7134b9999ecaf8bcd65542e436736ef32ddca1b3e06094cb6ec5755203b80" + [[package]] name = "flate2" version = "1.0.26" @@ -690,6 +962,12 @@ dependencies = [ "percent-encoding", ] +[[package]] +name = "fs_extra" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42703706b716c37f96a77aea830392ad231f44c9e9a67872fa5548707e11b11c" + [[package]] name = "fsevent" version = "0.4.0" @@ -725,12 +1003,53 @@ version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7" +[[package]] +name = "futures" +version = "0.3.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23342abe12aba583913b2e62f22225ff9c950774065e4bfb61a19cd9770fec40" +dependencies = [ + "futures-channel", + "futures-core", + "futures-io", + "futures-sink", + "futures-task", + "futures-util", +] + +[[package]] +name = "futures-channel" +version = "0.3.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "955518d47e09b25bbebc7a18df10b81f0c766eaf4c4f1cccef2fca5f2a4fb5f2" +dependencies = [ + "futures-core", + "futures-sink", +] + [[package]] name = "futures-core" version = "0.3.28" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4bca583b7e26f571124fe5b7561d49cb2868d79116cfa0eefce955557c6fee8c" +[[package]] +name = "futures-executor" +version = "0.3.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ccecee823288125bd88b4d7f565c9e58e41858e47ab72e8ea2d64e93624386e0" +dependencies = [ + "futures-core", + "futures-task", + "futures-util", +] + +[[package]] +name = "futures-io" +version = "0.3.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4fff74096e71ed47f8e023204cfd0aa1289cd54ae5430a9523be060cdb849964" + [[package]] name = "futures-macro" version = "0.3.28" @@ -760,10 +1079,13 @@ version = "0.3.28" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "26b01e40b772d54cf6c6d721c1d1abd0647a0106a12ecaa1c186273392a69533" dependencies = [ + "futures-channel", "futures-core", + "futures-io", "futures-macro", "futures-sink", "futures-task", + "memchr", "pin-project-lite", "pin-utils", "slab", @@ -821,6 +1143,37 @@ version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" +[[package]] +name = "headers" +version = "0.3.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f3e372db8e5c0d213e0cd0b9be18be2aca3d44cf2fe30a9d46a65581cd454584" +dependencies = [ + "base64 0.13.1", + "bitflags", + "bytes", + "headers-core", + "http", + "httpdate", + "mime", + "sha1", +] + +[[package]] +name = "headers-core" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7f66481bfee273957b1f20485a4ff3362987f85b2c236580d81b4eb7a326429" +dependencies = [ + "http", +] + +[[package]] +name = "heck" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" + [[package]] name = "hermit-abi" version = "0.2.6" @@ -836,6 +1189,15 @@ version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fed44880c466736ef9a5c5b5facefb5ed0785676d0c02d612db14e54f0d84286" +[[package]] +name = "home" +version = "0.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5444c27eef6923071f7ebcc33e3444508466a76f7a2b93da00ed6e19f30c1ddb" +dependencies = [ + "windows-sys 0.48.0", +] + [[package]] name = "hotwatch" version = "0.4.6" @@ -857,12 +1219,39 @@ dependencies = [ "itoa", ] +[[package]] +name = "http-body" +version = "0.4.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d5f38f16d184e36f2408a55281cd658ecbd3ca05cce6d6510a176eca393e26d1" +dependencies = [ + "bytes", + "http", + "pin-project-lite", +] + [[package]] name = "http-range" version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "21dec9db110f5f872ed9699c3ecf50cf16f423502706ba5c72462e28d3157573" +[[package]] +name = "http-range-header" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0bfe8eed0a9285ef776bb792479ea3834e8b94e13d615c2f66d03dd50a435a29" + +[[package]] +name = "http-serde" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0e272971f774ba29341db2f686255ff8a979365a26fb9e4277f6b6d9ec0cdd5e" +dependencies = [ + "http", + "serde", +] + [[package]] name = "httparse" version = "1.8.0" @@ -891,6 +1280,65 @@ dependencies = [ "serde", ] +[[package]] +name = "hyper" +version = "0.14.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ab302d72a6f11a3b910431ff93aae7e773078c769f0a3ef15fb9ec692ed147d4" +dependencies = [ + "bytes", + "futures-channel", + "futures-core", + "futures-util", + "h2", + "http", + "http-body", + "httparse", + "httpdate", + "itoa", + "pin-project-lite", + "socket2", + "tokio", + "tower-service", + "tracing", + "want", +] + +[[package]] +name = "hyper-timeout" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbb958482e8c7be4bc3cf272a766a2b0bf1a6755e7a6ae777f017a31d11b13b1" +dependencies = [ + "hyper", + "pin-project-lite", + "tokio", + "tokio-io-timeout", +] + +[[package]] +name = "iana-time-zone" +version = "0.1.56" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0722cd7114b7de04316e7ea5456a0bbb20e4adb46fd27a3697adb812cff0f37c" +dependencies = [ + "android_system_properties", + "core-foundation-sys", + "iana-time-zone-haiku", + "js-sys", + "wasm-bindgen", + "windows", +] + +[[package]] +name = "iana-time-zone-haiku" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f" +dependencies = [ + "cc", +] + [[package]] name = "ident_case" version = "1.0.1" @@ -1017,6 +1465,20 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "jsonwebtoken" +version = "8.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6971da4d9c3aa03c3d8f3ff0f4155b534aad021292003895a469716b2a230378" +dependencies = [ + "base64 0.21.0", + "pem", + "ring", + "serde", + "serde_json", + "simple_asn1", +] + [[package]] name = "kernel32-sys" version = "0.2.2" @@ -1123,6 +1585,21 @@ dependencies = [ "cfg-if 1.0.0", ] +[[package]] +name = "matchers" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8263075bb86c5a1b1427b5ae862e8889656f126e9f77c484496e8b47cf5c5558" +dependencies = [ + "regex-automata", +] + +[[package]] +name = "matchit" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b87248edafb776e59e6ee64a79086f65890d3510f2c656c000bf2a7e8a0aea40" + [[package]] name = "memchr" version = "2.5.0" @@ -1215,6 +1692,12 @@ dependencies = [ "ws2_32-sys", ] +[[package]] +name = "multimap" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5ce46fe64a9d73be07dcbe690a38ce1b293be448fd8ce1e6c1b8062c9f72c6a" + [[package]] name = "net2" version = "0.2.38" @@ -1254,6 +1737,46 @@ dependencies = [ "winapi 0.3.9", ] +[[package]] +name = "nu-ansi-term" +version = "0.46.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77a8165726e8236064dbb45459242600304b42a5ea24ee2948e18e023bf7ba84" +dependencies = [ + "overload", + "winapi 0.3.9", +] + +[[package]] +name = "num-bigint" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f93ab6289c7b344a8a9f60f88d80aa20032336fe78da341afc91c8a2341fc75f" +dependencies = [ + "autocfg", + "num-integer", + "num-traits", +] + +[[package]] +name = "num-integer" +version = "0.1.45" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "225d3389fb3509a24c93f5c29eb6bde2586b98d9f016636dff58d7c6f7569cd9" +dependencies = [ + "autocfg", + "num-traits", +] + +[[package]] +name = "num-traits" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "578ede34cf02f8924ab9447f50c28075b4d3e5b269972345e7e0372b38c6cdcd" +dependencies = [ + "autocfg", +] + [[package]] name = "num_cpus" version = "1.15.0" @@ -1270,6 +1793,104 @@ version = "1.17.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b7e5500299e16ebb147ae15a00a942af264cf3688f47923b8fc2cd5858f23ad3" +[[package]] +name = "opentelemetry" +version = "0.18.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "69d6c3d7288a106c0a363e4b0e8d308058d56902adefb16f4936f417ffef086e" +dependencies = [ + "opentelemetry_api", + "opentelemetry_sdk", +] + +[[package]] +name = "opentelemetry-http" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1edc79add46364183ece1a4542592ca593e6421c60807232f5b8f7a31703825d" +dependencies = [ + "async-trait", + "bytes", + "http", + "opentelemetry_api", +] + +[[package]] +name = "opentelemetry-otlp" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d1c928609d087790fc936a1067bdc310ae702bdf3b090c3f281b713622c8bbde" +dependencies = [ + "async-trait", + "futures", + "futures-util", + "http", + "opentelemetry", + "opentelemetry-proto", + "prost", + "thiserror", + "tokio", + "tonic", +] + +[[package]] +name = "opentelemetry-proto" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d61a2f56df5574508dd86aaca016c917489e589ece4141df1b5e349af8d66c28" +dependencies = [ + "futures", + "futures-util", + "opentelemetry", + "prost", + "tonic", + "tonic-build", +] + +[[package]] +name = "opentelemetry_api" +version = "0.18.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c24f96e21e7acc813c7a8394ee94978929db2bcc46cf6b5014fc612bf7760c22" +dependencies = [ + "fnv", + "futures-channel", + "futures-util", + "indexmap", + "js-sys", + "once_cell", + "pin-project-lite", + "thiserror", +] + +[[package]] +name = "opentelemetry_sdk" +version = "0.18.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ca41c4933371b61c2a2f214bf16931499af4ec90543604ec828f7a625c09113" +dependencies = [ + "async-trait", + "crossbeam-channel", + "dashmap", + "fnv", + "futures-channel", + "futures-executor", + "futures-util", + "once_cell", + "opentelemetry_api", + "percent-encoding", + "rand", + "thiserror", + "tokio", + "tokio-stream", +] + +[[package]] +name = "overload" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39" + [[package]] name = "parking_lot" version = "0.12.1" @@ -1311,12 +1932,31 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8835116a5c179084a830efb3adc117ab007512b535bc1a21c991d3b32a6b44dd" +[[package]] +name = "pem" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8835c273a76a90455d7344889b0964598e3316e2a79ede8e36f16bdcf2228b8" +dependencies = [ + "base64 0.13.1", +] + [[package]] name = "percent-encoding" version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "478c572c3d73181ff3c2539045f6eb99e5491218eae919370993b890cdbdd98e" +[[package]] +name = "petgraph" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4dd7d28ee937e54fe3080c91faa1c3a46c06de6252988a7f4592ba2310ef22a4" +dependencies = [ + "fixedbitset", + "indexmap", +] + [[package]] name = "petname" version = "1.1.3" @@ -1327,6 +1967,26 @@ dependencies = [ "rand", ] +[[package]] +name = "pin-project" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c95a7476719eab1e366eaf73d0260af3021184f18177925b07f54b30089ceead" +dependencies = [ + "pin-project-internal", +] + +[[package]] +name = "pin-project-internal" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "39407670928234ebc5e6e580247dd567ad73a3578460c5990f9503df207e8f07" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.15", +] + [[package]] name = "pin-project-lite" version = "0.2.9" @@ -1351,6 +2011,40 @@ version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" +[[package]] +name = "prettyplease" +version = "0.1.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c8646e95016a7a6c4adea95bafa8a16baab64b583356217f2c85db4a39d9a86" +dependencies = [ + "proc-macro2", + "syn 1.0.109", +] + +[[package]] +name = "proc-macro-error" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c" +dependencies = [ + "proc-macro-error-attr", + "proc-macro2", + "quote", + "syn 1.0.109", + "version_check", +] + +[[package]] +name = "proc-macro-error-attr" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869" +dependencies = [ + "proc-macro2", + "quote", + "version_check", +] + [[package]] name = "proc-macro2" version = "1.0.56" @@ -1360,6 +2054,60 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "prost" +version = "0.11.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b82eaa1d779e9a4bc1c3217db8ffbeabaae1dca241bf70183242128d48681cd" +dependencies = [ + "bytes", + "prost-derive", +] + +[[package]] +name = "prost-build" +version = "0.11.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "119533552c9a7ffacc21e099c24a0ac8bb19c2a2a3f363de84cd9b844feab270" +dependencies = [ + "bytes", + "heck", + "itertools", + "lazy_static", + "log", + "multimap", + "petgraph", + "prettyplease", + "prost", + "prost-types", + "regex", + "syn 1.0.109", + "tempfile", + "which", +] + +[[package]] +name = "prost-derive" +version = "0.11.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5d2d8d10f3c6ded6da8b05b5fb3b8a5082514344d56c9f871412d29b4e075b4" +dependencies = [ + "anyhow", + "itertools", + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "prost-types" +version = "0.11.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "213622a1460818959ac1181aaeb2dc9c7f63df720db7d788b3e24eacd1983e13" +dependencies = [ + "prost", +] + [[package]] name = "quote" version = "1.0.27" @@ -1425,9 +2173,24 @@ checksum = "af83e617f331cc6ae2da5443c602dfa5af81e517212d9d611a5b3ba1777b5370" dependencies = [ "aho-corasick", "memchr", - "regex-syntax", + "regex-syntax 0.7.1", ] +[[package]] +name = "regex-automata" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132" +dependencies = [ + "regex-syntax 0.6.29", +] + +[[package]] +name = "regex-syntax" +version = "0.6.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1" + [[package]] name = "regex-syntax" version = "0.7.1" @@ -1449,6 +2212,34 @@ dependencies = [ "winapi 0.3.9", ] +[[package]] +name = "rmp" +version = "0.8.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "44519172358fd6d58656c86ab8e7fbc9e1490c3e8f14d35ed78ca0dd07403c9f" +dependencies = [ + "byteorder", + "num-traits", + "paste", +] + +[[package]] +name = "rmp-serde" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c5b13be192e0220b8afb7222aa5813cb62cc269ebb5cac346ca6487681d2913e" +dependencies = [ + "byteorder", + "rmp", + "serde", +] + +[[package]] +name = "rustc-hash" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" + [[package]] name = "rustc_version" version = "0.4.0" @@ -1484,6 +2275,29 @@ dependencies = [ "webpki", ] +[[package]] +name = "rustrict" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4074b92c3fe398b8bc7b860a30dabda12539e876f6bbb4598c671fdddb3e3203" +dependencies = [ + "arrayvec", + "bitflags", + "doc-comment", + "finl_unicode", + "itertools", + "lazy_static", + "rustc-hash", + "strsim", + "unicode-normalization", +] + +[[package]] +name = "rustversion" +version = "1.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4f3208ce4d8448b3f3e7d168a73f5e0c43a61e32930de3bceeccedb388b6bf06" + [[package]] name = "rustypaste" version = "0.8.4" @@ -1512,6 +2326,10 @@ dependencies = [ "ring", "serde", "serde_regex", + "shuttle-actix-web", + "shuttle-runtime", + "shuttle-static-folder", + "tokio", "url", ] @@ -1625,6 +2443,149 @@ dependencies = [ "digest", ] +[[package]] +name = "sharded-slab" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "900fba806f70c630b0a382d0d825e17a0f19fcd059a2ade1ff237bcddf446b31" +dependencies = [ + "lazy_static", +] + +[[package]] +name = "shuttle-actix-web" +version = "0.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3a64d5b328d431b2b317bc4c4d41c34aec922a7f6e6f88fcc17e769368095560" +dependencies = [ + "actix-web", + "num_cpus", + "shuttle-runtime", +] + +[[package]] +name = "shuttle-codegen" +version = "0.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "207a2e8b132eba5beaeb809c1bb4f52d1286e91def671aa676afade1b390226c" +dependencies = [ + "proc-macro-error", + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "shuttle-common" +version = "0.16.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "038501726ae934aaaec90e203a0ade9fd261b60c52d2bc643bd4d17245758818" +dependencies = [ + "anyhow", + "async-trait", + "axum", + "bytes", + "chrono", + "headers", + "http", + "http-body", + "http-serde", + "hyper", + "jsonwebtoken", + "once_cell", + "opentelemetry", + "opentelemetry-http", + "opentelemetry-otlp", + "pin-project", + "prost-types", + "rmp-serde", + "rustrict", + "serde", + "serde_json", + "strum", + "thiserror", + "tower", + "tower-http", + "tracing", + "tracing-opentelemetry", + "tracing-subscriber", + "ttl_cache", + "uuid", +] + +[[package]] +name = "shuttle-proto" +version = "0.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fdb0b1e4029c73b2be07e2c885cab67cec48e44bce298bdbd76201bc1211b7a" +dependencies = [ + "anyhow", + "chrono", + "home", + "prost", + "prost-types", + "shuttle-common", + "tokio", + "tonic", + "tower", + "tracing", +] + +[[package]] +name = "shuttle-runtime" +version = "0.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "be538eec058fa1816086358e3315716876c9c45e85e09e566b365154133ea4ff" +dependencies = [ + "anyhow", + "async-trait", + "chrono", + "clap", + "prost-types", + "serde", + "serde_json", + "shuttle-common", + "shuttle-proto", + "shuttle-service", + "strfmt", + "thiserror", + "tokio", + "tokio-stream", + "tonic", + "tower", + "tracing", + "tracing-subscriber", +] + +[[package]] +name = "shuttle-service" +version = "0.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05c10309ce94dac2bba01a13e8c72e543fef8374e49cc30bd644e71d864b0764" +dependencies = [ + "anyhow", + "async-trait", + "serde", + "shuttle-codegen", + "shuttle-common", + "strfmt", + "thiserror", +] + +[[package]] +name = "shuttle-static-folder" +version = "0.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "27a9e59077a02423713e401f10600f9f54b44a4378400cda231527a37103f4ba" +dependencies = [ + "async-trait", + "dunce", + "fs_extra", + "serde", + "shuttle-service", + "tracing", +] + [[package]] name = "signal-hook-registry" version = "1.4.1" @@ -1634,6 +2595,18 @@ dependencies = [ "libc", ] +[[package]] +name = "simple_asn1" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "adc4e5204eb1910f40f9cfa375f6f05b68c3abac4b6fd879c8ff5e7ae8a0a085" +dependencies = [ + "num-bigint", + "num-traits", + "thiserror", + "time", +] + [[package]] name = "slab" version = "0.4.8" @@ -1665,12 +2638,40 @@ version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d" +[[package]] +name = "strfmt" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a8348af2d9fc3258c8733b8d9d8db2e56f54b2363a4b5b81585c7875ed65e65" + [[package]] name = "strsim" version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" +[[package]] +name = "strum" +version = "0.24.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "063e6045c0e62079840579a7e47a355ae92f60eb74daaf156fb1e84ba164e63f" +dependencies = [ + "strum_macros", +] + +[[package]] +name = "strum_macros" +version = "0.24.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e385be0d24f186b4ce2f9982191e7101bb737312ad61c1f2f984f34bcf85d59" +dependencies = [ + "heck", + "proc-macro2", + "quote", + "rustversion", + "syn 1.0.109", +] + [[package]] name = "syn" version = "1.0.109" @@ -1693,6 +2694,12 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "sync_wrapper" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2047c6ded9c721764247e62cd3b03c09ffc529b2ba5b10ec482ae507a4a70160" + [[package]] name = "tempfile" version = "3.5.0" @@ -1715,6 +2722,36 @@ dependencies = [ "winapi-util", ] +[[package]] +name = "thiserror" +version = "1.0.40" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "978c9a314bd8dc99be594bc3c175faaa9794be04a5a5e153caba6915336cebac" +dependencies = [ + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.40" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f9456a42c5b0d803c8cd86e73dd7cc9edd429499f37a3550d286d5e86720569f" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.15", +] + +[[package]] +name = "thread_local" +version = "1.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3fdd6f064ccff2d6567adcb3873ca630700f00b5ad3f060c25b5dcfd9a4ce152" +dependencies = [ + "cfg-if 1.0.0", + "once_cell", +] + [[package]] name = "time" version = "0.3.21" @@ -1767,13 +2804,36 @@ dependencies = [ "bytes", "libc", "mio 0.8.6", + "num_cpus", "parking_lot", "pin-project-lite", "signal-hook-registry", "socket2", + "tokio-macros", "windows-sys 0.48.0", ] +[[package]] +name = "tokio-io-timeout" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "30b74022ada614a1b4834de765f9bb43877f910cc8ce4be40e89042c9223a8bf" +dependencies = [ + "pin-project-lite", + "tokio", +] + +[[package]] +name = "tokio-macros" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "630bdcf245f78637c13ec01ffae6187cca34625e8c63150d424b59e55af2675e" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.15", +] + [[package]] name = "tokio-rustls" version = "0.23.4" @@ -1785,6 +2845,17 @@ dependencies = [ "webpki", ] +[[package]] +name = "tokio-stream" +version = "0.1.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "397c988d37662c7dda6d2208364a706264bf3d6138b11d436cbac0ad38832842" +dependencies = [ + "futures-core", + "pin-project-lite", + "tokio", +] + [[package]] name = "tokio-util" version = "0.7.8" @@ -1808,6 +2879,102 @@ dependencies = [ "serde", ] +[[package]] +name = "tonic" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f219fad3b929bef19b1f86fbc0358d35daed8f2cac972037ac0dc10bbb8d5fb" +dependencies = [ + "async-stream", + "async-trait", + "axum", + "base64 0.13.1", + "bytes", + "futures-core", + "futures-util", + "h2", + "http", + "http-body", + "hyper", + "hyper-timeout", + "percent-encoding", + "pin-project", + "prost", + "prost-derive", + "tokio", + "tokio-stream", + "tokio-util", + "tower", + "tower-layer", + "tower-service", + "tracing", + "tracing-futures", +] + +[[package]] +name = "tonic-build" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5bf5e9b9c0f7e0a7c027dcfaba7b2c60816c7049171f679d99ee2ff65d0de8c4" +dependencies = [ + "prettyplease", + "proc-macro2", + "prost-build", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "tower" +version = "0.4.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8fa9be0de6cf49e536ce1851f987bd21a43b771b09473c3549a6c853db37c1c" +dependencies = [ + "futures-core", + "futures-util", + "indexmap", + "pin-project", + "pin-project-lite", + "rand", + "slab", + "tokio", + "tokio-util", + "tower-layer", + "tower-service", + "tracing", +] + +[[package]] +name = "tower-http" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5d1d42a9b3f3ec46ba828e8d376aec14592ea199f70a06a548587ecd1c4ab658" +dependencies = [ + "bitflags", + "bytes", + "futures-core", + "futures-util", + "http", + "http-body", + "http-range-header", + "pin-project-lite", + "tower-layer", + "tower-service", + "tracing", +] + +[[package]] +name = "tower-layer" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c20c8dbed6283a09604c3e69b4b7eeb54e298b8a600d4d5ecb5ad39de609f1d0" + +[[package]] +name = "tower-service" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6bc1c9ce2b5135ac7f93c72918fc37feb872bdc6a5533a8b85eb4b86bfdae52" + [[package]] name = "tracing" version = "0.1.37" @@ -1817,9 +2984,21 @@ dependencies = [ "cfg-if 1.0.0", "log", "pin-project-lite", + "tracing-attributes", "tracing-core", ] +[[package]] +name = "tracing-attributes" +version = "0.1.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0f57e3ca2a01450b1a921183a9c9cbfda207fd822cef4ccb00a65402cbba7a74" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.15", +] + [[package]] name = "tracing-core" version = "0.1.30" @@ -1827,6 +3006,75 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "24eb03ba0eab1fd845050058ce5e616558e8f8d8fca633e6b163fe25c797213a" dependencies = [ "once_cell", + "valuable", +] + +[[package]] +name = "tracing-futures" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97d095ae15e245a057c8e8451bab9b3ee1e1f68e9ba2b4fbc18d0ac5237835f2" +dependencies = [ + "pin-project", + "tracing", +] + +[[package]] +name = "tracing-log" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78ddad33d2d10b1ed7eb9d1f518a5674713876e97e5bb9b7345a7984fbb4f922" +dependencies = [ + "lazy_static", + "log", + "tracing-core", +] + +[[package]] +name = "tracing-opentelemetry" +version = "0.18.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "21ebb87a95ea13271332df069020513ab70bdb5637ca42d6e492dc3bbbad48de" +dependencies = [ + "once_cell", + "opentelemetry", + "tracing", + "tracing-core", + "tracing-log", + "tracing-subscriber", +] + +[[package]] +name = "tracing-subscriber" +version = "0.3.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "30a651bc37f915e81f087d86e62a18eec5f79550c7faff886f7090b4ea757c77" +dependencies = [ + "matchers", + "nu-ansi-term", + "once_cell", + "regex", + "sharded-slab", + "smallvec", + "thread_local", + "tracing", + "tracing-core", + "tracing-log", +] + +[[package]] +name = "try-lock" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3528ecfd12c466c6f163363caf2d02a71161dd5e1cc6ae7b34207ea2d42d81ed" + +[[package]] +name = "ttl_cache" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4189890526f0168710b6ee65ceaedf1460c48a14318ceec933cb26baa492096a" +dependencies = [ + "linked-hash-map", ] [[package]] @@ -1888,6 +3136,28 @@ version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5190c9442dcdaf0ddd50f37420417d219ae5261bbf5db120d0f9bab996c9cba1" +[[package]] +name = "utf8parse" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" + +[[package]] +name = "uuid" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4dad5567ad0cf5b760e5665964bec1b47dfd077ba8a2544b513f3556d3d239a2" +dependencies = [ + "getrandom", + "serde", +] + +[[package]] +name = "valuable" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d" + [[package]] name = "version_check" version = "0.9.4" @@ -1904,6 +3174,16 @@ dependencies = [ "winapi-util", ] +[[package]] +name = "want" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ce8a968cb1cd110d136ff8b819a556d6fb6d919363c61534f6860c7eb172ba0" +dependencies = [ + "log", + "try-lock", +] + [[package]] name = "wasi" version = "0.11.0+wasi-snapshot-preview1" @@ -1993,6 +3273,17 @@ dependencies = [ "webpki", ] +[[package]] +name = "which" +version = "4.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2441c784c52b289a054b7201fc93253e288f094e2f4be9058343127c4226a269" +dependencies = [ + "either", + "libc", + "once_cell", +] + [[package]] name = "winapi" version = "0.2.8" @@ -2036,6 +3327,15 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" +[[package]] +name = "windows" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e686886bc078bc1b0b600cac0147aadb815089b6e4da64016cbd754b6342700f" +dependencies = [ + "windows-targets 0.48.0", +] + [[package]] name = "windows-sys" version = "0.45.0" diff --git a/Cargo.toml b/Cargo.toml index cd59455..dc108e8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,6 +12,15 @@ keywords = ["paste", "pastebin", "upload"] categories = ["web-programming::http-server"] include = ["src/**/*", "Cargo.*", "LICENSE", "README.md", "CHANGELOG.md"] +[features] +default = [] +shuttle = [ + "dep:shuttle-actix-web", + "dep:shuttle-runtime", + "dep:shuttle-static-folder", + "dep:tokio", +] + [dependencies] actix-web = { version = "4.3.1", features = ["rustls"] } actix-multipart = "0.6.0" @@ -21,7 +30,10 @@ env_logger = "0.10.0" log = "0.4.17" serde = "1.0.163" futures-util = "0.3.28" -petname = { version = "1.1.3", default-features = false, features = ["std_rng", "default_dictionary"] } +petname = { version = "1.1.3", default-features = false, features = [ + "std_rng", + "default_dictionary", +] } rand = "0.8.5" dotenvy = "0.15.7" url = "2.3.1" @@ -34,6 +46,10 @@ humantime-serde = "1.1.1" glob = "0.3.1" ring = "0.16.20" hotwatch = "0.4.5" +shuttle-actix-web = { version = "0.16.0", optional = true } +shuttle-runtime = { version = "0.16.0", optional = true } +shuttle-static-folder = { version = "0.16.0", optional = true } +tokio = { version = "1.28.1", optional = true } [dependencies.config] version = "0.13.3" @@ -54,7 +70,6 @@ actix-rt = "2.8.0" [profile.dev] opt-level = 0 debug = true -panic = "abort" [profile.test] opt-level = 0 diff --git a/README.md b/README.md index 0beecd2..2d4f64c 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,8 @@ $ curl https://paste.site.com/safe-toad.txt some text ``` +The public instance is available at [https://rustypaste.shuttleapp.rs](https://rustypaste.shuttleapp.rs) 🚀 + ## Features - File upload & URL shortening & upload from URL diff --git a/config.toml b/config.toml index a2a9064..a4314a5 100644 --- a/config.toml +++ b/config.toml @@ -3,6 +3,7 @@ refresh_rate = "1s" [server] address = "127.0.0.1:8000" +#url = "https://rustypaste.shuttleapp.rs" #workers=4 max_content_length = "10MB" upload_path = "./upload" diff --git a/shuttle/config.toml b/shuttle/config.toml new file mode 100644 index 0000000..2379e77 --- /dev/null +++ b/shuttle/config.toml @@ -0,0 +1,53 @@ +[config] +refresh_rate = "1s" + +[server] +address = "127.0.0.1:8000" +url = "https://rustypaste.shuttleapp.rs" +#workers=4 +max_content_length = "10MB" +upload_path = "./upload" +timeout = "30s" +expose_version = true +landing_page = """ +┬─┐┬ ┬┌─┐┌┬┐┬ ┬┌─┐┌─┐┌─┐┌┬┐┌─┐ +├┬┘│ │└─┐ │ └┬┘├─┘├─┤└─┐ │ ├┤ +┴└─└─┘└─┘ ┴ ┴ ┴ ┴ ┴└─┘ ┴ └─┘ + +Submit files via HTTP POST here: + + curl -F 'file=@example.txt' https://rustypaste.shuttleapp.rs + +This will return the URL of the uploaded file. + +Pastes expire every hour. Uploaded files might not be persistent. + +Check out the GitHub repository: https://github.com/orhun/rustypaste +Command line tool is available : https://github.com/orhun/rustypaste-cli + +If you liked this, consider supporting me: https://donate.orhun.dev <3 + +🦀 +""" + +[paste] +# random_url = { enabled = true, type = "petname", words = 2, separator = "-" } +random_url = { enabled = true, type = "alphanumeric", length = 6 } +default_extension = "txt" +mime_override = [ + { mime = "image/jpeg", regex = "^.*\\.jpg$" }, + { mime = "image/png", regex = "^.*\\.png$" }, + { mime = "image/svg+xml", regex = "^.*\\.svg$" }, + { mime = "video/webm", regex = "^.*\\.webm$" }, + { mime = "video/x-matroska", regex = "^.*\\.mkv$" }, + { mime = "application/octet-stream", regex = "^.*\\.bin$" }, + { mime = "text/plain", regex = "^.*\\.(log|txt|diff|sh|kt|rs|toml)$" }, +] +mime_blacklist = [ + "application/x-dosexec", + "application/java-archive", + "application/java-vm", +] +duplicate_files = true +default_expiry = "1h" +delete_expired_files = { enabled = true, interval = "1h" } diff --git a/src/main.rs b/src/main.rs index 55e3afc..57782b9 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,9 +1,10 @@ use actix_web::middleware::Logger; use actix_web::web::Data; +#[cfg(not(feature = "shuttle"))] use actix_web::{App, HttpServer}; use awc::ClientBuilder; use hotwatch::{Event, Hotwatch}; -use rustypaste::config::Config; +use rustypaste::config::{Config, ServerConfig}; use rustypaste::paste::PasteType; use rustypaste::server; use rustypaste::util; @@ -11,17 +12,28 @@ use rustypaste::CONFIG_ENV; use std::env; use std::fs; use std::io::Result as IoResult; -use std::path::PathBuf; +use std::path::{Path, PathBuf}; use std::sync::{mpsc, RwLock}; use std::thread; use std::time::Duration; +#[cfg(feature = "shuttle")] +use { + actix_web::web::{self, ServiceConfig}, + shuttle_actix_web::ShuttleActixWeb, +}; -#[actix_web::main] -async fn main() -> IoResult<()> { +/// Sets up the application. +/// +/// * loads the configuration +/// * initializes the logger +/// * creates the necessary directories +/// * spawns the threads +fn setup(config_folder: &Path) -> IoResult<(Data>, ServerConfig, Hotwatch)> { // Load the .env file. dotenvy::dotenv().ok(); // Initialize logger. + #[cfg(not(feature = "shuttle"))] env_logger::init_from_env(env_logger::Env::new().default_filter_or("info")); // Parse configuration. @@ -30,7 +42,7 @@ async fn main() -> IoResult<()> { env::remove_var(CONFIG_ENV); PathBuf::from(path) } - None => PathBuf::from("config.toml"), + None => config_folder.join("config.toml"), }; let config = Config::parse(&config_path).expect("failed to parse config"); log::trace!("{:#?}", config); @@ -83,6 +95,7 @@ async fn main() -> IoResult<()> { .unwrap_or_else(|_| panic!("failed to watch {config_path:?}")); // Create a thread for cleaning up expired files. + let upload_path = server_config.upload_path.clone(); thread::spawn(move || loop { let mut enabled = false; if let Some(ref cleanup_config) = paste_config @@ -92,7 +105,7 @@ async fn main() -> IoResult<()> { { if cleanup_config.enabled { log::debug!("Running cleanup..."); - for file in util::get_expired_files(&server_config.upload_path) { + for file in util::get_expired_files(&upload_path) { match fs::remove_file(&file) { Ok(()) => log::info!("Removed expired file: {:?}", file), Err(e) => log::error!("Cannot remove expired file: {}", e), @@ -118,6 +131,15 @@ async fn main() -> IoResult<()> { } }); + Ok((config, server_config, hotwatch)) +} + +#[cfg(not(feature = "shuttle"))] +#[actix_web::main] +async fn main() -> IoResult<()> { + // Set up the application. + let (config, server_config, _) = setup(&PathBuf::new())?; + // Create an HTTP server. let mut http_server = HttpServer::new(move || { let http_client = ClientBuilder::new() @@ -144,3 +166,33 @@ async fn main() -> IoResult<()> { // Run the server. http_server.run().await } + +#[cfg(feature = "shuttle")] +#[shuttle_runtime::main] +async fn actix_web( + #[shuttle_static_folder::StaticFolder(folder = "shuttle")] static_folder: PathBuf, +) -> ShuttleActixWeb { + // Set up the application. + let (config, server_config, _) = setup(&static_folder)?; + + // Create the service. + let service_config = move |cfg: &mut ServiceConfig| { + let http_client = ClientBuilder::new() + .timeout( + server_config + .timeout + .unwrap_or_else(|| Duration::from_secs(30)), + ) + .disable_redirects() + .finish(); + cfg.service( + web::scope("") + .app_data(Data::clone(&config)) + .app_data(Data::new(http_client)) + .wrap(Logger::default()) + .configure(server::configure_routes), + ); + }; + + Ok(service_config.into()) +} From 82f1a3207f574f06d009b49f610684f9e1709a38 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Orhun=20Parmaks=C4=B1z?= Date: Sun, 14 May 2023 21:44:22 +0300 Subject: [PATCH 16/30] chore(docker): remove dependency caching from Dockerfile --- Dockerfile | 5 ----- 1 file changed, 5 deletions(-) diff --git a/Dockerfile b/Dockerfile index b15eb8b..e007c11 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,11 +2,6 @@ FROM rust:1.67.0-alpine3.17 as builder WORKDIR /app RUN apk update RUN apk add --no-cache musl-dev -COPY Cargo.toml Cargo.toml -RUN mkdir -p src/ -RUN echo "fn main() {println!(\"failed to build\")}" > src/main.rs -RUN cargo build --release -RUN rm -f target/release/deps/rustypaste* COPY . . RUN cargo build --locked --release RUN mkdir -p build-out/ From a415ef60a0e5fa577b625b1307c0e33d10a57d27 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Orhun=20Parmaks=C4=B1z?= Date: Sun, 14 May 2023 21:57:27 +0300 Subject: [PATCH 17/30] chore(docker): enable dependency caching in Dockerfile This reverts commit 82f1a3207f574f06d009b49f610684f9e1709a38. --- Dockerfile | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Dockerfile b/Dockerfile index e007c11..b15eb8b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,6 +2,11 @@ FROM rust:1.67.0-alpine3.17 as builder WORKDIR /app RUN apk update RUN apk add --no-cache musl-dev +COPY Cargo.toml Cargo.toml +RUN mkdir -p src/ +RUN echo "fn main() {println!(\"failed to build\")}" > src/main.rs +RUN cargo build --release +RUN rm -f target/release/deps/rustypaste* COPY . . RUN cargo build --locked --release RUN mkdir -p build-out/ From d57ed1125fe2eb992465d8df354d19b2800663a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Orhun=20Parmaks=C4=B1z?= Date: Sun, 14 May 2023 22:06:29 +0300 Subject: [PATCH 18/30] chore(docker): disable arm64 builds temporarily --- .github/workflows/docker.yml | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 2426283..074564d 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -35,11 +35,6 @@ jobs: type=raw,value=latest type=semver,pattern={{version}} - - name: Set up QEMU - uses: docker/setup-qemu-action@v2 - with: - platforms: arm64 - - name: Set up Docker Buildx id: buildx uses: docker/setup-buildx-action@v2 @@ -73,7 +68,7 @@ jobs: with: context: ./ file: ./Dockerfile - platforms: linux/amd64,linux/arm64 + platforms: linux/amd64 builder: ${{ steps.buildx.outputs.name }} push: ${{ github.event_name != 'pull_request' }} tags: ${{ steps.meta.outputs.tags }} From 9e61cca98e45388416a242af36bc56fa7042e5cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Orhun=20Parmaks=C4=B1z?= Date: Sun, 14 May 2023 23:55:47 +0300 Subject: [PATCH 19/30] docs(readme): update features section about `default_expiry` --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 2d4f64c..2812a53 100644 --- a/README.md +++ b/README.md @@ -22,6 +22,7 @@ The public instance is available at [https://rustypaste.shuttleapp.rs](https://r - pet name (e.g. `capital-mosquito.txt`) - alphanumeric string (e.g. `yB84D2Dv.txt`) - supports expiring links + - auto-expiration of files (optional) - auto-deletion of expired files (optional) - supports one shot links (can only be viewed once) - guesses MIME types From e3a634b7af0b40bdfa0c1be67a88d7dce7b0d055 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Orhun=20Parmaks=C4=B1z?= Date: Wed, 17 May 2023 04:23:01 +0300 Subject: [PATCH 20/30] chore(deploy): restart the project before deployment --- .github/workflows/shuttle.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/shuttle.yml b/.github/workflows/shuttle.yml index 51af971..63442a7 100644 --- a/.github/workflows/shuttle.yml +++ b/.github/workflows/shuttle.yml @@ -27,5 +27,7 @@ jobs: run: sed -i 's|default = \[\]|default = \["shuttle"\]|g' Cargo.toml - name: Login run: cargo shuttle login --api-key ${{ secrets.SHUTTLE_TOKEN }} + - name: Restart + run: cargo shuttle project restart - name: Deploy run: cargo shuttle deploy --allow-dirty --no-test From 00d46b4b21aa57ab94125642cd13be343b5377d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Orhun=20Parmaks=C4=B1z?= Date: Wed, 17 May 2023 04:32:54 +0300 Subject: [PATCH 21/30] style(readme): add badges to README.md --- README.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/README.md b/README.md index 2812a53..03dcafe 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,13 @@ +[![GitHub Release](https://img.shields.io/github/v/release/orhun/rustypaste?style=flat&labelColor=823213&color=2c2c2c&logo=GitHub&logoColor=white)](https://github.com/orhun/rustypaste/releases) +[![Crate Release](https://img.shields.io/crates/v/rustypaste?style=flat&labelColor=823213&color=2c2c2c&logo=Rust&logoColor=white)](https://crates.io/crates/rustypaste/) +[![Coverage](https://img.shields.io/codecov/c/gh/orhun/rustypaste?style=flat&labelColor=823213&color=2c2c2c&logo=Codecov&logoColor=white)](https://codecov.io/gh/orhun/rustypaste) +[![Continuous Integration](https://img.shields.io/github/actions/workflow/status/orhun/rustypaste/ci.yml?branch=master&style=flat&labelColor=823213&color=2c2c2c&logo=GitHub%20Actions&logoColor=white)](https://github.com/orhun/rustypaste/actions?query=workflow%3A%22Continuous+Integration%22) +[![Continuous Deployment](https://img.shields.io/github/actions/workflow/status/orhun/rustypaste/cd.yml?style=flat&labelColor=823213&color=2c2c2c&logo=GitHub%20Actions&logoColor=white&label=deploy)](https://github.com/orhun/rustypaste/actions?query=workflow%3A%22Continuous+Deployment%22) +[![Docker Builds](https://img.shields.io/github/actions/workflow/status/orhun/rustypaste/docker.yml?style=flat&labelColor=823213&color=2c2c2c&label=docker&logo=Docker&logoColor=white)](https://hub.docker.com/r/orhunp/rustypaste) +[![Documentation](https://img.shields.io/docsrs/rustypaste?style=flat&labelColor=823213&color=2c2c2c&logo=Rust&logoColor=white)](https://docs.rs/rustypaste/) + **Rustypaste** is a minimal file upload/pastebin service. ```sh From b092b0047d137c071dd364350891c72e75ce176c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Orhun=20Parmaks=C4=B1z?= Date: Wed, 17 May 2023 12:25:12 +0300 Subject: [PATCH 22/30] style(changelog): format the changelog --- CHANGELOG.md | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index e9cedc7..d10f750 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,5 @@ # Changelog + All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), @@ -13,18 +14,24 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - This is useful when e.g. you want to be able to share the link to a file that would play in the browser (like `.mp4`) but also share a link that will auto-download as well. ## [0.8.3] - 2023-01-30 + ### Updated + - Bump dependencies - Switch to [Rust](https://hub.docker.com/_/rust) image for the Dockerfile - Remove unused `clap` dependency ## [0.8.2] - 2022-10-04 + ### Updated + - Don't expose version endpoint in default config - Set `expose_version` to `false` in the configuration file ## [0.8.1] - 2022-10-04 + ### Added + - Add `/version` endpoint for retrieving the server version ```toml @@ -35,11 +42,14 @@ expose_version=true If `expose_version` entry is not present in the configuration file, `/version` is not exposed. It is recommended to use this feature with authorization enabled. ### Fixed + - Replace unmaintained `dotenv` crate with `dotenvy` - Fixes [RUSTSEC-2021-0141](https://rustsec.org/advisories/RUSTSEC-2021-0141.html) ## [0.8.0] - 2022-10-03 + ### Added + - Support adding a landing page You can now specify a landing page text in the configuration file as follows: @@ -56,6 +66,7 @@ welcome! If the landing page entry is not present in the configuration file, visiting the index page will redirect to the repository. ### Updated + - Do not check for duplicate files by default - Set `duplicate_files` to `true` in the configuration file - It is an expensive operation to do on slower hardware and can take an unreasonable amount of time for bigger files @@ -63,13 +74,17 @@ If the landing page entry is not present in the configuration file, visiting the - Consider supporting me for my open-source work 💖 ## [0.7.1] - 2022-05-21 + ### Added + - Aggressively test everything - Add the missing unit tests for the server endpoints (code coverage is increased to 84%) - Create a custom testing framework (written in Bash) for adding [test fixtures](https://github.com/orhun/rustypaste/tree/master/fixtures) ## [0.7.0] - 2022-03-26 + ### Added + - Support auto-deletion of expired files `rustypaste` can now delete the expired files by itself. To enable this feature, add the following line to the `[paste]` section in the configuration file: @@ -86,26 +101,33 @@ For users who want to have this feature disabled, there is an alternative [shell - For the installation and usage, see the Arch Linux [PKGBUILD](https://github.com/archlinux/svntogit-community/blob/packages/rustypaste/trunk/PKGBUILD). ### Updated + - Upgrade Actix dependencies - `actix-web` is updated to [`4.0.*`](https://github.com/actix/actix-web/blob/master/actix-web/CHANGES.md#401---2022-02-25) - Strip the binaries during automated builds - Size of the Docker image is reduced by ~20% ### Fixed + - Prevent invalid attempts of serving directories - This fixes an issue where requesting a directory was possible via e.g. `curl --path-as-is 0.0.0.0:8080/.` - This issue had no security impact (path traversal wasn't possible) since internal server error was returned. ## [0.6.5] - 2022-03-13 + ### Added + - Add instructions for installing [rustypaste](https://archlinux.org/packages/community/x86_64/rustypaste/) on Arch Linux - `pacman -S rustypaste` 🎉 ### Fixed + - Fix a bug where the use of `CONFIG` environment variable causes a conflict between the configuration file path and `[config]` section ## [0.6.4] - 2022-03-11 + ### Added + - Support setting the refresh rate for hot-reloading the configuration file. ```toml @@ -121,11 +143,14 @@ timeout="30s" ``` ### Security + - Bump [regex crate](https://github.com/rust-lang/regex) to **1.5.5** - Fixes [CVE-2022-24713](https://github.com/advisories/GHSA-m5pq-gvj9-9vr8) ## [0.6.3] - 2022-02-24 + ### Added + - Support setting the authentication token in the configuration file. - This is an alternative (but not recommended) way of setting up authentication when the use of `AUTH_TOKEN` environment variable is not applicable. @@ -135,28 +160,37 @@ auth_token="hunter2" ``` ## [0.6.2] - 2021-12-05 + ### Updated + - Improve the concurrency - Shrink the scope of non-suspendable types (`#[must_not_suspend]`) for dropping them before reaching a suspend point (`.await` call). This avoids possible deadlocks, delays, and situations where `Future`s not implementing `Send`. - Reference: https://rust-lang.github.io/rfcs/3014-must-not-suspend-lint.html ## [0.6.1] - 2021-11-16 + ### Fixed + - Gracefully handle the hot-reloading errors. - Errors that may occur while locking the [Mutex](https://doc.rust-lang.org/std/sync/struct.Mutex.html) are handled properly hence a single configuration change cannot take down the whole service due to [poisoning](https://doc.rust-lang.org/std/sync/struct.Mutex.html#poisoning). ## [0.6.0] - 2021-11-07 + ### Added + - Support pasting files from remote URLs (via `remote=` form field) + - `{server.max_content_length}` is used for download limit - See [README.md#paste-file-from-remote-url](https://github.com/orhun/rustypaste#paste-file-from-remote-url) - Hot reload configuration file to apply configuration changes instantly without restarting the server ### Changed + - Library: Switch to Rust 2021 edition ### Security + - Prevent serving an already expired file In the previous versions, it was possible to view an expired file by using the correct extension (timestamp). e.g. `paste.com/expired_file.txt.1630094518049` will serve the file normally although `paste.com/expired_file.txt` says that it is expired. This version fixes this vulnerability by regex-checking the requested file's extension. @@ -164,7 +198,9 @@ In the previous versions, it was possible to view an expired file by using the c reference: [f078a9afa74f8608ee3f2a6e705159df15915c78](https://github.com/orhun/rustypaste/commit/f078a9afa74f8608ee3f2a6e705159df15915c78) ## [0.5.0] - 2021-10-12 + ### Added + - Added an entry in the configuration file to disable "duplicate uploads": ```toml @@ -176,13 +212,17 @@ duplicate_files = false Under the hood, it checks the SHA256 digest of the uploaded files. ## [0.4.1] - 2021-09-19 + ### Changed + - Update README.md: - Mention the new standalone tool: [rustypaste-cli](https://github.com/orhun/rustypaste-cli) - Add [installation](https://github.com/orhun/rustypaste#installation) section. ## [0.4.0] - 2021-08-27 + ### Added + - Support [expiring links](README.md#expiration) (via `expire:` header) - Timestamps are used as extension for expiring files - Expired files can be cleaned up with [this command](README.md#cleaning-up-expired-files) @@ -190,28 +230,39 @@ Under the hood, it checks the SHA256 digest of the uploaded files. - `{server.upload_path}/oneshot` is used for storage ## [0.3.1] - 2021-08-10 + ### Fixed + - Switch to [upload-release-action](https://github.com/svenstaro/upload-release-action) for uploading releases ## [0.3.0] - 2021-08-09 + ### Added + - Support overriding MIME types (config: `mime_override`) - Support blacklisting MIME types (config: `mime_blacklist`) ## [0.2.0] - 2021-08-04 + ### Added + - Support shortening URLs (via `url=` form field) - `{server.upload_path}/url` is used for storage ## [0.1.3] - 2021-07-28 + ### Fixed + - Prevent sending empty file name and zero bytes - Prevent path traversal on upload directory ([#2](https://github.com/orhun/rustypaste/issues/2)) - Check the content length while reading bytes for preventing OOM ([#1](https://github.com/orhun/rustypaste/issues/1)) ## [0.1.2] - 2021-07-27 + ### Changed + - Update Continuous Deployment workflow to publish Docker images ## [0.1.1] - 2021-07-27 + Initial release. From c1b47e28c957aadeeb3d066818b1b679be38e068 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Orhun=20Parmaks=C4=B1z?= Date: Wed, 17 May 2023 12:28:39 +0300 Subject: [PATCH 23/30] docs(readme): add instructions for Alpine Linux --- README.md | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 03dcafe..9fa1db9 100644 --- a/README.md +++ b/README.md @@ -64,9 +64,17 @@ cargo install rustypaste pacman -S rustypaste ``` +### Alpine Linux + +`rustypaste` is available for [Alpine Edge](https://pkgs.alpinelinux.org/packages?name=rustypaste&branch=edge). It can be installed via [apk](https://wiki.alpinelinux.org/wiki/Alpine_Package_Keeper) after enabling the [testing repository](https://wiki.alpinelinux.org/wiki/Repositories). + +```sh +apk add rustypaste +``` + ### Binary releases -See the available binaries on [releases](https://github.com/orhun/rustypaste/releases/) page. +See the available binaries on the [releases](https://github.com/orhun/rustypaste/releases/) page. ### Build from source From 5b45b35a448cf6cf842f0a388e3854d9232f2c89 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Orhun=20Parmaks=C4=B1z?= Date: Wed, 17 May 2023 12:29:40 +0300 Subject: [PATCH 24/30] docs(readme): add information about how to run test fixtures --- README.md | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 9fa1db9..0e6bafc 100644 --- a/README.md +++ b/README.md @@ -86,11 +86,18 @@ cargo build --release #### Testing +##### Unit tests + ```sh -# run unit tests cargo test -- --test-threads 1 ``` +##### Test Fixtures + +```sh +./fixtures/test-fixtures.sh +``` + ## Usage The standalone command line tool (`rpaste`) is available [here](https://github.com/orhun/rustypaste-cli). From dca80419902d71709fc4950a22c98d1b1cc2f382 Mon Sep 17 00:00:00 2001 From: alice Date: Wed, 17 May 2023 11:30:59 +0200 Subject: [PATCH 25/30] feat(deps): allow using openssl for tls (#37) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat(deps): allow using openssl for tls this allows reusing the openssl present on a distro already, and takes a release build with it from 5.5 to 4.7mb * chore(shuttle): update the enabled features for deployment --------- Co-authored-by: Orhun Parmaksız --- .github/workflows/shuttle.yml | 2 +- Cargo.lock | 74 +++++++++++++++++++++++++++++++++++ Cargo.toml | 8 ++-- 3 files changed, 80 insertions(+), 4 deletions(-) diff --git a/.github/workflows/shuttle.yml b/.github/workflows/shuttle.yml index 63442a7..0d250e9 100644 --- a/.github/workflows/shuttle.yml +++ b/.github/workflows/shuttle.yml @@ -24,7 +24,7 @@ jobs: run: cargo binstall -y cargo-shuttle - name: Prepare for deployment shell: bash - run: sed -i 's|default = \[\]|default = \["shuttle"\]|g' Cargo.toml + run: sed -i 's|default = \["rustls"\]|default = \["rustls", "shuttle"\]|g' Cargo.toml - name: Login run: cargo shuttle login --api-key ${{ secrets.SHUTTLE_TOKEN }} - name: Restart diff --git a/Cargo.lock b/Cargo.lock index 15ff787..c3a3d0f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -196,7 +196,9 @@ dependencies = [ "futures-core", "http", "log", + "openssl", "pin-project-lite", + "tokio-openssl", "tokio-rustls", "tokio-util", "webpki-roots", @@ -459,6 +461,7 @@ dependencies = [ "itoa", "log", "mime", + "openssl", "percent-encoding", "pin-project-lite", "rand", @@ -953,6 +956,21 @@ version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" +[[package]] +name = "foreign-types" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" +dependencies = [ + "foreign-types-shared", +] + +[[package]] +name = "foreign-types-shared" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" + [[package]] name = "form_urlencoded" version = "1.1.0" @@ -1793,6 +1811,44 @@ version = "1.17.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b7e5500299e16ebb147ae15a00a942af264cf3688f47923b8fc2cd5858f23ad3" +[[package]] +name = "openssl" +version = "0.10.52" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "01b8574602df80f7b85fdfc5392fa884a4e3b3f4f35402c070ab34c3d3f78d56" +dependencies = [ + "bitflags", + "cfg-if 1.0.0", + "foreign-types", + "libc", + "once_cell", + "openssl-macros", + "openssl-sys", +] + +[[package]] +name = "openssl-macros" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.15", +] + +[[package]] +name = "openssl-sys" +version = "0.9.87" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e17f59264b2809d77ae94f0e1ebabc434773f370d6ca667bd223ea10e06cc7e" +dependencies = [ + "cc", + "libc", + "pkg-config", + "vcpkg", +] + [[package]] name = "opentelemetry" version = "0.18.0" @@ -2834,6 +2890,18 @@ dependencies = [ "syn 2.0.15", ] +[[package]] +name = "tokio-openssl" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c08f9ffb7809f1b20c1b398d92acf4cc719874b3b2b2d9ea2f09b4a80350878a" +dependencies = [ + "futures-util", + "openssl", + "openssl-sys", + "tokio", +] + [[package]] name = "tokio-rustls" version = "0.23.4" @@ -3158,6 +3226,12 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d" +[[package]] +name = "vcpkg" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" + [[package]] name = "version_check" version = "0.9.4" diff --git a/Cargo.toml b/Cargo.toml index dc108e8..2f613c4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,7 +13,9 @@ categories = ["web-programming::http-server"] include = ["src/**/*", "Cargo.*", "LICENSE", "README.md", "CHANGELOG.md"] [features] -default = [] +default = ["rustls"] +openssl = ["actix-web/openssl", "awc/openssl"] +rustls = ["actix-web/rustls", "awc/rustls"] shuttle = [ "dep:shuttle-actix-web", "dep:shuttle-runtime", @@ -22,10 +24,10 @@ shuttle = [ ] [dependencies] -actix-web = { version = "4.3.1", features = ["rustls"] } +actix-web = { version = "4.3.1" } actix-multipart = "0.6.0" actix-files = "0.6.2" -awc = { version = "3.1.1", features = ["rustls"] } +awc = { version = "3.1.1" } env_logger = "0.10.0" log = "0.4.17" serde = "1.0.163" From f28fe68ba7478ead1ac383e2744ca356f7e3d2f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Orhun=20Parmaks=C4=B1z?= Date: Wed, 17 May 2023 12:32:48 +0300 Subject: [PATCH 26/30] chore(deps): upgrade transitive dependencies --- Cargo.lock | 78 +++++++++++++++++++++++++++--------------------------- 1 file changed, 39 insertions(+), 39 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c3a3d0f..2f48fdc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4,19 +4,19 @@ version = 3 [[package]] name = "actix-codec" -version = "0.5.0" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57a7559404a7f3573127aab53c08ce37a6c6a315c374a31070f3c91cd1b4a7fe" +checksum = "617a8268e3537fe1d8c9ead925fca49ef6400927ee7bc26750e90ecee14ce4b8" dependencies = [ "bitflags", "bytes", "futures-core", "futures-sink", - "log", "memchr", "pin-project-lite", "tokio", "tokio-util", + "tracing", ] [[package]] @@ -416,7 +416,7 @@ checksum = "16e62a023e7c117e27523144c5d2459f4397fcc3cab0085af8e2224f643a0193" dependencies = [ "proc-macro2", "quote", - "syn 2.0.15", + "syn 2.0.16", ] [[package]] @@ -427,7 +427,7 @@ checksum = "b9ccdd8f2a161be9bd5c023df56f1b2a0bd1d83872ae53b71a84a12c9bf6e842" dependencies = [ "proc-macro2", "quote", - "syn 2.0.15", + "syn 2.0.16", ] [[package]] @@ -669,7 +669,7 @@ dependencies = [ "heck", "proc-macro2", "quote", - "syn 2.0.15", + "syn 2.0.16", ] [[package]] @@ -1076,7 +1076,7 @@ checksum = "89ca545a94061b6365f2c7355b4b32bd20df3ff95f02da9329b34ccc3bd6ee72" dependencies = [ "proc-macro2", "quote", - "syn 2.0.15", + "syn 2.0.16", ] [[package]] @@ -1138,9 +1138,9 @@ checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" [[package]] name = "h2" -version = "0.3.18" +version = "0.3.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17f8a914c2987b688368b5138aa05321db91f4090cf26118185672ad588bce21" +checksum = "d357c7ae988e7d2182f7d7871d0b963962420b0678b0997ce7de72001aeab782" dependencies = [ "bytes", "fnv", @@ -1476,9 +1476,9 @@ dependencies = [ [[package]] name = "js-sys" -version = "0.3.62" +version = "0.3.63" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68c16e1bfd491478ab155fd8b4896b86f9ede344949b641e61501e07c2b8b4d5" +checksum = "2f37a4a5928311ac501dee68b3c7613a1037d0edb30c8e5427bd832d55d1b790" dependencies = [ "wasm-bindgen", ] @@ -1834,7 +1834,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.15", + "syn 2.0.16", ] [[package]] @@ -2040,7 +2040,7 @@ checksum = "39407670928234ebc5e6e580247dd567ad73a3578460c5990f9503df207e8f07" dependencies = [ "proc-macro2", "quote", - "syn 2.0.15", + "syn 2.0.16", ] [[package]] @@ -2103,9 +2103,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.56" +version = "1.0.57" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b63bdb0cd06f1f4dedf69b254734f9b45af66e4a031e42a7480257d9898b435" +checksum = "c4ec6d5fe0b140acb27c9a0444118cf55bfbb4e0b259739429abb4521dd67c16" dependencies = [ "unicode-ident", ] @@ -2443,7 +2443,7 @@ checksum = "8c805777e3930c8883389c602315a24224bcc738b63905ef87cd1420353ea93e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.15", + "syn 2.0.16", ] [[package]] @@ -2741,9 +2741,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.15" +version = "2.0.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a34fcf3e8b60f57e6a14301a2e916d323af98b0ea63c599441eec8558660c822" +checksum = "a6f671d4b5ffdb8eadec19c0ae67fe2639df8684bd7bc4b83d986b8db549cf01" dependencies = [ "proc-macro2", "quote", @@ -2795,7 +2795,7 @@ checksum = "f9456a42c5b0d803c8cd86e73dd7cc9edd429499f37a3550d286d5e86720569f" dependencies = [ "proc-macro2", "quote", - "syn 2.0.15", + "syn 2.0.16", ] [[package]] @@ -2887,7 +2887,7 @@ checksum = "630bdcf245f78637c13ec01ffae6187cca34625e8c63150d424b59e55af2675e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.15", + "syn 2.0.16", ] [[package]] @@ -3064,14 +3064,14 @@ checksum = "0f57e3ca2a01450b1a921183a9c9cbfda207fd822cef4ccb00a65402cbba7a74" dependencies = [ "proc-macro2", "quote", - "syn 2.0.15", + "syn 2.0.16", ] [[package]] name = "tracing-core" -version = "0.1.30" +version = "0.1.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "24eb03ba0eab1fd845050058ce5e616558e8f8d8fca633e6b163fe25c797213a" +checksum = "0955b8137a1df6f1a2e9a37d8a6656291ff0297c1a97c24e0d8425fe2312f79a" dependencies = [ "once_cell", "valuable", @@ -3212,9 +3212,9 @@ checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" [[package]] name = "uuid" -version = "1.3.2" +version = "1.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4dad5567ad0cf5b760e5665964bec1b47dfd077ba8a2544b513f3556d3d239a2" +checksum = "345444e32442451b267fc254ae85a209c64be56d2890e601a0c37ff0c3c5ecd2" dependencies = [ "getrandom", "serde", @@ -3266,9 +3266,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm-bindgen" -version = "0.2.85" +version = "0.2.86" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b6cb788c4e39112fbe1822277ef6fb3c55cd86b95cb3d3c4c1c9597e4ac74b4" +checksum = "5bba0e8cb82ba49ff4e229459ff22a191bbe9a1cb3a341610c9c33efc27ddf73" dependencies = [ "cfg-if 1.0.0", "wasm-bindgen-macro", @@ -3276,24 +3276,24 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.85" +version = "0.2.86" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "35e522ed4105a9d626d885b35d62501b30d9666283a5c8be12c14a8bdafe7822" +checksum = "19b04bc93f9d6bdee709f6bd2118f57dd6679cf1176a1af464fca3ab0d66d8fb" dependencies = [ "bumpalo", "log", "once_cell", "proc-macro2", "quote", - "syn 2.0.15", + "syn 2.0.16", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-macro" -version = "0.2.85" +version = "0.2.86" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "358a79a0cb89d21db8120cbfb91392335913e4890665b1a7981d9e956903b434" +checksum = "14d6b024f1a526bb0234f52840389927257beb670610081360e5a03c5df9c258" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -3301,28 +3301,28 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.85" +version = "0.2.86" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4783ce29f09b9d93134d41297aded3a712b7b979e9c6f28c32cb88c973a94869" +checksum = "e128beba882dd1eb6200e1dc92ae6c5dbaa4311aa7bb211ca035779e5efc39f8" dependencies = [ "proc-macro2", "quote", - "syn 2.0.15", + "syn 2.0.16", "wasm-bindgen-backend", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-shared" -version = "0.2.85" +version = "0.2.86" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a901d592cafaa4d711bc324edfaff879ac700b19c3dfd60058d2b445be2691eb" +checksum = "ed9d5b4305409d1fc9482fee2d7f9bcbf24b3972bf59817ef757e23982242a93" [[package]] name = "web-sys" -version = "0.3.62" +version = "0.3.63" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "16b5f940c7edfdc6d12126d98c9ef4d1b3d470011c47c76a6581df47ad9ba721" +checksum = "3bdd9ef4e984da1187bf8110c5cf5b845fbc87a23602cdf912386a76fcd3a7c2" dependencies = [ "js-sys", "wasm-bindgen", From bfe78c067e10e6245d06a551508456bbb3a750c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Orhun=20Parmaks=C4=B1z?= Date: Wed, 17 May 2023 13:46:39 +0300 Subject: [PATCH 27/30] chore(release): prepare for v0.9.0 --- CHANGELOG.md | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ Cargo.lock | 2 +- Cargo.toml | 2 +- 3 files changed, 50 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d10f750..9779f73 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,54 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [0.9.0] - 2023-05-17 + +The public instance is now available at [https://rustypaste.shuttleapp.rs](https://rustypaste.shuttleapp.rs) 🚀 + +Read the blog post about `rustypaste` and Shuttle deployments: [https://blog.orhun.dev/blazingly-fast-file-sharing](https://blog.orhun.dev/blazingly-fast-file-sharing) + +### Added + +- Deploy on Shuttle.rs +- Support setting a default expiry time + +You can now specify a expiry time for uploaded files. For example, if you want all the files to expire after one hour: + +```toml +[paste] +default_expiry = "1h" +``` + +- Support overriding the server URL + +If you are using `rustypaste` with a redirect or reverse proxy, it is now possible to set a different URL for the returned results: + +```toml +[server] +url = "https://rustypaste.shuttleapp.rs" +``` + +- Add instructions for installing on Alpine Linux + +`rustypaste` is now available in [testing](https://pkgs.alpinelinux.org/packages?name=rustypaste&branch=edge) repositories. + +- Add new crate features + + - `shuttle`: enable an entry point for deploying on Shuttle + - `openssl`: use distro OpenSSL (binary size is reduced ~20% in release mode) + - `rustls`: use [rustls](https://github.com/rustls/rustls) (enabled as default) + +### Changed + +- Make the default landing page fancier +- Generate SBOM attestation for the Docker image + +### Updated + +- Bump dependencies +- Update the funding options + - Consider donating if you liked `rustypaste`: [https://donate.orhun.dev](https://donate.orhun.dev) 💖 + ## [0.8.4] - 2023-01-31 ### Added diff --git a/Cargo.lock b/Cargo.lock index 2f48fdc..e8f3b37 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2356,7 +2356,7 @@ checksum = "4f3208ce4d8448b3f3e7d168a73f5e0c43a61e32930de3bceeccedb388b6bf06" [[package]] name = "rustypaste" -version = "0.8.4" +version = "0.9.0" dependencies = [ "actix-files", "actix-multipart", diff --git a/Cargo.toml b/Cargo.toml index 2f613c4..dcdfb9b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rustypaste" -version = "0.8.4" +version = "0.9.0" edition = "2021" description = "A minimal file upload/pastebin service" authors = ["Orhun Parmaksız "] From 8359aadec68cfcf88fcc91f214438eeaa8765ca8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Orhun=20Parmaks=C4=B1z?= Date: Wed, 17 May 2023 14:04:32 +0300 Subject: [PATCH 28/30] docs(readme): mention the available feature flags --- README.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/README.md b/README.md index 0e6bafc..705370a 100644 --- a/README.md +++ b/README.md @@ -84,6 +84,20 @@ cd rustypaste/ cargo build --release ``` +#### Feature flags + +- `shuttle`: enable an entry point for deploying on Shuttle +- `openssl`: use distro OpenSSL (binary size is reduced ~20% in release mode) +- `rustls`: use [rustls](https://github.com/rustls/rustls) (enabled as default) + +To enable a feature for build, pass `--features` flag to `cargo build` command. + +For example, to reuse the OpenSSL present on a distro already: + +```sh +cargo build --release --features openssl +``` + #### Testing ##### Unit tests From 9ead53097e498461cdba8e470ca278d030dc642d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Orhun=20Parmaks=C4=B1z?= Date: Wed, 17 May 2023 14:27:04 +0300 Subject: [PATCH 29/30] docs(readme): fix the OpenSSL feature example --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 705370a..f50cc62 100644 --- a/README.md +++ b/README.md @@ -95,7 +95,7 @@ To enable a feature for build, pass `--features` flag to `cargo build` command. For example, to reuse the OpenSSL present on a distro already: ```sh -cargo build --release --features openssl +cargo build --release --no-default-features --features openssl ``` #### Testing From 3789caf68f7039477b207842f68cfe712d118112 Mon Sep 17 00:00:00 2001 From: Dan Ponte Date: Tue, 28 Feb 2023 23:52:38 -0500 Subject: [PATCH 30/30] Add prettyness. --- Cargo.lock | 7 +++++++ Cargo.toml | 2 ++ README.md | 4 +++- config.toml | 25 +++++++------------------ src/config.rs | 7 +++++++ src/pretty.html | 23 +++++++++++++++++++++++ src/server.rs | 21 +++++++++++++++++++++ 7 files changed, 70 insertions(+), 19 deletions(-) create mode 100644 src/pretty.html diff --git a/Cargo.lock b/Cargo.lock index e8f3b37..e3a76e1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2385,6 +2385,7 @@ dependencies = [ "shuttle-actix-web", "shuttle-runtime", "shuttle-static-folder", + "text-template", "tokio", "url", ] @@ -2778,6 +2779,12 @@ dependencies = [ "winapi-util", ] +[[package]] +name = "text-template" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "51bcc3e9514cba67c087126b18600010c7c29b0cb51a6f6bc75e5058c2369bba" + [[package]] name = "thiserror" version = "1.0.40" diff --git a/Cargo.toml b/Cargo.toml index dcdfb9b..83c0711 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -52,6 +52,7 @@ shuttle-actix-web = { version = "0.16.0", optional = true } shuttle-runtime = { version = "0.16.0", optional = true } shuttle-static-folder = { version = "0.16.0", optional = true } tokio = { version = "1.28.1", optional = true } +text-template = "0.1.0" [dependencies.config] version = "0.13.3" @@ -72,6 +73,7 @@ actix-rt = "2.8.0" [profile.dev] opt-level = 0 debug = true +panic = "abort" [profile.test] opt-level = 0 diff --git a/README.md b/README.md index f50cc62..0feceb1 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,9 @@ [![Docker Builds](https://img.shields.io/github/actions/workflow/status/orhun/rustypaste/docker.yml?style=flat&labelColor=823213&color=2c2c2c&label=docker&logo=Docker&logoColor=white)](https://hub.docker.com/r/orhunp/rustypaste) [![Documentation](https://img.shields.io/docsrs/rustypaste?style=flat&labelColor=823213&color=2c2c2c&logo=Rust&logoColor=white)](https://docs.rs/rustypaste/) -**Rustypaste** is a minimal file upload/pastebin service. +**Rustypaste-pretty** is a minimal file upload/pastebin service with client side highlighting provided by highlight.js. + +Just add `?pretty` to the end of a link to highlight! ```sh $ echo "some text" > awesome.txt diff --git a/config.toml b/config.toml index a4314a5..d3543a5 100644 --- a/config.toml +++ b/config.toml @@ -2,34 +2,18 @@ refresh_rate = "1s" [server] -address = "127.0.0.1:8000" +address="127.0.0.1:8020" #url = "https://rustypaste.shuttleapp.rs" #workers=4 max_content_length = "10MB" upload_path = "./upload" timeout = "30s" expose_version = false +style="monokai" landing_page = """ ┬─┐┬ ┬┌─┐┌┬┐┬ ┬┌─┐┌─┐┌─┐┌┬┐┌─┐ ├┬┘│ │└─┐ │ └┬┘├─┘├─┤└─┐ │ ├┤ ┴└─└─┘└─┘ ┴ ┴ ┴ ┴ ┴└─┘ ┴ └─┘ - -Submit files via HTTP POST here: - curl -F 'file=@example.txt' -This will return the URL of the uploaded file. - -The server administrator might remove any pastes that they do not personally -want to host. - -If you are the server administrator and want to change this page, just go -into your config file and change it! If you change the expiry time, it is -recommended that you do. - -By default, pastes expire every hour. The server admin may or may not have -changed this. - -Check out the GitHub repository at https://github.com/orhun/rustypaste -Command line tool is available at https://github.com/orhun/rustypaste-cli """ [paste] @@ -50,6 +34,11 @@ mime_blacklist = [ "application/java-archive", "application/java-vm", ] + duplicate_files = true # default_expiry = "1h" delete_expired_files = { enabled = true, interval = "1h" } + +[paste.highlight_override] +# For example, to force markdown rather than using highlight.js's autodetection +#"text/markdown" = "markdown" diff --git a/src/config.rs b/src/config.rs index 6bad254..ea06918 100644 --- a/src/config.rs +++ b/src/config.rs @@ -2,6 +2,7 @@ use crate::mime::MimeMatcher; use crate::random::RandomURLConfig; use byte_unit::Byte; use config::{self, ConfigError}; +use std::collections::HashMap; use std::path::{Path, PathBuf}; use std::time::Duration; @@ -47,6 +48,8 @@ pub struct ServerConfig { pub landing_page: Option, /// Expose version. pub expose_version: Option, + /// Highlight.js style + pub style: Option, } /// Paste configuration. @@ -69,6 +72,9 @@ pub struct PasteConfig { pub default_expiry: Option, /// Delete expired files. pub delete_expired_files: Option, + /// Highlight override. + #[serde(default)] + pub highlight_override: HashMap, } /// Cleanup configuration. @@ -85,6 +91,7 @@ impl Config { /// Parses the config file and returns the values. pub fn parse(path: &Path) -> Result { config::Config::builder() + .set_default("style", "default").unwrap() .add_source(config::File::from(path)) .add_source(config::Environment::default().separator("__")) .build()? diff --git a/src/pretty.html b/src/pretty.html new file mode 100644 index 0000000..1fa8779 --- /dev/null +++ b/src/pretty.html @@ -0,0 +1,23 @@ + + + + ${file} + + + + + +

+		
+ + diff --git a/src/server.rs b/src/server.rs index 6d2f0b7..8085d8f 100644 --- a/src/server.rs +++ b/src/server.rs @@ -6,6 +6,7 @@ use crate::mime as mime_util; use crate::paste::{Paste, PasteType}; use crate::util; use crate::AUTH_TOKEN_ENV; +use text_template::*; use actix_files::NamedFile; use actix_multipart::Multipart; use actix_web::{error, get, post, web, Error, HttpRequest, HttpResponse}; @@ -16,7 +17,9 @@ use serde::Deserialize; use std::convert::TryFrom; use std::env; use std::fs; +use std::str; use std::sync::RwLock; +use std::collections::HashMap; /// Shows the landing page. #[get("/")] @@ -53,6 +56,7 @@ async fn serve( let config = config .read() .map_err(|_| error::ErrorInternalServerError("cannot acquire config"))?; + let path = config.server.upload_path.join(&*file); let mut path = util::glob_match_file(path)?; let mut paste_type = PasteType::File; @@ -80,6 +84,23 @@ async fn serve( mime_util::get_mime_type(&config.paste.mime_override, file.to_string()) .map_err(error::ErrorInternalServerError)? }; + + if request.query_string() == "pretty" { + let mut values = HashMap::new(); + let tmpl_bytes = str::from_utf8(include_bytes!("pretty.html")).unwrap(); + let tmpl = Template::from(tmpl_bytes); + values.insert("file", file.as_str()); + values.insert("style", match &config.server.style { + Some(style) => style.as_str(), + None => "default", + }); + let mime_str = mime_type.to_string(); + let overrides = &config.paste.highlight_override; + values.insert("type", if overrides.contains_key(&mime_str) { overrides[&mime_str].as_str() } else { "" }); + let rendered = tmpl.fill_in(&values); + return Ok(HttpResponse::Ok().content_type(mime::TEXT_HTML).body(rendered.to_string())) + } + let response = NamedFile::open(&path)? .disable_content_disposition() .set_content_type(mime_type)