aboutsummaryrefslogtreecommitdiffstats

What is this?

This is a URL shortener, a sort of a backend project practice. It uses GNU's libmicrohttpd and sqlite3 the database. The reason for me chosing libmicrohttpd is simple: it's lightweight and does not have too much magic. The reason for me chosing sqlite as a database is even simpler: it's fucking based.

Sadly, I think I might want to run this inside a docker container on my server, because it's C after and I'm no expect on security. Maybe I'll run it in a chroot environment, who knows.

Features

  • Will try to process URLs in this order:
  1. Checks if API endpoint exists at that URL, and if it does, and executes it.
  2. Checks if URL is a shortened link name, and if it is, redirects there.
  3. Tries to send a file at the location pointed to by URL (relative to executable's location).
  4. Tries to format file like this: www/{URL}.html and display the page [e.g. /docs -> www/docs.html]
  5. Returns 404
  • [In future]: uses inotify to track changes in endpoints.so and reload it
  • [In future]: SIGUSR1 makes it reload endpoints.so

API

Pretty small. See html docs page.

Build

Requirements

  1. submodules
  2. make
  3. gperf
  4. cc
  5. linker that supports .ld scripts
  6. libmicrohttpd installed with headers available.
  7. sqlite installed with headers available.
  8. git submodules cloned (c_headers) all of the paths can be configured in Makefile

Steps

make

Os-specific dependency installation:

  • debian12: # apt install libmicrohttpd-dev libsqlite3-dev gperf
  • arch: # pacman -S libmicrohttpd sqlite gperf

Run

  1. Copy config.env.default to config.env, change environment variables in there to match your needs
  2. make run, or env $(cat config.env) ./main, or . config.env && ./main, whichever fits your needs the most.

License

AGPL. Sorry fellas, gotta stay free (as in "freedom"). Also, sorry, google employees

Contributing

my email

I highly doubt that anyone whould contribute to this meme of a project, but you know better, so mail me if you want. I accept modifications in code as tar'ed archives of git repos.