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.

README.md 4.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. # rs-short
  2. Link shortener in Rust.
  3. Developed to be as minimalist and lightweight as possible.
  4. Powered by the [Rocket](https://rocket.rs) framework using (server-side) Handlebars templates.
  5. - Less than 1000 lines of code, including 20% of comments
  6. - Consumes between 5MB and 20MB of RAM
  7. - No JS
  8. - No CSS framework ; CSS is handmade and all rules are prefixed to avoid rule conflicts
  9. - No tracking features at all
  10. - No `unsafe` block
  11. Features:
  12. - Includes a captcha as a minimal protection against spamming
  13. - Easily customizable assets
  14. - Only needs a SQLite database to work
  15. - Localization (available in French and English)
  16. - Counting clicks
  17. - Allows shortcut deletion
  18. **Official instance:** https://s.42l.fr/
  19. ## Running an instance
  20. First, you must install Cargo and the latest stable version of Rust by following the instructions on [this website](https://rustup.rs/). Alternatively, you can use the [liuchong/rustup](https://hub.docker.com/r/liuchong/rustup) Docker image.
  21. - Clone the project:
  22. ```bash
  23. git clone https://git.42l.fr/42l/rs-short.git
  24. ```
  25. - Edit what you need. You might want to change the following elements:
  26. - constant `INSTANCE_HOSTNAME` in `main.rs`: replace with your instance hostname
  27. - constant `HOSTER_HOSTNAME` in `main.rs`: replace with the hostname of the organization hosting the project
  28. - `assets/hoster-logo.png`: replace with the logo of your organization
  29. - `assets/logo.svg`: the software logo
  30. - `assets/background.jpg`: the default background
  31. - Create a file named `Rocket.toml` at the project root, containing the following:
  32. ```toml
  33. [global]
  34. address = "<ADDRESS>"
  35. template_dir = "templates"
  36. secret_key = "<SECRET KEY>"
  37. [global.databases.sqlite_database]
  38. url = "db/db.sqlite"
  39. ```
  40. - Replace `<ADDRESS>` by the address to listen on
  41. - Replace `<SECRET KEY>` by the result of the command `openssl rand -base64 32`
  42. - Eventually change the database storage path.
  43. You can specify more parameters following the [Rocket documentation](https://api.rocket.rs/v0.4/rocket/config/index.html).
  44. - **Create the `banned_url_to.list` file** and enter keywords that causes IPs submitting links to get a `403 Forbidden` if their links contain those keywords. Example:
  45. ```
  46. ://bit.ly
  47. google
  48. ```
  49. You can configure a fail2ban instance to watch your favourite reverse-proxy logs to see which IPs are getting a 403 and ban accordingly.
  50. - `cargo run --release`
  51. ## Contributing
  52. The initial version of the software has been developed in one week ; there's still a lot to do.
  53. Here are many ways to contribute:
  54. - Translate!
  55. - Add your entries in the `lang.json` file.
  56. - Once you're done, edit `templates.rs` and add your language in the ValidLanguages structure.
  57. - Improve the software modularity
  58. - Add a configuration file
  59. - Configure instance and hoster's hostname from the configuration file
  60. - Toggle captcha
  61. - Add postgresql compatibility
  62. - Add different CSS themes (a dark theme would be a great start!)
  63. - Develop a more resilient protection to spambots
  64. - Improve hostname blacklisting ?
  65. - Blacklist shortcut names ?
  66. - Integrate a ban / ratelimiting system ? (the current system relies entirely on a separate fail2ban instance)
  67. - Clean up the code
  68. - Restructure the rocket routes in `main.rs` to something more readable
  69. - Make a better usage of template contexts
  70. - Improve the forms if you're knowledgeable in Rocket forms
  71. - Separate the code into more files if necessary
  72. This software is mainly developed and maintained by [Neil](https://shelter.moe/@Neil) for the [Association 42l](https://42l.fr).
  73. If you like the work done on this project, please consider to [donate or join](https://42l.fr/Support-us) the association. Thank you!
  74. ## Graphical credits
  75. - Link Shortener logo by [Brume](https://shelter.moe/@Brume).
  76. - Link Shortener logo font is Hylia Serif by [Artsy Omni](http://artsyomni.com/hyliaserif).
  77. - Default background by [Love-Kay on deviantart](https://www.deviantart.com/love-kay/art/Abstract-Colorful-Watercolor-Texture-438376516).
  78. - Website font by [Ubuntu](https://design.ubuntu.com/font/)