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:
/upload
for image/files/text/short
for 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/upload
Shortening link:
curl -X POST -F "url=http://your.long/ass/url/that/you/want/to/shorten" https://p.ihateani.me/short
Or 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.example
toconfig.json
- Go to Configuration to config stuff first.
- Run
cargo build --locked --profile release
- Run
./target/release/ihacdn
or.\target\release\ihacdn.exe
on 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
null
if 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
None
for no limit.) - admin_filesize_limit: upload size limit (in kilobytes) for someone using admin password (can be set to
None
for 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