aboutsummaryrefslogtreecommitdiff
path: root/crates/tor-dirserver
Commit message (Collapse)AuthorAgeFilesLines
...
* tor-dirserver: Remove serve functionClara Engler2026-03-092-129/+2
| | | | | This commit removes the operation serve function because it no longer fits into the new model of operation using a FSM.
* tor-dirserver: Refactor consensus retrieval logicClara Engler2026-03-092-260/+324
| | | | | | | | This commit moves the get_recent_consensus logic to the database module, which also introduces a struct querying all fields in it. This not only simplifies the return type but also makes working with this type more comfortable to work with.
* tor-dirserver: docid as consistent foreign keyClara Engler2026-03-091-10/+10
| | | | | | This commit replaces occurrences of rowid with docid, particularly in tables for N:M cardinalities. Purpose of this is, to achieve a greater consistency with the overall database schema.
* tor-dirserver: Return Timestamp in consensus queryingClara Engler2026-03-091-17/+10
| | | | | This is more useful and less boilerplate, removing a parameter for a conversion we can do ourselves if required.
* tor-dirserver: Scratch out the FSMClara Engler2026-03-092-5/+493
| | | | | | | This commit scratches out the FSM for the dirmirror operation. Right now, there are still lots of TODO, lots of code warnigns, and such. It should model the rough concept.
* Merge branch 'signature-rework-rename-signed' into 'main'Clara Engler2026-03-051-9/+9
|\ | | | | | | | | tor-netdoc parse2: Rename *Signed to *Unverified See merge request tpo/core/arti!3742
| * tor-netdoc: Rename *Signed to *UnverifiedIan Jackson2026-03-031-9/+9
| | | | | | | | | | | | | | | | | | | | This was a weird name, and while working in this area it all seemed to make the docs strange. Rename it. This is quite invasive! In theory we could have the macros generate compatibility aliases, but that seems quite complex.
* | deps: relax `libsqlite3-sys` version requirementHydroxideUnlaced2026-03-041-2/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The issue concerns `libsqlite3-sys` linking to a native library. Cargo cannot handle multiple versions/crates linking to the same native library. This affects both the `tor-dirmgr` and `tor-dirserver` crates, which depend on `rusqlite`. Relaxing the version requirement gives downstream projects flexibility so cargo can select an appropriate `libsqlite3-sys` version without a high chance of conflicts caused by pinning a specific version. The proposed supported version range was determined by testing until encountering a version lacking a feature currently in use (breaking unchange?). Regarding testing, the current CI with minimum-version test only validates the maximum and minimum versions, so breaking changes introduced between them can pass unnoticed. Tools like [Cargo-Bounds](https://github.com/vivax3794/cargo_bounds) can help, but this is out of scope for this MR. Also, supported versions of `rusqlite` for `tor-dirmgr` and `tor-dirserver` differ, so running tests for the whole project (same workspace) causes cargo to pick only overlapping versions, which hides parts of each crate’s supported range. Referencing #754, after this MR, increasing the maximum version or decreasing the minimum version of `rusqlite` shouldn't be a breaking change, but increasing the minimum version could be. Resolves: #1740
* | Bump strum to 0.28Gabriela Moldovan2026-03-041-1/+1
|/
* Bump all the unstable tor- and arti- crates to 0.40.0.Gabriela Moldovan2026-03-021-8/+8
| | | | | | | | | Done using: ``` for crate in $(./maint/list_crates | rg '^(tor|arti-)'); do cargo set-version -p $crate 0.40.0 done
* Bump the versions of the non-{arti-,tor-} cratesGabriela Moldovan2026-03-021-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The non-{arti-,tor-} crates are: ``` ./maint/list-crates | rg -v '^(tor|arti)' oneshot-fused-workaround slotmap-careful test-temp-dir fslock-guard hashx equix caret fs-mistrust safelog retry-error futures-copy ``` Because this release bumps the MSRV, I am bumping the minor version of all of them. MINOR=" oneshot-fused-workaround slotmap-careful test-temp-dir fslock-guard hashx equix caret fs-mistrust safelog retry-error futures-copy " for crate in $MINOR; do cargo set-version --bump minor -p $crate; done ```
* Allow clippy::collapsible_if to triggerGabriela Moldovan2026-02-161-0/+1
| | | | | | | | | `clippy::collapsible_if` started triggering after bumping the MSRV to 1.88. Since this triggers from a lot of places, and since there even are a couple of instances where we explicitly allow `clippy::collapsible_ifs`, I've opened #2342 for deciding what to do about it.
* Bump MSRV from 1.86 to 1.89Gabriela Moldovan2026-02-161-1/+1
| | | | | | | As agreed at our last team meeting. See https://gitlab.torproject.org/tpo/core/arti/#minimum-supported-rust-version
* Set package.metadata.docs.rs.all-features to true for all cratesNiel Duysters2026-02-091-0/+3
| | | | Makes docs.rs also document types behind optional feature flags.
* release: Bump `arti-*` and `tor-*` crates to 0.39.0Wesley Aptekar-Cassels2026-02-021-8/+8
| | | | | | | | | | Done via: ``` for crate in $(./maint/list-crates | rg '^(tor|arti-)'); do cargo set-version -p $crate 0.39.0 done ```
* release: run fixup-features.Wesley Aptekar-Cassels2026-01-291-0/+1
|
* dirserver: Allow clippy::unused_asyncGabriela Moldovan2026-01-272-0/+2
| | | | This code is still WIP, no need to address the lint yet.
* maint/add_warning: Run script to add new warningGabriela Moldovan2026-01-271-0/+1
| | | | This adds the lint to all our crates.
* tor-dirserver: Add comment on compression bugClara Engler2026-01-221-0/+4
| | | | | This commit adds a comment explaining why we treat compression errors as a bug.
* tor-dirserver: Make compression failures a bugClara Engler2026-01-222-5/+2
| | | | | | | | | | | | | | This commit removes `DatabaseError::Compression` because it does not fit in. Right now, this single variant makes the error to be call-site oriented which is not nice for error handling. Instead, this error should indicate that something was truly wrong with the database in itself, such as an invalid schema, a low-level SQLite bug, etc. Instead, we now map a compression error to `DatabaseError::Bug` because there is no good reason on why it should fail, given that we compress memory data to memory data. Probably because it uses the `std::io::Writer` interface which itself demands use of `std::io::Result`.
* Merge branch 'database-refactoring' into 'main'Clara Engler2026-01-224-197/+245
|\ | | | | | | | | tor-dirserver: Refactorings in the database.rs module See merge request tpo/core/arti!3599
| * tor-dirserver: Remove FromStr for DocumentIdClara Engler2026-01-223-39/+15
| | | | | | | | | | | | | | | | | | | | | | 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: Add `sha2` to `router_descriptor`Clara Engler2026-01-191-0/+2
| | | | | | | | | | | | | | | | | | | | This comit adds a `sha2` column to `router_descriptor` alongside a `CHECK` to see whether it equals `docid`. The reason for this is simple: Microdescriptors are the only kind of documents that are queriable with a SHA2 hash. Previously, we would have simply used the `docid` column for this, but in order to abstract it better, a distinct column with this hash is better.
| * tor-dirserver: Rename `doc_id` to `docid`Clara Engler2026-01-194-76/+75
| | | | | | | | | | 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-194-51/+51
| | | | | | | | | | | | 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.
| * tor-dirserver: Rename database meta tableClara Engler2026-01-191-16/+13
| | | | | | | | | | This commit renames arti_dirmirror_schema_version to arti_dirserver_schema_version.
| * database: Introduce DocumentIdClara Engler2026-01-195-136/+210
| | | | | | | | | | | | 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: Make downloader statelessClara Engler2026-01-202-53/+55
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This commit makes the downloader found in `mirror::operation::download` stateless by removing the `preferred_authority` field and changing all methods from `&mut self` to `&self`. The preferred authority is now accepted as a parameter to `DownloadManager::download` which also returns a tuple now with the actually used authority alongside the response, putting the management of this to the responsibility of the caller. Meanwhile, it also renames the structure from `ConsensusBoundDownloader` to `DownloadManager` because it no longer keeps a state that invalidates after a consensus "ends". The purpose of this is to simplify overall state in order to make the implementation of a finite-state-machine for the dirmirror operation more easy (and deterministic).
* | Fix flaky `request_fail_ultimately` testClara Engler2026-01-191-1/+10
|/ | | | | | | | | | | | | This commit fixes the flaky `request_fail_ultimately` in tor-dirserver, which is flaky due to the operating system's handling of TCP RSTs, which are generally detected stochastically and sometimes are not received even after the entire response has been parsed. This leads to tor-dirclient either returning a connection reset or a truncated header error, depending on whether it successfully or unsuccessfully reads zero bytes from the server. Fixes #2318
* tor-dirserver: Small pre-merge fixesClara Engler2026-01-152-3/+2
|
* tor-dirserver: Add TODO wrt hex::encode_upperClara Engler2026-01-151-0/+2
| | | | | Adding a comment suggesting to implement this as part of abstracting `Sha256` behind a more generic identifier.
* tor-dirserver: Fix clippy warningClara Engler2026-01-151-1/+1
|
* tor-dirserver: Use `INSERT OR REPLACE`Clara Engler2026-01-151-2/+43
| | | | | | | | | | | This commit rpelaces the use of `INSERT` with `INSERT OR REPLACE` for handling insertion conflicts in `store_insert`. Because everything is content-addressed anyways, it does not matter to do this, because if we get a conflict on a SHA256, it means the data is equal.[1] [1]: Excluding SHA-2 collisions which are impractical as of 2026.
* tor-dirserver: Change store_insert logicClara Engler2026-01-152-49/+53
| | | | | | This commit modifies the database::store_insert logic to accept an iterator of the encodings to store the document in, instead of encoding it with all encodings we support.
* tor-dirserver: Remove algorithm CHECK constraintClara Engler2026-01-151-2/+1
|
* tor-dirserver: Add TODO for hash agnostic type alias nameClara Engler2026-01-151-0/+1
|
* tor-dirmirror: Handle unparsable certificatesClara Engler2026-01-151-8/+69
| | | | Instead of failing, add them to missing and query them again.
* tor-dirserver: Improve note on query performanceClara Engler2026-01-151-6/+8
|
* tor-dirserver: Fix formulationClara Engler2026-01-151-1/+1
|
* tor-dirserver: Implement authcert retrieval logicClara Engler2026-01-153-4/+280
| | | | | | | | | | | This commit implements the logic necessary to retrieve the (missing) directory authority certificates from an upstream directory authority. In order to do so, this commit implements three new functions: 1. `download_authority_certificates()` 2. `parse_authority_certificates()` 3. `verify_authority_certificates()` 4. `insert_authority_certificates()`
* tor-dirserver: Ensure algorithm with CHECKClara Engler2026-01-151-2/+3
| | | | | | This commit adds a CHECK constraint to the compressed_document table in order to ensure that `algorithm` may only take up a limited set of values.
* tor-dirserver: Move ContentEncoding to databaseClara Engler2026-01-152-20/+18
| | | | | | 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-154-10/+227
| | | | | | | | 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.
* tor-dirserver: Test authcert queryingClara Engler2026-01-153-0/+138
|
* tor-dirserver: Operation test refactoringClara Engler2026-01-151-9/+7
|
* tor-dirserver: Add get_recent_authority_certificatesClara Engler2026-01-152-3/+111
| | | | | | | This commit adds the `get_recent_authority_certificates()` function to the operation of a directory mirror, which is responsible for looking up the certificates in the database, returning the parsed found ones as well as the missing ones.
* tor-dirserver: `From<Timestamp> for SystemTime`Clara Engler2026-01-151-0/+6
| | | | | | The reverse direction already exists and it will be required when we act with functions outside the crate that only accept a `SystemTime` in situations where we just have a `Timestamp`.
* tor-dirserver: Add `dir_key_published` to schemaClara Engler2026-01-151-1/+4
|
* tor-dirserver: Speedup tests using tokio's test-utilClara Engler2026-01-142-9/+7
| | | | | | | | | | | | | | | | | | | | | This commit speeds up the tests in `tor-dirserver` by using functionality from Tokio's `test-util`. Most notably, it runs the time intensive test in paused mode, which means that the clock gets advanced either explicitly or implicitly using auto-advance in case the runtime has nothing to do. In our case, the last one, auto-advancing, is used, leading to our sleep calls returning immediately. This is good enough for testing in this module. It is not the responsibility of tor-dirserver to ensure whether `RetryDelay` returns proper values, as this is the responsibility of `tor-basic-utils`. Still, it is a bit unfortunate that Tokio offers no way to manually disbale the auto-advancing. In the future, it might be useful to migrate more parts of this to crate to `tor-rtcompat`, but for now, this change is a good enough performance fix.
* tor-dirserver: Remove slow ineffective testClara Engler2026-01-141-27/+0
| | | | | | | | | | This commit removes `mirror::download::test::request_fail_timeout` which takes more than five seconds (due to a timeout) and is generally ineffective in what it does, because testing whether a task is still sleeping after a certain time is not super trivial with the tools Tokio offers. All this test offers is testing that we enter a timeout at all.