Link shortener in Rust. https://s.42l.fr/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
Neil d8094caddc updating css ver 1 day ago
assets hotfixing 42l icon on phishing page 1 day ago
db Don't delete the db folder; don't push blacklists 1 year ago
migrations version 2.0.0, initial commit 10 months ago
screenshots version 2.0.0, initial commit 10 months ago
src *trim* the link before saving it to db // checking it with protocols list 1 month ago
templates updating css ver 1 day ago
.gitignore version 2.0.0, initial commit 10 months ago
Cargo.toml bumping to 2.2.0 1 month ago
LICENSE Initial commit, version 1.0.0 1 year ago
README.md adding more features to readme 1 month ago
config.toml.sample add info to sample config, increment config version and optimize cache 1 month ago
lang.json introduce 404 catcher, fixes #5 1 month ago
url_from_blacklist.txt version 2.0.0, initial commit 10 months ago
url_to_blacklist.txt introduce soft blacklist 1 month ago
url_to_softblacklist.txt introduce soft blacklist 1 month ago

README.md

rs-short

Warning: A few steps are necessary to migrate the database from rs-short 1.x.x. Please check the release notes for details.

Link shortener in Rust.

Developed to be as minimalist and lightweight as possible.

Powered by the Actix framework using (server-side) Askama templates.

  • Around 1000 lines of code, including 20% of comments
  • Consumes between 5MB and 20MB of RAM
  • No JS
  • No CSS framework ; CSS is handmade and all rules are prefixed to avoid rule conflicts
  • No tracking features at all, user IPs are not saved in database
  • No unsafe block
  • Compiles on Rust stable

Features:

  • Includes a captcha as a minimal protection against spamming
  • Easily customizable assets, contact details, and hoster information
  • Light / dark theme
  • Only needs a SQLite database to work
  • Robust caching features to serve content even with database locks
  • Localization (available in French and English, please translate!)
  • Basic protection against spambots (captcha with a customizable difficulty)
  • Active detection of phishing links (detects "suspicious activity")
  • Counting clicks
  • Allows shortcut deletion by the user
  • Allows marking a shortcut as "phishing", which displays a awareness-raising message to victims

Official instance: https://s.42l.fr/

Screenshots

Main page:

Main page screenshot

Admin page for users when they create a link:

New link screenshot

Page displayed when a link is marked as phishing by the server administrator:

Main page screenshot

Running an instance

First, you must install Cargo and the latest stable version of Rust by following the instructions on this website. Alternatively, you can use the liuchong/rustup Docker image.

  • Clone the project:
git clone https://git.42l.fr/42l/rs-short.git
  • Edit what you need. You might want to change the following files:

    • assets/hoster-logo.svg: replace with the logo of your organization
    • assets/logo.svg: the software logo
    • assets/themes/light/background.jpg: the default background for the light theme
  • Copy config.toml.sample to config.toml and edit its values to suit your needs:

    • Important: Replace default values of cookie_key and phishing_password.
  • Edit blacklists at your convenience.

    • url_from_blacklist.list: Any client that submits a link name fully matching one of the elements in this list will get a 403 Forbidden HTTP status code.
    • url_to_softblacklist.list: Any client that submits an URL containing one of the elements in this list will get denied with a friendly warning.
    • url_to_blacklist.list: Any client that submits an URL containing one of the elements in this list will get a 403 Forbidden HTTP status code.

You can configure a fail2ban instance and watch your favourite reverse-proxy logs to see which IPs are getting a 403 and ban accordingly for the duration of your choice.

  • cargo run --release

Contributing

Here are many ways to contribute:

  • Translate!
    • Add your entries in the lang.json file.
    • Once you're done, edit init.rs and add your language in the ValidLanguages structure.
  • Add PostgreSQL/MySQL compatibility (easy thanks to Diesel)
  • Add some more CSS themes
  • Rework default themes' CSS (they've gone a bit messy since then. hopefully they are commented)
  • Develop a more resilient protection to spambots
    • Add JS? :(
  • Add a toggle to disable the captcha
  • Experiment around captchas to match accessibility needs. I have no idea... :(

This software is mainly developed and maintained by Neil for the Association 42l.

If you like the work done on this project, please consider to donate or join the association. Thank you!

Graphical credits