diff --git a/.gitignore b/.gitignore index 6351287..17edd4d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ /target /Files/posts.json +/Files/Stored_files/* diff --git a/Cargo.lock b/Cargo.lock index 55258a8..ea01bc3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -8,7 +8,7 @@ version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "617a8268e3537fe1d8c9ead925fca49ef6400927ee7bc26750e90ecee14ce4b8" dependencies = [ - "bitflags", + "bitflags 1.3.2", "bytes", "futures-core", "futures-sink", @@ -19,6 +19,29 @@ dependencies = [ "tracing", ] +[[package]] +name = "actix-files" +version = "0.6.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0773d59061dedb49a8aed04c67291b9d8cf2fe0b60130a381aab53c6dd86e9be" +dependencies = [ + "actix-http", + "actix-service", + "actix-utils", + "actix-web", + "bitflags 2.6.0", + "bytes", + "derive_more", + "futures-core", + "http-range", + "log", + "mime", + "mime_guess", + "percent-encoding", + "pin-project-lite", + "v_htmlescape", +] + [[package]] name = "actix-http" version = "3.3.1" @@ -31,7 +54,7 @@ dependencies = [ "actix-utils", "ahash 0.8.3", "base64 0.21.2", - "bitflags", + "bitflags 1.3.2", "brotli", "bytes", "bytestring", @@ -68,6 +91,44 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "actix-multipart" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d5118a26dee7e34e894f7e85aa0ee5080ae4c18bf03c0e30d49a80e418f00a53" +dependencies = [ + "actix-multipart-derive", + "actix-utils", + "actix-web", + "derive_more", + "futures-core", + "futures-util", + "httparse", + "local-waker", + "log", + "memchr", + "mime", + "rand", + "serde", + "serde_json", + "serde_plain", + "tempfile", + "tokio", +] + +[[package]] +name = "actix-multipart-derive" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e11eb847f49a700678ea2fa73daeb3208061afa2b9d1a8527c03390f4c4a1c6b" +dependencies = [ + "darling", + "parse-size", + "proc-macro2", + "quote", + "syn 2.0.23", +] + [[package]] name = "actix-router" version = "0.5.1" @@ -167,7 +228,7 @@ dependencies = [ "serde_urlencoded", "smallvec", "socket2", - "time 0.3.22", + "time 0.3.36", "url", ] @@ -281,12 +342,24 @@ version = "0.21.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "604178f6c5c21f02dc555784810edfb88d34ac2c73b2eae109655649ee73ce3d" +[[package]] +name = "base64" +version = "0.22.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" + [[package]] name = "bitflags" version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" +[[package]] +name = "bitflags" +version = "2.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de" + [[package]] name = "block-buffer" version = "0.9.0" @@ -422,7 +495,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e859cd57d0710d9e06c381b550c06e76992472a8c6d527aecd2fc673dcc231fb" dependencies = [ "percent-encoding", - "time 0.3.22", + "time 0.3.36", "version_check", ] @@ -469,12 +542,56 @@ dependencies = [ "typenum", ] +[[package]] +name = "darling" +version = "0.20.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6f63b86c8a8826a49b8c21f08a2d07338eec8d900540f8630dc76284be802989" +dependencies = [ + "darling_core", + "darling_macro", +] + +[[package]] +name = "darling_core" +version = "0.20.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95133861a8032aaea082871032f5815eb9e98cef03fa916ab4500513994df9e5" +dependencies = [ + "fnv", + "ident_case", + "proc-macro2", + "quote", + "strsim", + "syn 2.0.23", +] + +[[package]] +name = "darling_macro" +version = "0.20.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d336a2a514f6ccccaa3e09b02d41d35330c07ddf03a62165fcec10bb561c7806" +dependencies = [ + "darling_core", + "quote", + "syn 2.0.23", +] + [[package]] name = "debug-helper" version = "0.3.13" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f578e8e2c440e7297e008bb5486a3a8a194775224bbc23729b0dbdfaeebf162e" +[[package]] +name = "deranged" +version = "0.3.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b42b6fa04a440b495c8b04d0e71b707c585f83cb9cb28cf8cd0d976c315e31b4" +dependencies = [ + "powerfmt", +] + [[package]] name = "derive_more" version = "0.99.17" @@ -533,6 +650,22 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "88bffebc5d80432c9b140ee17875ff173a8ab62faad5b257da912bd2f6c1c0a1" +[[package]] +name = "errno" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "534c5cf6194dfab3db3242765c03bbe257cf92f22b38f6bc0c58d59108a820ba" +dependencies = [ + "libc", + "windows-sys 0.52.0", +] + +[[package]] +name = "fastrand" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9fc0510504f03c51ada170672ac806f1f105a88aa97a5281117e1ddc3368e51a" + [[package]] name = "flate2" version = "1.0.26" @@ -657,6 +790,12 @@ dependencies = [ "itoa", ] +[[package]] +name = "http-range" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "21dec9db110f5f872ed9699c3ecf50cf16f423502706ba5c72462e28d3157573" + [[package]] name = "httparse" version = "1.8.0" @@ -669,6 +808,15 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c4a1e36c821dbe04574f602848a19f742f4fb3c98d40449f11bcad18d6b17421" +[[package]] +name = "humansize" +version = "2.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6cb51c9a029ddc91b07a787f1d86b53ccfa49b0e86688c946ebe8d3555685dd7" +dependencies = [ + "libm", +] + [[package]] name = "iana-time-zone" version = "0.1.57" @@ -692,6 +840,12 @@ dependencies = [ "cc", ] +[[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" @@ -754,9 +908,21 @@ checksum = "d4345964bb142484797b161f473a503a434de77149dd8c7427788c6e13379388" [[package]] name = "libc" -version = "0.2.141" +version = "0.2.155" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3304a64d199bb964be99741b7a14d26972741915b3649639149b2479bb46f4b5" +checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c" + +[[package]] +name = "libm" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ec2a862134d2a7d32d7983ddcdd1c4923530833c9f2ea1a44fc5fa473989058" + +[[package]] +name = "linux-raw-sys" +version = "0.4.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78b3ae25bc7c8c38cec158d1f2757ee79e9b3740fbc7ccf0e59e4b08d793fa89" [[package]] name = "local-channel" @@ -835,6 +1001,16 @@ version = "0.3.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" +[[package]] +name = "mime_guess" +version = "2.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f7c44f8e672c00fe5308fa235f821cb4198414e1c77935c1ab6948d3fd78550e" +dependencies = [ + "mime", + "unicase", +] + [[package]] name = "miniz_oxide" version = "0.7.1" @@ -856,6 +1032,12 @@ dependencies = [ "windows-sys 0.45.0", ] +[[package]] +name = "num-conv" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "51d515d32fb182ee37cda2ccdcb92950d6a3c2893aa280e540671c2cd0f3b1d9" + [[package]] name = "num-traits" version = "0.2.15" @@ -910,6 +1092,12 @@ dependencies = [ "windows-targets 0.48.0", ] +[[package]] +name = "parse-size" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "944553dd59c802559559161f9816429058b869003836120e262e8caec061b7ae" + [[package]] name = "paste" version = "1.0.12" @@ -940,6 +1128,12 @@ version = "0.3.27" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "26072860ba924cbfa98ea39c8c19b4dd6a4a25423dbdf219c1eca91aa0cf6964" +[[package]] +name = "powerfmt" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391" + [[package]] name = "ppv-lite86" version = "0.2.17" @@ -1000,7 +1194,7 @@ version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "567664f262709473930a4bf9e51bf2ebf3348f2e748ccc50dea20646858f8f29" dependencies = [ - "bitflags", + "bitflags 1.3.2", ] [[package]] @@ -1029,6 +1223,19 @@ dependencies = [ "semver", ] +[[package]] +name = "rustix" +version = "0.38.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70dc5ec042f7a43c4a73241207cecc9873a06d45debb38b329f8541d85c2730f" +dependencies = [ + "bitflags 2.6.0", + "errno", + "libc", + "linux-raw-sys", + "windows-sys 0.52.0", +] + [[package]] name = "ryu" version = "1.0.13" @@ -1049,9 +1256,9 @@ checksum = "bebd363326d05ec3e2f532ab7660680f3b02130d780c299bca73469d521bc0ed" [[package]] name = "serde" -version = "1.0.164" +version = "1.0.185" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e8c8cf938e98f769bc164923b06dce91cea1751522f46f8466461af04c9027d" +checksum = "be9b6f69f1dfd54c3b568ffa45c310d6973a5e5148fd40cf515acaf38cf5bc31" [[package]] name = "serde_derive" @@ -1075,6 +1282,15 @@ dependencies = [ "serde", ] +[[package]] +name = "serde_plain" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ce1fc6db65a611022b23a0dec6975d63fb80a302cb3388835ff02c097258d50" +dependencies = [ + "serde", +] + [[package]] name = "serde_spanned" version = "0.6.3" @@ -1156,10 +1372,14 @@ dependencies = [ [[package]] name = "sqpad" -version = "1.0.0" +version = "1.1.0" dependencies = [ + "actix-files", + "actix-multipart", "actix-web", + "base64 0.22.1", "chrono", + "humansize", "magic-crypt", "rand", "serde", @@ -1168,6 +1388,12 @@ dependencies = [ "toml", ] +[[package]] +name = "strsim" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" + [[package]] name = "syn" version = "1.0.109" @@ -1190,6 +1416,18 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "tempfile" +version = "3.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85b77fafb263dd9d05cbeac119526425676db3784113aa9295c88498cbf8bff1" +dependencies = [ + "cfg-if", + "fastrand", + "rustix", + "windows-sys 0.52.0", +] + [[package]] name = "tiger" version = "0.1.0" @@ -1214,11 +1452,14 @@ dependencies = [ [[package]] name = "time" -version = "0.3.22" +version = "0.3.36" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea9e1b3cf1243ae005d9e74085d4d542f3125458f3a81af210d901dcd7411efd" +checksum = "5dfd88e563464686c916c7e46e623e520ddc6d79fa6641390f2e3fa86e83e885" dependencies = [ + "deranged", "itoa", + "num-conv", + "powerfmt", "serde", "time-core", "time-macros", @@ -1226,16 +1467,17 @@ dependencies = [ [[package]] name = "time-core" -version = "0.1.1" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7300fbefb4dadc1af235a9cef3737cea692a9d97e1b9cbcd4ebdae6f8868e6fb" +checksum = "ef927ca75afb808a4d64dd374f00a2adf8d0fcff8e7b184af886c3c87ec4a3f3" [[package]] name = "time-macros" -version = "0.2.9" +version = "0.2.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "372950940a5f07bf38dbe211d7283c9e6d7327df53794992d293e534c733d09b" +checksum = "3f252a68540fde3a3877aeea552b832b40ab9a69e318efd078774a01ddee1ccf" dependencies = [ + "num-conv", "time-core", ] @@ -1346,6 +1588,15 @@ version = "1.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "497961ef93d974e23eb6f433eb5fe1b7930b659f06d12dec6fc44a8f554c0bba" +[[package]] +name = "unicase" +version = "2.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f7d2d4dafb69621809a81864c9c1b864479e1235c0dd4e199924b9742439ed89" +dependencies = [ + "version_check", +] + [[package]] name = "unicode-bidi" version = "0.3.13" @@ -1378,6 +1629,12 @@ dependencies = [ "percent-encoding", ] +[[package]] +name = "v_htmlescape" +version = "0.15.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4e8257fbc510f0a46eb602c10215901938b5c2a7d5e70fc11483b1d3c9b5b18c" + [[package]] name = "version_check" version = "0.9.4" @@ -1499,6 +1756,15 @@ dependencies = [ "windows-targets 0.48.0", ] +[[package]] +name = "windows-sys" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" +dependencies = [ + "windows-targets 0.52.6", +] + [[package]] name = "windows-targets" version = "0.42.2" @@ -1529,6 +1795,22 @@ dependencies = [ "windows_x86_64_msvc 0.48.0", ] +[[package]] +name = "windows-targets" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" +dependencies = [ + "windows_aarch64_gnullvm 0.52.6", + "windows_aarch64_msvc 0.52.6", + "windows_i686_gnu 0.52.6", + "windows_i686_gnullvm", + "windows_i686_msvc 0.52.6", + "windows_x86_64_gnu 0.52.6", + "windows_x86_64_gnullvm 0.52.6", + "windows_x86_64_msvc 0.52.6", +] + [[package]] name = "windows_aarch64_gnullvm" version = "0.42.2" @@ -1541,6 +1823,12 @@ version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "91ae572e1b79dba883e0d315474df7305d12f569b400fcf90581b06062f7e1bc" +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" + [[package]] name = "windows_aarch64_msvc" version = "0.42.2" @@ -1553,6 +1841,12 @@ version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b2ef27e0d7bdfcfc7b868b317c1d32c641a6fe4629c171b8928c7b08d98d7cf3" +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" + [[package]] name = "windows_i686_gnu" version = "0.42.2" @@ -1565,6 +1859,18 @@ version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "622a1962a7db830d6fd0a69683c80a18fda201879f0f447f065a3b7467daa241" +[[package]] +name = "windows_i686_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" + [[package]] name = "windows_i686_msvc" version = "0.42.2" @@ -1577,6 +1883,12 @@ version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4542c6e364ce21bf45d69fdd2a8e455fa38d316158cfd43b3ac1c5b1b19f8e00" +[[package]] +name = "windows_i686_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" + [[package]] name = "windows_x86_64_gnu" version = "0.42.2" @@ -1589,6 +1901,12 @@ version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ca2b8a661f7628cbd23440e50b05d705db3686f894fc9580820623656af974b1" +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" + [[package]] name = "windows_x86_64_gnullvm" version = "0.42.2" @@ -1601,6 +1919,12 @@ version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7896dbc1f41e08872e9d5e8f8baa8fdd2677f29468c4e156210174edc7f7b953" +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" + [[package]] name = "windows_x86_64_msvc" version = "0.42.2" @@ -1613,6 +1937,12 @@ version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1a515f5799fe4961cb532f983ce2b23082366b898e52ffbce459c86f67c8378a" +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" + [[package]] name = "winnow" version = "0.4.7" diff --git a/Cargo.toml b/Cargo.toml index 53ec779..2cd5643 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,13 +1,17 @@ [package] name = "sqpad" -version = "1.0.0" +version = "1.1.0" edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] +actix-files = "0.6.6" +actix-multipart = "0.7.2" actix-web = "4.3.1" +base64 = "0.22.1" chrono = "0.4.26" +humansize = "2.1.3" #clap = "4.2.4" magic-crypt = "3.1.12" #message-io = "0.15.1" diff --git a/Files/fonts/FantasqueSansMono-Bold.woff b/Files/fonts/FantasqueSansMono-Bold.woff new file mode 100644 index 0000000..9173a57 Binary files /dev/null and b/Files/fonts/FantasqueSansMono-Bold.woff differ diff --git a/Files/fonts/FantasqueSansMono-Bold.woff2 b/Files/fonts/FantasqueSansMono-Bold.woff2 new file mode 100644 index 0000000..3159612 Binary files /dev/null and b/Files/fonts/FantasqueSansMono-Bold.woff2 differ diff --git a/Files/fonts/FantasqueSansMono-Regular.woff b/Files/fonts/FantasqueSansMono-Regular.woff new file mode 100644 index 0000000..5713fc2 Binary files /dev/null and b/Files/fonts/FantasqueSansMono-Regular.woff differ diff --git a/Files/fonts/FantasqueSansMono-Regular.woff2 b/Files/fonts/FantasqueSansMono-Regular.woff2 new file mode 100644 index 0000000..07172c7 Binary files /dev/null and b/Files/fonts/FantasqueSansMono-Regular.woff2 differ diff --git a/Files/index.html b/Files/index.html index f535c37..3744392 100644 --- a/Files/index.html +++ b/Files/index.html @@ -9,11 +9,14 @@ body { background-color: #2e2e2e; color: white; - font-family: Arial, sans-serif; text-align: center; padding-top: 50px; + font-family: Fira Mono; } + @import url(https://fonts.bunny.net/css?family=fira-mono:400); + + h1 { color: pink; } @@ -27,14 +30,14 @@ max-width: 90%; margin: 0 auto; padding: 20px; - border: 2px solid pink; - border-radius: 10px; + /*border: 2px solid pink; + border-radius: 10px;*/ align: center; } label { display: block; - margin-top: 10px; + margin-top: 5px; } input[type="text"] { @@ -45,6 +48,8 @@ color: white; margin: auto; display: block; + height: 40px; + font-size: x-large; } textarea { @@ -56,6 +61,7 @@ align: center; margin: auto; display: block; + font-size: x-large; } @@ -123,21 +129,30 @@ -

