mirror of https://github.com/PiyushXCoder/lupt.git
Compare commits
No commits in common. "289b99d9f8019a9e53e87c0c5f39c2eaf908a846" and "c518e8cf91729561b773985ddbfda069756b1a07" have entirely different histories.
289b99d9f8
...
c518e8cf91
|
|
@ -0,0 +1,25 @@
|
||||||
|
FROM rust:1-alpine3.16
|
||||||
|
|
||||||
|
ENV APP=lupt
|
||||||
|
ENV PORT=8081
|
||||||
|
|
||||||
|
RUN cargo search --limit 0 && \
|
||||||
|
apk upgrade --update-cache --available && \
|
||||||
|
apk add musl-dev && \
|
||||||
|
apk add pkgconfig && \
|
||||||
|
apk add openssl-dev && \
|
||||||
|
rm -rf /var/cache/apk/* && \
|
||||||
|
mkdir -pv /app/${APP}/etc
|
||||||
|
|
||||||
|
WORKDIR /app/${APP}
|
||||||
|
COPY . .
|
||||||
|
|
||||||
|
RUN cargo build --release && \
|
||||||
|
cp target/release/${APP} . && \
|
||||||
|
cargo clean && \
|
||||||
|
rm -rf /usr/local/rustup/ /usr/local/cargo/ && \
|
||||||
|
apk del gcc
|
||||||
|
|
||||||
|
EXPOSE ${PORT}/tcp
|
||||||
|
|
||||||
|
CMD ./${APP} --bind-address 0.0.0.0 --port ${PORT} --config-file /app/${APP}/etc/config.json --static-path /app/${APP}/static/
|
||||||
13
.config.json
13
.config.json
|
|
@ -1,13 +0,0 @@
|
||||||
{
|
|
||||||
"static_dir": "./static/",
|
|
||||||
"bind_address": "0.0.0.0",
|
|
||||||
"non_ssl_port": 8000,
|
|
||||||
"ssl_enabled": false,
|
|
||||||
"ssl_port": null,
|
|
||||||
"ssl_cert": null,
|
|
||||||
"ssl_key": null,
|
|
||||||
"logger_pattern": "%t [%a] %s %{User-Agent}i %r",
|
|
||||||
"log_file": "logs.txt",
|
|
||||||
"salt": "PUT SOME TEXT FOR SALT",
|
|
||||||
"tenor_key": "GET API KEY FROM https://tenor.com AND PASTE HERE"
|
|
||||||
}
|
|
||||||
|
|
@ -0,0 +1,12 @@
|
||||||
|
|
||||||
|
version: "3.2"
|
||||||
|
services:
|
||||||
|
web:
|
||||||
|
container_name: lupt-chat
|
||||||
|
build: .
|
||||||
|
ports:
|
||||||
|
- "8080:8081"
|
||||||
|
volumes:
|
||||||
|
- type: bind
|
||||||
|
source: ./etc
|
||||||
|
target: /app/lupt/etc
|
||||||
|
|
@ -1,3 +1,2 @@
|
||||||
/target
|
/target
|
||||||
/actix-web-middleware-redirect-https/
|
/etc
|
||||||
/logs.txt
|
|
||||||
|
|
|
||||||
|
|
@ -1,29 +0,0 @@
|
||||||
name: Docker Image CI
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches:
|
|
||||||
- "main"
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
push-store-image:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- name: 'Checkout GitHub Action'
|
|
||||||
uses: actions/checkout@main
|
|
||||||
|
|
||||||
- name: 'Login to GitHub Container Registry'
|
|
||||||
uses: docker/login-action@v1
|
|
||||||
with:
|
|
||||||
registry: ghcr.io
|
|
||||||
username: ${{github.actor}}
|
|
||||||
password: ${{secrets.GITHUB_TOKEN}}
|
|
||||||
|
|
||||||
- name: 'Build Inventory Image'
|
|
||||||
run: |
|
|
||||||
docker buildx create --name builder1 --use --bootstrap
|
|
||||||
docker buildx build --push --platform linux/arm64/v8,linux/amd64 \
|
|
||||||
--build-arg="RUNNER_GROUP_ID=${{vars.RUNNER_GROUP_ID}}" \
|
|
||||||
--build-arg="RUNNER_USER_ID=${{vars.RUNNER_USER_ID}}" \
|
|
||||||
--build-arg="APP=${{vars.APP}}" --tag ghcr.io/${GITHUB_REPOSITORY,,}:main $(pwd)
|
|
||||||
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
/target
|
/target
|
||||||
|
/Dockerfile
|
||||||
|
/etc/config.json
|
||||||
/localhost-key.pem
|
/localhost-key.pem
|
||||||
/localhost.pem
|
/localhost.pem
|
||||||
/actix-web-middleware-redirect-https/
|
/docker-compose.yml
|
||||||
/logs.txt
|
|
||||||
|
|
|
||||||
|
|
@ -280,16 +280,6 @@ dependencies = [
|
||||||
"syn 1.0.85",
|
"syn 1.0.85",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "actix-web-middleware-redirect-https"
|
|
||||||
version = "3.0.1"
|
|
||||||
source = "git+https://github.com/PiyushXCoder/actix-web-middleware-redirect-https.git#00234bef996e3373a73e34edd4c373984649f656"
|
|
||||||
dependencies = [
|
|
||||||
"actix-service",
|
|
||||||
"actix-web",
|
|
||||||
"futures",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "actix_derive"
|
name = "actix_derive"
|
||||||
version = "0.6.0"
|
version = "0.6.0"
|
||||||
|
|
@ -384,7 +374,7 @@ version = "0.2.14"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8"
|
checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"hermit-abi",
|
"hermit-abi 0.1.19",
|
||||||
"libc",
|
"libc",
|
||||||
"winapi",
|
"winapi",
|
||||||
]
|
]
|
||||||
|
|
@ -423,7 +413,6 @@ dependencies = [
|
||||||
"percent-encoding",
|
"percent-encoding",
|
||||||
"pin-project-lite",
|
"pin-project-lite",
|
||||||
"rand",
|
"rand",
|
||||||
"rustls",
|
|
||||||
"serde",
|
"serde",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
"serde_urlencoded",
|
"serde_urlencoded",
|
||||||
|
|
@ -510,12 +499,11 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cc"
|
name = "cc"
|
||||||
version = "1.0.83"
|
version = "1.0.72"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "f1174fb0b6ec23863f8b971027804a42614e347eafb0a95bf0b12cdae21fc4d0"
|
checksum = "22a9137b95ea06864e018375b72adfb7db6e6f68cfc8df5a04d00288050485ee"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"jobserver",
|
"jobserver",
|
||||||
"libc",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
|
@ -657,6 +645,40 @@ dependencies = [
|
||||||
"cfg-if",
|
"cfg-if",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "env_logger"
|
||||||
|
version = "0.10.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "85cdab6a89accf66733ad5a1693a4dcced6aeff64602b634530dd73c1f3ee9f0"
|
||||||
|
dependencies = [
|
||||||
|
"humantime",
|
||||||
|
"is-terminal",
|
||||||
|
"log",
|
||||||
|
"regex",
|
||||||
|
"termcolor",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "errno"
|
||||||
|
version = "0.3.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "4bcfec3a70f97c962c307b2d2c56e358cf1d00b558d74262b5f929ee8cc7e73a"
|
||||||
|
dependencies = [
|
||||||
|
"errno-dragonfly",
|
||||||
|
"libc",
|
||||||
|
"windows-sys",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "errno-dragonfly"
|
||||||
|
version = "0.1.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "aa68f1b12764fab894d2755d2518754e71b4fd80ecfb822714a1206c2aab39bf"
|
||||||
|
dependencies = [
|
||||||
|
"cc",
|
||||||
|
"libc",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "flate2"
|
name = "flate2"
|
||||||
version = "1.0.22"
|
version = "1.0.22"
|
||||||
|
|
@ -675,6 +697,21 @@ version = "1.0.7"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1"
|
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]]
|
[[package]]
|
||||||
name = "form_urlencoded"
|
name = "form_urlencoded"
|
||||||
version = "1.0.1"
|
version = "1.0.1"
|
||||||
|
|
@ -841,6 +878,12 @@ dependencies = [
|
||||||
"libc",
|
"libc",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "hermit-abi"
|
||||||
|
version = "0.3.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "fed44880c466736ef9a5c5b5facefb5ed0785676d0c02d612db14e54f0d84286"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "http"
|
name = "http"
|
||||||
version = "0.2.9"
|
version = "0.2.9"
|
||||||
|
|
@ -870,6 +913,12 @@ version = "1.0.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "c4a1e36c821dbe04574f602848a19f742f4fb3c98d40449f11bcad18d6b17421"
|
checksum = "c4a1e36c821dbe04574f602848a19f742f4fb3c98d40449f11bcad18d6b17421"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "humantime"
|
||||||
|
version = "2.1.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "idna"
|
name = "idna"
|
||||||
version = "0.2.3"
|
version = "0.2.3"
|
||||||
|
|
@ -891,6 +940,29 @@ dependencies = [
|
||||||
"hashbrown",
|
"hashbrown",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "io-lifetimes"
|
||||||
|
version = "1.0.11"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "eae7b9aee968036d54dce06cebaefd919e4472e753296daccd6d344e3e2df0c2"
|
||||||
|
dependencies = [
|
||||||
|
"hermit-abi 0.3.1",
|
||||||
|
"libc",
|
||||||
|
"windows-sys",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "is-terminal"
|
||||||
|
version = "0.4.7"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "adcf93614601c8129ddf72e2d5633df827ba6551541c6d8c59520a371475be1f"
|
||||||
|
dependencies = [
|
||||||
|
"hermit-abi 0.3.1",
|
||||||
|
"io-lifetimes",
|
||||||
|
"rustix",
|
||||||
|
"windows-sys",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "itoa"
|
name = "itoa"
|
||||||
version = "1.0.1"
|
version = "1.0.1"
|
||||||
|
|
@ -929,9 +1001,15 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "libc"
|
name = "libc"
|
||||||
version = "0.2.151"
|
version = "0.2.146"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "302d7ab3130588088d277783b1e2d2e10c9e9e4a16dd9050e6ec93fb3e7048f4"
|
checksum = "f92be4933c13fd498862a9e02a3055f8a8d9c039ce33db97306fd5a6caa7f29b"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "linux-raw-sys"
|
||||||
|
version = "0.3.8"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "ef53942eb7bf7ff43a617b3e2c1c4a5ecf5944a7c1bc12d7ee39bbb15e5c1519"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "local-channel"
|
name = "local-channel"
|
||||||
|
|
@ -972,29 +1050,28 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "lupt"
|
name = "lupt"
|
||||||
version = "0.2.1"
|
version = "0.2.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"actix",
|
"actix",
|
||||||
"actix-broker",
|
"actix-broker",
|
||||||
"actix-files",
|
"actix-files",
|
||||||
"actix-web",
|
"actix-web",
|
||||||
"actix-web-actors",
|
"actix-web-actors",
|
||||||
"actix-web-middleware-redirect-https",
|
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"awc",
|
"awc",
|
||||||
"base64",
|
"base64",
|
||||||
"clap",
|
"clap",
|
||||||
|
"env_logger",
|
||||||
"futures",
|
"futures",
|
||||||
"lazy_static",
|
"lazy_static",
|
||||||
"log",
|
"log",
|
||||||
|
"openssl",
|
||||||
"rand",
|
"rand",
|
||||||
"rustls",
|
"rustls",
|
||||||
"rustls-pemfile",
|
"rustls-pemfile",
|
||||||
"serde",
|
"serde",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
"sha2",
|
"sha2",
|
||||||
"simplelog",
|
|
||||||
"tokio",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
|
@ -1053,16 +1130,7 @@ version = "1.13.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "19e64526ebdee182341572e50e9ad03965aa510cd94427a4549448f285e957a1"
|
checksum = "19e64526ebdee182341572e50e9ad03965aa510cd94427a4549448f285e957a1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"hermit-abi",
|
"hermit-abi 0.1.19",
|
||||||
"libc",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "num_threads"
|
|
||||||
version = "0.1.6"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "2819ce041d2ee131036f4fc9d6ae7ae125a3a40e97ba64d04fe799ad9dabbb44"
|
|
||||||
dependencies = [
|
|
||||||
"libc",
|
"libc",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
@ -1081,6 +1149,33 @@ version = "1.18.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d"
|
checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "openssl"
|
||||||
|
version = "0.10.38"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "0c7ae222234c30df141154f159066c5093ff73b63204dcda7121eb082fc56a95"
|
||||||
|
dependencies = [
|
||||||
|
"bitflags",
|
||||||
|
"cfg-if",
|
||||||
|
"foreign-types",
|
||||||
|
"libc",
|
||||||
|
"once_cell",
|
||||||
|
"openssl-sys",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "openssl-sys"
|
||||||
|
version = "0.9.72"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "7e46109c383602735fa0a2e48dd2b7c892b048e1bf69e5c3b1d804b7d9c203cb"
|
||||||
|
dependencies = [
|
||||||
|
"autocfg",
|
||||||
|
"cc",
|
||||||
|
"libc",
|
||||||
|
"pkg-config",
|
||||||
|
"vcpkg",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "os_str_bytes"
|
name = "os_str_bytes"
|
||||||
version = "6.0.0"
|
version = "6.0.0"
|
||||||
|
|
@ -1284,6 +1379,20 @@ dependencies = [
|
||||||
"semver",
|
"semver",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "rustix"
|
||||||
|
version = "0.37.20"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "b96e891d04aa506a6d1f318d2771bcb1c7dfda84e126660ace067c9b474bb2c0"
|
||||||
|
dependencies = [
|
||||||
|
"bitflags",
|
||||||
|
"errno",
|
||||||
|
"io-lifetimes",
|
||||||
|
"libc",
|
||||||
|
"linux-raw-sys",
|
||||||
|
"windows-sys",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rustls"
|
name = "rustls"
|
||||||
version = "0.20.8"
|
version = "0.20.8"
|
||||||
|
|
@ -1298,9 +1407,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rustls-pemfile"
|
name = "rustls-pemfile"
|
||||||
version = "1.0.4"
|
version = "1.0.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "1c74cae0a4cf6ccbbf5f359f08efdf8ee7e1dc532573bf0db71968cb56b1448c"
|
checksum = "d194b56d58803a43635bdc398cd17e383d6f71f9182b9a192c127ca42494a59b"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"base64",
|
"base64",
|
||||||
]
|
]
|
||||||
|
|
@ -1407,17 +1516,6 @@ dependencies = [
|
||||||
"libc",
|
"libc",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "simplelog"
|
|
||||||
version = "0.12.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "acee08041c5de3d5048c8b3f6f13fafb3026b24ba43c6a695a0c76179b844369"
|
|
||||||
dependencies = [
|
|
||||||
"log",
|
|
||||||
"termcolor",
|
|
||||||
"time",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "slab"
|
name = "slab"
|
||||||
version = "0.4.5"
|
version = "0.4.5"
|
||||||
|
|
@ -1490,8 +1588,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "ea9e1b3cf1243ae005d9e74085d4d542f3125458f3a81af210d901dcd7411efd"
|
checksum = "ea9e1b3cf1243ae005d9e74085d4d542f3125458f3a81af210d901dcd7411efd"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"itoa",
|
"itoa",
|
||||||
"libc",
|
|
||||||
"num_threads",
|
|
||||||
"serde",
|
"serde",
|
||||||
"time-core",
|
"time-core",
|
||||||
"time-macros",
|
"time-macros",
|
||||||
|
|
@ -1537,26 +1633,13 @@ dependencies = [
|
||||||
"bytes",
|
"bytes",
|
||||||
"libc",
|
"libc",
|
||||||
"mio",
|
"mio",
|
||||||
"num_cpus",
|
|
||||||
"parking_lot",
|
"parking_lot",
|
||||||
"pin-project-lite",
|
"pin-project-lite",
|
||||||
"signal-hook-registry",
|
"signal-hook-registry",
|
||||||
"socket2",
|
"socket2",
|
||||||
"tokio-macros",
|
|
||||||
"windows-sys",
|
"windows-sys",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[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.18",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "tokio-rustls"
|
name = "tokio-rustls"
|
||||||
version = "0.23.4"
|
version = "0.23.4"
|
||||||
|
|
@ -1675,6 +1758,12 @@ dependencies = [
|
||||||
"percent-encoding",
|
"percent-encoding",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "vcpkg"
|
||||||
|
version = "0.2.15"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "version_check"
|
name = "version_check"
|
||||||
version = "0.9.4"
|
version = "0.9.4"
|
||||||
|
|
|
||||||
15
Cargo.toml
15
Cargo.toml
|
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "lupt"
|
name = "lupt"
|
||||||
version = "0.2.1"
|
version = "0.2.0"
|
||||||
description = "Chat app for lupt(लुप्त) users!"
|
description = "Chat app for lupt(लुप्त) users!"
|
||||||
authors = ["Piyush Raj <piyush.raj.kit@gmail.com>"]
|
authors = ["Piyush Raj <piyush.raj.kit@gmail.com>"]
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
|
|
@ -16,21 +16,22 @@ keywords = ["chat", "Chatting", "Talk", "Stranger"]
|
||||||
actix = "0.13"
|
actix = "0.13"
|
||||||
actix-web = { version = "4", features = ["rustls"] }
|
actix-web = { version = "4", features = ["rustls"] }
|
||||||
actix-web-actors = "4"
|
actix-web-actors = "4"
|
||||||
actix-web-middleware-redirect-https = { git = "https://github.com/PiyushXCoder/actix-web-middleware-redirect-https.git" }
|
|
||||||
actix-broker = "0.4"
|
actix-broker = "0.4"
|
||||||
actix-files = "0.6"
|
actix-files = "0.6"
|
||||||
awc = { version = "3.1", features = ["rustls"] }
|
awc = "3.1"
|
||||||
|
env_logger = "0.10"
|
||||||
|
openssl = "0.10"
|
||||||
|
|
||||||
clap = { version = "4", features = ["derive"] }
|
clap = { version = "4", features = ["derive"] }
|
||||||
lazy_static = "1.4"
|
lazy_static = "1.4"
|
||||||
serde = { version = "1.0", features = ["serde_derive"] }
|
serde = { version = "1.0", features = ["serde_derive"] }
|
||||||
serde_json = "1.0"
|
serde_json = "1.0"
|
||||||
rand = "0.8"
|
rand = "0.8"
|
||||||
futures = "0.3"
|
futures = "0.3"
|
||||||
|
|
||||||
sha2 = "0.10"
|
sha2 = "0.10"
|
||||||
base64 = "0.21"
|
base64 = "0.21"
|
||||||
log = "0.4"
|
log = "0.4"
|
||||||
anyhow = { version = "1.0.71", features = ["backtrace"] }
|
|
||||||
simplelog = "0.12.1"
|
|
||||||
tokio = { version = "1.5.0", features = ['rt', 'rt-multi-thread', 'macros'] }
|
|
||||||
rustls = "0.20"
|
rustls = "0.20"
|
||||||
rustls-pemfile = "1.0.4"
|
rustls-pemfile = "1.0.2"
|
||||||
|
anyhow = { version = "1.0.71", features = ["backtrace"] }
|
||||||
|
|
|
||||||
27
Dockerfile
27
Dockerfile
|
|
@ -1,27 +0,0 @@
|
||||||
FROM rust:alpine3.18 AS build
|
|
||||||
RUN cargo search --limit 1 && \
|
|
||||||
apk add --no-cache musl-dev pkgconfig openssl-dev
|
|
||||||
WORKDIR /app
|
|
||||||
COPY . .
|
|
||||||
RUN cargo build --release
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
FROM alpine:3.18
|
|
||||||
|
|
||||||
ARG RUNNER_GROUP_ID=1000
|
|
||||||
ENV RUNNER_GROUP_ID=${RUNNER_GROUP_ID}
|
|
||||||
|
|
||||||
ARG RUNNER_USER_ID=1000
|
|
||||||
ENV RUNNER_USER_ID=${RUNNER_USER_ID}
|
|
||||||
|
|
||||||
ENV APP=lupt
|
|
||||||
ENV RUST_LOG="actix_web=info"
|
|
||||||
|
|
||||||
USER ${RUNNER_USER_ID}:${RUNNER_GROUP_ID}
|
|
||||||
WORKDIR /app
|
|
||||||
COPY --from=build --chown=${RUNNER_USER_ID}:${RUNNER_GROUP_ID} /app/target/release/${APP} app
|
|
||||||
COPY --from=build --chown=${RUNNER_USER_ID}:${RUNNER_GROUP_ID} /app/static static/
|
|
||||||
COPY --from=build --chown=${RUNNER_USER_ID}:${RUNNER_GROUP_ID} [ "/app/.config.json", "config.json" ]
|
|
||||||
CMD RUST_LOG="${RUST_LOG}" ./app --config-file config.json
|
|
||||||
|
|
@ -1,18 +0,0 @@
|
||||||
|
|
||||||
version: "3.2"
|
|
||||||
services:
|
|
||||||
web:
|
|
||||||
build:
|
|
||||||
context: .
|
|
||||||
args:
|
|
||||||
RUNNER_USER_ID: 1000
|
|
||||||
RUNNER_GROUP_ID: 1000
|
|
||||||
ports:
|
|
||||||
- ${PORT}:8000
|
|
||||||
volumes:
|
|
||||||
- ${CONFIG}:/app/config.json
|
|
||||||
- ${LOG}:/app/logs.txt:rw
|
|
||||||
environment:
|
|
||||||
- RUST_LOG=actix_web=info
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1,13 +0,0 @@
|
||||||
|
|
||||||
version: "3.2"
|
|
||||||
services:
|
|
||||||
web:
|
|
||||||
image: "ghcr.io/piyushxcoder/lupt:main"
|
|
||||||
restart: always
|
|
||||||
ports:
|
|
||||||
- ${PORT}:8000
|
|
||||||
volumes:
|
|
||||||
- ${CONFIG}:/app/config.json
|
|
||||||
- ${LOG}:/app/logs.txt:rw
|
|
||||||
environment:
|
|
||||||
- RUST_LOG=actix_web=info
|
|
||||||
|
|
@ -0,0 +1,10 @@
|
||||||
|
{
|
||||||
|
"bind_address": "Address to start server. (For example: localhost:8000)",
|
||||||
|
"static_dir_path": "Directory to static html files to serve",
|
||||||
|
"logger_pattern": "https://docs.rs/actix-web/latest/actix_web/middleware/struct.Logger.html (For example: %t [%a] %s %{User-Agent}i %r)",
|
||||||
|
"salt": "PUT SOME TEXT FOR SALT",
|
||||||
|
"tenor_key": "GET API KEY FROM https://tenor.com AND PASTE HERE",
|
||||||
|
"allow_ssl": false,
|
||||||
|
"ssl_cert": "Path to ssl certificate",
|
||||||
|
"ssl_key": "Path to ssl key"
|
||||||
|
}
|
||||||
|
|
@ -294,6 +294,7 @@ impl Handler<ms::pind::JoinRandomNext> for ChatPinnd {
|
||||||
);
|
);
|
||||||
|
|
||||||
let log_count = kaksh.loog.len();
|
let log_count = kaksh.loog.len();
|
||||||
|
drop(kaksh);
|
||||||
if log_count == 0 {
|
if log_count == 0 {
|
||||||
self.kaksh.remove(&msg.kaksh_kunjika);
|
self.kaksh.remove(&msg.kaksh_kunjika);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -29,21 +29,17 @@ pub(crate) struct Args {
|
||||||
|
|
||||||
#[derive(Deserialize)]
|
#[derive(Deserialize)]
|
||||||
pub(crate) struct ConfigFile {
|
pub(crate) struct ConfigFile {
|
||||||
pub(crate) static_dir: PathBuf,
|
|
||||||
|
|
||||||
pub(crate) bind_address: String,
|
pub(crate) bind_address: String,
|
||||||
pub(crate) non_ssl_port: u16,
|
|
||||||
|
|
||||||
pub(crate) ssl_enabled: bool,
|
|
||||||
pub(crate) ssl_port: Option<u16>,
|
|
||||||
pub(crate) ssl_cert: Option<String>,
|
|
||||||
pub(crate) ssl_key: Option<String>,
|
|
||||||
|
|
||||||
|
pub(crate) static_dir_path: PathBuf,
|
||||||
pub(crate) logger_pattern: String,
|
pub(crate) logger_pattern: String,
|
||||||
pub(crate) log_file: PathBuf,
|
|
||||||
|
|
||||||
pub(crate) salt: String,
|
pub(crate) salt: String,
|
||||||
pub(crate) tenor_key: Option<String>,
|
pub(crate) tenor_key: Option<String>,
|
||||||
|
|
||||||
|
pub(crate) allow_ssl: Option<bool>,
|
||||||
|
pub(crate) ssl_cert: Option<String>,
|
||||||
|
pub(crate) ssl_key: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn generate() -> ConfigFile {
|
pub(crate) fn generate() -> ConfigFile {
|
||||||
|
|
|
||||||
|
|
@ -18,5 +18,5 @@
|
||||||
mod kaksh_full_error;
|
mod kaksh_full_error;
|
||||||
mod user_kunjika_error;
|
mod user_kunjika_error;
|
||||||
|
|
||||||
// pub use kaksh_full_error::KakshFullError;
|
pub use kaksh_full_error::KakshFullError;
|
||||||
// pub use user_kunjika_error::AlreadyExistError;
|
pub use user_kunjika_error::AlreadyExistError;
|
||||||
|
|
|
||||||
127
src/main.rs
127
src/main.rs
|
|
@ -36,10 +36,7 @@ use actix_web_actors::ws;
|
||||||
use awc::Client;
|
use awc::Client;
|
||||||
use config::CONFIG;
|
use config::CONFIG;
|
||||||
use rustls::{Certificate, PrivateKey, ServerConfig};
|
use rustls::{Certificate, PrivateKey, ServerConfig};
|
||||||
use rustls_pemfile::{certs, pkcs8_private_keys};
|
|
||||||
use simplelog::*;
|
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
use std::io::BufReader;
|
|
||||||
use ws_sansad::WsSansad;
|
use ws_sansad::WsSansad;
|
||||||
|
|
||||||
mod broker_messages;
|
mod broker_messages;
|
||||||
|
|
@ -51,30 +48,12 @@ mod ws_sansad;
|
||||||
|
|
||||||
#[actix_web::main]
|
#[actix_web::main]
|
||||||
async fn main() -> std::io::Result<()> {
|
async fn main() -> std::io::Result<()> {
|
||||||
|
std::env::set_var("RUST_LOG", "info");
|
||||||
|
env_logger::init();
|
||||||
|
|
||||||
lazy_static::initialize(&CONFIG);
|
lazy_static::initialize(&CONFIG);
|
||||||
|
|
||||||
CombinedLogger::init(vec![
|
let main_server = HttpServer::new(move || {
|
||||||
TermLogger::new(
|
|
||||||
LevelFilter::Warn,
|
|
||||||
Config::default(),
|
|
||||||
TerminalMode::Mixed,
|
|
||||||
ColorChoice::Auto,
|
|
||||||
),
|
|
||||||
WriteLogger::new(
|
|
||||||
LevelFilter::Info,
|
|
||||||
Config::default(),
|
|
||||||
File::options()
|
|
||||||
.write(true)
|
|
||||||
.open(&CONFIG.log_file)
|
|
||||||
.unwrap_or_else(|_| {
|
|
||||||
println!("Creating new log file");
|
|
||||||
File::create(&CONFIG.log_file).unwrap()
|
|
||||||
}),
|
|
||||||
),
|
|
||||||
])
|
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
let server = HttpServer::new(move || {
|
|
||||||
let mut app = App::new()
|
let mut app = App::new()
|
||||||
.wrap(Logger::new(&CONFIG.logger_pattern))
|
.wrap(Logger::new(&CONFIG.logger_pattern))
|
||||||
.service(web::resource("/ws/").route(web::get().to(ws_index)));
|
.service(web::resource("/ws/").route(web::get().to(ws_index)));
|
||||||
|
|
@ -87,84 +66,56 @@ async fn main() -> std::io::Result<()> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
app = app.service(fs::Files::new("/", &CONFIG.static_dir).index_file("index.html"));
|
app = app.service(fs::Files::new("/", &CONFIG.static_dir_path).index_file("index.html"));
|
||||||
app
|
app
|
||||||
});
|
});
|
||||||
|
|
||||||
if CONFIG.ssl_enabled {
|
let main_server = if CONFIG.allow_ssl.unwrap_or(false) {
|
||||||
let server = server
|
main_server
|
||||||
.bind_rustls(
|
.bind_rustls(
|
||||||
format!("{}:{}", CONFIG.bind_address, CONFIG.ssl_port.unwrap()),
|
&CONFIG.bind_address,
|
||||||
load_rustls_config(
|
gen_rustls_server_config(
|
||||||
CONFIG.ssl_key.clone().unwrap(),
|
CONFIG.ssl_key.clone().unwrap(),
|
||||||
CONFIG.ssl_cert.clone().unwrap(),
|
CONFIG.ssl_cert.clone().unwrap(),
|
||||||
),
|
),
|
||||||
)?
|
)?
|
||||||
.run();
|
.run()
|
||||||
let redirect_server = create_redirect_server(
|
|
||||||
CONFIG.ssl_port.unwrap(),
|
|
||||||
CONFIG.non_ssl_port,
|
|
||||||
&CONFIG.bind_address,
|
|
||||||
);
|
|
||||||
let (r1, r2) = tokio::join!(server, redirect_server);
|
|
||||||
r1.unwrap();
|
|
||||||
r2.unwrap();
|
|
||||||
} else {
|
} else {
|
||||||
server
|
main_server.bind(&CONFIG.bind_address)?.run()
|
||||||
.bind(format!("{}:{}", CONFIG.bind_address, CONFIG.non_ssl_port))?
|
};
|
||||||
.run()
|
|
||||||
.await?;
|
main_server.await
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
fn gen_rustls_server_config(key: String, cert: String) -> ServerConfig {
|
||||||
}
|
let mut br = std::io::BufReader::new(File::open(cert).unwrap());
|
||||||
|
let certs = rustls_pemfile::certs(&mut br)
|
||||||
fn load_rustls_config(key: String, cert: String) -> rustls::ServerConfig {
|
|
||||||
// Load key files
|
|
||||||
let cert_file = &mut BufReader::new(File::open(cert).unwrap());
|
|
||||||
let key_file = &mut BufReader::new(File::open(key).unwrap());
|
|
||||||
|
|
||||||
// Parse the certificate and set it in the configuration
|
|
||||||
let cert_chain = certs(cert_file)
|
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.into_iter()
|
.iter()
|
||||||
.map(|a: Vec<u8>| rustls::Certificate(a))
|
.map(|a| Certificate(a.to_owned()))
|
||||||
.collect::<Vec<Certificate>>();
|
.collect::<Vec<Certificate>>();
|
||||||
let key = pkcs8_private_keys(key_file)
|
|
||||||
.unwrap()
|
|
||||||
.into_iter()
|
|
||||||
.map(|a: Vec<u8>| rustls::PrivateKey(a))
|
|
||||||
.collect::<Vec<PrivateKey>>()
|
|
||||||
.first()
|
|
||||||
.unwrap()
|
|
||||||
.to_owned();
|
|
||||||
|
|
||||||
// Create configuration
|
let mut br = std::io::BufReader::new(File::open(key).unwrap());
|
||||||
ServerConfig::builder()
|
let private_key = rustls_pemfile::ec_private_keys(&mut br).unwrap_or(
|
||||||
.with_safe_defaults()
|
rustls_pemfile::rsa_private_keys(&mut br)
|
||||||
|
.unwrap_or(rustls_pemfile::pkcs8_private_keys(&mut br).unwrap()),
|
||||||
|
);
|
||||||
|
|
||||||
|
let private_key = private_key.get(0).unwrap();
|
||||||
|
|
||||||
|
let private_key = PrivateKey(private_key.to_owned());
|
||||||
|
|
||||||
|
let config = ServerConfig::builder()
|
||||||
|
.with_safe_default_cipher_suites()
|
||||||
|
.with_safe_default_kx_groups()
|
||||||
|
.with_safe_default_protocol_versions()
|
||||||
|
.map_err(|e| anyhow!(e))
|
||||||
|
.expect("Build TLS!")
|
||||||
.with_no_client_auth()
|
.with_no_client_auth()
|
||||||
.with_single_cert(cert_chain, key)
|
.with_single_cert(certs, private_key)
|
||||||
.unwrap()
|
.map_err(|e| anyhow!(e))
|
||||||
}
|
.expect("Add TLS certificates!");
|
||||||
|
config
|
||||||
async fn create_redirect_server(
|
|
||||||
ssl_port: u16,
|
|
||||||
non_ssl_port: u16,
|
|
||||||
bind_address: &str,
|
|
||||||
) -> std::io::Result<()> {
|
|
||||||
HttpServer::new(move || {
|
|
||||||
App::new().wrap(
|
|
||||||
actix_web_middleware_redirect_https::RedirectHTTPS::with_replacements(&[(
|
|
||||||
non_ssl_port.to_string(),
|
|
||||||
ssl_port.to_string(),
|
|
||||||
)]),
|
|
||||||
)
|
|
||||||
})
|
|
||||||
.bind(format!("{}:{}", bind_address, non_ssl_port))?
|
|
||||||
.run()
|
|
||||||
.await
|
|
||||||
.unwrap();
|
|
||||||
Ok(())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn ws_index(req: HttpRequest, stream: web::Payload) -> Result<HttpResponse, Error> {
|
async fn ws_index(req: HttpRequest, stream: web::Payload) -> Result<HttpResponse, Error> {
|
||||||
|
|
|
||||||
|
|
@ -237,6 +237,7 @@ impl WsSansad {
|
||||||
for id in ids {
|
for id in ids {
|
||||||
msg_id.push(id.as_str().unwrap().to_owned());
|
msg_id.push(id.as_str().unwrap().to_owned());
|
||||||
}
|
}
|
||||||
|
drop(ids);
|
||||||
|
|
||||||
let kaksh_kunjika = match &self.isthiti {
|
let kaksh_kunjika = match &self.isthiti {
|
||||||
Isthiti::Kaksh(kaksh_kunjika) => kaksh_kunjika.to_owned(),
|
Isthiti::Kaksh(kaksh_kunjika) => kaksh_kunjika.to_owned(),
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue