Comet is a blazingly fast Content Delivery Network (CDN) node written in Rust.
Before you start, make sure you have Rust installed on your system. If you don't have it installed, you can download it from the official website: https://www.rust-lang.org/tools/install
-
Clone the repository & Navigate to it:
git clone https://github.com/du-cki/comet.git cd comet
-
Build the project:
SQLX_OFFLINE=true cargo build --release
-
Edit the
comet-config.toml
file and apply the necessary configurations. -
Run the project:
cargo run --release
Please refer to the wiki for other ways to running & exposing this project.
Once you've installed comet, you can start using it as a CDN node. Here's a basic guide on how to use it:
To upload a file, you need to make a POST request to the /upload
endpoint with the file (as FormData) and the password (set in the comet-config.toml
file) in the Authorisation
header.
To retrieve a file, make a GET request to the /media/:media_id
endpoint, replacing :media_id
with the name of the file you want to retrieve.
To delete a file, make a DELETE request to the /delete/:media_id
endpoint, replacing :media_id
with the relevant file name and along with the password set in the Authorisation header.
You can configure Comet by modifying the comet-config.example.toml
file. Here are the available settings
(don't forget to rename the file into comet-config.toml
):
bind_addr
: The IP address to bind the server to.
bind_port
: The port to bind the server to.
password
: The password required to access authenticated routes (i.e. upload route).
file_name_length
: The length of the randomly generated file names.
file_save_path
: The path on disk where uploaded files will be saved onto.
file_size_limit
: The file upload limit, if you pass in 0
, this will be disabled.
enforce_file_extensions
: Whether to enforce file extensions when requesting for the file.
fallback_content_type
: The content type to use when the uploaded file's content type cannot be determined.
endpoints.get_file
: The endpoint for retrieving files.
endpoints.upload_file
: The endpoint for uploading files.
endpoints.delete_file
: The endpoint for deleting files.
Please note that you should restart the server for the changes to take effect.
If you are interested in contributing to the development of Comet, here's how to setup an development enviroment:
Make sure you have Rust installed on your system. If not, you can download it from the official website: https://www.rust-lang.org/tools/install
-
Clone the Repository & Navigate to the project
Clone the repository to your local machine:
git clone https://github.com/du-cki/comet.git cd comet
-
Build the Project
As comet uses SQLite as its database as choice, you'll need to set up the database. To do so, you will need to perform an offline compilation. Build the project with the env variable
SQLX_OFFLINE
astrue
:SQLX_OFFLINE=true cargo build
-
Environment Variables
After building the project initially, you can create an
.env
file in the root of the project and setDATABASE_URL
assqlite://data.db
for compile-time checks.
If you make changes to any SQL queries, you'll need to regenerate the sqlx-data.json file for a successful offline compilation. You can regenerate it with the SQLx CLI through cargo sqlx prepare
.
Once you've made your changes, please provide a clear and detailed explanation of your changes and open a pull request.
comet is licensed under the MIT license.