aboutsummaryrefslogtreecommitdiff
path: root/handler.c
Commit message (Collapse)AuthorAgeFilesLines
* wildcard_cmp: Allow case-insensitive searchesXavier Del Campo Romero2023-06-061-1/+1
| | | | The new search feature will require them.
* Split wildcard_cmp into its own componentXavier Del Campo Romero2023-06-061-42/+1
| | | | Future commits will make use of this function outside handler.c.
* Replace select(2) with poll(2)Xavier Del Campo Romero2023-05-011-2/+2
| | | | | | select(2) has a number of well-known issues (e.g.: FD_SETSIZE limiting the maximum amount of file descriptors to watch) that are mostly solved by poll(2) and thus can be used as a drop-in replacement.
* Define _POSIX_C_SOURCEXavier Del Campo Romero2023-03-241-0/+2
| | | | | This allows using the default compiler defined by make(1) (i.e., c99(1)), thus improving POSIX compatibility.
* Send response on quota exceededXavier Del Campo Romero2023-03-201-2/+3
| | | | | | | | | | | | | | | | | So far, slcl would just close the connection with a client when the Content-Length of an incoming request exceeded the user quota, without any meaningful information given back to the user. Now, slcl responds with a HTML file with meaningful information about the error. Limitations: - While this commits has been successfully tested on ungoogled-chromium, LibreWolf (and I assume Firefox and any other derivates too) does not seem to receive the response from the server. - However, this issue only occurred during local testing, but not on remote instances.
* Implement user quotaXavier Del Campo Romero2023-03-061-18/+30
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | This feature allows admins to set a specific quota for each user, in MiB. This feature is particularly useful for shared instances, where unlimited user storage might be unfeasible or even dangerous for the server. Also, a nice HTML5 <progress> element has been added to the site that shows how much of the quota has been consumed. If no quota is set, slcl falls back to the default behaviour i.e., assume unlimited storage. Limitations: - While HTTP does specify a Content-Length, which determines the length of the whole request, it does not specify how many files are involved or their individual sizes. - Because of this, if multiple files are uploaded simultaneously, the whole request would be dropped if user quota is exceeded, even if not all files exceeded it. - Also, Content-Length adds the length of some HTTP boilerplate (e.g.: boundaries), but slcl must rely on this before accepting the whole request. In other words, this means some requests might be rejected by slcl because of the extra bytes caused by such boilerplate. - When the quota is exceeded, slcl must close the connection so that the rest of the transfer is cancelled. Unfortunately, this means no HTML can be sent back to the customer to inform about the situation.
* Perform some minor optimizationsXavier Del Campo Romero2023-03-061-3/+2
|
* Fix memory leak on failed realloc(3)Xavier Del Campo Romero2023-03-041-10/+16
| | | | | | | | | | According to C99 ยง7.20.3.4: If memory for the new object cannot be allocated, the old object is not deallocated and its value is unchanged. Therefore, a temporary pointer must be used to ensure the original object can still be deallocated should realloc(3) return a null pointer.
* Initial commitXavier Del Campo Romero2023-02-281-0/+336