/AsthoBin

AsthoBin is a simple website to share pieces of code with a URL, written in Rust (available on https://bin.asthowen.fr).

Primary LanguageRustGNU General Public License v3.0GPL-3.0

AsthoBin

Made with Rust Use git
License Stars

AsthoBin is a simple website to share pieces of code with a URL, written in Rust.

Features

  • Lightweight < 5MB
  • Low RAM consumption
  • Responsive UI
  • Code coloring with highlight.js
  • Automatic deletion after custom time
  • Recovery of files raws

TODO

  • GitHub actions
  • Add code documentation
  • Unit tests
  • Docker image

Installation

Docker

Start by cloning the repo:

git clone https://github.com/Asthowen/AsthoBin.git && cd AsthoBin

After that, create a database with the name you want, then edit .env config file, for this please refer to configuration.

And finally, run Docker container (do not forget to change the two ports, one for AsthoBin and the other for your SQL database):

docker run -d \
  --name=asthobin \
  -p 8080:8080 \
  -p 3306:3306 \
  --restart unless-stopped \
  --env-file .env \
  asthowen/asthobin:latest

You can also use docker-compose with the docker/docker-compose.yml file.

Manually

Start by cloning the repo:

git clone https://github.com/Asthowen/AsthoBin.git && cd AsthoBin

For the next step you need to have Rust and Cargo installed on your PC, for that follow the official documentation. You will also need pnpm.

Install diesel-cli:

cargo install diesel_cli --no-default-features --features mysql

Now compile a release:

cargo build --release

Your executable will be in the target/release/ folder, it is named asthobin.

Configuration

To configure AsthoBin, just use the example configuration: .env.example, you just have to rename it to .env and complete it.

List of variables

Key Default Description
HOST 127.0.0.1 The desired hostname to launch AsthoBin.
PORT 8080 The desired port to launch AsthoBin.
DATABASE_URL Nothing (required) The URL of your database.
BASE_URL Nothing (required) The URL at which your AsthoBin instance is accessible, e.g: http://127.0.0.1:8080/.
CORS_ORIGIN * CORS parameters.
LOG_ON_ACCESS false Display a log when a user access to a file.
LOG_ON_SAVE false Display a log when a user creates a file.
RATELIMIT_BETWEEN_SAVE 2 Number of seconds between each file save.
RATELIMIT_ALLOWED_BEFORE 4 Number of requests before blocking.
ACTIX_WORKER_THREADS_NUMBER 8 The number of threads used by Actix.
TZ System value The time zone of the logger, e.g: Europe/Paris.
HTTP_PRIVATE_KEY Nothing (optional) The file path of SSL certificate private key.
HTTP_CERTIFICATE_CHAIN Nothing (optional) The file path of SSL certificate chain.
SSL_FILE_TYPE PEM The private key algorithm(PEM/ASN1).
SSL_CA_FILE Nothing (optional) The file path of SSL certificate authority.
SSL_PROTOCOL_MIN_VERSION Nothing (optional) The minimum value of SSL protocol (ssl3/tls1/tls1.1/tls1.2/tls1.3).
SSL_PROTOCOL_MAX_VERSION Nothing (optional) The maximum value of SSL protocol (ssl3/tls1/tls1.1/tls1.2/tls1.3).

Development

Before submit a PR

You must make sure that clippy (cargo clippy) does not return any errors/warning. You must also run cargo fmt.

Versioning

This project uses semantic versioning, which has the format: MAJOR.MINOR.PATCH with:

  • MAJOR version when you make incompatible API changes.
  • MINOR version when you add functionality in a backwards compatible manner.
  • PATCH version when you make backwards compatible bug fixes.

Contributors

Asthowen

License

AsthoBin | GNU General Public License v3.0