SqPad

+ + - - - - + - - + +
+
+
+ + +
+

SqPad by Squi
+ Conditions d'utilisation +

Need to report something hosted on this website ? Send an email to admin@squi.fr including the link to the content.

+

Vous avez trouvé quelque chose de problématique hebergé sur ce site ? Ecrivez à admin@squi.fr en incluant le lien du contenu.

+ + diff --git a/Files/posts.json b/Files/posts.json index 5d393f0..6e3ad62 100644 --- a/Files/posts.json +++ b/Files/posts.json @@ -1,3 +1,4 @@ -{"name":"qzdqzd","crypt":"EFOUHjEiFhRorSgOQAgOgA==","date":"03/07/2023@18:45:45","id":11295522918797061807} -{"name":"qzdqzdq","crypt":"Wap895rKiiX6QKQcoW/HeA==","date":"07/07/2023@13:54:54","id":11359763750215510915} -{"name":"Salut","crypt":"HgTgatuvDrFDzSzB1NBD8g==","date":"07/07/2023@13:58:53","id":7122794868924569050} +{"name":"Coucou","crypt":"v2GQruagmH/4mH23jHsQsQ==","date":"30/07/2024@17:37:42","id":13756540686218610888} +{"name":"ccc","crypt":"CPxmHNEzGTjTzLnPD4cT1g==","date":"31/07/2024@12:32:43","id":2023961136064904175} +{"name":"azdazd","crypt":"VHkcgcJYiWMPL6iAsR7VaA==","date":"31/07/2024@13:02:16","id":12968686421810818419} +{"name":"d","crypt":"gUvEqnyQ0471LO9c0zluZQ==","date":"31/07/2024@13:23:06","id":6034734435954264973} diff --git a/Files/tos.html b/Files/tos.html new file mode 100644 index 0000000..ae09910 --- /dev/null +++ b/Files/tos.html @@ -0,0 +1,54 @@ + + + + + + Conditions Générales d'Utilisation + + +

