Compare commits

..

19 Commits

Author SHA1 Message Date
135e1de827 Update README.md
Some checks failed
Rust-build / build (push) Has been cancelled
2024-07-31 14:05:20 +02:00
d0f3161a39 Readme
Some checks are pending
Rust-build / build (push) Waiting to run
2024-07-31 14:04:09 +02:00
821e53b2c0 Added file upload and TOS in french
Some checks are pending
Rust-build / build (push) Waiting to run
2024-07-31 13:52:49 +02:00
d68ffcebd7 Update docker-compose.yml
All checks were successful
Rust-build / build (push) Successful in 3m11s
2023-07-17 17:52:39 +02:00
d0d6c6877b Update .gitea/workflows/build.yml
All checks were successful
Rust-build / build (push) Successful in 3m10s
2023-07-17 17:33:46 +02:00
2ba26cc33f build before pushing container
All checks were successful
Rust-build / build (push) Successful in 2m51s
2023-07-17 17:18:19 +02:00
b4c07a3902 Added actions
Some checks reported warnings
Rust-build / build-docker (push) Has been cancelled
Rust-build / build (push) Has been cancelled
2023-07-17 17:16:09 +02:00
a15a7ca974 Modified CSS 2023-07-07 13:59:09 +02:00
8787d3cdc5 Update README.md 2023-07-03 19:00:36 +02:00
f638047508 Improved the post page 2023-07-03 18:55:33 +02:00
d64e020abb Moved upload size 2023-07-03 18:44:17 +02:00
fd9addbbf2 Merge branch 'main' of ssh://docker.sq.lan:3022/Rust/SqPad 2023-07-03 18:43:10 +02:00
aa1789f6b0 Moved upload limit 2023-07-03 18:43:05 +02:00
6d4f6a96f8 Update docker-compose.yml 2023-07-03 17:41:43 +02:00
06c38f6279 Update docker-compose.yml 2023-07-03 17:40:15 +02:00
954ee6cafc Update docker-compose.yml 2023-07-03 17:39:08 +02:00
4716754aec Added Docker and License 2023-07-03 17:38:06 +02:00
e49efa4b64 Merge branch 'main' of ssh://docker.sq.lan:3022/Rust/SqPad 2023-07-03 17:10:11 +02:00
e67bfe9b58 Create posts file if it does not exist 2023-07-03 17:10:05 +02:00
20 changed files with 824 additions and 74 deletions

View File

@ -0,0 +1,57 @@
name: Rust-build
on:
push:
branches:
- "main"
jobs:
build:
runs-on: ubuntu-latest
container:
image: catthehacker/ubuntu:act-latest
steps:
- name: Check-out
uses: actions/checkout@v3
- name: Install stable toolchain
uses: https://github.com/actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- name: Run cargo check
uses: https://github.com/actions-rs/cargo@v1
with:
command: check
- name: Test
run: cargo test
- name: Build
run: cargo build --release
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to registry
uses: docker/login-action@v2
with:
registry: gitea.squi.fr
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build and push
uses: docker/build-push-action@v4
env:
ACTIONS_RUNTIME_TOKEN: '' # See https://gitea.com/gitea/act_runner/issues/119
with:
context: .
file: ./Dockerfile
platforms: |
linux/amd64
linux/arm64
push: true
tags: gitea.squi.fr/justine/sqpad:latest

2
.gitignore vendored
View File

