A simple file hosting using axum.
This is a port of TypeScript version with Express.js framework right here: ihacdn-server-ts
Currently running on: https://p.ihateani.me/
- Image/Files/Text support with blacklisting.
- Auto determining if it's text or files without user defining itself.
- Filesize limit support. [Can be disabled.]
- Customizable.
- Code highlighting support via Shiki.js
- Shortlink generation support
- You don't need the extension to access your files/code
- File retention support
Formula:min_days + (-max_days + min_days) * (file_size / filesize_limit - 1) ** 5 - Discord Webhook Notification Support
There's 2 POST endpoint:
/uploadfor image/files/text/shortfor shortening link.
To upload, you need to provide file with the name file.
To shorten url, you need to use form data with url as the key.
Example with curl:
Uploading files:
curl -X POST -F "file=@yourfile.png" https://p.ihateani.me/uploadShortening link:
curl -X POST -F "url=http://your.long/ass/url/that/you/want/to/shorten" https://p.ihateani.me/shortOr you could use ShareX and import the provided sxcu files.
What you need:
- Rust 1.85.0
- Redis 7
To install and run:
- Download Rust and other build requirements
- Clone this repository
- Rename
config.json.exampletoconfig.json - Go to Configuration to config stuff first.
- Run
cargo build --locked --profile release - Run
./target/release/ihacdnor.\target\release\ihacdn.exeon Windows - By default your server will be hosted at https://127.0.0.1:6969
Configure this program by opening config.json
You will see a lot of stuff that you could change.
That's the default settings, you can adjust it what you want.
Explanation:
- hostname: are your website domain.
- https_mode: is your website gonna run on https or not.
- upload_path: where to put your uploads path, recommended to leave it just like that.
- admin_password: admin password, please modify this.
- filename_length: the randomized filename length.
- redis: The redis:// database configuration URL
- notifier
- enable: Enable notifier that will notify for a new upload or link shorten
- discord_webhook: if you want to use discord webhook, add your webhook url here or leave it to
nullif you don't need it.
- file_retention
- enable: Enable file retention that basically will time the file before deletion
- min_age: Minimum age of file being saved in server (in days)
- max_age: Minimum age of file being saved in server (in days)
- storage
- filesize_limit: upload size limit (in kilobytes) for normal user. (can be set to
Nonefor no limit.) - admin_filesize_limit: upload size limit (in kilobytes) for someone using admin password (can be set to
Nonefor no limit.)
- filesize_limit: upload size limit (in kilobytes) for normal user. (can be set to
- blocklist
- extension: Blocked extension, this will not allow anything with this extension.
- content_type: Blocked content-type, this will not allow any file with this content-type.
[To be written.]
If you're using Reverse Proxy like Nginx, it's recommended to set client_max_body_size to make sure you can upload large files.
You can either put it on http block on /etc/nginx/nginx.conf or the server block on sites-available conf.
Example:
http {
...
client_max_body_size 1024M; # This will set the limit to 1 GiB.
...
}This project uses the following libraries for Pastebin:
shiki- for syntax highlightingIBM Mono Plex- for font
This project is licensed with MIT License
{ "hostname": "localhost", // Hostname that will be used. "host": "127.0.0.1", // The host where the program will be running "port": 6969, // The port where the program will be running. "https_mode": false, // Enable HTTPS Mode or not "upload_path": "./", // The saved uploads "admin_password": "pleasechangethis", // Password for Admin "filename_length": 8, // Randomized password length "redisdb": { "host": "127.0.0.1", // Redis Host "port": 6379, // Redis Port "password": null // Redis password, leave at null if there's none }, "notifier": { "enable": false, // This will enable the notifier for a new upload or short "discord_webhook": null // discord webhook URL }, "file_retention": { "enable": false, // This will enable file retention before being deleted from server "min_age": 30, // Minimum age in days before deletion "max_age": 180 // Maximum age in days before deletion }, "storage": { "filesize_limit": 512, // Filesize limit for normal user (in kb), leave at null if you don't want any limit "admin_filesize_limit": null // Filesize limit for admin (in kb), leave at null if you don't want any limit }, "blocklist": { // Block certain type of file "extension": [ "exe", "sh", "msi", "bat", "dll", "com" ], "content_type": [ "text/x-sh", "text/x-msdos-batch", "application/x-dosexec", "application/x-msdownload", "application/vnd.microsoft.portable-executable", "application/x-msi", "application/x-msdos-program", "application/x-sh" ] } }