summaryrefslogtreecommitdiff
path: root/crates/tor-dirserver/src/http.rs
Commit message (Collapse)AuthorAgeFilesLines
* Fix typosTobias Stoeckmann2026-03-241-2/+2
| | | | Typos found with codespell
* dirserver: Allow clippy::unused_asyncGabriela Moldovan2026-01-271-0/+1
| | | | This code is still WIP, no need to address the lint yet.
* tor-dirserver: Remove FromStr for DocumentIdClara Engler2026-01-221-15/+10
| | | | | | | | | | | This commit removes FromStr for DocumentId because it was only used in testing anyways. Instead, it replaces it with a simple From<[u8; 32]> only enabled in test builds, which is sufficient for what we are trying to do. An alternative would be to make the inner field pub, but this seems to aggressive for a testing only thing.
* tor-dirserver: Rename `doc_id` to `docid`Clara Engler2026-01-191-41/+41
| | | | | Because we went with `docid` in the database (due to `rowid`), it is only natural to call the code variables `docid` too.
* tor-dirserver: Rename sha256 to docid in schemaClara Engler2026-01-191-4/+4
| | | | | | This commit renames the sha256 column to docid for the reason that we agreed upon making the schema visible to all modules, so if we were to encapsulate docid properly, this change is only natural.
* database: Introduce DocumentIdClara Engler2026-01-191-72/+77
| | | | | | This commit introduces a new type in the database module named `DocumentId` for abstracting the underlying content-addressable hash algorithm we are using.
* tor-dirserver: Move ContentEncoding to databaseClara Engler2026-01-151-19/+1
| | | | | | This commit moves the ContentEncoding enum from the http module to the database module, primarily because the content encoding is more of a matter to the database, as this is where the data actually resides.
* tor-dirserver: Support for inserting into storeClara Engler2026-01-151-2/+3
| | | | | | | | This commit implements support for adding arbitrary documents into the store table. It is non-trivial because the relevant data has to be compressed into various formats, so it can be retrieved without delays.
* Fix name of clippy lint to unchecked_time_subtraction (2)Ian Jackson2025-11-061-1/+1
| | | | Run maint/add_warning
* tor-dirserver: clippy fixesClara Engler2025-11-031-2/+2
|
* tor-dirserver: Apply database changes to httpClara Engler2025-11-031-70/+62
| | | | | | | | | | This commit applies the recent changes to the database module into the http and http::cache module. Notably, this includes the use of the database::sql! macro as well as the use of database::read_tx and database::rw_tx for creation transaction and saving, as well as retrying, although the latter one is subject to SQLite's own busy handler
* tor-dirserver: Make database full syncClara Engler2025-10-301-65/+39
| | | | | | | | | | This commit makes the entire database operations synchronous, thereby replacing deadpool with r2d2. The full motivation is outlined in a rustdoc comment at the top of the `database` module, but it can be summarized to the fact that SQLite is by design inherently synchronous due to directly interfacing with the file system.
* tor-dirserver: Implement read_tx and rw_txClara Engler2025-10-301-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This commit does a large overhaul in the overall way on how we interact with SQLite. Although SQLite is a fairly straightforward tool, it has one large caveat, namely the handling of the infamous `SQLITE_BUSY` error. In WAL mode, the journaling mode we are using, the respective error may occur if there is an existing write transaction while another thread is trying to either upgrade an existing read transaction or create an exclusive transaction at the same time. In this case, SQLite will fail at the statement that either requires the write operation or at the creation of the transaction respectively. In order to tackle this problem, SQLite provides the `busy_timeout` pragma, which allows specifying a timeout in milliseconds during which SQLite will retry to obtain a write transaction or fail immediately. This only works in the latter case, that is, creating a write transaction from the beginning. To solve this issue, we introduce two new functions: 1. `database::read_tx` 2. `database::rw_tx` Both functions accept a database pool alongside a closure accepting a `Transaction` and returning an arbitrary return value. The first function creates a deferred transaction that gets rolled-back in the end, making it suitable for read-only connections. The latter function creates an exclusive transaction that gets committed in the end, making it suitable for read-write connections. This also honors the `busy_timeout`, i.e. the function retries for up to 1s to acquire a write transaction before failing ultimately.
* tor-dirmirror: Introduce the `sql!` macroClara Engler2025-10-301-0/+2
| | | | | | This commit introduces the no-op sql macro used to mark string literals as SQL statements. It is purely semantical and serves the purpose to quickly identify string literals as SQL statements.
* tor-dirserver: Expose Arc of StoreCacheClara Engler2025-10-151-6/+6
|
* tor-dirserver: Some clippy fixesClara Engler2025-10-151-2/+1
|
* tor-dirserver: Remove unsafe unreachableClara Engler2025-10-151-3/+3
|
* tor-dirserver: Improve the error situationClara Engler2025-10-151-43/+35
|
* tor-dirserver: Remove unused importsClara Engler2025-10-151-4/+0
|
* tor-dirserver: Store endpoint paths in `&str`Clara Engler2025-10-151-11/+34
|
* tor-dirserver: Get rid of the poor buildersClara Engler2025-10-151-85/+19
|
* tor-dirserver: Move StoreCache into own moduleClara Engler2025-10-151-151/+18
|
* tor-dirserver: Allow complexity in some fn'sClara Engler2025-09-041-0/+2
| | | | | | | This commit allows `#[allow(clippy::cognitive_complexity)]` in `HttpServer::serve` and `HttpServer::handler_tx`. Allowing this might be controversial but both functions, especially the latter one, are well documented.
* tor-dirserver: Add TODOs for unresolved discussionsClara Engler2025-09-041-0/+5
|
* tor-dirserver: Better wording for "thread poisoned"Clara Engler2025-09-041-2/+2
|
* tor-dirserver: Use `internal!` macro for errorClara Engler2025-09-041-7/+3
|
* tor-dirserver Use `tor_error::Bug`Clara Engler2025-09-041-2/+7
| | | | This commit uses `tor_error::Bug` for indicating thread poisoning.
* tor-dirserver: Use `expect` instead of `unwrap`Clara Engler2025-09-041-11/+6
|
* tor-dirserver: TODO about endpoint error handlingClara Engler2025-09-041-0/+3
|
* tor-dirserver: Rename `cb` to `endpoint_fn`Clara Engler2025-09-041-6/+6
| | | | | This commit renames `cb` to `endpoint_fn` everywhere, including internal implementations.
* tor-dirmirror: Add several "TODO DIRMIRROR" linesClara Engler2025-09-041-0/+13
|
* tor-dirserver: Use strum for `ContentEncoding`Clara Engler2025-09-041-33/+42
|
* tor-dirserver: Fix clippy warnings in testsClara Engler2025-09-041-3/+18
|
* tor-dirserver: Use transactions in endpointsClara Engler2025-09-041-264/+243
| | | | | | | | | | | | | | | | | | This commit refactors a large part of the HTTP module, namely it refactors the `Callback` type to a new type called `EndpointFn` which now works in a transaction based approach and no longer gives access to the `StoreCache`. The type itself is also no longer a trait but a concrete type using `fn`. Another very notable change that became necessary during this commit was to make large parts of the codebase synchronous instead of async, namely because it is non-trivial to `Send` a `Transaction` created inside an async context to a synchronous function. Besides, this change has been deemed necessary for other reasons to. The refactoring to more synchronous code has lead to some interesting changes in `StoreCache` too, namely that in no longer uses async mutex, but a synchronous mutex instead.
* tor-dirserver: Add clippy checks and fix themClara Engler2025-09-041-15/+24
|
* tor-dirserver: Add http moduleClara Engler2025-09-041-0/+1145
This commit implements the initial draft for the HTTP module. It is fairly complicated but well documented within the source code, please refer to that instead.