Conditions Générales d'Utilisation

+

Dernière mise à jour : 31 juillet 2024

+

Bienvenue sur SqPad (le "Site"). En accédant à notre Site ou en l'utilisant, vous acceptez de vous conformer aux présentes Conditions Générales d'Utilisation ("CGU"). Veuillez lire attentivement ces conditions.

+ +

1. Acceptation des Conditions

+

En utilisant le Site, vous acceptez ces CGU et toute modification future. Si vous n'acceptez pas ces termes, n'utilisez pas le Site.

+ +

2. Description du Service

+

SqPad fournit une plateforme permettant aux utilisateurs de télécharger et de stocker des contenus chiffrés (le "Service"). Les clés de chiffrement sont gérées exclusivement par les utilisateurs, et SqPad n'a pas accès au contenu des fichiers chiffrés.

+ +

3. Responsabilités de l'Utilisateur

+ + +

4. Procédure de Notification et de Retrait

+

Si vous pensez que du contenu hébergé sur notre Site est illégal ou enfreint ces CGU, veuillez nous en informer immédiatement par un mail à admin@squi.fr en précisant le nom du site et l'infraction constatée. Nous examinerons toutes les notifications et prendrons les mesures appropriées, y compris le retrait ou la désactivation de l'accès au contenu si nécessaire.