@ -1 +1,3 @@
/target
/Files/posts.json
/Files/Stored_files/*

362
Cargo.lock generated
View File

@ -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"

View File

@ -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"

8
Dockerfile Normal file
View File

@ -0,0 +1,8 @@
FROM debian:stable-slim
WORKDIR /opt
COPY --chown=root --chmod=0755 sqpad /opt/sqpad
RUN mkdir -p -m 0755 /opt/Files
RUN touch /opt/Files/posts.json
COPY --chown=root --chmod=0755 Files/* /opt/Files/
EXPOSE 8080
CMD ["/opt/sqpad"]

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -1,2 +1,5 @@
<br>
<hr>
<a href="https://gitea.squi.fr/Rust/SqPad">SqPad</a> by Squi
</body>
</html>

View File

@ -7,7 +7,7 @@
<title>SqPad</title>
<style>
body {
background-color: black;
background-color: #2e2e2e;
color: white;
font-family: Arial, sans-serif;
text-align: center;
@ -15,7 +15,7 @@
}
h1 {
color: orange;
color: pink;
}
#logo {
@ -24,11 +24,12 @@
}
#form-container {
max-width: 400px;
max-width: 90%;
margin: 0 auto;
padding: 20px;
border: 2px solid orange;
border: 2px solid pink;
border-radius: 10px;
align: center;
}
label {
@ -38,16 +39,33 @@
input[type="text"] {
width: 100%;
padding: 8px;
margin-top: 5px;
border: 1px solid orange;
border: 1px solid pink;
border-radius: 5px;
background-color: black;
background-color: #2e2e2e;
color: white;
margin: auto;
display: block;
}
textarea {
width: 100%;
border: 1px solid pink;
border-radius: 5px;
background-color: #2e2e2e;
color: white;
align: center;
margin: auto;
display: block;
}
a {
color: pink;
}
input[type="submit"] {
background-color: orange;
background-color: pink;
color: black;
padding: 10px 20px;
border: none;
@ -57,7 +75,7 @@
}
input[type="submit"]:hover {
background-color: darkorange;
background-color: darkpink;
}
/* CSS for the table */
@ -65,7 +83,7 @@
width: 100%;
border-collapse: collapse;
margin-top: 20px;
border: 2px solid orange;
border: 2px solid pink;
color: white;
}
@ -73,12 +91,12 @@
td {
padding: 10px;
text-align: left;
border-bottom: 1px solid orange;
border-bottom: 1px solid pink;
}
th {
background-color: black;
color: orange;
color: pink;
}
tr:nth-child(even) {
@ -94,7 +112,7 @@
font-size: 1.2em;
font-weight: bold;
margin-bottom: 10px;
color: orange;
color: pink;
}
.table-container {

View File

@ -7,15 +7,18 @@
<title>SqPad</title>
<style>
body {
background-color: black;
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: orange;
color: pink;
}
#logo {
@ -24,44 +27,51 @@
}
#form-container {
max-width: 400px;
max-width: 90%;
margin: 0 auto;
padding: 20px;
border: 2px solid orange;
border-radius: 10px;
/*border: 2px solid pink;
border-radius: 10px;*/
align: center;
}
label {
display: block;
margin-top: 10px;
margin-top: 5px;
}
input[type="text"] {
width: 100%;
border: 1px solid orange;
border: 1px solid pink;
border-radius: 5px;
background-color: black;
background-color: #2e2e2e;
color: white;
margin: auto;
display: block;
height: 40px;
font-size: x-large;
}
textarea {
width: 100%;
border: 1px solid orange;
border: 1px solid pink;
border-radius: 5px;
background-color: black;
background-color: #2e2e2e;
color: white;
align: center;
margin: auto;
display: block;
font-size: x-large;
}
a {
color: pink;
}
input[type="submit"] {
background-color: orange;
background-color: pink;
color: black;
padding: 10px 20px;
border: none;
@ -71,7 +81,7 @@
}
input[type="submit"]:hover {
background-color: darkorange;
background-color: darkpink;
}
/* CSS for the table */
@ -79,7 +89,7 @@
width: 100%;
border-collapse: collapse;
margin-top: 20px;
border: 2px solid orange;
border: 2px solid pink;
color: white;
}
@ -87,12 +97,12 @@
td {
padding: 10px;
text-align: left;
border-bottom: 1px solid orange;
border-bottom: 1px solid pink;
}
th {
background-color: black;
color: orange;
color: pink;
}
tr:nth-child(even) {
@ -108,7 +118,7 @@
font-size: 1.2em;
font-weight: bold;
margin-bottom: 10px;
color: orange;
color: pink;
}
.table-container {
@ -119,19 +129,30 @@
</head>
<body>
<h1>SqPad</h1>
<div id="form-container">
<form action="/" method="post" enctype="application/x-www-form-urlencoded">
<label for="name"></label>
<input type="text" id="name" name="name" placeholder="Title Here." required>
<label for="name">Name (optionnal):</label>
<input type="text" id="name" name="name" required>
<label for="content">Content:</label>
<label for="content"></label>
<textarea type="input" id="content" name="content" rows="30" cols="55" placeholder="Put your content here. It will be encrypted via DES-256 and stored." required></textarea>
<input type="submit" value="submit">
<input type="submit" value="Send">
</form>
<form action="/file" method="post" enctype="multipart/form-data">
<br>
<label for="fileupload">Or upload a file, max. size 100MB:</label>
<input id="fileupload" name="file" type="file" required>
<br>
<input type="submit" value="Upload">
</form>
</div>
<hr>
<a href="https://gitea.squi.fr/Rust/SqPad">SqPad</a> by Squi
<hr>
<a href="tos"> Conditions d'utilisation </a>
<p> Need to report something hosted on this website ? Send an email to <a href="mailto:admin@squi.fr">admin@squi.fr</a> including the link to the content.</p>
<p> Vous avez trouvé quelque chose de problématique hebergé sur ce site ? Ecrivez à <a href="mailto:admin@squi.fr">admin@squi.fr</a> en incluant le lien du contenu.</p>

View File

@ -1,2 +1,4 @@
{"name":"llllllll","crypt":"U6O3QDZVQiFfRnj4aG0Exw==","date":"03/07/2023@16:39:26","id":790468326923469714}
{"name":"Hi","crypt":"2Mj3sF0C0loJjnWVgAB7tQ==","date":"03/07/2023@16:54:51","id":8071774849875630801}
{"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}

54
Files/tos.html Normal file
View File

@ -0,0 +1,54 @@
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Conditions Générales d'Utilisation</title>
</head>
<body>
<h1>Conditions Générales d'Utilisation</h1>
<p><strong>Dernière mise à jour : 31 juillet 2024</strong></p>
<p>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.</p>
<h2>1. Acceptation des Conditions</h2>
<p>En utilisant le Site, vous acceptez ces CGU et toute modification future. Si vous n'acceptez pas ces termes, n'utilisez pas le Site.</p>
<h2>2. Description du Service</h2>
<p>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.</p>
<h2>3. Responsabilités de l'Utilisateur</h2>
<ul>
<li><strong>Conformité aux Lois</strong> : Vous acceptez d'utiliser le Service en conformité avec toutes les lois et réglementations locales, nationales et internationales applicables.</li>
<li><strong>Contenu Interdit</strong> : Il est strictement interdit de télécharger tout contenu illégal, nuisible, diffamatoire, contrefaisant ou autrement répréhensible. Cela inclut, mais ne se limite pas à, du matériel relatif à l'abus sexuel d'enfants (CSAM), au terrorisme et à la violation des droits d'auteur.</li>
<li><strong>Sécurité du Compte</strong> : Vous êtes responsable de maintenir la confidentialité de votre compte et de vos clés de chiffrement. Vous acceptez de nous informer immédiatement de toute utilisation non autorisée de votre compte.</li>
</ul>
<h2>4. Procédure de Notification et de Retrait</h2>
<p>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.</p>
<h2>5. Limitation de Responsabilité</h2>
<ul>
<li><strong>Absence de Responsabilité pour le Contenu des Utilisateurs</strong> : SqPad n'a pas la capacité de déchiffrer et de surveiller le contenu téléchargé par les utilisateurs. Par conséquent, nous ne sommes pas responsables du contenu téléchargé par les utilisateurs.</li>
<li><strong>Réponse aux Demandes Légales</strong> : Nous nous conformerons aux demandes légales et aux ordonnances judiciaires dans la mesure requise par la loi, y compris la coopération avec les autorités judiciaires dans les enquêtes sur les activités illégales.</li>
</ul>
<h2>6. Vie Privée et Protection des Données</h2>
<ul>
<li><strong>Données des Utilisateurs</strong> : Nous collectons et traitons les données personnelles conformément à notre Politique de Confidentialité, qui est incorporée par référence dans ces CGU.</li>
<li><strong>Chiffrement</strong> : Tout le contenu téléchargé est chiffré par les utilisateurs, et SqPad n'a pas accès aux clés de chiffrement ni au contenu des fichiers.</li>
</ul>
<h2>7. Résiliation</h2>
<p>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.</p>
<h2>8. Modifications des Conditions</h2>
<p>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.</p>
<h2>9. Droit Applicable</h2>
<p>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.</p>
<h2>10. Coordonnées</h2>
<p>Pour toute question concernant ces CGU ou le Service, veuillez nous contacter à :</p>
<p>admin@squi.fr</p>
</body>
</html>

22
License.txt Normal file
View File

@ -0,0 +1,22 @@
MIT License
Copyright (c) 2023 Justine PELLETREAU
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@ -1,9 +1,19 @@
# SqPad
A encrypted pastebin.
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:
```
docker compose up -f docker-compose.yml -d
```
## Usage
Simply enter a note on the form on the main page. Once submitted, the note is encrypted using DES-256.
@ -13,6 +23,10 @@ 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.
TODO :
* Put the "files" folder somewhere else
* Write a dockerfile
## Warnings
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.
# TODO
Mettre à jour le dockerfile avec une crontab qui supprime les vieux fichiers, ou le faire dans le code.
Ajouter dans la page la bonne commande curl pour uploader des fichiers.

9
docker-compose.yml Normal file
View File

@ -0,0 +1,9 @@
version: "3"
services:
sqpad:
image: gitea.squi.fr/justine/sqpad:latest
container_name: sqpad
ports:
- "8080:8080"
restart: unless-stopped

BIN
sqpad Executable file

Binary file not shown.

186
src/fileupload.rs Normal file
View File

@ -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<dyn std::error::Error>> {
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<dyn std::error::Error>> {
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<String, Box<dyn std::error::Error>> {
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<String, String> {
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<UploadForm>, 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::<u64>();
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\
<br><br><a href=\"{}\">Here</a>\n\
<br><br>You can download it with in a terminal with<br>\
<pre>curl -JLO {}</pre>{}",
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);
}
}

View File

@ -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 {
@ -46,6 +49,7 @@ fn save_post(text: &str) {
let mut file = OpenOptions::new()
.write(true)
.append(true)
.create(true)
.open("./Files/posts.json")
.unwrap();
@ -122,14 +126,14 @@ async fn show_post(path: web::Path<(u64, String)>, req: HttpRequest) -> impl Res
}
let _ = &mut ret_text.push_str(&format!("\n\
<b>This is the link to your post. Don't lose it !\
It can also be accessed raw using Curl or Wget.</b><br>\n\
><i>{} @{}</i><br><br>\n", post.name, post.date));
<b>Save the link to this page ! We will not store it anywhere.</b><br><br><i>\
This page can be also be accessed using curl or wget.</i><hr>\n\
<h2>{}</h2>\n<i>{}</i><br><br>\n<pre>\n", post.name, post.date));
let _ = match decrypt(post.crypt, &password) {
Ok(v) => {
let _ = &mut ret_text.push_str(&v);
let _ = &mut ret_text.push_str("\n");
let _ = &mut ret_text.push_str("\n</pre>\n");
ret_text.push_str("</body>\n</html>");
break;
},
@ -155,13 +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(|| {
HttpServer::new(move || {
App::new()
.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()