+ +

5. Limitation de Responsabilité

+ + +

6. Vie Privée et Protection des Données

+ + +

7. Résiliation

+

Nous nous réservons le droit de suspendre ou de résilier votre accès au Site et au Service à notre seule discrétion, sans préavis, si vous violez ces CGU ou si nous sommes tenus de le faire par la loi.

+ +

8. Modifications des Conditions

+

Nous pouvons modifier ces CGU à tout moment. Nous vous informerons des changements importants en publiant les nouvelles CGU sur le Site ou par d'autres moyens. Votre utilisation continue du Service après de telles modifications constitue votre acceptation des nouvelles CGU.

+ +

9. Droit Applicable

+

Ces CGU sont régies par et interprétées conformément aux lois de la France. Tout litige découlant de ces CGU sera soumis à la juridiction exclusive des tribunaux français.

+ +

10. Coordonnées

+

Pour toute question concernant ces CGU ou le Service, veuillez nous contacter à :

+

admin@squi.fr

+ + diff --git a/README.md b/README.md index 18caaa6..e2b358f 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,13 @@ # SqPad A encrypted pastebin. Gives a webui where you can post text with a title, which can then be shared via a link. The server stores the text encrypted thanks to MagicCrypt using AES-256. +New : you can also send files. + ## Install Juste compile and launch it in the same folder as "Files". +This is only for development, though. + ## Docker Start by ![installing docker](https://docs.docker.com/engine/install/) if need be, then: ``` @@ -20,21 +24,4 @@ The link can be used via a browser normally; it can also be used with curl or wg For now, notes are kept forever until some admin manually removes them. ## Warnings -The size of a post is limited to 1MB. This value can be changed in the source code, see the end of the main function, at the bottom of src/main.rs : -```rust -#[actix_web::main] -async fn main() -> std::io::Result<()> { - - HttpServer::new(move || { - App::new() - //Limit is configured here - .app_data(web::FormConfig::default().limit(1024 * 1000)) - .service(get_index) - .service(post_index) - .service(show_post) - }) - .bind(("0.0.0.0", 8080))? - .run() - .await -} -``` +The size of a post or upload is limited to 100MB. This value can be changed in the source code, see the end of the main function, at the bottom of src/main.rs. diff --git a/src/fileupload.rs b/src/fileupload.rs new file mode 100644 index 0000000..e13d977 --- /dev/null +++ b/src/fileupload.rs @@ -0,0 +1,186 @@ +pub mod fileupload { + + pub use actix_multipart::form::{tempfile::TempFile, MultipartForm}; + pub use actix_web::{get, post, web, App, HttpResponse, HttpServer, HttpRequest, Responder}; + pub use std::fs; + pub use std::io::{Read, Write}; + pub use serde_derive::{Serialize, Deserialize}; + pub use base64::prelude::*; + pub use actix_files::NamedFile; + pub use rand::Rng; + pub use chrono::Local; + pub use magic_crypt::{new_magic_crypt, MagicCryptTrait}; + pub use std::fs::OpenOptions; + pub use humansize::{format_size, DECIMAL}; + pub use actix_web::Error; + pub use actix_multipart::MultipartError; + + + + #[derive(Debug, MultipartForm)] + pub struct UploadForm { + #[multipart(limit = "100MB")] + file: TempFile, + } + + #[derive(Debug, Serialize, Deserialize, Clone)] + pub struct EncryptedFile { + name: String, + crypt: String, + date: String, + id: u64, + } + + + fn b64_to_file(b64: &String, destfile: &str) -> Result<(), Box> { + let decoded_data = BASE64_STANDARD.decode(b64)?; + fs::write(destfile, &decoded_data)?; + Ok(()) + } + + fn encrypt(content: &String, password: &String) -> String { + let mc = new_magic_crypt!(password, 256); + let encrypted = mc.encrypt_str_to_base64(&content); + return String::from(encrypted); + } + + fn random_password() -> String { + const CHARSET: &[u8] = b"ABCDEFGHIJKLMNOPQRSTUVWXYZ\ + abcdefghijklmnopqrstuvwxyz\ + 0123456789"; + let mut rng = rand::thread_rng(); + let password: String = (0..64) + .map(|_| { + let idx = rng.gen_range(0..CHARSET.len()); + CHARSET[idx] as char + }) + .collect(); + return password; + } + + fn store_encrypted_file(b64: &String, name: &String, password: &String, id: &u64) -> Result<(), Box> { + let mut file = OpenOptions::new() + .write(true) + .append(true) + .create(true) + .open(format!("./Files/Stored_files/{}.json", id)) + .unwrap(); + + let crypt = encrypt(b64, password); + let now = Local::now(); + let now = now.format("%d/%m/%Y@%H:%M:%S"); + let my_encrypted_file = EncryptedFile { name: name.clone(), crypt: crypt, date: format!("{}", now), id: id.clone() }; + let json = serde_json::to_string(&my_encrypted_file).unwrap(); + + writeln!(file, "{}", &json)?; + Ok(()) + + } + + fn get_decrypted_file(id: &u64, password: &String) -> Result> { + let json_content = fs::read_to_string(format!("./Files/Stored_files/{}.json", id))?; + let encr_file: EncryptedFile = serde_json::from_str(json_content.as_str())?; + let decr_file = decrypt(encr_file.crypt.clone(), password.clone().as_str())?; + let path = format!("/tmp/{}", encr_file.name); + b64_to_file(&decr_file, &path)?; + Ok(path) + } + + + fn decrypt(encrypted: String, pass: &str) -> Result { + let mc = new_magic_crypt!(pass, 256); + let result = mc.decrypt_base64_to_string(&encrypted); + match result { + Ok(v) => { + return Ok(v); + }, + Err(_) => { + return Err("Could not decrypt".to_string()); + }, + } + } + + #[post("/file")] + pub async fn post_file(MultipartForm(form): MultipartForm, req: HttpRequest) -> impl Responder { + + //File is : + //UploadForm { file: TempFile { file: NamedTempFile("/tmp/.tmp8yLb6N"), content_type: Some("image/jpeg"), file_name: Some("157.jpg"), size: 1437187 } } + + //The file is written to /tmp, which means trying to persist it in current dir fails. + //But we can read it directly instead. + + + //Persisting == writing the temporary file to a definitive file. + //let destpath = String::from("/tmp/destfile.jpg"); + //let stored_file = form.file.file.persist(destpath).unwrap(); + + + + //Reading the file in base64. + let mut src_file = form.file.file.reopen().unwrap(); + let mut buffer = Vec::new(); + src_file.read_to_end(&mut buffer).unwrap(); + let base64_content = BASE64_STANDARD.encode(&buffer); + + //Writing it back on disk. + //let destpath = String::from("./coucou.jpg"); + //b64_to_file(&base64_content, &destpath).unwrap(); + + //Storing it encrypted. + let password = random_password(); + let mut rng = rand::thread_rng(); + let id: u64 = rng.gen::(); + let hostname = req.headers().get("Host").unwrap().to_str().unwrap(); + let filename = String::from(form.file.file_name.unwrap_or("NAMENOTFOUND".to_string())); + match store_encrypted_file(&base64_content, &filename, &password, &id){ + Ok(_) => (), + Err(e) => return HttpResponse::Ok().body(format!("File could not be saved, got {}", e)), + }; + + //try to get html header and footer files. + let header = fs::read_to_string("./Files/header.html").unwrap_or("".to_string()); + let footer = fs::read_to_string("./Files/footer.html").unwrap_or("".to_string()); + let hsize = format_size(form.file.size, DECIMAL); + + //We have to send smthing back to the user. + let link = format!("http://{}/getfile/{}/{}", hostname, id, password); + let answer = format!( + "{}Uploaded {} with size: {}\n\ +

Here\n\ +

You can download it with in a terminal with
\ +
curl -JLO {}
{}", + header, + filename, + hsize, + link, + link, + footer, + ); + return HttpResponse::Ok().body(answer); + } + + //Serve the file back to the user + #[get("/getfile/{id}/{password}")] + pub async fn get_file(path: web::Path<(u64, String)>) -> impl Responder { + let (id,password) = path.into_inner(); + let path = get_decrypted_file(&id, &password).unwrap(); + let sendback = NamedFile::open(path.clone()); + match fs::remove_file(path.clone()) { + Ok(_) => (), + Err(e) => eprintln!("File {} could not be deleted, got {}", path, e), + }; + sendback + } + + + #[get("/")] + pub async fn get_index() -> impl Responder { + let page = fs::read_to_string("./Files/index.html").unwrap(); + return HttpResponse::Ok().body(page); + } + + pub fn handle_multipart_error(err: MultipartError, _req: &HttpRequest) -> Error { + eprintln!("Multipart error {}", err); + return Error::from(err); + } +} diff --git a/src/main.rs b/src/main.rs index a638034..58d3e05 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,6 +1,5 @@ use magic_crypt::{new_magic_crypt, MagicCryptTrait}; use std::fs; -use serde::{Serialize, Deserialize}; use serde_derive::{Serialize, Deserialize}; use actix_web::{get, post, web, App, HttpResponse, HttpServer, HttpRequest, Responder}; use actix_web::http::header::HeaderValue; @@ -8,6 +7,10 @@ use std::fs::OpenOptions; use std::io::prelude::*; use chrono::Local; use rand::Rng; +use actix_multipart::form::MultipartFormConfig; + +pub mod fileupload; +use crate::fileupload::fileupload::*; #[derive(Deserialize)] struct Post { @@ -156,15 +159,29 @@ async fn get_index() -> impl Responder { return HttpResponse::Ok().body(page); } +#[get("/tos")] +async fn get_tos() -> impl Responder { + let page = fs::read_to_string("./Files/tos.html").unwrap(); + return HttpResponse::Ok().body(page); +} + #[actix_web::main] async fn main() -> std::io::Result<()> { HttpServer::new(move || { App::new() - .app_data(web::FormConfig::default().limit(1024 * 1000)) + .app_data( + MultipartFormConfig::default() + .total_limit(100 * 1024 * 1024 )//Maximum form size 100MB + .memory_limit(10 * 1024 * 1024)//10 MB + .error_handler(handle_multipart_error) + ) .service(get_index) .service(post_index) .service(show_post) + .service(post_file) + .service(get_file) + .service(get_tos) }) .bind(("0.0.0.0", 8080))? .run()