mirror of
https://forgejo.ellis.link/continuwuation/continuwuity.git
synced 2026-11-30 04:17:32 +00:00
Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ac7f8f6b9f |
No files matched your search
@@ -71,7 +71,7 @@ runs:
|
|||||||
|
|
||||||
- name: Install timelord-cli and git-warp-time
|
- name: Install timelord-cli and git-warp-time
|
||||||
if: steps.check-binaries.outputs.need-install == 'true'
|
if: steps.check-binaries.outputs.need-install == 'true'
|
||||||
uses: https://github.com/taiki-e/install-action@fe3acb53a98b62c772db35de75ce0e4595e7ca8c # v2
|
uses: https://github.com/taiki-e/install-action@ab49d3c64680143e184118bed66a46419fc15519 # v2
|
||||||
with:
|
with:
|
||||||
tool: git-warp-time,timelord-cli@3.0.1
|
tool: git-warp-time,timelord-cli@3.0.1
|
||||||
|
|
||||||
|
|||||||
@@ -17,6 +17,8 @@ jobs:
|
|||||||
docs:
|
docs:
|
||||||
name: Build and Deploy Documentation
|
name: Build and Deploy Documentation
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
if: secrets.CLOUDFLARE_API_TOKEN != ''
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Sync repository
|
- name: Sync repository
|
||||||
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
|
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
|
||||||
@@ -28,14 +30,6 @@ jobs:
|
|||||||
id: runner-env
|
id: runner-env
|
||||||
uses: https://forgejo.ellis.link/continuwuation/detect-versions@d39555789fed25b8eb8e086d9f199c514dfa311e # v1
|
uses: https://forgejo.ellis.link/continuwuation/detect-versions@d39555789fed25b8eb8e086d9f199c514dfa311e # v1
|
||||||
|
|
||||||
- name: Setup Go
|
|
||||||
if: steps.runner-env.outputs.go_minor == '' || steps.runner-env.outputs.go_minor < '27'
|
|
||||||
uses: actions/setup-go@d8cbb8045d7f43706b9177cceb36c1f91a6644d5 # v7
|
|
||||||
with:
|
|
||||||
go-version: '1.27'
|
|
||||||
go-version-file: 'go.mod'
|
|
||||||
cache-dependency-path: 'go.sum'
|
|
||||||
|
|
||||||
- name: Setup Node.js
|
- name: Setup Node.js
|
||||||
if: steps.runner-env.outputs.node_major == '' || steps.runner-env.outputs.node_major < '20'
|
if: steps.runner-env.outputs.node_major == '' || steps.runner-env.outputs.node_major < '20'
|
||||||
uses: https://github.com/actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7
|
uses: https://github.com/actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7
|
||||||
@@ -51,43 +45,35 @@ jobs:
|
|||||||
continuwuity-rspress-${{ steps.runner-env.outputs.slug }}-${{ steps.runner-env.outputs.arch }}-node-${{ steps.runner-env.outputs.node_version }}-
|
continuwuity-rspress-${{ steps.runner-env.outputs.slug }}-${{ steps.runner-env.outputs.arch }}-node-${{ steps.runner-env.outputs.node_version }}-
|
||||||
continuwuity-rspress-${{ steps.runner-env.outputs.slug }}-${{ steps.runner-env.outputs.arch }}-node-
|
continuwuity-rspress-${{ steps.runner-env.outputs.slug }}-${{ steps.runner-env.outputs.arch }}-node-
|
||||||
|
|
||||||
- name: Install Rspress and dependencies
|
- name: Install dependencies
|
||||||
run: npm ci
|
run: npm ci
|
||||||
|
|
||||||
- name: Build documentation with Rspress
|
- name: Build Rspress documentation
|
||||||
env:
|
env:
|
||||||
SITE_PATH: ${{ github.ref != 'refs/heads/main' && format('/@{0}/', forgejo.event.number) || '/' }}
|
SITE_PATH: ${{ github.ref != 'refs/heads/main' && format('/pr/{0}/', '${{ forgejo.event.number }}') || '/' }}
|
||||||
run: npm run docs:build
|
run: npm run docs:build
|
||||||
|
|
||||||
- name: Deploy to Grebedoc (Production)
|
- name: Install Wrangler
|
||||||
if: github.ref == 'refs/heads/main'
|
run: npm install --save-dev wrangler@latest
|
||||||
run: |
|
|
||||||
go tool git-pages-cli https://continuwuity.org \
|
- name: Deploy to Cloudflare Pages (Production)
|
||||||
--server grebedoc.dev \
|
if: github.ref == 'refs/heads/main' && vars.CLOUDFLARE_PROJECT_NAME != ''
|
||||||
--token "${{ forgejo.token }}" \
|
uses: https://github.com/cloudflare/wrangler-action@953926a2e2182532811c01a25e53647d93bf07c0 # v4
|
||||||
--upload-dir doc_build \
|
with:
|
||||||
--pretty-urls \
|
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
|
||||||
--comment "${{ forgejo.sha }}" \
|
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
|
||||||
--verbose
|
command: pages deploy ./doc_build --branch="main" --commit-dirty=true --project-name="${{ vars.CLOUDFLARE_PROJECT_NAME }}"
|
||||||
|
|
||||||
- name: Deploy to Grebedoc (Preview)
|
- name: Deploy to Grebedoc (Preview)
|
||||||
if: github.ref != 'refs/heads/main'
|
if: github.ref != 'refs/heads/main'
|
||||||
run: |
|
uses: actions/git-pages@v2
|
||||||
go tool git-pages-cli https://preview.continuwuity.org/@${{ forgejo.event.number }} \
|
with:
|
||||||
--server grebedoc.dev \
|
site: https://preview.continuwuity.org
|
||||||
--token "${{ forgejo.token }}" \
|
path: "pr/${{ forgejo.event.number }}"
|
||||||
--upload-dir doc_build \
|
server: grebedoc.dev
|
||||||
--pretty-urls \
|
token: ${{ forgejo.token }}
|
||||||
--expires 14 \
|
source: doc_build/
|
||||||
--comment "${{ forgejo.sha }}" \
|
strict: true
|
||||||
--verbose
|
pretty-urls: true
|
||||||
|
expires: 14
|
||||||
- name: Post comment to PR
|
comment: ${{ forgejo.sha }}
|
||||||
if: github.ref != 'refs/heads/main' && forgejo.event.name == 'pull_request'
|
|
||||||
run: |
|
|
||||||
if curl -s ${{ forgejo.api_url }}/repos/${{ forgejo.repository }}/issues/${{ forgejo.event.number }}/comments | grep -qv 'PR-PREVIEW-MARKER'; then
|
|
||||||
echo -n 'Posting comment: '
|
|
||||||
curl -s -X POST ${{ forgejo.api_url }}/repos/${{ forgejo.repository }}/issues/${{ forgejo.event.number }}/comments \
|
|
||||||
-H 'Authorization: token ${{ forgejo.token }}' \
|
|
||||||
--json '{"body":"<!--PR-PREVIEW-MARKER-->Preview ready: https://preview.continuwuity.org/@${{ forgejo.event.number }}/"}'
|
|
||||||
fi
|
|
||||||
@@ -43,7 +43,7 @@ jobs:
|
|||||||
name: Renovate
|
name: Renovate
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
container:
|
container:
|
||||||
image: ghcr.io/renovatebot/renovate:44.257.9@sha256:578179439fceea89646662dd583b27efdad8d1429e0cbd90681c40dde068589e
|
image: ghcr.io/renovatebot/renovate:44.241.0@sha256:22d22b4ca7d768b5b469309d34379783bf91cd94a58faecf1cd0f4528a65d21c
|
||||||
options: --tmpfs /tmp:exec
|
options: --tmpfs /tmp:exec
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
|
|||||||
@@ -36,11 +36,6 @@ repos:
|
|||||||
hooks:
|
hooks:
|
||||||
- id: committed
|
- id: committed
|
||||||
|
|
||||||
- repo: https://github.com/twisted/towncrier
|
|
||||||
rev: 26.9.0
|
|
||||||
hooks:
|
|
||||||
- id: towncrier-check
|
|
||||||
|
|
||||||
- repo: local
|
- repo: local
|
||||||
hooks:
|
hooks:
|
||||||
- id: cargo-fmt
|
- id: cargo-fmt
|
||||||
|
|||||||
-101
@@ -1,104 +1,3 @@
|
|||||||
# Continuwuity v26.11.0-rc.1 (2026-11-27)
|
|
||||||
|
|
||||||
## Features
|
|
||||||
|
|
||||||
- Added opt-in OpenTelemetry metrics, exported over OTLP or scraped by Prometheus from `/_continuwuity/metrics`, and a Grafana dashboard. Contributed by @eleboucher. (prometheus-metrics)
|
|
||||||
- Add support for using custom DNS servers instead of using /etc/resolv.conf. Contributed by @s1lv3r. ([#2056](https://forgejo.ellis.link/continuwuation/continuwuity/pulls/2056))
|
|
||||||
- Continuwuity now supports configuring additional trusted audience values for deployments using OIDC with an IDP that sends them. Contributed by @ginger ([#2226](https://forgejo.ellis.link/continuwuation/continuwuity/pulls/2226))
|
|
||||||
- "!admin users list" now hides deactivated users by default, but can display them with the optional "--show-deactivated" flag. "--hide-suspended" and "--hide-locked" have been added as well, which stop suspended and locked users from being displayed respectively. Contributed by @Clubs. ([#2292](https://forgejo.ellis.link/continuwuation/continuwuity/pulls/2292))
|
|
||||||
- Added support for [MSC4494: Membership-based invite blocking](https://github.com/matrix-org/matrix-spec-proposals/pull/4494) ([#2297](https://forgejo.ellis.link/continuwuation/continuwuity/pulls/2297))
|
|
||||||
- Added support for acting as a trusted server, meaning the `trusted_servers` list can consist of servers that are either Synapse OR continuwuity. ([#2314](https://forgejo.ellis.link/continuwuation/continuwuity/pulls/2314))
|
|
||||||
- Appservices now receive typing indicators and read receipts. Contributed by @Jade ([#2327](https://forgejo.ellis.link/continuwuation/continuwuity/pulls/2327))
|
|
||||||
- Added support for servers returning 410 gone to indicate they are no longer serving a Matrix server ([MSC4188](https://github.com/matrix-org/matrix-spec-proposals/pull/4188)). Contributed by @nex and @silversys ([#2355](https://forgejo.ellis.link/continuwuation/continuwuity/pulls/2355))
|
|
||||||
- Added support for [MSC4388](https://github.com/matrix-org/matrix-spec-proposals/pull/4388), allowing compatible Matrix clients to log in to Continuwuity by scanning a QR code on an already logged-in client. Contributed by @ginger. ([#2429](https://forgejo.ellis.link/continuwuation/continuwuity/pulls/2429))
|
|
||||||
- Changed the policy on unstable features, disabling most by default and making them configurable in a tidy little `experiments` configuration. See also: #1884. ([#2517](https://forgejo.ellis.link/continuwuation/continuwuity/pulls/2517))
|
|
||||||
- Dropped support for `hardened_malloc` and add support for `mimalloc` instead. Contributed by @nex and @jade. ([#2564](https://forgejo.ellis.link/continuwuation/continuwuity/pulls/2564))
|
|
||||||
- Continuwuity will now request the `profile` OIDC scope from identity providers by default to improve compatibility with identity providers that require it to access users' profile claims, as recommended by the OIDC specification. Contributed by @ginger. ([#2588](https://forgejo.ellis.link/continuwuation/continuwuity/pulls/2588))
|
|
||||||
- Advertise support for Matrix v1.6. Contributed by @jade ([#2593](https://forgejo.ellis.link/continuwuation/continuwuity/pulls/2593))
|
|
||||||
- Added support for [MSC4363](https://github.com/matrix-org/matrix-spec-proposals/pull/4363) (OAuth step-up authentication). Contributed by @ginger.
|
|
||||||
- Added support for [MSC2815](https://github.com/matrix-org/matrix-spec-proposals/pull/2815), allowing room moderators to fetch the original content of redacted events, behind the `allow_moderators_to_view_redacted_content` config option. Contributed by @eleboucher.
|
|
||||||
- Added support for [MSC4484](https://github.com/matrix-org/matrix-spec-proposals/pull/4484). Clients which use the built-in Matrix server administration APIs will need to ask for the appropriate scope when signing in with OAuth. Contributed by @ginger.
|
|
||||||
- Added support for the stable MatrixRTC transports discovery endpoint (`GET /_matrix/client/v1/rtc/transports`) from the accepted [MSC4143](https://github.com/matrix-org/matrix-spec-proposals/pull/4143), advertised via the `org.matrix.msc4143.stable` unstable feature. The unstable endpoint remains available. Contributed by @Henry-Hiles (QuadRadical).
|
|
||||||
- Added the `GET /_matrix/client/v1/rooms/{roomId}/timestamp_to_event` endpoint as per [MSC3030](https://github.com/matrix-org/matrix-spec-proposals/pull/3030), letting clients find the event closest to a given timestamp. Contributed by @eleboucher.
|
|
||||||
- Check content-type header on federation responses, ignoring any that don't match (spec compliance)
|
|
||||||
- Implemented unstable support for [MSC4560] (Stripped state requests over federation). Contributed by @ginger.
|
|
||||||
|
|
||||||
[MSC4560]: https://github.com/matrix-org/matrix-spec-proposals/pull/4560
|
|
||||||
- Profile banners are now treated as images when imported from OIDC claims, like avatars already were.
|
|
||||||
- Remove support for legacy, unauthenticated media, including the `allow_legacy_media` and `freeze_legacy_media` options.
|
|
||||||
- The first-run version of the web UI now includes a link to the registration page. Contributed by @ginger
|
|
||||||
|
|
||||||
## Bugfixes
|
|
||||||
|
|
||||||
- Fixed `/get_missing_events` rejecting requests with more `earliest_events` than the `limit`. Contributed by @eleboucher. (get-missing-events-earliest-limit)
|
|
||||||
- Fix outgoing federation stalling after a sender worker panics. Contributed by @eleboucher. (sender-supervision)
|
|
||||||
- Invitees are now added as room creators when creating a v12+ trusted private chat. Contributed by @ginger. ([#2162](https://forgejo.ellis.link/continuwuation/continuwuity/pulls/2162))
|
|
||||||
- Fixed push gateway URLs containing the configured notification path outside of their suffix. Contributed by @eleboucher. ([#2261](https://forgejo.ellis.link/continuwuation/continuwuity/pulls/2261))
|
|
||||||
- "!admin users change-email" now verifies a user exists before attempting to change their email. Contributed by @Clubs. ([#2298](https://forgejo.ellis.link/continuwuation/continuwuity/pulls/2298))
|
|
||||||
- Fixed URL preview image MIME types and rejected failed downloads. Contributed by @eleboucher. ([#2308](https://forgejo.ellis.link/continuwuation/continuwuity/pulls/2308))
|
|
||||||
- Correctly set RocksDB column options, including enabling block caches. Contributed by @Jade ([#2345](https://forgejo.ellis.link/continuwuation/continuwuity/pulls/2345))
|
|
||||||
- Fix some possible deadlocks/freezes and reduce lock contention (improving performance). Contributed by @Jade ([#2351](https://forgejo.ellis.link/continuwuation/continuwuity/pulls/2351))
|
|
||||||
- Fixed Prometheus accounting for in-flight requests, federation PDU lag, latency buckets, and thumbnail sizes. Contributed by @eleboucher. ([#2354](https://forgejo.ellis.link/continuwuation/continuwuity/pulls/2354))
|
|
||||||
- Once again fixed how room extremities are handled, fixing a problem that made continuwuity gradually make rooms needlessly complex, which also caused more frequent state resets. ([#2356](https://forgejo.ellis.link/continuwuation/continuwuity/pulls/2356))
|
|
||||||
- Requests waiting on `/_matrix/client/v3/sync` can now be interrupted by the server shutdown, unblocking the 30-second shutdown delay imposed on a quiet server. ([#2361](https://forgejo.ellis.link/continuwuation/continuwuity/pulls/2361))
|
|
||||||
- The OAuth identity reset page is no longer linked from the account management UI to reduce confusion. Contributed by @ginger. ([#2383](https://forgejo.ellis.link/continuwuation/continuwuity/pulls/2383))
|
|
||||||
- Fixed a worker panic when knocking on a room over federation. Contributed by @eleboucher. ([#2387](https://forgejo.ellis.link/continuwuation/continuwuity/pulls/2387))
|
|
||||||
- Perform more validation on events received during atomic gapfill from remote servers, fixing a panic if bad data was persisted by another server and later lazily fetched by us. ([#2400](https://forgejo.ellis.link/continuwuation/continuwuity/pulls/2400))
|
|
||||||
- Fix remote server key signature verification when extra fields exist. Contributed by @hexchen ([#2415](https://forgejo.ellis.link/continuwuation/continuwuity/pulls/2415))
|
|
||||||
- Redirect URIs in OAuth clients' metadata are now properly validated to be on a subdomain of the OAuth issuer URL domain. Contributed by @ginger. ([#2421](https://forgejo.ellis.link/continuwuation/continuwuity/pulls/2421))
|
|
||||||
- Fix v12 rooms created by the same user in the same millisecond ending up as the same room. Contributed by @eleboucher. ([#2424](https://forgejo.ellis.link/continuwuation/continuwuity/pulls/2424))
|
|
||||||
- Client-server API endpoints are now properly ratelimited for unauthenticated requests. Contributed by @ginger. ([#2444](https://forgejo.ellis.link/continuwuation/continuwuity/pulls/2444))
|
|
||||||
- URL previews no longer completely fail if downloading auxiliary content (images/videos/audio) fails. Contributed by @nex. ([#2448](https://forgejo.ellis.link/continuwuation/continuwuity/pulls/2448))
|
|
||||||
- Setting a profile key longer than 255 bytes now returns 400 `M_KEY_TOO_LARGE` as required by the spec, instead of 413 `M_TOO_LARGE`. ([#2451](https://forgejo.ellis.link/continuwuation/continuwuity/pulls/2451))
|
|
||||||
- Setting profile data that would make the profile exceed 64 KiB now returns 400 `M_PROFILE_TOO_LARGE` as required by the spec, instead of a 500 error. ([#2451](https://forgejo.ellis.link/continuwuation/continuwuity/pulls/2451))
|
|
||||||
- Appservices masquerading as a device that does not exist now receive 400 `M_UNKNOWN_DEVICE` as required by the spec, instead of 403 `M_FORBIDDEN`. ([#2451](https://forgejo.ellis.link/continuwuation/continuwuity/pulls/2451))
|
|
||||||
- Setting `m.fully_read` via the account data endpoints now returns 405 `M_BAD_JSON` as required by the spec, instead of 400. ([#2451](https://forgejo.ellis.link/continuwuation/continuwuity/pulls/2451))
|
|
||||||
- The `m.forget_forced_upon_leave` capability now reflects the `forget_forced_upon_leave` config option instead of always being advertised as enabled. ([#2452](https://forgejo.ellis.link/continuwuation/continuwuity/pulls/2452))
|
|
||||||
- Fixed push notifications for membership events setting `user_is_target` based on the sender rather than the user being notified. ([#2454](https://forgejo.ellis.link/continuwuation/continuwuity/pulls/2454))
|
|
||||||
- Ensure HTTP clients actually follow the `dns_servers` config option. Contributed by @silversys ([#2460](https://forgejo.ellis.link/continuwuation/continuwuity/pulls/2460))
|
|
||||||
- `/_matrix/client/v3/sync` no longer waits 30 seconds if the `timeout` parameter is omitted or set to zero, correctly reflecting the specification's rule that such requests should return immediately, even if they are empty. ([#2462](https://forgejo.ellis.link/continuwuation/continuwuity/pulls/2462))
|
|
||||||
- Reworked event relations to follow the spec more closely. Pagination of `/relations` now returns the correct pages and `next_batch` tokens, recursive relations are returned in the right order without duplicates, and bundled `m.reference` aggregations now include every reference. Contributed by @Henry-Hiles (QuadRadical). ([#2465](https://forgejo.ellis.link/continuwuation/continuwuity/pulls/2465))
|
|
||||||
- Read receipts are now more spec compliant, will work better in threads and are less likely to end up causing loops with other software. Contributed by @Jade ([#2481](https://forgejo.ellis.link/continuwuation/continuwuity/pulls/2481))
|
|
||||||
- Fix the DNS resolver failing to start without `/etc/resolv.conf` when `dns_servers` is configured. Contributed by @eleboucher. ([#2495](https://forgejo.ellis.link/continuwuation/continuwuity/pulls/2495))
|
|
||||||
- Fixed OIDC logins failing after the identity provider rotates its signing keys. Contributed by @eleboucher. ([#2497](https://forgejo.ellis.link/continuwuation/continuwuity/pulls/2497))
|
|
||||||
- Fixed the experiments implementation in #2517 not properly disabling some functionality when associated experiments weren't enabled. ([#2533](https://forgejo.ellis.link/continuwuation/continuwuity/pulls/2533))
|
|
||||||
- The sticky events feature flag is correctly advertised in `/_matrix/client/versions` again after it was accidentally removed in #2517. ([#2542](https://forgejo.ellis.link/continuwuation/continuwuity/pulls/2542))
|
|
||||||
- A message is now sent to the admin room when a user logs in for the first time through an OIDC provider, if admin room notices are enabled. Contributed by @ginger. ([#2561](https://forgejo.ellis.link/continuwuation/continuwuity/pulls/2561))
|
|
||||||
- Fix soundness and correctness issues in the jemalloc interface, improving performance. Contributed by @Jade ([#2565](https://forgejo.ellis.link/continuwuation/continuwuity/pulls/2565))
|
|
||||||
- Modernised the room knocking helper functions to make them match the behaviour of our room join helpers, which are safer and more efficient. This also fixes a bug that caused an error when knocking on rooms not local to the server. Contributed by @nex. ([#2572](https://forgejo.ellis.link/continuwuation/continuwuity/pulls/2572))
|
|
||||||
- Network issues while refreshing an access token will no longer cause OAuth-compatible clients to be forcibly logged out. Contributed by @ginger. ([#2587](https://forgejo.ellis.link/continuwuation/continuwuity/pulls/2587))
|
|
||||||
- Attempting to start a UIAA session on a homeserver with UIAA disabled will now return `403 M_UNAUTHORIZED` instead of `404 M_UNSUPPORTED`. Contributed by @ginger. ([#2589](https://forgejo.ellis.link/continuwuation/continuwuity/pulls/2589))
|
|
||||||
- Creating a room with valid but non-canonical JSON now returns `400 M_BAD_JSON` instead of panicking the worker and returning `500 M_UNKNOWN`.
|
|
||||||
- Fix account data updates sent at the same time leaving old copies behind, which every initial sync then returned. Existing copies are removed on startup. Contributed by @eleboucher.
|
|
||||||
- Fix gap filling skipping outlier events that are missing their previous events. Contributed by @eleboucher.
|
|
||||||
- Fix incoming federation events losing state changes when predecessors share the same state-before snapshot. Contributed by @eleboucher.
|
|
||||||
- Fix new devices sometimes never reaching other users' device lists. Contributed by @eleboucher.
|
|
||||||
- Fix state resolution applying events out of order, which could undo room joins. Contributed by @eleboucher.
|
|
||||||
- Fix to-device messages, including room keys, sometimes being lost before delivery. Contributed by @eleboucher.
|
|
||||||
- For deployments using OIDC with `profile_key_import_mode` set to `on_login`, users' avatars will no longer be clobbered if they didn't change their avatar since their last login.
|
|
||||||
- Joining a local room the user is not allowed to join now returns `403 M_FORBIDDEN` instead of `500 M_UNKNOWN` when there are no other servers to try.
|
|
||||||
- Legacy `/sync` now honours the `room.rooms`, `room.not_rooms`, `account_data.types` and `account_data.not_types` filter fields instead of returning every room and all account data. Contributed by @eleboucher.
|
|
||||||
- Room summary visibility checks are no longer incorrectly applied for remote rooms. Contributed by @ginger.
|
|
||||||
- The userinfo endpoint is now accessible even if federation is disabled, allowing LiveKit to be used on servers with federation disabled without using the server name whitelist.
|
|
||||||
|
|
||||||
## Improved Documentation
|
|
||||||
|
|
||||||
- Add the Authentication section to document available auth methods for Continuwuity. The "delegated authentication" guide has also been migrated to here. Contributed by @stratself. ([#2234](https://forgejo.ellis.link/continuwuation/continuwuity/pulls/2234))
|
|
||||||
- Add a guide for push notifications, detailing how it works, push gateway specifics, troubleshooting common issues, and pointing to external guides for UnifiedPush backends. Contributed by @stratself ([#2244](https://forgejo.ellis.link/continuwuation/continuwuity/pulls/2244))
|
|
||||||
- The deploying page now includes vital general information about installing Continuwuity: release tracks, update steps, and post-installation recommendations. Contributed by @stratself ([#2252](https://forgejo.ellis.link/continuwuation/continuwuity/pulls/2252))
|
|
||||||
- Add some missing instructions on configuring Continuwuity on the RPM page. Users are encouraged to use the [generic deploying docs](https://continuwuity.org/deploying/generic) for the bulk of guidance anyhow. Contributed by @stratself ([#2275](https://forgejo.ellis.link/continuwuation/continuwuity/pulls/2275))
|
|
||||||
- Better, more succinct [introduction page](https://continuwuity.org/introduction.html). Contributed by @stratself ([#2279](https://forgejo.ellis.link/continuwuation/continuwuity/pulls/2279))
|
|
||||||
- Add a section on [troubleshooting Docker issues](https://continuwuity.org/troubleshooting#docker-issues). Contributed by @stratself. ([#2324](https://forgejo.ellis.link/continuwuation/continuwuity/pulls/2324))
|
|
||||||
- Instructions for Authelia added to the [OIDC guide](https://continuwuity.org/authentication/oidc.html). Contributed by @fhoekstra ([#2341](https://forgejo.ellis.link/continuwuation/continuwuity/pulls/2341))
|
|
||||||
- Docker compose examples now use bind mounts by default, instead of Docker volumes, as they are easier to work with esp. for backup/restore. Contributed by @stratself. ([#2353](https://forgejo.ellis.link/continuwuation/continuwuity/pulls/2353))
|
|
||||||
- The documentation now refers to the Continuwuity Docker service as `continuwuity` instead of `homeserver`.
|
|
||||||
|
|
||||||
## Misc
|
|
||||||
|
|
||||||
- #2423, #2556, #2595
|
|
||||||
- Upgraded rocksdb from 11.1.1 to 11.12.0 and jemalloc to 5.4.0.
|
|
||||||
|
|
||||||
|
|
||||||
# Continuwuity v26.11.0-alpha.2 (2026-11-14)
|
# Continuwuity v26.11.0-alpha.2 (2026-11-14)
|
||||||
|
|
||||||
## Features
|
## Features
|
||||||
|
|||||||
Generated
+37
-38
@@ -574,9 +574,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "built"
|
name = "built"
|
||||||
version = "0.8.1"
|
version = "0.9.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "5c0e531d93d39c34eef561e929e8a7f86d77a5af08aac4f6d6e39976c51858e9"
|
checksum = "6192709ebc97997197804bcbb092ef897b5a6a2f33e2c77779f694dbe90fec1e"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "bumpalo"
|
name = "bumpalo"
|
||||||
@@ -871,7 +871,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "conduwuit"
|
name = "conduwuit"
|
||||||
version = "26.11.0-rc.1"
|
version = "26.11.0-alpha.2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"clap",
|
"clap",
|
||||||
"conduwuit_build_metadata",
|
"conduwuit_build_metadata",
|
||||||
@@ -903,7 +903,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "conduwuit_admin"
|
name = "conduwuit_admin"
|
||||||
version = "26.11.0-rc.1"
|
version = "26.11.0-alpha.2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"clap",
|
"clap",
|
||||||
"conduwuit_api",
|
"conduwuit_api",
|
||||||
@@ -927,7 +927,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "conduwuit_api"
|
name = "conduwuit_api"
|
||||||
version = "26.11.0-rc.1"
|
version = "26.11.0-alpha.2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"axum",
|
"axum",
|
||||||
"base64 0.23.1",
|
"base64 0.23.1",
|
||||||
@@ -960,7 +960,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "conduwuit_build_metadata"
|
name = "conduwuit_build_metadata"
|
||||||
version = "26.11.0-rc.1"
|
version = "26.11.0-alpha.2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"built",
|
"built",
|
||||||
"cargo_metadata",
|
"cargo_metadata",
|
||||||
@@ -968,7 +968,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "conduwuit_core"
|
name = "conduwuit_core"
|
||||||
version = "26.11.0-rc.1"
|
version = "26.11.0-alpha.2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"argon2",
|
"argon2",
|
||||||
"arrayvec",
|
"arrayvec",
|
||||||
@@ -1038,7 +1038,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "conduwuit_database"
|
name = "conduwuit_database"
|
||||||
version = "26.11.0-rc.1"
|
version = "26.11.0-alpha.2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"async-channel",
|
"async-channel",
|
||||||
"conduwuit_core",
|
"conduwuit_core",
|
||||||
@@ -1058,7 +1058,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "conduwuit_macros"
|
name = "conduwuit_macros"
|
||||||
version = "26.11.0-rc.1"
|
version = "26.11.0-alpha.2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"itertools 0.15.0",
|
"itertools 0.15.0",
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
@@ -1068,7 +1068,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "conduwuit_router"
|
name = "conduwuit_router"
|
||||||
version = "26.11.0-rc.1"
|
version = "26.11.0-alpha.2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"axum",
|
"axum",
|
||||||
"axum-server",
|
"axum-server",
|
||||||
@@ -1101,7 +1101,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "conduwuit_service"
|
name = "conduwuit_service"
|
||||||
version = "26.11.0-rc.1"
|
version = "26.11.0-alpha.2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"askama",
|
"askama",
|
||||||
"assign",
|
"assign",
|
||||||
@@ -1127,7 +1127,6 @@ dependencies = [
|
|||||||
"log",
|
"log",
|
||||||
"loole",
|
"loole",
|
||||||
"lru-cache",
|
"lru-cache",
|
||||||
"mime",
|
|
||||||
"nonzero_ext",
|
"nonzero_ext",
|
||||||
"openidconnect",
|
"openidconnect",
|
||||||
"opentelemetry",
|
"opentelemetry",
|
||||||
@@ -1158,7 +1157,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "conduwuit_web"
|
name = "conduwuit_web"
|
||||||
version = "26.11.0-rc.1"
|
version = "26.11.0-alpha.2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"askama",
|
"askama",
|
||||||
"async-trait",
|
"async-trait",
|
||||||
@@ -4986,8 +4985,8 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ruma"
|
name = "ruma"
|
||||||
version = "0.18.0"
|
version = "0.17.2"
|
||||||
source = "git+https://github.com/ruma/ruma.git?rev=decdf3f6c5160e1db595d4edb4d65d5de935e13c#decdf3f6c5160e1db595d4edb4d65d5de935e13c"
|
source = "git+https://github.com/ruma/ruma.git?rev=472a23ef86bc0bb40a22d856fc0af539eb9d71b7#472a23ef86bc0bb40a22d856fc0af539eb9d71b7"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"assign",
|
"assign",
|
||||||
"js_int",
|
"js_int",
|
||||||
@@ -5005,8 +5004,8 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ruma-appservice-api"
|
name = "ruma-appservice-api"
|
||||||
version = "0.18.0"
|
version = "0.17.1"
|
||||||
source = "git+https://github.com/ruma/ruma.git?rev=decdf3f6c5160e1db595d4edb4d65d5de935e13c#decdf3f6c5160e1db595d4edb4d65d5de935e13c"
|
source = "git+https://github.com/ruma/ruma.git?rev=472a23ef86bc0bb40a22d856fc0af539eb9d71b7#472a23ef86bc0bb40a22d856fc0af539eb9d71b7"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"http",
|
"http",
|
||||||
"js_int",
|
"js_int",
|
||||||
@@ -5018,8 +5017,8 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ruma-client-api"
|
name = "ruma-client-api"
|
||||||
version = "0.26.0"
|
version = "0.25.2"
|
||||||
source = "git+https://github.com/ruma/ruma.git?rev=decdf3f6c5160e1db595d4edb4d65d5de935e13c#decdf3f6c5160e1db595d4edb4d65d5de935e13c"
|
source = "git+https://github.com/ruma/ruma.git?rev=472a23ef86bc0bb40a22d856fc0af539eb9d71b7#472a23ef86bc0bb40a22d856fc0af539eb9d71b7"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"as_variant",
|
"as_variant",
|
||||||
"assign",
|
"assign",
|
||||||
@@ -5040,8 +5039,8 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ruma-common"
|
name = "ruma-common"
|
||||||
version = "0.21.0"
|
version = "0.20.2"
|
||||||
source = "git+https://github.com/ruma/ruma.git?rev=decdf3f6c5160e1db595d4edb4d65d5de935e13c#decdf3f6c5160e1db595d4edb4d65d5de935e13c"
|
source = "git+https://github.com/ruma/ruma.git?rev=472a23ef86bc0bb40a22d856fc0af539eb9d71b7#472a23ef86bc0bb40a22d856fc0af539eb9d71b7"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"as_variant",
|
"as_variant",
|
||||||
"base64 0.23.1",
|
"base64 0.23.1",
|
||||||
@@ -5073,8 +5072,8 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ruma-events"
|
name = "ruma-events"
|
||||||
version = "0.36.0"
|
version = "0.35.2"
|
||||||
source = "git+https://github.com/ruma/ruma.git?rev=decdf3f6c5160e1db595d4edb4d65d5de935e13c#decdf3f6c5160e1db595d4edb4d65d5de935e13c"
|
source = "git+https://github.com/ruma/ruma.git?rev=472a23ef86bc0bb40a22d856fc0af539eb9d71b7#472a23ef86bc0bb40a22d856fc0af539eb9d71b7"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"as_variant",
|
"as_variant",
|
||||||
"indexmap 2.14.2",
|
"indexmap 2.14.2",
|
||||||
@@ -5094,8 +5093,8 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ruma-federation-api"
|
name = "ruma-federation-api"
|
||||||
version = "0.17.0"
|
version = "0.16.1"
|
||||||
source = "git+https://github.com/ruma/ruma.git?rev=decdf3f6c5160e1db595d4edb4d65d5de935e13c#decdf3f6c5160e1db595d4edb4d65d5de935e13c"
|
source = "git+https://github.com/ruma/ruma.git?rev=472a23ef86bc0bb40a22d856fc0af539eb9d71b7#472a23ef86bc0bb40a22d856fc0af539eb9d71b7"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bytes",
|
"bytes",
|
||||||
"http",
|
"http",
|
||||||
@@ -5116,8 +5115,8 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ruma-identifiers-validation"
|
name = "ruma-identifiers-validation"
|
||||||
version = "0.14.1"
|
version = "0.14.0"
|
||||||
source = "git+https://github.com/ruma/ruma.git?rev=decdf3f6c5160e1db595d4edb4d65d5de935e13c#decdf3f6c5160e1db595d4edb4d65d5de935e13c"
|
source = "git+https://github.com/ruma/ruma.git?rev=472a23ef86bc0bb40a22d856fc0af539eb9d71b7#472a23ef86bc0bb40a22d856fc0af539eb9d71b7"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"js_int",
|
"js_int",
|
||||||
"thiserror 2.0.21",
|
"thiserror 2.0.21",
|
||||||
@@ -5125,8 +5124,8 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ruma-macros"
|
name = "ruma-macros"
|
||||||
version = "0.20.3"
|
version = "0.20.2"
|
||||||
source = "git+https://github.com/ruma/ruma.git?rev=decdf3f6c5160e1db595d4edb4d65d5de935e13c#decdf3f6c5160e1db595d4edb4d65d5de935e13c"
|
source = "git+https://github.com/ruma/ruma.git?rev=472a23ef86bc0bb40a22d856fc0af539eb9d71b7#472a23ef86bc0bb40a22d856fc0af539eb9d71b7"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"as_variant",
|
"as_variant",
|
||||||
"cfg-if",
|
"cfg-if",
|
||||||
@@ -5141,8 +5140,8 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ruma-push-gateway-api"
|
name = "ruma-push-gateway-api"
|
||||||
version = "0.17.0"
|
version = "0.16.0"
|
||||||
source = "git+https://github.com/ruma/ruma.git?rev=decdf3f6c5160e1db595d4edb4d65d5de935e13c#decdf3f6c5160e1db595d4edb4d65d5de935e13c"
|
source = "git+https://github.com/ruma/ruma.git?rev=472a23ef86bc0bb40a22d856fc0af539eb9d71b7#472a23ef86bc0bb40a22d856fc0af539eb9d71b7"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"js_int",
|
"js_int",
|
||||||
"ruma-common",
|
"ruma-common",
|
||||||
@@ -5153,8 +5152,8 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ruma-signatures"
|
name = "ruma-signatures"
|
||||||
version = "0.23.0"
|
version = "0.22.1"
|
||||||
source = "git+https://github.com/ruma/ruma.git?rev=decdf3f6c5160e1db595d4edb4d65d5de935e13c#decdf3f6c5160e1db595d4edb4d65d5de935e13c"
|
source = "git+https://github.com/ruma/ruma.git?rev=472a23ef86bc0bb40a22d856fc0af539eb9d71b7#472a23ef86bc0bb40a22d856fc0af539eb9d71b7"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"base64 0.23.1",
|
"base64 0.23.1",
|
||||||
"ed25519-dalek",
|
"ed25519-dalek",
|
||||||
@@ -5170,8 +5169,8 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ruma-state-res"
|
name = "ruma-state-res"
|
||||||
version = "0.19.0"
|
version = "0.18.0"
|
||||||
source = "git+https://github.com/ruma/ruma.git?rev=decdf3f6c5160e1db595d4edb4d65d5de935e13c#decdf3f6c5160e1db595d4edb4d65d5de935e13c"
|
source = "git+https://github.com/ruma/ruma.git?rev=472a23ef86bc0bb40a22d856fc0af539eb9d71b7#472a23ef86bc0bb40a22d856fc0af539eb9d71b7"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"js_int",
|
"js_int",
|
||||||
"ruma-common",
|
"ruma-common",
|
||||||
@@ -5185,7 +5184,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ruminuwuity"
|
name = "ruminuwuity"
|
||||||
version = "26.11.0-rc.1"
|
version = "26.11.0-alpha.2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"assign",
|
"assign",
|
||||||
"http",
|
"http",
|
||||||
@@ -5642,7 +5641,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||||||
checksum = "969cde0349344dbbf58b5f9badbfb8f806db13969364eb8007c057ef687007d9"
|
checksum = "969cde0349344dbbf58b5f9badbfb8f806db13969364eb8007c057ef687007d9"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"annotate-snippets",
|
"annotate-snippets",
|
||||||
"base64 0.22.1",
|
"base64 0.23.1",
|
||||||
"encoding_rs_io",
|
"encoding_rs_io",
|
||||||
"granit-parser",
|
"granit-parser",
|
||||||
"nohash-hasher",
|
"nohash-hasher",
|
||||||
@@ -7368,7 +7367,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "xtask"
|
name = "xtask"
|
||||||
version = "26.11.0-rc.1"
|
version = "26.11.0-alpha.2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"askama",
|
"askama",
|
||||||
"cargo_metadata",
|
"cargo_metadata",
|
||||||
|
|||||||
+3
-5
@@ -12,7 +12,7 @@ license = "Apache-2.0"
|
|||||||
# See also `rust-toolchain.toml`
|
# See also `rust-toolchain.toml`
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
repository = "https://forgejo.ellis.link/continuwuation/continuwuity"
|
repository = "https://forgejo.ellis.link/continuwuation/continuwuity"
|
||||||
version = "26.11.0-rc.1"
|
version = "26.11.0-alpha.2"
|
||||||
|
|
||||||
[workspace.metadata.crane]
|
[workspace.metadata.crane]
|
||||||
name = "conduwuit"
|
name = "conduwuit"
|
||||||
@@ -357,7 +357,7 @@ version = "1.1.1"
|
|||||||
# Used for matrix spec type definitions and helpers
|
# Used for matrix spec type definitions and helpers
|
||||||
[workspace.dependencies.ruma]
|
[workspace.dependencies.ruma]
|
||||||
git = "https://github.com/ruma/ruma.git"
|
git = "https://github.com/ruma/ruma.git"
|
||||||
rev = "decdf3f6c5160e1db595d4edb4d65d5de935e13c"
|
rev = "472a23ef86bc0bb40a22d856fc0af539eb9d71b7"
|
||||||
features = [
|
features = [
|
||||||
"appservice-api-c",
|
"appservice-api-c",
|
||||||
"client-api",
|
"client-api",
|
||||||
@@ -370,6 +370,7 @@ features = [
|
|||||||
"compat-upload-signatures",
|
"compat-upload-signatures",
|
||||||
"compat-optional-txn-pdus",
|
"compat-optional-txn-pdus",
|
||||||
"compat-get-3pids",
|
"compat-get-3pids",
|
||||||
|
"unstable-msc2867",
|
||||||
"unstable-msc2870",
|
"unstable-msc2870",
|
||||||
"unstable-msc3814",
|
"unstable-msc3814",
|
||||||
"unstable-msc3245",
|
"unstable-msc3245",
|
||||||
@@ -588,9 +589,6 @@ version = "0.10.4"
|
|||||||
default-features = false
|
default-features = false
|
||||||
features = ["std"]
|
features = ["std"]
|
||||||
|
|
||||||
[workspace.dependencies.mime]
|
|
||||||
version = "0.3.18"
|
|
||||||
|
|
||||||
[workspace.dependencies.nonzero_ext]
|
[workspace.dependencies.nonzero_ext]
|
||||||
version = "0.3.0"
|
version = "0.3.0"
|
||||||
|
|
||||||
|
|||||||
@@ -1 +0,0 @@
|
|||||||
Rejected events are no longer used as auth events during state resolution.
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
Added support for the stable MatrixRTC transports discovery endpoint (`GET /_matrix/client/v1/rtc/transports`) from the accepted MSC4143, advertised via the `org.matrix.msc4143.stable` unstable feature. The unstable endpoint remains available. Contributed by @Henry-Hiles (QuadRadical).
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
Added support for acting as a trusted server, meaning the `trusted_servers` list can consist of servers that are either Synapse OR continuwuity.
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
URL previews no longer completely fail if downloading auxiliary content (images/videos/audio) fails. Contributed by @nex.
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
Modernised the room knocking helper functions to make them match the behaviour of our room join helpers, which are safer and more efficient. This also fixes a bug that caused an error when knocking on rooms not local to the server. Contributed by @nex.
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
Network issues while refreshing an access token will no longer cause OAuth-compatible clients to be forcibly logged out. Contributed by @ginger.
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
Continuwuity will now request the `profile` OIDC scope from identity providers by default to improve compatibility with identity providers that require it to access users' profile claims, as recommended by the OIDC specification. Contributed by @ginger.
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
Attempting to start a UIAA session on a homeserver with UIAA disabled will now return `403 M_UNAUTHORIZED` instead of `404 M_UNSUPPORTED`. Contributed by @ginger.
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
Advertise support for Matrix v1.6. Contributed by @jade
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
Moved the `jemalloc` feature out of `standard` (and `full`) into `default` so builders can more easily swap allocators. Builders using `--no-default-features` with the `full` or `standard` feature should now explicitly select an allocator (either `jemalloc` or `mimalloc`). Contributed by @Jade
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
Fix outgoing federation stalling after a sender worker panics. Contributed by @eleboucher.
|
|
||||||
+7
-22
@@ -1043,7 +1043,10 @@
|
|||||||
# (trusted key notary servers), as well as serve as trusted servers for
|
# (trusted key notary servers), as well as serve as trusted servers for
|
||||||
# other operations like backfill and event fetching.
|
# other operations like backfill and event fetching.
|
||||||
#
|
#
|
||||||
# example: ["continuwuity.org", "matrix.org"]
|
# Currently, continuwuity doesn't support inbound key requests, so
|
||||||
|
# this list should only contain other Synapse servers.
|
||||||
|
#
|
||||||
|
# example: ["matrix.org", "starstruck.systems"]
|
||||||
#
|
#
|
||||||
# It is possible to restrict which signing keys trusted servers are
|
# It is possible to restrict which signing keys trusted servers are
|
||||||
# allowed to sign responses with. Without configuring this, all responses
|
# allowed to sign responses with. Without configuring this, all responses
|
||||||
@@ -1081,7 +1084,7 @@
|
|||||||
# is discouraged for performance and reliability reasons.
|
# is discouraged for performance and reliability reasons.
|
||||||
#
|
#
|
||||||
# env: CONTINUWUITY_TRUSTED_SERVERS
|
# env: CONTINUWUITY_TRUSTED_SERVERS
|
||||||
#trusted_servers = ["continuwuity.org", "continuwuity.rocks", "matrix.org"]
|
#trusted_servers = ["matrix.org"]
|
||||||
|
|
||||||
# Whether to prioritise trusted server lookups over origin server lookups.
|
# Whether to prioritise trusted server lookups over origin server lookups.
|
||||||
#
|
#
|
||||||
@@ -2579,12 +2582,10 @@
|
|||||||
|
|
||||||
# Additional scopes Continuwuity should request from the IDP. This may be
|
# Additional scopes Continuwuity should request from the IDP. This may be
|
||||||
# necessary to access certain claims. Continuwuity always requests the
|
# necessary to access certain claims. Continuwuity always requests the
|
||||||
# `openid` scope, regardless of the contents of this option,
|
# `openid` scope.
|
||||||
# and will also request the `profile` scope by default if this option is
|
|
||||||
# not set.
|
|
||||||
#
|
#
|
||||||
# env: CONTINUWUITY_OAUTH__OIDC__ADDITIONAL_SCOPES
|
# env: CONTINUWUITY_OAUTH__OIDC__ADDITIONAL_SCOPES
|
||||||
#additional_scopes = ["profile"]
|
#additional_scopes = []
|
||||||
|
|
||||||
# Additional trusted audiences that Continuwuity will accept in the `aud`
|
# Additional trusted audiences that Continuwuity will accept in the `aud`
|
||||||
# claim of the OIDC token returned by the IDP. If your identity
|
# claim of the OIDC token returned by the IDP. If your identity
|
||||||
@@ -2780,22 +2781,6 @@
|
|||||||
# env: CONTINUWUITY_EXPERIMENTS__MSC4494
|
# env: CONTINUWUITY_EXPERIMENTS__MSC4494
|
||||||
#msc4494 = false
|
#msc4494 = false
|
||||||
|
|
||||||
# MSC4556: Notary request limits
|
|
||||||
#
|
|
||||||
# Creates a new key notary server route that has stricter limits on how
|
|
||||||
# many signing keys can be requested in one query, to avoid a resource
|
|
||||||
# exhaustion exploit vector in the existing key notary endpoint.
|
|
||||||
#
|
|
||||||
# Continuwuity mitigates the exploit vector in the old notary endpoint
|
|
||||||
# anyway, so you do not need to enable this to be protected.
|
|
||||||
#
|
|
||||||
# Requires that remote servers support this MSC before it does anything.
|
|
||||||
#
|
|
||||||
# https://github.com/matrix-org/matrix-spec-proposals/pull/4556
|
|
||||||
#
|
|
||||||
# env: CONTINUWUITY_EXPERIMENTS__MSC4556
|
|
||||||
#msc4556 = false
|
|
||||||
|
|
||||||
# MSC4560: Stripped state requests over federation
|
# MSC4560: Stripped state requests over federation
|
||||||
#
|
#
|
||||||
# Implements a more efficient way for servers to acquire and serve
|
# Implements a more efficient way for servers to acquire and serve
|
||||||
|
|||||||
+4
-4
@@ -167,8 +167,8 @@ ARG RUST_PROFILE=release
|
|||||||
ARG CARGO_FEATURES="default"
|
ARG CARGO_FEATURES="default"
|
||||||
|
|
||||||
# Build the binary
|
# Build the binary
|
||||||
RUN --mount=type=cache,target=/usr/local/cargo/registry,sharing=locked \
|
RUN --mount=type=cache,target=/usr/local/cargo/registry \
|
||||||
--mount=type=cache,target=/usr/local/cargo/git/db,sharing=locked \
|
--mount=type=cache,target=/usr/local/cargo/git/db \
|
||||||
--mount=type=cache,target=/app/target,id=continuwuity-cargo-target-${TARGET_CPU}-${TARGETPLATFORM}-${RUST_PROFILE} \
|
--mount=type=cache,target=/app/target,id=continuwuity-cargo-target-${TARGET_CPU}-${TARGETPLATFORM}-${RUST_PROFILE} \
|
||||||
bash <<'EOF'
|
bash <<'EOF'
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
@@ -205,8 +205,8 @@ RUN --mount=type=cache,target=/usr/local/cargo/registry,sharing=locked \
|
|||||||
EOF
|
EOF
|
||||||
|
|
||||||
# Generate Software Bill of Materials (SBOM)
|
# Generate Software Bill of Materials (SBOM)
|
||||||
RUN --mount=type=cache,target=/usr/local/cargo/registry,sharing=locked \
|
RUN --mount=type=cache,target=/usr/local/cargo/registry \
|
||||||
--mount=type=cache,target=/usr/local/cargo/git/db,sharing=locked \
|
--mount=type=cache,target=/usr/local/cargo/git/db \
|
||||||
bash <<'EOF'
|
bash <<'EOF'
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
set -o xtrace
|
set -o xtrace
|
||||||
|
|||||||
@@ -120,8 +120,8 @@ ENV CONTINUWUITY_VERSION_EXTRA=$CONTINUWUITY_VERSION_EXTRA
|
|||||||
ARG RUST_PROFILE=release
|
ARG RUST_PROFILE=release
|
||||||
|
|
||||||
# Build the binary
|
# Build the binary
|
||||||
RUN --mount=type=cache,target=/usr/local/cargo/registry,sharing=locked \
|
RUN --mount=type=cache,target=/usr/local/cargo/registry \
|
||||||
--mount=type=cache,target=/usr/local/cargo/git/db,sharing=locked \
|
--mount=type=cache,target=/usr/local/cargo/git/db \
|
||||||
--mount=type=cache,target=/app/target,id=continuwuity-cargo-target-${TARGET_CPU}-${TARGETPLATFORM}-musl-${RUST_PROFILE} \
|
--mount=type=cache,target=/app/target,id=continuwuity-cargo-target-${TARGET_CPU}-${TARGETPLATFORM}-musl-${RUST_PROFILE} \
|
||||||
bash <<'EOF'
|
bash <<'EOF'
|
||||||
set -o allexport
|
set -o allexport
|
||||||
@@ -143,8 +143,8 @@ RUN --mount=type=cache,target=/usr/local/cargo/registry,sharing=locked \
|
|||||||
EOF
|
EOF
|
||||||
|
|
||||||
# Generate Software Bill of Materials (SBOM)
|
# Generate Software Bill of Materials (SBOM)
|
||||||
RUN --mount=type=cache,target=/usr/local/cargo/registry,sharing=locked \
|
RUN --mount=type=cache,target=/usr/local/cargo/registry \
|
||||||
--mount=type=cache,target=/usr/local/cargo/git/db,sharing=locked \
|
--mount=type=cache,target=/usr/local/cargo/git/db \
|
||||||
bash <<'EOF'
|
bash <<'EOF'
|
||||||
set -o xtrace
|
set -o xtrace
|
||||||
mkdir /out/sbom
|
mkdir /out/sbom
|
||||||
|
|||||||
@@ -44,29 +44,6 @@ appservice can send requests to the homeserver. You don't need to restart
|
|||||||
Continuwuity, but if it doesn't work, restarting while the appservice is running
|
Continuwuity, but if it doesn't work, restarting while the appservice is running
|
||||||
could help.
|
could help.
|
||||||
|
|
||||||
### Changing parts of the appservice configuration
|
|
||||||
|
|
||||||
If you want to change an option in the yaml configuration without
|
|
||||||
re-registering, you can send the `!admin appservices register` command again,
|
|
||||||
making sure that the `id` is the same.
|
|
||||||
|
|
||||||
For example, take this registration yaml:
|
|
||||||
~~~txt
|
|
||||||
!admin appservices register
|
|
||||||
```
|
|
||||||
id: meowlnir
|
|
||||||
url: https://url-i-just-changed.com
|
|
||||||
...other options below
|
|
||||||
```
|
|
||||||
~~~
|
|
||||||
|
|
||||||
This new configuration will be applied immediately. Note that this *replaces*
|
|
||||||
the prior configuration. You must send the complete configuration, changing the
|
|
||||||
fields you want to change.
|
|
||||||
|
|
||||||
You can see the current configuration using `!admin appservices
|
|
||||||
show-appservice-config <id>`.
|
|
||||||
|
|
||||||
## Appservice-specific instructions
|
## Appservice-specific instructions
|
||||||
|
|
||||||
### Remove an appservice
|
### Remove an appservice
|
||||||
|
|||||||
@@ -71,9 +71,6 @@ Names below are as they appear in Prometheus. OTLP uses the dotted OpenTelemetry
|
|||||||
| `continuwuity_sender_events_total` | counter | `destination`, `kind`, `outcome` | PDUs and EDUs sent in outgoing transactions |
|
| `continuwuity_sender_events_total` | counter | `destination`, `kind`, `outcome` | PDUs and EDUs sent in outgoing transactions |
|
||||||
| `continuwuity_sender_events_queued_total` | counter | `destination`, `kind` | PDUs and EDUs queued for sending |
|
| `continuwuity_sender_events_queued_total` | counter | `destination`, `kind` | PDUs and EDUs queued for sending |
|
||||||
| `continuwuity_sender_queue_depth` | gauge | | Messages waiting for the sender workers |
|
| `continuwuity_sender_queue_depth` | gauge | | Messages waiting for the sender workers |
|
||||||
| `continuwuity_sender_requests` | gauge | `state` | Estimated outgoing requests stored as `queued` or `active` (in flight) |
|
|
||||||
| `continuwuity_sender_workers` | gauge | | Running sender workers; below the configured count means a worker is restarting |
|
|
||||||
| `continuwuity_sender_panics_total` | counter | `scope` | Panics caught in a single outgoing `transaction` or a whole sender `worker` |
|
|
||||||
| `continuwuity_users` | gauge | `origin` | Known `local` users, including deactivated, and `remote` users |
|
| `continuwuity_users` | gauge | `origin` | Known `local` users, including deactivated, and `remote` users |
|
||||||
| `continuwuity_invites_total` | counter | `direction`, `destination`, `outcome` | Invites sent by local users or received over federation |
|
| `continuwuity_invites_total` | counter | `direction`, `destination`, `outcome` | Invites sent by local users or received over federation |
|
||||||
| `continuwuity_media_write_size_bytes` | histogram | `origin` | Media files written, from local uploads or cached remote media |
|
| `continuwuity_media_write_size_bytes` | histogram | `origin` | Media files written, from local uploads or cached remote media |
|
||||||
|
|||||||
+1
-10
@@ -1,8 +1,6 @@
|
|||||||
import { normalizeImagePath } from '@rspress/core/runtime';
|
|
||||||
|
|
||||||
<div align="center">
|
<div align="center">
|
||||||
|
|
||||||
<img src={normalizeImagePath("/assets/logo.svg")} width="150"/>
|
<img src="/assets/logo.svg" width="150"/>
|
||||||
|
|
||||||
# Continuwuity
|
# Continuwuity
|
||||||
|
|
||||||
@@ -92,13 +90,6 @@ Our source code and mirrors can be accessed through these buttons:
|
|||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
Our documentation is proudly hosted on Grebedoc.
|
|
||||||
<div className="no-zoom" align="center">
|
|
||||||
<a href="https://grebedoc.dev">
|
|
||||||
<img src="https://grebedoc.dev/88x31-homu.gif" alt="served by Grebedoc" style={{imageRendering:"pixelated"}}/>
|
|
||||||
</a>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
[forge-badge]: https://img.shields.io/badge/Ellis%20Git-main+packages-green?style=flat&logo=forgejo&labelColor=fff
|
[forge-badge]: https://img.shields.io/badge/Ellis%20Git-main+packages-green?style=flat&logo=forgejo&labelColor=fff
|
||||||
[forge-link]: https://forgejo.ellis.link/continuwuation/continuwuity
|
[forge-link]: https://forgejo.ellis.link/continuwuation/continuwuity
|
||||||
[forge-releases-badge]: https://forgejo.ellis.link/continuwuation/continuwuity/badges/release.svg?style=flat&label=Latest%20release&labelColor=fff&color=green
|
[forge-releases-badge]: https://forgejo.ellis.link/continuwuation/continuwuity/badges/release.svg?style=flat&label=Latest%20release&labelColor=fff&color=green
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
/.well-known/matrix/*
|
/.well-known/matrix/*
|
||||||
|
Access-Control-Allow-Origin: *
|
||||||
Content-Type: application/json
|
Content-Type: application/json
|
||||||
/.well-known/continuwuity/*
|
/.well-known/continuwuity/*
|
||||||
|
Access-Control-Allow-Origin: *
|
||||||
Content-Type: application/json
|
Content-Type: application/json
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
module forgejo.ellis.link/continuwuation/continuwuity
|
|
||||||
|
|
||||||
go 1.27
|
|
||||||
|
|
||||||
toolchain go1.27.4
|
|
||||||
|
|
||||||
tool codeberg.org/git-pages/git-pages-cli
|
|
||||||
|
|
||||||
require (
|
|
||||||
codeberg.org/git-pages/git-pages-cli v1.13.2 // indirect
|
|
||||||
codeberg.org/git-pages/go-redirects v1.0.0 // indirect
|
|
||||||
github.com/google/uuid v1.6.0 // indirect
|
|
||||||
github.com/klauspost/compress v1.20.4 // indirect
|
|
||||||
github.com/pkg/errors v0.9.1 // indirect
|
|
||||||
github.com/spf13/pflag v1.1.0 // indirect
|
|
||||||
golang.org/x/net v0.62.0 // indirect
|
|
||||||
golang.org/x/text v0.43.0 // indirect
|
|
||||||
)
|
|
||||||
@@ -1,26 +0,0 @@
|
|||||||
codeberg.org/git-pages/git-pages-cli v1.13.2 h1:ZEp6q939eTmB4GcZgnPQVm4Ml2BFaF2GOJgpCNhSha8=
|
|
||||||
codeberg.org/git-pages/git-pages-cli v1.13.2/go.mod h1:hWoewK332MgUQuOMt5O07lFTjs3l3kUywxIFs90W3IY=
|
|
||||||
codeberg.org/git-pages/go-redirects v1.0.0 h1:RfrPwtk60ii5JyQgH1XkUmsUrTqPjwvbqy3CGapPVwA=
|
|
||||||
codeberg.org/git-pages/go-redirects v1.0.0/go.mod h1:0zdliclTux3tFONB7E6ZWV7WoWrK7cXHIi2hrMcLf8g=
|
|
||||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
|
||||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
|
||||||
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
|
|
||||||
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
|
||||||
github.com/klauspost/compress v1.20.4 h1:dD0v/bvxtjCBqQu6sx1TNWkalEY5lNTIe+HY9w8TeNI=
|
|
||||||
github.com/klauspost/compress v1.20.4/go.mod h1:LUdAzn7YLVvxLpc7y3V1m40wESHTgc1422pwwBSKYuI=
|
|
||||||
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
|
|
||||||
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
|
||||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
|
||||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
|
||||||
github.com/spf13/pflag v1.1.0 h1:6W6MbVUrnMb8PEhjkqwsVLY7ryuzRfFHF4mQd7L94ag=
|
|
||||||
github.com/spf13/pflag v1.1.0/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
|
|
||||||
github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0=
|
|
||||||
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
|
||||||
github.com/tj/assert v0.0.3 h1:Df/BlaZ20mq6kuai7f5z2TvPFiwC3xaWJSDQNiIS3Rk=
|
|
||||||
github.com/tj/assert v0.0.3/go.mod h1:Ne6X72Q+TB1AteidzQncjw9PabbMp4PBMZ1k+vd1Pvk=
|
|
||||||
golang.org/x/net v0.62.0 h1:18ELalfM5+XNRwzM2nYqXsZQ9ByS1uhj2O/U7+5jqRY=
|
|
||||||
golang.org/x/net v0.62.0/go.mod h1:WgDCOTH8iwtB66T4/GfI94AHo/hhdb7Hah9NDseQfiI=
|
|
||||||
golang.org/x/text v0.43.0 h1:1QivrlhwAsnMOcqgOdl9my7s9OyZl8O5/UGUTJVXoWc=
|
|
||||||
golang.org/x/text v0.43.0/go.mod h1:hbSIYA/amXcRXTFSZqh8tWHEoqRvvbKPJ2uz/KU+a+s=
|
|
||||||
gopkg.in/yaml.v3 v3.0.0-20200605160147-a5ece683394c h1:grhR+C34yXImVGp7EzNk+DTIk+323eIUWOmEevy6bDo=
|
|
||||||
gopkg.in/yaml.v3 v3.0.0-20200605160147-a5ece683394c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
|
||||||
+8
-3
@@ -16,16 +16,21 @@
|
|||||||
pkgs.nodejs
|
pkgs.nodejs
|
||||||
pkgs.pkg-config
|
pkgs.pkg-config
|
||||||
]
|
]
|
||||||
++ lib.optional pkgs.stdenv.hostPlatform.isLinux pkgs.liburing;
|
++ lib.optionals pkgs.stdenv.hostPlatform.isLinux [
|
||||||
|
pkgs.liburing
|
||||||
|
pkgs.rust-jemalloc-sys-unprefixed
|
||||||
|
];
|
||||||
|
|
||||||
env = {
|
env = {
|
||||||
LIBCLANG_PATH = lib.makeLibraryPath [ pkgs.llvmPackages.libclang.lib ];
|
LIBCLANG_PATH = lib.makeLibraryPath [ pkgs.llvmPackages.libclang.lib ];
|
||||||
LD_LIBRARY_PATH = lib.makeLibraryPath (
|
LD_LIBRARY_PATH = lib.makeLibraryPath (
|
||||||
[
|
[
|
||||||
pkgs.stdenv.cc.cc.lib
|
pkgs.stdenv.cc.cc.lib
|
||||||
pkgs.llvmPackages.libclang.lib
|
|
||||||
]
|
]
|
||||||
++ lib.optional pkgs.stdenv.hostPlatform.isLinux pkgs.liburing
|
++ lib.optionals pkgs.stdenv.hostPlatform.isLinux [
|
||||||
|
pkgs.liburing
|
||||||
|
pkgs.jemalloc
|
||||||
|
]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
// lib.optionalAttrs pkgs.stdenv.hostPlatform.isLinux {
|
// lib.optionalAttrs pkgs.stdenv.hostPlatform.isLinux {
|
||||||
|
|||||||
+29
-20
@@ -1,27 +1,36 @@
|
|||||||
{
|
{
|
||||||
|
# stdenv,
|
||||||
|
# enableJemalloc ? stdenv.hostPlatform.isLinux,
|
||||||
|
enableJemalloc ? false,
|
||||||
rocksdb,
|
rocksdb,
|
||||||
fetchFromGitea,
|
fetchFromGitea,
|
||||||
|
rust-jemalloc-sys-unprefixed,
|
||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
# RocksDB is built without jemalloc integration (the nixpkgs default). On Linux
|
(rocksdb.override {
|
||||||
# it still uses jemalloc at runtime, because continuwuity statically links an
|
# rocksdb fails to build with prefixed jemalloc, which is required on
|
||||||
# unprefixed jemalloc that replaces malloc/free process-wide. Linking RocksDB
|
# darwin due to [1]. In this case, fall back to building rocksdb with
|
||||||
# against a separate jemalloc puts two allocator instances in one process, which
|
# libc malloc. This should not cause conflicts, because all of the
|
||||||
# caused segfaults on db close/migration.
|
# jemalloc symbols are prefixed.
|
||||||
rocksdb.overrideAttrs ({
|
#
|
||||||
version = "continuwuity-v0.5.0-unstable-2026-11-08";
|
# [1]: https://github.com/tikv/jemallocator/blob/ab0676d77e81268cd09b059260c75b38dbef2d51/jemalloc-sys/src/env.rs#L17
|
||||||
src = fetchFromGitea {
|
jemalloc = rust-jemalloc-sys-unprefixed;
|
||||||
domain = "forgejo.ellis.link";
|
inherit enableJemalloc;
|
||||||
owner = "continuwuation";
|
}).overrideAttrs
|
||||||
repo = "rocksdb";
|
({
|
||||||
rev = "722fa3219df4169610fda8962221a1ff74026fdb";
|
version = "continuwuity-v0.5.0-unstable-2026-11-08";
|
||||||
hash = "sha256-ZuXXp83Hgj0B5v499CNxa9oNQUS/ZKYOAZEhmarUifc=";
|
src = fetchFromGitea {
|
||||||
};
|
domain = "forgejo.ellis.link";
|
||||||
|
owner = "continuwuation";
|
||||||
|
repo = "rocksdb";
|
||||||
|
rev = "722fa3219df4169610fda8962221a1ff74026fdb";
|
||||||
|
hash = "sha256-ZuXXp83Hgj0B5v499CNxa9oNQUS/ZKYOAZEhmarUifc=";
|
||||||
|
};
|
||||||
|
|
||||||
# We have this already at https://forgejo.ellis.link/continuwuation/rocksdb/commit/a935c0273e1ba44eacf88ce3685a9b9831486155
|
# We have this already at https://forgejo.ellis.link/continuwuation/rocksdb/commit/a935c0273e1ba44eacf88ce3685a9b9831486155
|
||||||
# Unsetting `patches` so we don't have to revert it and make this nix exclusive
|
# Unsetting `patches` so we don't have to revert it and make this nix exclusive
|
||||||
patches = [ ];
|
patches = [ ];
|
||||||
|
|
||||||
# Unset postPatch, as our version override breaks version-specific sed calls in the original package
|
# Unset postPatch, as our version override breaks version-specific sed calls in the original package
|
||||||
postPatch = "";
|
postPatch = "";
|
||||||
})
|
})
|
||||||
+1
-1
@@ -12,7 +12,7 @@
|
|||||||
target:
|
target:
|
||||||
target.fromToolchainName {
|
target.fromToolchainName {
|
||||||
name = (lib.importTOML "${inputs.self}/rust-toolchain.toml").toolchain.channel;
|
name = (lib.importTOML "${inputs.self}/rust-toolchain.toml").toolchain.channel;
|
||||||
sha256 = "sha256-W3A3rtdDaQW5yOvFr5JVTfngRUCKKUqPCPIW/3aH0nM=";
|
sha256 = "sha256-MFHoWVcPZKjFrLnQnodCXbUsfZcofGfo9tV9fTTvklg=";
|
||||||
};
|
};
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
|
|||||||
Generated
+164
-221
@@ -11,7 +11,7 @@
|
|||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@rspress/core": "^2.0.0",
|
"@rspress/core": "^2.0.0",
|
||||||
"@rspress/plugin-client-redirects": "^2.0.0",
|
"@rspress/plugin-client-redirects": "^2.0.0",
|
||||||
"@types/node": "^26.6.7",
|
"@types/node": "^26.6.6",
|
||||||
"typescript": "^7.0.0"
|
"typescript": "^7.0.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -128,13 +128,13 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@rsbuild/core": {
|
"node_modules/@rsbuild/core": {
|
||||||
"version": "2.3.4",
|
"version": "2.3.3",
|
||||||
"resolved": "https://registry.npmjs.org/@rsbuild/core/-/core-2.3.4.tgz",
|
"resolved": "https://registry.npmjs.org/@rsbuild/core/-/core-2.3.3.tgz",
|
||||||
"integrity": "sha512-1P3nLh/uXOcNTJZxvymRzAmuz8SBiCqY2InliNxQTlS0mWtoXbrRBC/W7zfv3MATk/vPmzODAYoZ5oIULk3Ilg==",
|
"integrity": "sha512-IdbBXZrIY16RxnQduXRrsRBQtJ/X7JkYESrk6D46WA918wrckYTBxE09vHvDxR+3JoCLE02vOm2NPBNxqaUw5A==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@rspack/core": "~2.3.4",
|
"@rspack/core": "~2.3.3",
|
||||||
"@swc/helpers": "^0.5.24"
|
"@swc/helpers": "^0.5.24"
|
||||||
},
|
},
|
||||||
"bin": {
|
"bin": {
|
||||||
@@ -172,32 +172,32 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@rspack/binding": {
|
"node_modules/@rspack/binding": {
|
||||||
"version": "2.3.4",
|
"version": "2.3.3",
|
||||||
"resolved": "https://registry.npmjs.org/@rspack/binding/-/binding-2.3.4.tgz",
|
"resolved": "https://registry.npmjs.org/@rspack/binding/-/binding-2.3.3.tgz",
|
||||||
"integrity": "sha512-wSOT16LVITL/IKeIiLXgN5Q5jZIDqnQ7Gmk+wzKOSZ6OHYNfEBXAKhSJuYtCBq8ovJuGl8cJjdqatAlHE5XKIA==",
|
"integrity": "sha512-wwF++36a3rqYi0G9zj+rUavn/GIMzbzXehelGS1jkYeKPHyPXrVYwRHqwEKNKMD9z+FdW4YJKQcfFkPlHEiwUg==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"optionalDependencies": {
|
"optionalDependencies": {
|
||||||
"@rspack/binding-darwin-arm64": "2.3.4",
|
"@rspack/binding-darwin-arm64": "2.3.3",
|
||||||
"@rspack/binding-darwin-x64": "2.3.4",
|
"@rspack/binding-darwin-x64": "2.3.3",
|
||||||
"@rspack/binding-linux-arm64-gnu": "2.3.4",
|
"@rspack/binding-linux-arm64-gnu": "2.3.3",
|
||||||
"@rspack/binding-linux-arm64-musl": "2.3.4",
|
"@rspack/binding-linux-arm64-musl": "2.3.3",
|
||||||
"@rspack/binding-linux-ppc64-gnu": "2.3.4",
|
"@rspack/binding-linux-ppc64-gnu": "2.3.3",
|
||||||
"@rspack/binding-linux-riscv64-gnu": "2.3.4",
|
"@rspack/binding-linux-riscv64-gnu": "2.3.3",
|
||||||
"@rspack/binding-linux-riscv64-musl": "2.3.4",
|
"@rspack/binding-linux-riscv64-musl": "2.3.3",
|
||||||
"@rspack/binding-linux-s390x-gnu": "2.3.4",
|
"@rspack/binding-linux-s390x-gnu": "2.3.3",
|
||||||
"@rspack/binding-linux-x64-gnu": "2.3.4",
|
"@rspack/binding-linux-x64-gnu": "2.3.3",
|
||||||
"@rspack/binding-linux-x64-musl": "2.3.4",
|
"@rspack/binding-linux-x64-musl": "2.3.3",
|
||||||
"@rspack/binding-wasm32-wasi": "2.3.4",
|
"@rspack/binding-wasm32-wasi": "2.3.3",
|
||||||
"@rspack/binding-win32-arm64-msvc": "2.3.4",
|
"@rspack/binding-win32-arm64-msvc": "2.3.3",
|
||||||
"@rspack/binding-win32-ia32-msvc": "2.3.4",
|
"@rspack/binding-win32-ia32-msvc": "2.3.3",
|
||||||
"@rspack/binding-win32-x64-msvc": "2.3.4"
|
"@rspack/binding-win32-x64-msvc": "2.3.3"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@rspack/binding-darwin-arm64": {
|
"node_modules/@rspack/binding-darwin-arm64": {
|
||||||
"version": "2.3.4",
|
"version": "2.3.3",
|
||||||
"resolved": "https://registry.npmjs.org/@rspack/binding-darwin-arm64/-/binding-darwin-arm64-2.3.4.tgz",
|
"resolved": "https://registry.npmjs.org/@rspack/binding-darwin-arm64/-/binding-darwin-arm64-2.3.3.tgz",
|
||||||
"integrity": "sha512-eBD71fbmoJKnxcHD03bukbAIOP5r7nD0Ehs+mUrUQlZ6N53EhuJsTeJ1oYdg5L4GoSeQ+KecCqME81Nm0COLrA==",
|
"integrity": "sha512-G9WcBOP/6ZWeqTM/G0/rkJRY4DWmYQvk2untzcpj92uO12tqjZ9BSMgtBFvwElwagfQBkX8PPutkAZgtnlAoWA==",
|
||||||
"cpu": [
|
"cpu": [
|
||||||
"arm64"
|
"arm64"
|
||||||
],
|
],
|
||||||
@@ -209,9 +209,9 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"node_modules/@rspack/binding-darwin-x64": {
|
"node_modules/@rspack/binding-darwin-x64": {
|
||||||
"version": "2.3.4",
|
"version": "2.3.3",
|
||||||
"resolved": "https://registry.npmjs.org/@rspack/binding-darwin-x64/-/binding-darwin-x64-2.3.4.tgz",
|
"resolved": "https://registry.npmjs.org/@rspack/binding-darwin-x64/-/binding-darwin-x64-2.3.3.tgz",
|
||||||
"integrity": "sha512-CqdfzTLPVFQCniOy/GDVWbg+rqg31qfdzbFf8NYCzdDkCQg+p15hU2HsckD/1sLsaNB8Y55EjGz4ZyGDny0cHg==",
|
"integrity": "sha512-6agI5XDoihay+84vzZgIwwpQQ3xBWbe2HTWBRc0n42LzynIj9h7Qv8CJzf1gSDV1Ts0jzDgAJCYUFJ6Ya5F6MA==",
|
||||||
"cpu": [
|
"cpu": [
|
||||||
"x64"
|
"x64"
|
||||||
],
|
],
|
||||||
@@ -223,16 +223,13 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"node_modules/@rspack/binding-linux-arm64-gnu": {
|
"node_modules/@rspack/binding-linux-arm64-gnu": {
|
||||||
"version": "2.3.4",
|
"version": "2.3.3",
|
||||||
"resolved": "https://registry.npmjs.org/@rspack/binding-linux-arm64-gnu/-/binding-linux-arm64-gnu-2.3.4.tgz",
|
"resolved": "https://registry.npmjs.org/@rspack/binding-linux-arm64-gnu/-/binding-linux-arm64-gnu-2.3.3.tgz",
|
||||||
"integrity": "sha512-T/Y1FYiSegcNc+oHuDOLRGIcc+eSdBnfbS70d51EWQj4+0TG/tlfuqFKeAIL3mnKUV5lDLaTz3vsoD0Sws5Fxw==",
|
"integrity": "sha512-VdjK1mDq+GBexd041lmWBFmAvcWIZy7kepTJbJgxLeHYYOnI3KmBG15kemhlK0pBySa+bePX7p2w8uYtl1HsCA==",
|
||||||
"cpu": [
|
"cpu": [
|
||||||
"arm64"
|
"arm64"
|
||||||
],
|
],
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"libc": [
|
|
||||||
"glibc"
|
|
||||||
],
|
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"optional": true,
|
"optional": true,
|
||||||
"os": [
|
"os": [
|
||||||
@@ -240,16 +237,13 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"node_modules/@rspack/binding-linux-arm64-musl": {
|
"node_modules/@rspack/binding-linux-arm64-musl": {
|
||||||
"version": "2.3.4",
|
"version": "2.3.3",
|
||||||
"resolved": "https://registry.npmjs.org/@rspack/binding-linux-arm64-musl/-/binding-linux-arm64-musl-2.3.4.tgz",
|
"resolved": "https://registry.npmjs.org/@rspack/binding-linux-arm64-musl/-/binding-linux-arm64-musl-2.3.3.tgz",
|
||||||
"integrity": "sha512-WZHCzZ532UfXFXNU8XyM8jb+I6wddegbs/7IXsyw7xiPwwZX1D/M6iKFVpBYdvKcupUM8bS8Uw2REirR/cERVw==",
|
"integrity": "sha512-xF4Wy4XwGjC3m13tFm1q9p9Qpm31qrk6f5zEMPZC31UVabb+2jrgTI1pfZ8IRuo9x/Qw9s+Zq3hyDbtJvvD8Pg==",
|
||||||
"cpu": [
|
"cpu": [
|
||||||
"arm64"
|
"arm64"
|
||||||
],
|
],
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"libc": [
|
|
||||||
"musl"
|
|
||||||
],
|
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"optional": true,
|
"optional": true,
|
||||||
"os": [
|
"os": [
|
||||||
@@ -257,16 +251,13 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"node_modules/@rspack/binding-linux-ppc64-gnu": {
|
"node_modules/@rspack/binding-linux-ppc64-gnu": {
|
||||||
"version": "2.3.4",
|
"version": "2.3.3",
|
||||||
"resolved": "https://registry.npmjs.org/@rspack/binding-linux-ppc64-gnu/-/binding-linux-ppc64-gnu-2.3.4.tgz",
|
"resolved": "https://registry.npmjs.org/@rspack/binding-linux-ppc64-gnu/-/binding-linux-ppc64-gnu-2.3.3.tgz",
|
||||||
"integrity": "sha512-WeizqeI6HIh7Ax9w2tlmpTtipJWxXcdgt3QqI3N9LOixymlMD5yMBMZNPqwZ6cHXT9gOQ69SvPcVgMwxsdmceQ==",
|
"integrity": "sha512-jVmn+LpF44D4FdZyT91rlT/tPMdHIfPfQTgVzwPB5nDICp4b57SFjVBApuAPIxnLT1pKLkv/LIcdvGSdAeX12w==",
|
||||||
"cpu": [
|
"cpu": [
|
||||||
"ppc64"
|
"ppc64"
|
||||||
],
|
],
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"libc": [
|
|
||||||
"glibc"
|
|
||||||
],
|
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"optional": true,
|
"optional": true,
|
||||||
"os": [
|
"os": [
|
||||||
@@ -274,16 +265,13 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"node_modules/@rspack/binding-linux-riscv64-gnu": {
|
"node_modules/@rspack/binding-linux-riscv64-gnu": {
|
||||||
"version": "2.3.4",
|
"version": "2.3.3",
|
||||||
"resolved": "https://registry.npmjs.org/@rspack/binding-linux-riscv64-gnu/-/binding-linux-riscv64-gnu-2.3.4.tgz",
|
"resolved": "https://registry.npmjs.org/@rspack/binding-linux-riscv64-gnu/-/binding-linux-riscv64-gnu-2.3.3.tgz",
|
||||||
"integrity": "sha512-h+001Vbq8LyGwPMNkeRWidPOVKwlAbwNPskY3CjNlSw3euHkVchfhM3uo6+1h0GyTtb3rzsWqsfm1kar7m/tiQ==",
|
"integrity": "sha512-JcQJm8M634jkbG6zJ3TfziKYsCINEAh3FwKuxLljvBgGDEupBxPuB0n2bXBIUeI8P9C33B45IYX6BwWYXll/zw==",
|
||||||
"cpu": [
|
"cpu": [
|
||||||
"riscv64"
|
"riscv64"
|
||||||
],
|
],
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"libc": [
|
|
||||||
"glibc"
|
|
||||||
],
|
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"optional": true,
|
"optional": true,
|
||||||
"os": [
|
"os": [
|
||||||
@@ -291,16 +279,13 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"node_modules/@rspack/binding-linux-riscv64-musl": {
|
"node_modules/@rspack/binding-linux-riscv64-musl": {
|
||||||
"version": "2.3.4",
|
"version": "2.3.3",
|
||||||
"resolved": "https://registry.npmjs.org/@rspack/binding-linux-riscv64-musl/-/binding-linux-riscv64-musl-2.3.4.tgz",
|
"resolved": "https://registry.npmjs.org/@rspack/binding-linux-riscv64-musl/-/binding-linux-riscv64-musl-2.3.3.tgz",
|
||||||
"integrity": "sha512-S1rlaCnNVG5s4WZ9odLsqN3ySh5TEdNTLXWapEK8x3iQl56aLtdvqXTfbJWHWnYLJuS7M1WqnQGdJNdjy2NDsA==",
|
"integrity": "sha512-YMIOS7rFvCDnpeyxoVEVbM7U/TwcC2VDtN3Oiq9BenRsNTEvk0imINhuVRFanh15+wkiQHk9h0b+pzcggYLAsA==",
|
||||||
"cpu": [
|
"cpu": [
|
||||||
"riscv64"
|
"riscv64"
|
||||||
],
|
],
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"libc": [
|
|
||||||
"musl"
|
|
||||||
],
|
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"optional": true,
|
"optional": true,
|
||||||
"os": [
|
"os": [
|
||||||
@@ -308,16 +293,13 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"node_modules/@rspack/binding-linux-s390x-gnu": {
|
"node_modules/@rspack/binding-linux-s390x-gnu": {
|
||||||
"version": "2.3.4",
|
"version": "2.3.3",
|
||||||
"resolved": "https://registry.npmjs.org/@rspack/binding-linux-s390x-gnu/-/binding-linux-s390x-gnu-2.3.4.tgz",
|
"resolved": "https://registry.npmjs.org/@rspack/binding-linux-s390x-gnu/-/binding-linux-s390x-gnu-2.3.3.tgz",
|
||||||
"integrity": "sha512-0SkgGrgulVMam3xel5dMNKQ+U7BEpCczhF1avGT1DzDVIbMfIOsbb32gApQNSz0E7RfAQ/Pa5eWiA9oyRq7ZMQ==",
|
"integrity": "sha512-tHGtIG6GGHsk2KvSleQp/BrVqiGdjDsLJuMKR7hE7W1uJW6WDJ+a+Z23Rk5kHXh5BjeFLjXxcufGuokvmLmTag==",
|
||||||
"cpu": [
|
"cpu": [
|
||||||
"s390x"
|
"s390x"
|
||||||
],
|
],
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"libc": [
|
|
||||||
"glibc"
|
|
||||||
],
|
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"optional": true,
|
"optional": true,
|
||||||
"os": [
|
"os": [
|
||||||
@@ -325,16 +307,13 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"node_modules/@rspack/binding-linux-x64-gnu": {
|
"node_modules/@rspack/binding-linux-x64-gnu": {
|
||||||
"version": "2.3.4",
|
"version": "2.3.3",
|
||||||
"resolved": "https://registry.npmjs.org/@rspack/binding-linux-x64-gnu/-/binding-linux-x64-gnu-2.3.4.tgz",
|
"resolved": "https://registry.npmjs.org/@rspack/binding-linux-x64-gnu/-/binding-linux-x64-gnu-2.3.3.tgz",
|
||||||
"integrity": "sha512-q7E6x3rJJ/9fJyLuRe5+KyEPi23BF/xkAU4xCM5VwLkTf+rVyOkDZfu0qOkxmILjrxllQPV+b/ojBL/ZaIeQPw==",
|
"integrity": "sha512-spe8SjywfO+dD7Sk+vIpPaOXf56wstrgeuztfJdiI9zTeQmf/lhdaNUUSUAXlGIaLjrN/PhV8i5kbQ7VaAkenw==",
|
||||||
"cpu": [
|
"cpu": [
|
||||||
"x64"
|
"x64"
|
||||||
],
|
],
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"libc": [
|
|
||||||
"glibc"
|
|
||||||
],
|
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"optional": true,
|
"optional": true,
|
||||||
"os": [
|
"os": [
|
||||||
@@ -342,16 +321,13 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"node_modules/@rspack/binding-linux-x64-musl": {
|
"node_modules/@rspack/binding-linux-x64-musl": {
|
||||||
"version": "2.3.4",
|
"version": "2.3.3",
|
||||||
"resolved": "https://registry.npmjs.org/@rspack/binding-linux-x64-musl/-/binding-linux-x64-musl-2.3.4.tgz",
|
"resolved": "https://registry.npmjs.org/@rspack/binding-linux-x64-musl/-/binding-linux-x64-musl-2.3.3.tgz",
|
||||||
"integrity": "sha512-rey4Tyasui/WeMn6KfhH5xyZGOMt+Ny+GDK7nGh9TSz/cb3/bisxqGzpbu6GJK8leDmTUDD5ZdpODexytA5rzQ==",
|
"integrity": "sha512-4E4OJodrmsS52zkSAWShG/F07etr0OG4oSrIN+/2BBgc0qR2wwu2T+rAs308IL3lbywlS+J+cynrRcsSFMD+Kg==",
|
||||||
"cpu": [
|
"cpu": [
|
||||||
"x64"
|
"x64"
|
||||||
],
|
],
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"libc": [
|
|
||||||
"musl"
|
|
||||||
],
|
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"optional": true,
|
"optional": true,
|
||||||
"os": [
|
"os": [
|
||||||
@@ -359,9 +335,9 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"node_modules/@rspack/binding-wasm32-wasi": {
|
"node_modules/@rspack/binding-wasm32-wasi": {
|
||||||
"version": "2.3.4",
|
"version": "2.3.3",
|
||||||
"resolved": "https://registry.npmjs.org/@rspack/binding-wasm32-wasi/-/binding-wasm32-wasi-2.3.4.tgz",
|
"resolved": "https://registry.npmjs.org/@rspack/binding-wasm32-wasi/-/binding-wasm32-wasi-2.3.3.tgz",
|
||||||
"integrity": "sha512-sDt2MSXZrIaMBa6UaEqmXEqebwpTOPAXLdo9CYJ2Fa9FJWP4TCYbn30mbvV38ZC2n5YX411DRbjck+s97CceIg==",
|
"integrity": "sha512-AhlsPjW31TGP8N+J7OmbCPaamARUl+OQNiT3xo0PL5Dz5oMm+bEfYLostpehKyy8MNDrmJcY97M9pDb5MDMA0w==",
|
||||||
"cpu": [
|
"cpu": [
|
||||||
"wasm32"
|
"wasm32"
|
||||||
],
|
],
|
||||||
@@ -375,9 +351,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@rspack/binding-win32-arm64-msvc": {
|
"node_modules/@rspack/binding-win32-arm64-msvc": {
|
||||||
"version": "2.3.4",
|
"version": "2.3.3",
|
||||||
"resolved": "https://registry.npmjs.org/@rspack/binding-win32-arm64-msvc/-/binding-win32-arm64-msvc-2.3.4.tgz",
|
"resolved": "https://registry.npmjs.org/@rspack/binding-win32-arm64-msvc/-/binding-win32-arm64-msvc-2.3.3.tgz",
|
||||||
"integrity": "sha512-24YC1YSodLAJ8VsMQJmJSHCNvHTqK9JP5hj50T50WE8lCHNsNl/rIYXO9V0VlCYT/HshE6EHHzAeKdahiEOtcw==",
|
"integrity": "sha512-Zqbj7GBPtkJ8GlUKAjFgvmOxKkQwjfS3XfjwGBcmoIAUb4IxUsmMqvi+gfKrvI45SjYVFZaJnTpOJw6GL79K+Q==",
|
||||||
"cpu": [
|
"cpu": [
|
||||||
"arm64"
|
"arm64"
|
||||||
],
|
],
|
||||||
@@ -389,9 +365,9 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"node_modules/@rspack/binding-win32-ia32-msvc": {
|
"node_modules/@rspack/binding-win32-ia32-msvc": {
|
||||||
"version": "2.3.4",
|
"version": "2.3.3",
|
||||||
"resolved": "https://registry.npmjs.org/@rspack/binding-win32-ia32-msvc/-/binding-win32-ia32-msvc-2.3.4.tgz",
|
"resolved": "https://registry.npmjs.org/@rspack/binding-win32-ia32-msvc/-/binding-win32-ia32-msvc-2.3.3.tgz",
|
||||||
"integrity": "sha512-xmUNu6kgV9lLEkRP1Zb+t6i1Z1ZMEWXmLlMalPx8tHqndz2RflNMBBx6kjB2nAPQBIZgWufwm7dVGS0HKomCmw==",
|
"integrity": "sha512-sJJmbrdzH6kI48mCsUu5a2+BzEktLmHrHUmWGkAPAi0zhi4anA7sOdS1+uERbkkd/XAzs0bdn3JXyT2djY+3IA==",
|
||||||
"cpu": [
|
"cpu": [
|
||||||
"ia32"
|
"ia32"
|
||||||
],
|
],
|
||||||
@@ -403,9 +379,9 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"node_modules/@rspack/binding-win32-x64-msvc": {
|
"node_modules/@rspack/binding-win32-x64-msvc": {
|
||||||
"version": "2.3.4",
|
"version": "2.3.3",
|
||||||
"resolved": "https://registry.npmjs.org/@rspack/binding-win32-x64-msvc/-/binding-win32-x64-msvc-2.3.4.tgz",
|
"resolved": "https://registry.npmjs.org/@rspack/binding-win32-x64-msvc/-/binding-win32-x64-msvc-2.3.3.tgz",
|
||||||
"integrity": "sha512-WY+AkJqpbLtLEZiG1fE7CVJZ54y0qHeCiVmLxGBsh4OOGIDCs6v2Ub5COcPrYVzGJFGyeHUS29dV7JAs93qIHw==",
|
"integrity": "sha512-1r3wxV1pBNykqpbEbZWqcrZd13PKLq0e7Ku6qv8IGKKeftuf3RUxTkeM5AzppGMGEIA9sw8mRdN7NvEXxqLLxw==",
|
||||||
"cpu": [
|
"cpu": [
|
||||||
"x64"
|
"x64"
|
||||||
],
|
],
|
||||||
@@ -417,13 +393,13 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"node_modules/@rspack/core": {
|
"node_modules/@rspack/core": {
|
||||||
"version": "2.3.4",
|
"version": "2.3.3",
|
||||||
"resolved": "https://registry.npmjs.org/@rspack/core/-/core-2.3.4.tgz",
|
"resolved": "https://registry.npmjs.org/@rspack/core/-/core-2.3.3.tgz",
|
||||||
"integrity": "sha512-T8HGkIjPVDlGlIN8st/ICe8Gfixq8te75g/8crSdNSf8F+6884sBcKNky0CRdfPxao1C5SXV+Vjv1XJTjyu83w==",
|
"integrity": "sha512-stAYr0SXf+ZFXFsWTv+Ljxoj/nQs2p7gX9V1kBwlO2IXlRAAhabLONYibT3ZeEGybx3kowrs7uJkcOQsuHgghw==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@rspack/binding": "2.3.4"
|
"@rspack/binding": "2.3.3"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": "^20.19.0 || >=22.12.0"
|
"node": "^20.19.0 || >=22.12.0"
|
||||||
@@ -442,9 +418,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@rspack/plugin-react-refresh": {
|
"node_modules/@rspack/plugin-react-refresh": {
|
||||||
"version": "2.0.3",
|
"version": "2.0.2",
|
||||||
"resolved": "https://registry.npmjs.org/@rspack/plugin-react-refresh/-/plugin-react-refresh-2.0.3.tgz",
|
"resolved": "https://registry.npmjs.org/@rspack/plugin-react-refresh/-/plugin-react-refresh-2.0.2.tgz",
|
||||||
"integrity": "sha512-/K86+2fzdtGdqorm8IwxaouAr5uXFdn7yej0P6/JtuqVYEo9tAUMypGbepAZgt3ClVevn6sC8Oo+fUCLhR10zg==",
|
"integrity": "sha512-dGNZiCxQxgAUI9sah7gd8u+O7OJZRCmqtEJNDOd8xW5RqcieC86F7p5qcShyw6onH5pKf57evpr2VjGbaFGkZg==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
@@ -458,9 +434,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@rspress/core": {
|
"node_modules/@rspress/core": {
|
||||||
"version": "2.1.5",
|
"version": "2.1.4",
|
||||||
"resolved": "https://registry.npmjs.org/@rspress/core/-/core-2.1.5.tgz",
|
"resolved": "https://registry.npmjs.org/@rspress/core/-/core-2.1.4.tgz",
|
||||||
"integrity": "sha512-kzTqrfJ4UiW+RLLHLunoW/rET5Vjb6Qz4YjhEhiWEp4HYM+KxLVhfyYB5aL8af9+mdnwiTaqlu1s+BZGrMD2zw==",
|
"integrity": "sha512-7OmP7ABDgQLSpVfpBHfpjqu4H3PGBGMyhLxF1crPQ48Q6MIWAVu77nw7cONn8AZa9GoVq0N/DoE3GEtgZzlu6w==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
@@ -468,29 +444,27 @@
|
|||||||
"@mdx-js/react": "^3.1.1",
|
"@mdx-js/react": "^3.1.1",
|
||||||
"@rsbuild/core": "^2.3.3",
|
"@rsbuild/core": "^2.3.3",
|
||||||
"@rsbuild/plugin-react": "~2.1.1",
|
"@rsbuild/plugin-react": "~2.1.1",
|
||||||
"@rspress/shared": "2.1.5",
|
"@rspress/shared": "2.1.4",
|
||||||
"@shikijs/rehype": "^4.2.0",
|
"@shikijs/rehype": "^4.2.0",
|
||||||
"@shikijs/transformers": "^4.2.0",
|
"@shikijs/transformers": "^4.2.0",
|
||||||
"@types/mdast": "^4.0.4",
|
"@types/mdast": "^4.0.4",
|
||||||
"@types/react": "^19.3.0",
|
"@types/react": "^19.3.0",
|
||||||
"@unhead/react": "^2.1.18",
|
"@unhead/react": "^2.1.17",
|
||||||
"body-scroll-lock": "4.0.0-beta.0",
|
"body-scroll-lock": "4.0.0-beta.0",
|
||||||
"clsx": "2.1.1",
|
"clsx": "2.1.1",
|
||||||
"copy-to-clipboard": "^3.3.3",
|
"copy-to-clipboard": "^3.3.3",
|
||||||
"flexsearch": "0.8.212",
|
"flexsearch": "0.8.212",
|
||||||
"hast-util-heading-rank": "^3.0.0",
|
"hast-util-heading-rank": "^3.0.0",
|
||||||
"hast-util-to-jsx-runtime": "^2.3.7",
|
"hast-util-to-jsx-runtime": "^2.3.7",
|
||||||
"mdast-util-gfm": "^3.1.0",
|
|
||||||
"mdast-util-mdx": "^3.0.0",
|
"mdast-util-mdx": "^3.0.0",
|
||||||
"mdast-util-mdxjs-esm": "^2.0.1",
|
"mdast-util-mdxjs-esm": "^2.0.1",
|
||||||
"mdast-util-to-markdown": "^2.1.2",
|
|
||||||
"medium-zoom": "1.1.2",
|
"medium-zoom": "1.1.2",
|
||||||
"nprogress": "^0.2.0",
|
"nprogress": "^0.2.0",
|
||||||
"react": "^19.3.1",
|
"react": "^19.3.1",
|
||||||
"react-dom": "^19.3.1",
|
"react-dom": "^19.3.1",
|
||||||
"react-lazy-with-preload": "^2.2.1",
|
"react-lazy-with-preload": "^2.2.1",
|
||||||
"react-render-to-markdown": "19.2.0",
|
"react-render-to-markdown": "19.1.0",
|
||||||
"react-router-dom": "^7.18.6",
|
"react-router-dom": "^7.18.5",
|
||||||
"rehype-external-links": "^3.0.0",
|
"rehype-external-links": "^3.0.0",
|
||||||
"rehype-raw": "^7.0.0",
|
"rehype-raw": "^7.0.0",
|
||||||
"remark-cjk-friendly": "^2.3.4",
|
"remark-cjk-friendly": "^2.3.4",
|
||||||
@@ -514,9 +488,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@rspress/plugin-client-redirects": {
|
"node_modules/@rspress/plugin-client-redirects": {
|
||||||
"version": "2.1.5",
|
"version": "2.1.4",
|
||||||
"resolved": "https://registry.npmjs.org/@rspress/plugin-client-redirects/-/plugin-client-redirects-2.1.5.tgz",
|
"resolved": "https://registry.npmjs.org/@rspress/plugin-client-redirects/-/plugin-client-redirects-2.1.4.tgz",
|
||||||
"integrity": "sha512-vqAi7ynOgVsuwJi7cXwWEF5UgoNhXqGOyBfQubeZHZKWRtdNHRU42P9rG9DZLTss2dZUiDKlVrM2/vNY40t5hw==",
|
"integrity": "sha512-6/g+Mr8lslqiFzlMBouex8TLm6PlQK6cmZ71Yfv82+Uxcrb+LaFAFiPbq2G7gToXBQUoECM4D/7nSLAfeOhnEQ==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"engines": {
|
"engines": {
|
||||||
@@ -527,16 +501,16 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@rspress/shared": {
|
"node_modules/@rspress/shared": {
|
||||||
"version": "2.1.5",
|
"version": "2.1.4",
|
||||||
"resolved": "https://registry.npmjs.org/@rspress/shared/-/shared-2.1.5.tgz",
|
"resolved": "https://registry.npmjs.org/@rspress/shared/-/shared-2.1.4.tgz",
|
||||||
"integrity": "sha512-XXxegxRZ7VPADS2veN9FTNmmLlA65ieydKH0tOhOZbMJC4OJpKbr/d/JS2jxxAO4u+ZmZxbDyEEir83NQHLKIw==",
|
"integrity": "sha512-SuQyVKn9xcQwkzfl+4bPBzX10gxbhCs9UupqSoPtxvyr9pMgSbXnlo3gxTPZXLzk5HUqZZ6tlIju25PVCEtYWA==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@rsbuild/core": "^2.3.3",
|
"@rsbuild/core": "^2.3.3",
|
||||||
"@shikijs/rehype": "^4.2.0",
|
"@shikijs/rehype": "^4.2.0",
|
||||||
"@types/react": "^19.3.0",
|
"@types/react": "^19.3.0",
|
||||||
"mdast-util-mdx-jsx": "^3.2.2",
|
"mdast-util-mdx-jsx": "^3.2.1",
|
||||||
"unified": "^11.0.5"
|
"unified": "^11.0.5"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -709,9 +683,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@types/estree": {
|
"node_modules/@types/estree": {
|
||||||
"version": "1.0.11",
|
"version": "1.0.10",
|
||||||
"resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.11.tgz",
|
"resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.10.tgz",
|
||||||
"integrity": "sha512-YBdNe5JcjYR0sPhJW1QIeRCmI11YhYvaRuGCs9+WCeTTb+Yhb2BE2XMe5/wAqF10FK5g3+q1PDhQABfT7aX0gg==",
|
"integrity": "sha512-lTyOMnOcmRBzdCv6/4zUZCrEhV0xrqQiUZBZtVcbmLHBXKLnN8q89v/wKRF/Q0HbwVsqbIG3o5HDoFl9sduM+g==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
@@ -760,9 +734,9 @@
|
|||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
"node_modules/@types/node": {
|
"node_modules/@types/node": {
|
||||||
"version": "26.6.11",
|
"version": "26.6.6",
|
||||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-26.6.11.tgz",
|
"resolved": "https://registry.npmjs.org/@types/node/-/node-26.6.6.tgz",
|
||||||
"integrity": "sha512-uUyQ2XLEz+EXh34lmS3GhKrkqn/8FU7KUiKRpk347At2bmnMVWss45yz8b4FG/tUtmV1tV/+TVkITItPROyeeQ==",
|
"integrity": "sha512-MzQj+8Kx3XI40OmUAE6Qoh58ZMNstNNMwn2nfd3qWsfe7nDNSqJNzes4njhz6AHwrSHOffSLwXU6yb474Q4aog==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
@@ -770,9 +744,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@types/react": {
|
"node_modules/@types/react": {
|
||||||
"version": "19.3.3",
|
"version": "19.3.0",
|
||||||
"resolved": "https://registry.npmjs.org/@types/react/-/react-19.3.3.tgz",
|
"resolved": "https://registry.npmjs.org/@types/react/-/react-19.3.0.tgz",
|
||||||
"integrity": "sha512-K8uWpJc4teiuOPdiP1umjeA9rGMgVPiXuoL66fcS1QlwBT1WMqY8PORmub9FadopIs+RCW6siYEs7Lpq+vDlog==",
|
"integrity": "sha512-N0rFCuH9YoxG9/m61l9MfpJKfmLOVU0em7ipIz6TRgSSkvReLB9vL85GB+yr8Bs5leqpvg96JSwF4ZS1s4viQg==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
@@ -1134,13 +1108,13 @@
|
|||||||
"license": "ISC"
|
"license": "ISC"
|
||||||
},
|
},
|
||||||
"node_modules/@unhead/react": {
|
"node_modules/@unhead/react": {
|
||||||
"version": "2.1.19",
|
"version": "2.1.17",
|
||||||
"resolved": "https://registry.npmjs.org/@unhead/react/-/react-2.1.19.tgz",
|
"resolved": "https://registry.npmjs.org/@unhead/react/-/react-2.1.17.tgz",
|
||||||
"integrity": "sha512-UNLxU5CgyJw6NzTOsxzUr11pX9zyW1DIHXPwkg2/V1zLcwPKPPcpDkx1tRmWmlajPdpSFZli3xmSrEt1HCGSDw==",
|
"integrity": "sha512-KmcYksDjlLozL0fxUjIDwH/0k6+Lg2HWHLUPlkRW8Gl08hdB1AbLB5iU9QxFvkaT8p0Q4dFEqZWnz3g6RMeiRA==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"unhead": "2.1.19"
|
"unhead": "2.1.17"
|
||||||
},
|
},
|
||||||
"funding": {
|
"funding": {
|
||||||
"url": "https://github.com/sponsors/harlan-zw"
|
"url": "https://github.com/sponsors/harlan-zw"
|
||||||
@@ -1288,9 +1262,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/compute-scroll-into-view": {
|
"node_modules/compute-scroll-into-view": {
|
||||||
"version": "3.2.2",
|
"version": "3.1.1",
|
||||||
"resolved": "https://registry.npmjs.org/compute-scroll-into-view/-/compute-scroll-into-view-3.2.2.tgz",
|
"resolved": "https://registry.npmjs.org/compute-scroll-into-view/-/compute-scroll-into-view-3.1.1.tgz",
|
||||||
"integrity": "sha512-X+jf3y2j3TbtxA3fq3/kBNiSnD1QlIChiIQdAc2Yo1LtOc0yjO1TzgxWJf8PwtKPGgSvSfWUlVvrb7vGx1eYWA==",
|
"integrity": "sha512-VRhuHOLoKYOy4UbilLbUzbYg93XLjv2PncJC50EuTWPA3gaja1UjBsUP/D/9/juV3vQFr6XBEzn9KCAHdUvOHw==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
@@ -1319,9 +1293,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/csstype": {
|
"node_modules/csstype": {
|
||||||
"version": "3.2.4",
|
"version": "3.2.3",
|
||||||
"resolved": "https://registry.npmjs.org/csstype/-/csstype-3.2.4.tgz",
|
"resolved": "https://registry.npmjs.org/csstype/-/csstype-3.2.3.tgz",
|
||||||
"integrity": "sha512-PoKaoPzQapnEoqUSnHx1u6W6ku8CVEgKsnpmmzU3m1nwkidpPBQ8V/Zq2+bWNrsOKoKLwTGdbx6xF7BXP1zLVQ==",
|
"integrity": "sha512-z1HGKcYy2xA8AGQfwrn0PAy+PB7X/GSj3UVJW9qKyn43xWa+gl5nXmU4qqLMRzWVLFC8KusUX8T/0kCiOYpAIQ==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
@@ -1652,9 +1626,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/hast-util-raw": {
|
"node_modules/hast-util-raw": {
|
||||||
"version": "9.2.1",
|
"version": "9.2.0",
|
||||||
"resolved": "https://registry.npmjs.org/hast-util-raw/-/hast-util-raw-9.2.1.tgz",
|
"resolved": "https://registry.npmjs.org/hast-util-raw/-/hast-util-raw-9.2.0.tgz",
|
||||||
"integrity": "sha512-8P0PLAr5C7xCRb+tkhUTV4v6OSNcnccKwjBkH/r19R5CkVCgTWlv4vmTkxFH1CVCA2UJOvOPQdBBMC3c6qnuOg==",
|
"integrity": "sha512-1zVq3M9AlZiBZ4mlMPnLtkK2rdd+I8VhmFLNLb//XJm6xA2AVH2tz19EHy25RgRWut6z6FpTARAs7P8rnmRJUQ==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
@@ -1665,7 +1639,7 @@
|
|||||||
"hast-util-to-parse5": "^8.0.0",
|
"hast-util-to-parse5": "^8.0.0",
|
||||||
"html-void-elements": "^3.0.0",
|
"html-void-elements": "^3.0.0",
|
||||||
"mdast-util-to-hast": "^13.0.0",
|
"mdast-util-to-hast": "^13.0.0",
|
||||||
"parse5": "^8.1.0",
|
"parse5": "^8.0.0",
|
||||||
"unist-util-position": "^5.0.0",
|
"unist-util-position": "^5.0.0",
|
||||||
"unist-util-visit": "^5.0.0",
|
"unist-util-visit": "^5.0.0",
|
||||||
"vfile": "^6.0.0",
|
"vfile": "^6.0.0",
|
||||||
@@ -1707,9 +1681,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/hast-util-to-html": {
|
"node_modules/hast-util-to-html": {
|
||||||
"version": "9.0.7",
|
"version": "9.0.6",
|
||||||
"resolved": "https://registry.npmjs.org/hast-util-to-html/-/hast-util-to-html-9.0.7.tgz",
|
"resolved": "https://registry.npmjs.org/hast-util-to-html/-/hast-util-to-html-9.0.6.tgz",
|
||||||
"integrity": "sha512-HYNDA3qdnzUPitY/LcQm1nWs8z0cWFNH1Nz09jdI/tXifAqF7h3+jrLl4S/b9Mi4VSjn0Dsn54ctuTV6zhBthA==",
|
"integrity": "sha512-1SZUxCN3TtJAE7e2BQN2MBHsoZ1gnmi9GoCP5Di59CSWptIezSAW09yDZyVbanb78V9eCwrKqdQsjtfVTxYHWA==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
@@ -1758,6 +1732,23 @@
|
|||||||
"url": "https://opencollective.com/unified"
|
"url": "https://opencollective.com/unified"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/hast-util-to-jsx-runtime/node_modules/inline-style-parser": {
|
||||||
|
"version": "0.2.9",
|
||||||
|
"resolved": "https://registry.npmjs.org/inline-style-parser/-/inline-style-parser-0.2.9.tgz",
|
||||||
|
"integrity": "sha512-IttN8BqKLxzUrnTqHI+/hwAJQItBAUjdoHERCDv+oOuX48VP6bzW8+QjOXSfoevzq3YrYAwX1uLHp8TqO9yIeg==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT"
|
||||||
|
},
|
||||||
|
"node_modules/hast-util-to-jsx-runtime/node_modules/style-to-object": {
|
||||||
|
"version": "2.0.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/style-to-object/-/style-to-object-2.0.2.tgz",
|
||||||
|
"integrity": "sha512-QmbXPUylqU80HAgTOJeEOdbA40W9KtxmjMhQy+tq+b8F2aoh3aQLuy82hh2jm2qsC9hR9eI0+eQidTMydKcqRA==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"inline-style-parser": "0.2.9"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/hast-util-to-parse5": {
|
"node_modules/hast-util-to-parse5": {
|
||||||
"version": "8.0.1",
|
"version": "8.0.1",
|
||||||
"resolved": "https://registry.npmjs.org/hast-util-to-parse5/-/hast-util-to-parse5-8.0.1.tgz",
|
"resolved": "https://registry.npmjs.org/hast-util-to-parse5/-/hast-util-to-parse5-8.0.1.tgz",
|
||||||
@@ -1842,13 +1833,6 @@
|
|||||||
"url": "https://github.com/sponsors/wooorm"
|
"url": "https://github.com/sponsors/wooorm"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/inline-style-parser": {
|
|
||||||
"version": "0.2.9",
|
|
||||||
"resolved": "https://registry.npmjs.org/inline-style-parser/-/inline-style-parser-0.2.9.tgz",
|
|
||||||
"integrity": "sha512-IttN8BqKLxzUrnTqHI+/hwAJQItBAUjdoHERCDv+oOuX48VP6bzW8+QjOXSfoevzq3YrYAwX1uLHp8TqO9yIeg==",
|
|
||||||
"dev": true,
|
|
||||||
"license": "MIT"
|
|
||||||
},
|
|
||||||
"node_modules/is-absolute-url": {
|
"node_modules/is-absolute-url": {
|
||||||
"version": "4.0.1",
|
"version": "4.0.1",
|
||||||
"resolved": "https://registry.npmjs.org/is-absolute-url/-/is-absolute-url-4.0.1.tgz",
|
"resolved": "https://registry.npmjs.org/is-absolute-url/-/is-absolute-url-4.0.1.tgz",
|
||||||
@@ -1959,9 +1943,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/mdast-util-find-and-replace": {
|
"node_modules/mdast-util-find-and-replace": {
|
||||||
"version": "3.0.5",
|
"version": "3.0.4",
|
||||||
"resolved": "https://registry.npmjs.org/mdast-util-find-and-replace/-/mdast-util-find-and-replace-3.0.5.tgz",
|
"resolved": "https://registry.npmjs.org/mdast-util-find-and-replace/-/mdast-util-find-and-replace-3.0.4.tgz",
|
||||||
"integrity": "sha512-of3wZLEBWpK8mSYy8wmKnwyxfUKjhCkXxGLz45DVBqfcahTP37LscCK+0oAZh+ReZ5OunPDkB2zdGMIxrojLhw==",
|
"integrity": "sha512-z4B5c6jrnJ1ltOQemhWYPBSAo6y42Z8Gt2yEgfgNTMcLSU59B8bfj8Z8AnAlJrBGLnqkdAUZ7jdDEqQw3KuipQ==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
@@ -2021,9 +2005,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/mdast-util-gfm-autolink-literal": {
|
"node_modules/mdast-util-gfm-autolink-literal": {
|
||||||
"version": "2.1.2",
|
"version": "2.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/mdast-util-gfm-autolink-literal/-/mdast-util-gfm-autolink-literal-2.1.2.tgz",
|
"resolved": "https://registry.npmjs.org/mdast-util-gfm-autolink-literal/-/mdast-util-gfm-autolink-literal-2.1.0.tgz",
|
||||||
"integrity": "sha512-rAlbZBGZfv2YRr6lSFGHTN305KkNawOYRRlbldFyPHnTlHJZwlGdzVwyIDvr3fxbhRbmJOSZc06c8H5Fgfu8Ng==",
|
"integrity": "sha512-Jx6QSK8wDo558Bcf7q+1pe0v81g2PVs09Hlvu9xJHmCFRF3sAPW7vXFVIAwBncs3sde92WbsVqNxwdqViA2XnQ==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
@@ -2147,9 +2131,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/mdast-util-mdx-jsx": {
|
"node_modules/mdast-util-mdx-jsx": {
|
||||||
"version": "3.2.2",
|
"version": "3.2.1",
|
||||||
"resolved": "https://registry.npmjs.org/mdast-util-mdx-jsx/-/mdast-util-mdx-jsx-3.2.2.tgz",
|
"resolved": "https://registry.npmjs.org/mdast-util-mdx-jsx/-/mdast-util-mdx-jsx-3.2.1.tgz",
|
||||||
"integrity": "sha512-/0FHaZMv2fSjIL3z/NYmXnQTSdzYyamPpI1BXpSCngTUqpSvMNIlERa26ABz+Z6UFQbrh3I5Yhzp448WZsPfMA==",
|
"integrity": "sha512-oXp1GIa+E9IwIs3a106+tr3Bz2MlTTBvlXjOZMoIat11kk7vjqgmBnksB9WHmWv+gZh7k3IUgpAHlwHB7DH4GQ==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
@@ -2206,9 +2190,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/mdast-util-to-hast": {
|
"node_modules/mdast-util-to-hast": {
|
||||||
"version": "13.2.2",
|
"version": "13.2.1",
|
||||||
"resolved": "https://registry.npmjs.org/mdast-util-to-hast/-/mdast-util-to-hast-13.2.2.tgz",
|
"resolved": "https://registry.npmjs.org/mdast-util-to-hast/-/mdast-util-to-hast-13.2.1.tgz",
|
||||||
"integrity": "sha512-l2pnmOuqs+SGLVpTVXnRLQu5v1AzvDe181404fbXzzqObVxrAnnVxapAP27pUwzLBL/ABIkgUhGlPVU7QSvIFg==",
|
"integrity": "sha512-cctsq2wp5vTsLIcaymblUriiTcZd0CwWtCbLvrOzYCDZoWyMNV8sZ7krj09FSnsiJi3WVsHLM4k6Dq/yaPyCXA==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
@@ -2228,9 +2212,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/mdast-util-to-markdown": {
|
"node_modules/mdast-util-to-markdown": {
|
||||||
"version": "2.2.4",
|
"version": "2.2.3",
|
||||||
"resolved": "https://registry.npmjs.org/mdast-util-to-markdown/-/mdast-util-to-markdown-2.2.4.tgz",
|
"resolved": "https://registry.npmjs.org/mdast-util-to-markdown/-/mdast-util-to-markdown-2.2.3.tgz",
|
||||||
"integrity": "sha512-aCsogoZ2Oz1EItAlC12A+/uGuzp+CWlDU0xZ3o5jbJaepLsOu2tlxpvHslnX5dRhspD1gxNVkBtYG0yMiIpXoQ==",
|
"integrity": "sha512-dImdB6VZRMRac1SwAW6o1c0ESk/7pFFAMCMuKM+9v7LpTSthMM5nzXpqKw4Mjo66aXVKhNkyrP4bMB9MurPyWg==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
@@ -3320,9 +3304,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/react-render-to-markdown": {
|
"node_modules/react-render-to-markdown": {
|
||||||
"version": "19.2.0",
|
"version": "19.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/react-render-to-markdown/-/react-render-to-markdown-19.2.0.tgz",
|
"resolved": "https://registry.npmjs.org/react-render-to-markdown/-/react-render-to-markdown-19.1.0.tgz",
|
||||||
"integrity": "sha512-hVF80DyFXazwW8vuUaptMwnW9ZZHMRrLE3WE36U3Iz1M6pPrFbtE8yYcTq8CYRBVn7YdagJUR/2ik3qJD2Rlvg==",
|
"integrity": "sha512-dF9b3tO41ezqdmHP8X92kbHbMexJ6iC7iHw4ykC8fwiO7DgpFc9PhMoKlI+BcPzRxGcWgQSdrixVB9RykhjJpQ==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
@@ -3333,9 +3317,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/react-router": {
|
"node_modules/react-router": {
|
||||||
"version": "7.18.7",
|
"version": "7.18.5",
|
||||||
"resolved": "https://registry.npmjs.org/react-router/-/react-router-7.18.7.tgz",
|
"resolved": "https://registry.npmjs.org/react-router/-/react-router-7.18.5.tgz",
|
||||||
"integrity": "sha512-nXl672FFobymVY/Ywbo0DnlXV/+VXOB5pOslCeuVqoegwwL7sau2yASdyGoWHvPRxAoqUBrAiFZRdli4nT7Wow==",
|
"integrity": "sha512-dTgvcXDOrLPrlLHrcZAqWveiK1hMSqN+rGAJzegP8HtmNkfRxOoshGWBNX3ZJ0cZjOHkRdlUJtaIhZMLLyGyPw==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
@@ -3346,27 +3330,23 @@
|
|||||||
"node": ">=20.0.0"
|
"node": ">=20.0.0"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"@types/react": ">=18",
|
|
||||||
"react": ">=18",
|
"react": ">=18",
|
||||||
"react-dom": ">=18"
|
"react-dom": ">=18"
|
||||||
},
|
},
|
||||||
"peerDependenciesMeta": {
|
"peerDependenciesMeta": {
|
||||||
"@types/react": {
|
|
||||||
"optional": true
|
|
||||||
},
|
|
||||||
"react-dom": {
|
"react-dom": {
|
||||||
"optional": true
|
"optional": true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/react-router-dom": {
|
"node_modules/react-router-dom": {
|
||||||
"version": "7.18.7",
|
"version": "7.18.5",
|
||||||
"resolved": "https://registry.npmjs.org/react-router-dom/-/react-router-dom-7.18.7.tgz",
|
"resolved": "https://registry.npmjs.org/react-router-dom/-/react-router-dom-7.18.5.tgz",
|
||||||
"integrity": "sha512-EBWBKV1TjvScebAIvidowN0Bfh9Bg7p54IDBRVJkFXz0wBKTBblDNLxUvCewx/GdzTiC7VWV/MOjWqsLWEMygA==",
|
"integrity": "sha512-9HcfDMU6JJ/fp6gJZYGwNE6RknVGS4kBjH1HkNw959mCJi70TVwdipQWv2FEol9uGpi+SZTFtVpJPtEQfayeOw==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"react-router": "7.18.7"
|
"react-router": "7.18.5"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=20.0.0"
|
"node": ">=20.0.0"
|
||||||
@@ -3664,13 +3644,13 @@
|
|||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
"node_modules/scroll-into-view-if-needed": {
|
"node_modules/scroll-into-view-if-needed": {
|
||||||
"version": "3.2.1",
|
"version": "3.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/scroll-into-view-if-needed/-/scroll-into-view-if-needed-3.2.1.tgz",
|
"resolved": "https://registry.npmjs.org/scroll-into-view-if-needed/-/scroll-into-view-if-needed-3.1.0.tgz",
|
||||||
"integrity": "sha512-dgeJvJhSV9MY6hyhtsivbSxHoZVm+lumsWTObtUdAchJflwOGmKKHNkEpU8pVYMomZ8h/yrfzVQkcPlObQNDWQ==",
|
"integrity": "sha512-49oNpRjWRvnU8NyGVmUaYG4jtTkNonFZI86MmGRDqBphEK2EXT9gdEUoQPZhuBM8yWHxCWbobltqYO5M4XrUvQ==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"compute-scroll-into-view": "^3.2.2"
|
"compute-scroll-into-view": "^3.0.2"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/set-cookie-parser": {
|
"node_modules/set-cookie-parser": {
|
||||||
@@ -3722,9 +3702,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/stringify-entities": {
|
"node_modules/stringify-entities": {
|
||||||
"version": "4.0.5",
|
"version": "4.0.4",
|
||||||
"resolved": "https://registry.npmjs.org/stringify-entities/-/stringify-entities-4.0.5.tgz",
|
"resolved": "https://registry.npmjs.org/stringify-entities/-/stringify-entities-4.0.4.tgz",
|
||||||
"integrity": "sha512-jNuI2fNNw5ecxrWmgm90R3iH0Kc/94AQwoQWoSUYphWzvmUA2pjFG34H56Z7Z3FkvH3FpYwwewKAa97oQnPFhw==",
|
"integrity": "sha512-IwfBptatlO+QCJUo19AqvrPNqlVMpW9YEL2LIVY+Rpv2qsjCGxaDLNRgeGsQWJhfItebuJhsGSLjaBbNSQ+ieg==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
@@ -3763,16 +3743,6 @@
|
|||||||
"inline-style-parser": "0.2.7"
|
"inline-style-parser": "0.2.7"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/style-to-object": {
|
|
||||||
"version": "2.0.2",
|
|
||||||
"resolved": "https://registry.npmjs.org/style-to-object/-/style-to-object-2.0.2.tgz",
|
|
||||||
"integrity": "sha512-QmbXPUylqU80HAgTOJeEOdbA40W9KtxmjMhQy+tq+b8F2aoh3aQLuy82hh2jm2qsC9hR9eI0+eQidTMydKcqRA==",
|
|
||||||
"dev": true,
|
|
||||||
"license": "MIT",
|
|
||||||
"dependencies": {
|
|
||||||
"inline-style-parser": "0.2.9"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/toggle-selection": {
|
"node_modules/toggle-selection": {
|
||||||
"version": "1.0.6",
|
"version": "1.0.6",
|
||||||
"resolved": "https://registry.npmjs.org/toggle-selection/-/toggle-selection-1.0.6.tgz",
|
"resolved": "https://registry.npmjs.org/toggle-selection/-/toggle-selection-1.0.6.tgz",
|
||||||
@@ -3853,45 +3823,18 @@
|
|||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
"node_modules/unhead": {
|
"node_modules/unhead": {
|
||||||
"version": "2.1.19",
|
"version": "2.1.17",
|
||||||
"resolved": "https://registry.npmjs.org/unhead/-/unhead-2.1.19.tgz",
|
"resolved": "https://registry.npmjs.org/unhead/-/unhead-2.1.17.tgz",
|
||||||
"integrity": "sha512-W+zxYQeulbi738I839IQFxOgdAzkNWLrNdaK0XmRGAqcDhojlFufESM7d/IeaMwPmue1rff27Sdl6NNckZqrrQ==",
|
"integrity": "sha512-HLMKXOszRhAPBrr6VlqCeVeJq2kbC4kXwzGLEZvvojPLWNYTJw22xG7Bfwhsvs31+IBet3Wl8ADg9dwYdyphfQ==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"hookable": "^6.0.1",
|
"hookable": "^6.0.1"
|
||||||
"parse5": "^7.3.0"
|
|
||||||
},
|
},
|
||||||
"funding": {
|
"funding": {
|
||||||
"url": "https://github.com/sponsors/harlan-zw"
|
"url": "https://github.com/sponsors/harlan-zw"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/unhead/node_modules/entities": {
|
|
||||||
"version": "6.0.1",
|
|
||||||
"resolved": "https://registry.npmjs.org/entities/-/entities-6.0.1.tgz",
|
|
||||||
"integrity": "sha512-aN97NXWF6AWBTahfVOIrB/NShkzi5H7F9r1s9mD3cDj4Ko5f2qhhVoYMibXF7GlLveb/D2ioWay8lxI97Ven3g==",
|
|
||||||
"dev": true,
|
|
||||||
"license": "BSD-2-Clause",
|
|
||||||
"engines": {
|
|
||||||
"node": ">=0.12"
|
|
||||||
},
|
|
||||||
"funding": {
|
|
||||||
"url": "https://github.com/fb55/entities?sponsor=1"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/unhead/node_modules/parse5": {
|
|
||||||
"version": "7.3.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/parse5/-/parse5-7.3.0.tgz",
|
|
||||||
"integrity": "sha512-IInvU7fabl34qmi9gY8XOVxhYyMyuH2xUNpb2q8/Y+7552KlejkRvqvD19nMoUW/uQGGbqNpA6Tufu5FL5BZgw==",
|
|
||||||
"dev": true,
|
|
||||||
"license": "MIT",
|
|
||||||
"dependencies": {
|
|
||||||
"entities": "^6.0.0"
|
|
||||||
},
|
|
||||||
"funding": {
|
|
||||||
"url": "https://github.com/inikulin/parse5?sponsor=1"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/unified": {
|
"node_modules/unified": {
|
||||||
"version": "11.0.5",
|
"version": "11.0.5",
|
||||||
"resolved": "https://registry.npmjs.org/unified/-/unified-11.0.5.tgz",
|
"resolved": "https://registry.npmjs.org/unified/-/unified-11.0.5.tgz",
|
||||||
|
|||||||
+1
-1
@@ -24,7 +24,7 @@
|
|||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@rspress/core": "^2.0.0",
|
"@rspress/core": "^2.0.0",
|
||||||
"@rspress/plugin-client-redirects": "^2.0.0",
|
"@rspress/plugin-client-redirects": "^2.0.0",
|
||||||
"@types/node": "^26.6.7",
|
"@types/node": "^26.6.6",
|
||||||
"typescript": "^7.0.0"
|
"typescript": "^7.0.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+1
-10
@@ -1,9 +1,7 @@
|
|||||||
{
|
{
|
||||||
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
|
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
|
||||||
"extends": ["config:recommended", "replacements:all", ":semanticCommitTypeAll(chore)", "helpers:pinGitHubActionDigests"],
|
"extends": ["config:recommended", "replacements:all", ":semanticCommitTypeAll(chore)", "helpers:pinGitHubActionDigests"],
|
||||||
"dependencyDashboard": {
|
"dependencyDashboard": true,
|
||||||
"enabled": true
|
|
||||||
},
|
|
||||||
"osvVulnerabilityAlerts": true,
|
"osvVulnerabilityAlerts": true,
|
||||||
"lockFileMaintenance": {
|
"lockFileMaintenance": {
|
||||||
"enabled": true,
|
"enabled": true,
|
||||||
@@ -92,13 +90,6 @@
|
|||||||
"matchUpdateTypes": ["patch"],
|
"matchUpdateTypes": ["patch"],
|
||||||
"groupName": "node-patch-updates"
|
"groupName": "node-patch-updates"
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"description": "Batch patch-level Go dependency updates",
|
|
||||||
"matchManagers": ["gomod"],
|
|
||||||
"matchUpdateTypes": ["patch"],
|
|
||||||
"postUpdateOptions": ["gomodTidy"],
|
|
||||||
"groupName": "go-patch-updates"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"description": "Pin forgejo artifact actions to prevent breaking changes",
|
"description": "Pin forgejo artifact actions to prevent breaking changes",
|
||||||
"matchManagers": ["github-actions"],
|
"matchManagers": ["github-actions"],
|
||||||
|
|||||||
@@ -79,7 +79,6 @@ export default defineConfig({
|
|||||||
enableContentAnimation: true,
|
enableContentAnimation: true,
|
||||||
enableAppearanceAnimation: false,
|
enableAppearanceAnimation: false,
|
||||||
footer: {},
|
footer: {},
|
||||||
darkMode: 'auto'
|
|
||||||
},
|
},
|
||||||
|
|
||||||
plugins: [pluginClientRedirects({
|
plugins: [pluginClientRedirects({
|
||||||
|
|||||||
+1
-1
@@ -10,7 +10,7 @@
|
|||||||
|
|
||||||
[toolchain]
|
[toolchain]
|
||||||
profile = "minimal"
|
profile = "minimal"
|
||||||
channel = "1.100.1"
|
channel = "1.100.0"
|
||||||
components = [
|
components = [
|
||||||
# For rust-analyzer
|
# For rust-analyzer
|
||||||
"rust-src",
|
"rust-src",
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ use std::time::Duration;
|
|||||||
|
|
||||||
use axum::extract::State;
|
use axum::extract::State;
|
||||||
use conduwuit::{
|
use conduwuit::{
|
||||||
Err, Result, debug, err,
|
Err, Result, err,
|
||||||
utils::{self, content_disposition::make_content_disposition, math::ruma_from_usize},
|
utils::{self, content_disposition::make_content_disposition, math::ruma_from_usize},
|
||||||
};
|
};
|
||||||
use conduwuit_core::error;
|
use conduwuit_core::error;
|
||||||
@@ -219,12 +219,10 @@ pub(crate) async fn get_media_preview_route(
|
|||||||
)));
|
)));
|
||||||
}
|
}
|
||||||
|
|
||||||
debug!("Fetching a URL preview for {url} on behalf of {sender_user}");
|
|
||||||
let preview = services
|
let preview = services
|
||||||
.media
|
.media
|
||||||
.get_url_preview(&url)
|
.get_url_preview(&url)
|
||||||
.await
|
.await
|
||||||
.inspect(|_| debug!(user=%sender_user, %url, "Finished fetching a URL preview"))
|
|
||||||
.map_err(|error| {
|
.map_err(|error| {
|
||||||
err!(Request(Unknown(
|
err!(Request(Unknown(
|
||||||
debug_error!(%sender_user, %url, "Failed to fetch URL preview: {error}")
|
debug_error!(%sender_user, %url, "Failed to fetch URL preview: {error}")
|
||||||
|
|||||||
+488
-252
@@ -1,10 +1,9 @@
|
|||||||
use std::collections::{HashMap, hash_map::Entry};
|
use std::{borrow::Borrow, collections::HashMap, sync::Arc};
|
||||||
|
|
||||||
use axum::extract::State;
|
use axum::extract::State;
|
||||||
use conduwuit::{
|
use conduwuit::{
|
||||||
Err, EventTypeExt, Result, debug, debug_warn, err, info,
|
Err, Result, debug, debug_info, debug_warn, err, info,
|
||||||
matrix::{
|
matrix::{
|
||||||
StateKey,
|
|
||||||
event::gen_event_id,
|
event::gen_event_id,
|
||||||
pdu::{PartialPdu, PduEvent},
|
pdu::{PartialPdu, PduEvent},
|
||||||
},
|
},
|
||||||
@@ -16,25 +15,28 @@ use conduwuit::{
|
|||||||
use futures::{FutureExt, StreamExt};
|
use futures::{FutureExt, StreamExt};
|
||||||
use ruma::{
|
use ruma::{
|
||||||
CanonicalJsonObject, CanonicalJsonValue, OwnedEventId, OwnedRoomId, OwnedServerName,
|
CanonicalJsonObject, CanonicalJsonValue, OwnedEventId, OwnedRoomId, OwnedServerName,
|
||||||
OwnedUserId, RoomId, RoomVersionId, UserId,
|
OwnedUserId, RoomId, UserId,
|
||||||
api::{
|
api::{client::knock::knock_room, federation},
|
||||||
client::knock::knock_room,
|
|
||||||
error::{ErrorKind, IncompatibleRoomVersionErrorData},
|
|
||||||
federation::{self, membership::RawStrippedState},
|
|
||||||
},
|
|
||||||
canonical_json::to_canonical_value,
|
canonical_json::to_canonical_value,
|
||||||
events::{
|
events::{
|
||||||
StateEventType,
|
StateEventType,
|
||||||
room::member::{MembershipState, RoomMemberEventContent},
|
room::{
|
||||||
|
join_rules::{AllowRule, JoinRule},
|
||||||
|
member::{MembershipState, RoomMemberEventContent},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
use service::{
|
use service::{
|
||||||
Services,
|
Services,
|
||||||
rooms::{membership::validate_remote_member_event_stub, state::RoomMutexGuard},
|
rooms::{
|
||||||
|
membership::validate_remote_member_event_stub,
|
||||||
|
state::RoomMutexGuard,
|
||||||
|
state_compressor::{CompressedState, HashSetCompressStateEvent},
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::banned_room_check;
|
use super::banned_room_check;
|
||||||
use crate::{Ruma, server::validate_partial_membership_event};
|
use crate::Ruma;
|
||||||
|
|
||||||
/// # `POST /_matrix/client/*/knock/{roomIdOrAlias}`
|
/// # `POST /_matrix/client/*/knock/{roomIdOrAlias}`
|
||||||
///
|
///
|
||||||
@@ -56,42 +58,30 @@ pub(crate) async fn knock_room_route(
|
|||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
let mut servers = body.via.clone();
|
let mut servers = body.via.clone();
|
||||||
if servers.is_empty() {
|
servers.extend(
|
||||||
debug!("No via servers provided for knock, injecting some.");
|
services
|
||||||
servers.extend(
|
.rooms
|
||||||
services
|
.state_cache
|
||||||
.rooms
|
.servers_invite_via(&room_id)
|
||||||
.state_cache
|
.collect::<Vec<_>>()
|
||||||
.servers_invite_via(&room_id)
|
.await,
|
||||||
.collect::<Vec<_>>()
|
);
|
||||||
.await,
|
|
||||||
);
|
|
||||||
|
|
||||||
let invite_state = services
|
servers.extend(
|
||||||
|
services
|
||||||
.rooms
|
.rooms
|
||||||
.state_cache
|
.state_cache
|
||||||
.invite_state(sender_user, &room_id)
|
.invite_state(sender_user, &room_id)
|
||||||
.await
|
.await
|
||||||
.unwrap_or_default();
|
.unwrap_or_default()
|
||||||
let knock_state = services
|
.iter()
|
||||||
.rooms
|
.filter_map(|event| event.get_field("sender").ok().flatten())
|
||||||
.state_cache
|
.filter_map(|sender: &str| UserId::parse(sender).ok())
|
||||||
.knock_state(sender_user, &room_id)
|
.map(|user| user.server_name().to_owned()),
|
||||||
.await
|
);
|
||||||
.unwrap_or_default();
|
|
||||||
|
|
||||||
servers.extend(
|
if let Some(server) = room_id.server_name() {
|
||||||
invite_state
|
servers.push(server.to_owned());
|
||||||
.iter()
|
|
||||||
.chain(knock_state.iter())
|
|
||||||
.filter_map(|event| event.get_field("sender").ok().flatten())
|
|
||||||
.filter_map(|sender: &str| UserId::parse(sender).ok())
|
|
||||||
.map(|user| user.server_name().to_owned()),
|
|
||||||
);
|
|
||||||
|
|
||||||
if let Some(server) = room_id.server_name() {
|
|
||||||
servers.push(server.to_owned());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
servers.sort_unstable();
|
servers.sort_unstable();
|
||||||
@@ -113,28 +103,20 @@ pub(crate) async fn knock_room_route(
|
|||||||
|
|
||||||
let addl_via_servers = services.rooms.state_cache.servers_invite_via(&room_id);
|
let addl_via_servers = services.rooms.state_cache.servers_invite_via(&room_id);
|
||||||
|
|
||||||
let addl_invite_state = services
|
let addl_state_servers = services
|
||||||
.rooms
|
.rooms
|
||||||
.state_cache
|
.state_cache
|
||||||
.invite_state(sender_user, &room_id)
|
.invite_state(sender_user, &room_id)
|
||||||
.await
|
.await
|
||||||
.unwrap_or_default();
|
.unwrap_or_default();
|
||||||
let addl_knock_state = services
|
|
||||||
.rooms
|
|
||||||
.state_cache
|
|
||||||
.knock_state(sender_user, &room_id)
|
|
||||||
.await
|
|
||||||
.unwrap_or_default();
|
|
||||||
|
|
||||||
let mut addl_servers: Vec<_> = addl_invite_state
|
let mut addl_servers: Vec<_> = addl_state_servers
|
||||||
.iter()
|
.iter()
|
||||||
.chain(addl_knock_state.iter())
|
|
||||||
.map(|event| event.get_field("sender"))
|
.map(|event| event.get_field("sender"))
|
||||||
.filter_map(FlatOk::flat_ok)
|
.filter_map(FlatOk::flat_ok)
|
||||||
.map(|user: OwnedUserId| user.server_name().to_owned())
|
.map(|user: OwnedUserId| user.server_name().to_owned())
|
||||||
.stream()
|
.stream()
|
||||||
.chain(addl_via_servers)
|
.chain(addl_via_servers)
|
||||||
.chain(body.via.iter().cloned().stream())
|
|
||||||
.collect()
|
.collect()
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
@@ -161,69 +143,165 @@ async fn knock_room_by_id_helper(
|
|||||||
) -> Result<knock_room::v3::Response> {
|
) -> Result<knock_room::v3::Response> {
|
||||||
let state_lock = services.rooms.state.mutex.lock(room_id).await;
|
let state_lock = services.rooms.state.mutex.lock(room_id).await;
|
||||||
|
|
||||||
|
if services
|
||||||
|
.rooms
|
||||||
|
.state_cache
|
||||||
|
.is_invited(sender_user, room_id)
|
||||||
|
.await
|
||||||
|
{
|
||||||
|
debug_warn!("{sender_user} is already invited in {room_id} but attempted to knock");
|
||||||
|
return Err!(Request(Forbidden(
|
||||||
|
"You cannot knock on a room you are already invited/accepted to."
|
||||||
|
)));
|
||||||
|
}
|
||||||
|
|
||||||
|
if services
|
||||||
|
.rooms
|
||||||
|
.state_cache
|
||||||
|
.is_joined(sender_user, room_id)
|
||||||
|
.await
|
||||||
|
{
|
||||||
|
debug_warn!("{sender_user} is already joined in {room_id} but attempted to knock");
|
||||||
|
return Err!(Request(Forbidden("You cannot knock on a room you are already joined in.")));
|
||||||
|
}
|
||||||
|
|
||||||
|
if services
|
||||||
|
.rooms
|
||||||
|
.state_cache
|
||||||
|
.is_knocked(sender_user, room_id)
|
||||||
|
.await
|
||||||
|
{
|
||||||
|
debug_warn!("{sender_user} is already knocked in {room_id}");
|
||||||
|
return Ok(knock_room::v3::Response::new(room_id.into()));
|
||||||
|
}
|
||||||
|
|
||||||
|
if let Ok(membership) = services
|
||||||
|
.rooms
|
||||||
|
.state_accessor
|
||||||
|
.get_member(room_id, sender_user)
|
||||||
|
.await
|
||||||
|
{
|
||||||
|
if membership.membership == MembershipState::Ban {
|
||||||
|
debug_warn!("{sender_user} is banned from {room_id} but attempted to knock");
|
||||||
|
return Err!(Request(Forbidden("You cannot knock on a room you are banned from.")));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// For knock_restricted rooms, check if the user meets the restricted
|
||||||
|
// conditions If they do, attempt to join instead of knock
|
||||||
|
// This is not mentioned in the spec, but should be allowable (we're allowed
|
||||||
|
// to auto-join invites to knocked rooms)
|
||||||
|
let join_rule = services.rooms.state_accessor.get_join_rules(room_id).await;
|
||||||
|
|
||||||
|
if let JoinRule::KnockRestricted(restricted) = &join_rule {
|
||||||
|
let restriction_rooms: Vec<_> = restricted
|
||||||
|
.allow
|
||||||
|
.iter()
|
||||||
|
.filter_map(|a| match a {
|
||||||
|
| AllowRule::RoomMembership(r) => Some(&r.room_id),
|
||||||
|
| _ => None,
|
||||||
|
})
|
||||||
|
.collect();
|
||||||
|
|
||||||
|
// Check if the user is in any of the allowed rooms
|
||||||
|
let mut user_meets_restrictions = false;
|
||||||
|
for restriction_room_id in &restriction_rooms {
|
||||||
|
if services
|
||||||
|
.rooms
|
||||||
|
.state_cache
|
||||||
|
.is_joined(sender_user, restriction_room_id)
|
||||||
|
.await
|
||||||
|
{
|
||||||
|
user_meets_restrictions = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// If the user meets the restrictions, try joining instead
|
||||||
|
if user_meets_restrictions {
|
||||||
|
debug_info!(
|
||||||
|
"{sender_user} meets the restricted criteria in knock_restricted room \
|
||||||
|
{room_id}, attempting to join instead of knock"
|
||||||
|
);
|
||||||
|
// For this case, we need to drop the state lock and get a new one
|
||||||
|
// in join_room_by_id_helper We need to release the lock here and
|
||||||
|
// let join_room_by_id_helper acquire it again
|
||||||
|
drop(state_lock);
|
||||||
|
match services
|
||||||
|
.rooms
|
||||||
|
.membership
|
||||||
|
.join_room(sender_user, room_id, reason.clone(), servers)
|
||||||
|
.await
|
||||||
|
{
|
||||||
|
| Ok(_) => return Ok(knock_room::v3::Response::new(room_id.to_owned())),
|
||||||
|
| Err(e) => {
|
||||||
|
debug_warn!(
|
||||||
|
"Failed to convert knock to join for {sender_user} in {room_id}: {e:?}"
|
||||||
|
);
|
||||||
|
// Get a new state lock for the remaining knock logic
|
||||||
|
let new_state_lock = services.rooms.state.mutex.lock(room_id).await;
|
||||||
|
|
||||||
|
let server_in_room = services
|
||||||
|
.rooms
|
||||||
|
.state_cache
|
||||||
|
.server_in_room(services.globals.server_name(), room_id)
|
||||||
|
.await;
|
||||||
|
|
||||||
|
let local_knock = server_in_room
|
||||||
|
|| servers.is_empty()
|
||||||
|
|| (servers.len() == 1 && services.globals.server_is_ours(&servers[0]));
|
||||||
|
|
||||||
|
if local_knock {
|
||||||
|
knock_room_helper_local(
|
||||||
|
services,
|
||||||
|
sender_user,
|
||||||
|
room_id,
|
||||||
|
reason,
|
||||||
|
servers,
|
||||||
|
new_state_lock,
|
||||||
|
)
|
||||||
|
.boxed()
|
||||||
|
.await?;
|
||||||
|
} else {
|
||||||
|
knock_room_helper_remote(
|
||||||
|
services,
|
||||||
|
sender_user,
|
||||||
|
room_id,
|
||||||
|
reason,
|
||||||
|
servers,
|
||||||
|
new_state_lock,
|
||||||
|
)
|
||||||
|
.boxed()
|
||||||
|
.await?;
|
||||||
|
}
|
||||||
|
|
||||||
|
return Ok(knock_room::v3::Response::new(room_id.to_owned()));
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if !matches!(join_rule, JoinRule::Knock | JoinRule::KnockRestricted(_)) {
|
||||||
|
debug_warn!(
|
||||||
|
"{sender_user} attempted to knock on room {room_id} but its join rule is \
|
||||||
|
{join_rule:?}, not knock or knock_restricted"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
let server_in_room = services
|
let server_in_room = services
|
||||||
.rooms
|
.rooms
|
||||||
.state_cache
|
.state_cache
|
||||||
.server_in_room(services.globals.server_name(), room_id)
|
.server_in_room(services.globals.server_name(), room_id)
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
// Only check our known membership if we're already in the room.
|
let local_knock = server_in_room
|
||||||
if server_in_room {
|
|| servers.is_empty()
|
||||||
if services
|
|| (servers.len() == 1 && services.globals.server_is_ours(&servers[0]));
|
||||||
.rooms
|
|
||||||
.state_cache
|
|
||||||
.is_invited(sender_user, room_id)
|
|
||||||
.await
|
|
||||||
{
|
|
||||||
debug_warn!("{sender_user} is already invited in {room_id} but attempted to knock");
|
|
||||||
return Err!(Request(Forbidden(
|
|
||||||
"You cannot knock on a room you are already invited/accepted to."
|
|
||||||
)));
|
|
||||||
}
|
|
||||||
|
|
||||||
if services
|
if local_knock {
|
||||||
.rooms
|
knock_room_helper_local(services, sender_user, room_id, reason, servers, state_lock)
|
||||||
.state_cache
|
|
||||||
.is_joined(sender_user, room_id)
|
|
||||||
.await
|
|
||||||
{
|
|
||||||
debug_warn!("{sender_user} is already joined in {room_id} but attempted to knock");
|
|
||||||
return Err!(Request(Forbidden(
|
|
||||||
"You cannot knock on a room you are already joined in."
|
|
||||||
)));
|
|
||||||
}
|
|
||||||
|
|
||||||
if let Ok(membership) = services
|
|
||||||
.rooms
|
|
||||||
.state_accessor
|
|
||||||
.get_member(room_id, sender_user)
|
|
||||||
.await
|
|
||||||
&& membership.membership == MembershipState::Ban
|
|
||||||
{
|
|
||||||
debug_warn!("{sender_user} is banned from {room_id} but attempted to knock");
|
|
||||||
return Err!(Request(Forbidden("You cannot knock on a room you are banned from.")));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Local knocks can't fail unless the room is corrupted, so we don't
|
|
||||||
// fall back to remote knocks like we do with remote joins.
|
|
||||||
knock_room_helper_local(services, sender_user, room_id, reason, state_lock)
|
|
||||||
.boxed()
|
.boxed()
|
||||||
.await?;
|
.await?;
|
||||||
} else {
|
} else {
|
||||||
drop(state_lock);
|
knock_room_helper_remote(services, sender_user, room_id, reason, servers, state_lock)
|
||||||
let remote_servers: Vec<_> = servers
|
|
||||||
.iter()
|
|
||||||
.filter(|sn| !services.globals.server_is_ours(sn))
|
|
||||||
.cloned()
|
|
||||||
.collect();
|
|
||||||
|
|
||||||
if remote_servers.is_empty() {
|
|
||||||
return Err!(Request(NotFound(
|
|
||||||
"Room {room_id} not found and no remote servers were provided to discover it"
|
|
||||||
)));
|
|
||||||
}
|
|
||||||
|
|
||||||
knock_room_helper_remote(services, sender_user, room_id, reason, &remote_servers)
|
|
||||||
.boxed()
|
.boxed()
|
||||||
.await?;
|
.await?;
|
||||||
}
|
}
|
||||||
@@ -231,14 +309,16 @@ async fn knock_room_by_id_helper(
|
|||||||
Ok(knock_room::v3::Response::new(room_id.to_owned()))
|
Ok(knock_room::v3::Response::new(room_id.to_owned()))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(name = "local", skip(services, reason, state_lock))]
|
|
||||||
async fn knock_room_helper_local(
|
async fn knock_room_helper_local(
|
||||||
services: &Services,
|
services: &Services,
|
||||||
sender_user: &UserId,
|
sender_user: &UserId,
|
||||||
room_id: &RoomId,
|
room_id: &RoomId,
|
||||||
reason: Option<String>,
|
reason: Option<String>,
|
||||||
|
servers: &[OwnedServerName],
|
||||||
state_lock: RoomMutexGuard,
|
state_lock: RoomMutexGuard,
|
||||||
) -> Result {
|
) -> Result {
|
||||||
|
debug_info!("We can knock locally");
|
||||||
|
|
||||||
let room_version = services.rooms.state.get_room_version(room_id).await?;
|
let room_version = services.rooms.state.get_room_version(room_id).await?;
|
||||||
let room_version_rules = room_version
|
let room_version_rules = room_version
|
||||||
.rules()
|
.rules()
|
||||||
@@ -251,9 +331,10 @@ async fn knock_room_helper_local(
|
|||||||
let mut content = RoomMemberEventContent::new(MembershipState::Knock);
|
let mut content = RoomMemberEventContent::new(MembershipState::Knock);
|
||||||
content.displayname = services.users.displayname(sender_user).await.ok();
|
content.displayname = services.users.displayname(sender_user).await.ok();
|
||||||
content.avatar_url = services.users.avatar_url(sender_user).await.ok();
|
content.avatar_url = services.users.avatar_url(sender_user).await.ok();
|
||||||
content.reason = reason;
|
content.reason.clone_from(&reason.clone());
|
||||||
|
|
||||||
services
|
// Try normal knock first
|
||||||
|
let Err(error) = services
|
||||||
.rooms
|
.rooms
|
||||||
.timeline
|
.timeline
|
||||||
.build_and_append_pdu(
|
.build_and_append_pdu(
|
||||||
@@ -263,24 +344,21 @@ async fn knock_room_helper_local(
|
|||||||
&state_lock,
|
&state_lock,
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
.map(|_| ())
|
else {
|
||||||
}
|
return Ok(());
|
||||||
|
};
|
||||||
|
|
||||||
#[tracing::instrument(name = "remote", skip(services, reason, servers))]
|
if servers.is_empty() || (servers.len() == 1 && services.globals.server_is_ours(&servers[0]))
|
||||||
async fn knock_room_helper_remote(
|
{
|
||||||
services: &Services,
|
return Err(error);
|
||||||
sender_user: &UserId,
|
}
|
||||||
room_id: &RoomId,
|
|
||||||
reason: Option<String>,
|
|
||||||
servers: &[OwnedServerName],
|
|
||||||
) -> Result {
|
|
||||||
info!(via=?servers, "Knocking on {room_id} over federation.");
|
|
||||||
|
|
||||||
let (mut stub, room_version, remote_server) =
|
let (make_knock_response, remote_server) =
|
||||||
make_knock_request(services, sender_user, room_id, servers).await?;
|
make_knock_request(services, sender_user, room_id, servers).await?;
|
||||||
|
|
||||||
info!(%remote_server, "make_knock finished");
|
info!("make_knock finished");
|
||||||
|
|
||||||
|
let room_version = make_knock_response.room_version;
|
||||||
let room_version_rules = room_version
|
let room_version_rules = room_version
|
||||||
.rules()
|
.rules()
|
||||||
.expect("room version should have defined rules");
|
.expect("room version should have defined rules");
|
||||||
@@ -289,7 +367,142 @@ async fn knock_room_helper_remote(
|
|||||||
return Err!(BadServerResponse("Remote room version {room_version} is not supported"));
|
return Err!(BadServerResponse("Remote room version {room_version} is not supported"));
|
||||||
}
|
}
|
||||||
|
|
||||||
stub.insert(
|
let mut knock_event_stub = serde_json::from_str::<CanonicalJsonObject>(
|
||||||
|
make_knock_response.event.get(),
|
||||||
|
)
|
||||||
|
.map_err(|e| {
|
||||||
|
err!(BadServerResponse("Invalid make_knock event json received from server: {e:?}"))
|
||||||
|
})?;
|
||||||
|
|
||||||
|
validate_remote_member_event_stub(
|
||||||
|
&MembershipState::Knock,
|
||||||
|
sender_user,
|
||||||
|
room_id,
|
||||||
|
&knock_event_stub,
|
||||||
|
)?;
|
||||||
|
|
||||||
|
knock_event_stub.insert(
|
||||||
|
"origin".to_owned(),
|
||||||
|
CanonicalJsonValue::String(services.globals.server_name().as_str().to_owned()),
|
||||||
|
);
|
||||||
|
knock_event_stub.insert(
|
||||||
|
"origin_server_ts".to_owned(),
|
||||||
|
CanonicalJsonValue::Integer(
|
||||||
|
utils::millis_since_unix_epoch()
|
||||||
|
.try_into()
|
||||||
|
.expect("Timestamp is valid js_int value"),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
knock_event_stub.insert(
|
||||||
|
"content".to_owned(),
|
||||||
|
to_canonical_value(content).expect("event is valid, we just created it"),
|
||||||
|
);
|
||||||
|
|
||||||
|
// In order to create a compatible ref hash (EventID) the `hashes` field
|
||||||
|
// needs to be present
|
||||||
|
services
|
||||||
|
.server_keys
|
||||||
|
.hash_and_sign_event(&mut knock_event_stub, &room_version_rules)?;
|
||||||
|
|
||||||
|
// Generate event id
|
||||||
|
let event_id = gen_event_id(&knock_event_stub, &room_version_rules)?;
|
||||||
|
|
||||||
|
// Add event_id
|
||||||
|
knock_event_stub
|
||||||
|
.insert("event_id".to_owned(), CanonicalJsonValue::String(event_id.clone().into()));
|
||||||
|
|
||||||
|
// It has enough fields to be called a proper event now
|
||||||
|
let knock_event = knock_event_stub;
|
||||||
|
|
||||||
|
info!("Asking {remote_server} for send_knock in room {room_id}");
|
||||||
|
let send_knock_request = federation::membership::create_knock_event::v1::Request::new(
|
||||||
|
room_id.to_owned(),
|
||||||
|
event_id.clone(),
|
||||||
|
services
|
||||||
|
.sending
|
||||||
|
.convert_to_outgoing_federation_event(knock_event.clone())
|
||||||
|
.await,
|
||||||
|
);
|
||||||
|
|
||||||
|
services
|
||||||
|
.sending
|
||||||
|
.send_federation_request(&remote_server, send_knock_request)
|
||||||
|
.await?;
|
||||||
|
|
||||||
|
info!("send_knock finished");
|
||||||
|
|
||||||
|
services
|
||||||
|
.rooms
|
||||||
|
.short
|
||||||
|
.get_or_create_shortroomid(room_id)
|
||||||
|
.await;
|
||||||
|
|
||||||
|
info!("Parsing knock event");
|
||||||
|
|
||||||
|
let parsed_knock_pdu = PduEvent::from_id_val(&event_id, knock_event.clone())
|
||||||
|
.map_err(|e| err!(BadServerResponse("Invalid knock event PDU: {e:?}")))?;
|
||||||
|
|
||||||
|
info!("Updating membership locally to knock state with provided stripped state events");
|
||||||
|
// TODO: this call does not appear to do anything because
|
||||||
|
// `update_membership` doesn't call `mark_as_knock`. investigate further,
|
||||||
|
// ideally with the aim of removing this call entirely -- Ginger thinks
|
||||||
|
// `update_membership` should only be called from `force_state` and
|
||||||
|
// `append_pdu`.
|
||||||
|
services
|
||||||
|
.rooms
|
||||||
|
.state_cache
|
||||||
|
.update_membership(room_id, sender_user, &parsed_knock_pdu, false)
|
||||||
|
.await?;
|
||||||
|
|
||||||
|
info!("Appending room knock event locally");
|
||||||
|
services
|
||||||
|
.rooms
|
||||||
|
.timeline
|
||||||
|
.progress_extremities(&parsed_knock_pdu)
|
||||||
|
.await?;
|
||||||
|
services
|
||||||
|
.rooms
|
||||||
|
.timeline
|
||||||
|
.append_pdu(&parsed_knock_pdu, knock_event, room_id)
|
||||||
|
.await;
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn knock_room_helper_remote(
|
||||||
|
services: &Services,
|
||||||
|
sender_user: &UserId,
|
||||||
|
room_id: &RoomId,
|
||||||
|
reason: Option<String>,
|
||||||
|
servers: &[OwnedServerName],
|
||||||
|
state_lock: RoomMutexGuard,
|
||||||
|
) -> Result {
|
||||||
|
info!("Knocking {room_id} over federation.");
|
||||||
|
|
||||||
|
let (make_knock_response, remote_server) =
|
||||||
|
make_knock_request(services, sender_user, room_id, servers).await?;
|
||||||
|
|
||||||
|
info!("make_knock finished");
|
||||||
|
|
||||||
|
let room_version = make_knock_response.room_version;
|
||||||
|
let room_version_rules = room_version
|
||||||
|
.rules()
|
||||||
|
.expect("room version should have defined rules");
|
||||||
|
|
||||||
|
if !services.server.supported_room_version(&room_version) {
|
||||||
|
return Err!(BadServerResponse("Remote room version {room_version} is not supported"));
|
||||||
|
}
|
||||||
|
|
||||||
|
let mut knock_event_stub: CanonicalJsonObject =
|
||||||
|
serde_json::from_str(make_knock_response.event.get()).map_err(|e| {
|
||||||
|
err!(BadServerResponse("Invalid make_knock event json received from server: {e:?}"))
|
||||||
|
})?;
|
||||||
|
|
||||||
|
knock_event_stub.insert(
|
||||||
|
"origin".to_owned(),
|
||||||
|
CanonicalJsonValue::String(services.globals.server_name().as_str().to_owned()),
|
||||||
|
);
|
||||||
|
knock_event_stub.insert(
|
||||||
"origin_server_ts".to_owned(),
|
"origin_server_ts".to_owned(),
|
||||||
CanonicalJsonValue::Integer(
|
CanonicalJsonValue::Integer(
|
||||||
utils::millis_since_unix_epoch()
|
utils::millis_since_unix_epoch()
|
||||||
@@ -303,7 +516,7 @@ async fn knock_room_helper_remote(
|
|||||||
knock_content.avatar_url = services.users.avatar_url(sender_user).await.ok();
|
knock_content.avatar_url = services.users.avatar_url(sender_user).await.ok();
|
||||||
knock_content.reason = reason;
|
knock_content.reason = reason;
|
||||||
|
|
||||||
stub.insert(
|
knock_event_stub.insert(
|
||||||
"content".to_owned(),
|
"content".to_owned(),
|
||||||
to_canonical_value(knock_content).expect("event is valid, we just created it"),
|
to_canonical_value(knock_content).expect("event is valid, we just created it"),
|
||||||
);
|
);
|
||||||
@@ -312,15 +525,17 @@ async fn knock_room_helper_remote(
|
|||||||
// needs to be present
|
// needs to be present
|
||||||
services
|
services
|
||||||
.server_keys
|
.server_keys
|
||||||
.hash_and_sign_event(&mut stub, &room_version_rules)?;
|
.hash_and_sign_event(&mut knock_event_stub, &room_version_rules)?;
|
||||||
|
|
||||||
let event_id = gen_event_id(&stub, &room_version_rules)?;
|
// Generate event id
|
||||||
|
let event_id = gen_event_id(&knock_event_stub, &room_version_rules)?;
|
||||||
|
|
||||||
// Just verify that this event isn't hilariously malformed before we sent it
|
// Add event_id
|
||||||
// off.
|
knock_event_stub
|
||||||
debug!(?stub, "Parsing knock event");
|
.insert("event_id".to_owned(), CanonicalJsonValue::String(event_id.clone().into()));
|
||||||
PduEvent::from_id_val(&event_id, stub.clone())
|
|
||||||
.map_err(|e| err!(BadServerResponse("Invalid knock event PDU: {e:?}")))?;
|
// It has enough fields to be called a proper event now
|
||||||
|
let knock_event = knock_event_stub;
|
||||||
|
|
||||||
info!("Asking {remote_server} for send_knock in room {room_id}");
|
info!("Asking {remote_server} for send_knock in room {room_id}");
|
||||||
let request = federation::membership::create_knock_event::v1::Request::new(
|
let request = federation::membership::create_knock_event::v1::Request::new(
|
||||||
@@ -328,7 +543,7 @@ async fn knock_room_helper_remote(
|
|||||||
event_id.clone(),
|
event_id.clone(),
|
||||||
services
|
services
|
||||||
.sending
|
.sending
|
||||||
.convert_to_outgoing_federation_event(stub.clone())
|
.convert_to_outgoing_federation_event(knock_event.clone())
|
||||||
.await,
|
.await,
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -339,95 +554,126 @@ async fn knock_room_helper_remote(
|
|||||||
|
|
||||||
info!("send_knock finished");
|
info!("send_knock finished");
|
||||||
|
|
||||||
info!("Validating send_knock response");
|
|
||||||
services
|
services
|
||||||
.rooms
|
.rooms
|
||||||
.short
|
.short
|
||||||
.get_or_create_shortroomid(room_id)
|
.get_or_create_shortroomid(room_id)
|
||||||
.await;
|
.await;
|
||||||
let mut state: HashMap<(StateEventType, StateKey), CanonicalJsonObject> =
|
|
||||||
HashMap::with_capacity(send_knock_response.knock_room_state.len().saturating_add(1));
|
|
||||||
let mut create_event: Option<(OwnedEventId, CanonicalJsonObject)> = None;
|
|
||||||
|
|
||||||
for (idx, event) in send_knock_response.knock_room_state.iter().enumerate() {
|
info!("Parsing knock event");
|
||||||
let (state_event_id, key, state_event_json) = match validate_partial_membership_event(
|
let parsed_knock_pdu = PduEvent::from_id_val(&event_id, knock_event.clone())
|
||||||
services,
|
.map_err(|e| err!(BadServerResponse("Invalid knock event PDU: {e:?}")))?;
|
||||||
event,
|
|
||||||
&room_version_rules,
|
info!("Going through send_knock response knock state events");
|
||||||
room_id,
|
let state = send_knock_response
|
||||||
idx,
|
.knock_room_state
|
||||||
)
|
.iter()
|
||||||
.await
|
.map(|event| {
|
||||||
{
|
#[allow(deprecated)]
|
||||||
| Ok(res) => res,
|
let raw_value = match event {
|
||||||
| Err(e) => {
|
| federation::membership::RawStrippedState::Stripped(raw_state) =>
|
||||||
debug_warn!(%idx, "Dropping invalid event from knock_room_state: {e}");
|
&raw_state.clone().into_json(),
|
||||||
continue;
|
| federation::membership::RawStrippedState::Pdu(raw_value) => raw_value,
|
||||||
},
|
| _ => panic!("unknown raw stripped state type"),
|
||||||
|
};
|
||||||
|
|
||||||
|
serde_json::from_str::<CanonicalJsonObject>(raw_value.get())
|
||||||
|
})
|
||||||
|
.filter_map(Result::ok);
|
||||||
|
|
||||||
|
let mut state_map: HashMap<u64, OwnedEventId> = HashMap::new();
|
||||||
|
|
||||||
|
for mut event in state {
|
||||||
|
let Some(state_key) = event.get("state_key") else {
|
||||||
|
debug_warn!("send_knock stripped state event missing state_key: {event:?}");
|
||||||
|
continue;
|
||||||
|
};
|
||||||
|
let Some(event_type) = event.get("type") else {
|
||||||
|
debug_warn!("send_knock stripped state event missing event type: {event:?}");
|
||||||
|
continue;
|
||||||
};
|
};
|
||||||
|
|
||||||
match state.entry(key) {
|
let Ok(state_key) = serde_json::from_value::<String>(state_key.clone().into()) else {
|
||||||
| Entry::Occupied(entry) => {
|
debug_warn!("send_knock stripped state event has invalid state_key: {event:?}");
|
||||||
debug_warn!(
|
continue;
|
||||||
key=?entry.key(),
|
};
|
||||||
"Dropping duplicate state event from knock_room_state"
|
let Ok(event_type) = serde_json::from_value::<StateEventType>(event_type.clone().into())
|
||||||
);
|
else {
|
||||||
},
|
debug_warn!("send_knock stripped state event has invalid event type: {event:?}");
|
||||||
| Entry::Vacant(entry) => {
|
continue;
|
||||||
if entry.key().0 == StateEventType::RoomCreate {
|
};
|
||||||
create_event = Some((state_event_id, state_event_json.clone()));
|
|
||||||
}
|
|
||||||
entry.insert(state_event_json);
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if let Some((create_event_id, create_event_json)) = &create_event {
|
let event_id = gen_event_id(&event, &room_version_rules)?;
|
||||||
state.retain(|key, event_json| {
|
let shortstatekey = services
|
||||||
if let Err(e) = service::rooms::event_handler::Service::pdu_format_check_1(
|
|
||||||
event_json,
|
|
||||||
&room_version_rules,
|
|
||||||
create_event_id,
|
|
||||||
) {
|
|
||||||
debug_warn!(
|
|
||||||
?key,
|
|
||||||
"Dropping event from knock_room_state violating room event format: {e}"
|
|
||||||
);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
true
|
|
||||||
});
|
|
||||||
|
|
||||||
// Much like when receiving an invite over federation, if we're in this
|
|
||||||
// room we'll receive the knock PDU over /send. Otherwise, we need to
|
|
||||||
// add it as an outlier. Since this function isn't a fallback when local
|
|
||||||
// knocks fail, we can do this unconditionally.
|
|
||||||
services
|
|
||||||
.rooms
|
.rooms
|
||||||
.outlier
|
.short
|
||||||
.add_pdu_outlier(create_event_id, create_event_json);
|
.get_or_create_shortstatekey(&event_type, &state_key)
|
||||||
|
.await;
|
||||||
|
|
||||||
|
event.insert("event_id".into(), CanonicalJsonValue::String(event_id.to_string()));
|
||||||
|
services.rooms.outlier.add_pdu_outlier(&event_id, &event);
|
||||||
|
state_map.insert(shortstatekey, event_id.clone());
|
||||||
}
|
}
|
||||||
|
|
||||||
state.insert(StateEventType::RoomMember.with_state_key(sender_user.as_str()), stub);
|
info!("Compressing state from send_knock");
|
||||||
|
let compressed: CompressedState = services
|
||||||
let knocked_state = state
|
|
||||||
.into_values()
|
|
||||||
.filter_map(|event_json| serde_json::value::to_raw_value(&event_json).ok())
|
|
||||||
.map(RawStrippedState::Pdu)
|
|
||||||
.collect();
|
|
||||||
|
|
||||||
info!("Saving knock data");
|
|
||||||
services
|
|
||||||
.rooms
|
.rooms
|
||||||
.state_cache
|
.state_compressor
|
||||||
.mark_as_knocked(sender_user, room_id, knocked_state);
|
.compress_state_events(state_map.iter().map(|(ssk, eid)| (ssk, eid.borrow())))
|
||||||
services
|
.collect()
|
||||||
.rooms
|
|
||||||
.state_cache
|
|
||||||
.update_joined_count(room_id)
|
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
services.sync.wake(sender_user).await;
|
debug!("Saving compressed state");
|
||||||
|
let HashSetCompressStateEvent {
|
||||||
|
shortstatehash: statehash_before_knock,
|
||||||
|
added,
|
||||||
|
removed,
|
||||||
|
} = services
|
||||||
|
.rooms
|
||||||
|
.state_compressor
|
||||||
|
.save_state(room_id, Arc::new(compressed))
|
||||||
|
.await?;
|
||||||
|
|
||||||
|
debug!("Forcing state for new room");
|
||||||
|
services
|
||||||
|
.rooms
|
||||||
|
.state
|
||||||
|
.force_state(room_id, statehash_before_knock, added, removed, &state_lock)
|
||||||
|
.await?;
|
||||||
|
|
||||||
|
let statehash_after_knock = services
|
||||||
|
.rooms
|
||||||
|
.state
|
||||||
|
.append_to_state(&parsed_knock_pdu, room_id)
|
||||||
|
.await?;
|
||||||
|
|
||||||
|
info!("Updating membership locally to knock state with provided stripped state events");
|
||||||
|
// TODO: see TODO on the other call to `update_membership`
|
||||||
|
services
|
||||||
|
.rooms
|
||||||
|
.state_cache
|
||||||
|
.update_membership(room_id, sender_user, &parsed_knock_pdu, false)
|
||||||
|
.await?;
|
||||||
|
|
||||||
|
info!("Appending room knock event locally");
|
||||||
|
services
|
||||||
|
.rooms
|
||||||
|
.timeline
|
||||||
|
.progress_extremities(&parsed_knock_pdu)
|
||||||
|
.await?;
|
||||||
|
services
|
||||||
|
.rooms
|
||||||
|
.timeline
|
||||||
|
.append_pdu(&parsed_knock_pdu, knock_event, room_id)
|
||||||
|
.await;
|
||||||
|
|
||||||
|
info!("Setting final room state for new room");
|
||||||
|
// We set the room state after inserting the pdu, so that we never have a
|
||||||
|
// moment in time where events in the current room state do not exist
|
||||||
|
services
|
||||||
|
.rooms
|
||||||
|
.state
|
||||||
|
.set_room_state(room_id, statehash_after_knock, &state_lock);
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
@@ -437,13 +683,18 @@ async fn make_knock_request(
|
|||||||
sender_user: &UserId,
|
sender_user: &UserId,
|
||||||
room_id: &RoomId,
|
room_id: &RoomId,
|
||||||
servers: &[OwnedServerName],
|
servers: &[OwnedServerName],
|
||||||
) -> Result<(CanonicalJsonObject, RoomVersionId, OwnedServerName)> {
|
) -> Result<(federation::membership::prepare_knock_event::v1::Response, OwnedServerName)> {
|
||||||
for (idx, remote_server) in servers.iter().enumerate() {
|
let mut make_knock_response_and_server =
|
||||||
|
Err!(BadServerResponse("No server available to assist in knocking."));
|
||||||
|
|
||||||
|
let mut make_knock_counter: usize = 0;
|
||||||
|
|
||||||
|
for remote_server in servers {
|
||||||
if services.globals.server_is_ours(remote_server) {
|
if services.globals.server_is_ours(remote_server) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
info!("Asking {remote_server} for make_knock ({})", idx.saturating_add(1));
|
info!("Asking {remote_server} for make_knock ({make_knock_counter})");
|
||||||
|
|
||||||
let mut request = federation::membership::prepare_knock_event::v1::Request::new(
|
let mut request = federation::membership::prepare_knock_event::v1::Request::new(
|
||||||
room_id.to_owned(),
|
room_id.to_owned(),
|
||||||
@@ -457,51 +708,36 @@ async fn make_knock_request(
|
|||||||
.await;
|
.await;
|
||||||
|
|
||||||
trace!("make_knock response: {make_knock_response:?}");
|
trace!("make_knock response: {make_knock_response:?}");
|
||||||
match make_knock_response
|
make_knock_counter = make_knock_counter.saturating_add(1);
|
||||||
.and_then(|r| {
|
if let Ok(r) = &make_knock_response {
|
||||||
to_canonical_object(&r.event)
|
if let Err(e) = validate_remote_member_event_stub(
|
||||||
.map(|o| (o, r.room_version))
|
&MembershipState::Knock,
|
||||||
.map_err(Into::into)
|
sender_user,
|
||||||
})
|
room_id,
|
||||||
.and_then(|(stub, room_version)| {
|
&to_canonical_object(&r.event)?,
|
||||||
validate_remote_member_event_stub(
|
) {
|
||||||
&MembershipState::Knock,
|
warn!("make_knock response from {remote_server} failed validation: {e}");
|
||||||
sender_user,
|
continue;
|
||||||
room_id,
|
}
|
||||||
&stub,
|
}
|
||||||
)
|
|
||||||
.map(|()| (stub, room_version))
|
make_knock_response_and_server = make_knock_response.map(|r| (r, remote_server.clone()));
|
||||||
}) {
|
|
||||||
| Ok((evt, room_version)) =>
|
if make_knock_response_and_server.is_ok() {
|
||||||
return Ok((evt, room_version, remote_server.to_owned())),
|
break;
|
||||||
| Err(e) => match e.kind() {
|
}
|
||||||
| ErrorKind::IncompatibleRoomVersion(IncompatibleRoomVersionErrorData {
|
|
||||||
room_version,
|
if make_knock_counter > 40 {
|
||||||
..
|
warn!(
|
||||||
}) => {
|
"50 servers failed to provide valid make_knock response, assuming no server can \
|
||||||
warn!(
|
assist in knocking."
|
||||||
"{remote_server} reports the room we are trying to knock on is \
|
);
|
||||||
v{room_version}, which we do not support."
|
make_knock_response_and_server =
|
||||||
);
|
Err!(BadServerResponse("No server available to assist in knocking."));
|
||||||
return Err(e);
|
|
||||||
},
|
return make_knock_response_and_server;
|
||||||
| ErrorKind::Forbidden => {
|
|
||||||
warn!("{remote_server} refuses to let us knock: {e}.");
|
|
||||||
return Err(e);
|
|
||||||
},
|
|
||||||
| ErrorKind::NotFound => {
|
|
||||||
info!(
|
|
||||||
"{remote_server} does not know about {room_id}: {e}. Will continue \
|
|
||||||
trying."
|
|
||||||
);
|
|
||||||
},
|
|
||||||
| _ => {
|
|
||||||
info!("{remote_server} failed to make_knock: {e}. Will continue trying.");
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
info!("All {} servers were unable to assist in knocking {room_id} :(", servers.len());
|
make_knock_response_and_server
|
||||||
Err!(BadServerResponse("No server available to assist in knocking."))
|
|
||||||
}
|
}
|
||||||
@@ -88,13 +88,19 @@ pub async fn leave_room(
|
|||||||
.server_in_room(services.globals.server_name(), room_id)
|
.server_in_room(services.globals.server_name(), room_id)
|
||||||
.eq(&false);
|
.eq(&false);
|
||||||
|
|
||||||
|
let not_knocked = services
|
||||||
|
.rooms
|
||||||
|
.state_cache
|
||||||
|
.is_knocked(user_id, room_id)
|
||||||
|
.eq(&false);
|
||||||
|
|
||||||
pin_mut!(is_banned, is_disabled);
|
pin_mut!(is_banned, is_disabled);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
there are three possible cases when leaving a room:
|
there are three possible cases when leaving a room:
|
||||||
1. the room is banned or disabled, so we're not federating with it.
|
1. the room is banned or disabled, so we're not federating with it.
|
||||||
2. nobody on the homeserver is in the room, which can happen if the user is rejecting an invite
|
2. nobody on the homeserver is in the room, which can happen if the user is rejecting an invite
|
||||||
or rescinding a knock for a room that we don't have any members in.
|
to a room that we don't have any members in.
|
||||||
3. someone else on the homeserver is in the room. in this case we can leave like normal by sending a PDU over federation.
|
3. someone else on the homeserver is in the room. in this case we can leave like normal by sending a PDU over federation.
|
||||||
|
|
||||||
in cases 1 and 2, we have to update the state cache using `mark_as_left` directly.
|
in cases 1 and 2, we have to update the state cache using `mark_as_left` directly.
|
||||||
@@ -107,7 +113,7 @@ pub async fn leave_room(
|
|||||||
// case 1: the room is banned/disabled. we don't want to federate with
|
// case 1: the room is banned/disabled. we don't want to federate with
|
||||||
// another server to leave, so we can't create an outlier PDU.
|
// another server to leave, so we can't create an outlier PDU.
|
||||||
None
|
None
|
||||||
} else if dont_have_room.await {
|
} else if dont_have_room.and(not_knocked).await {
|
||||||
// case 2: ask a remote server to assist us with leaving
|
// case 2: ask a remote server to assist us with leaving
|
||||||
// we always mark the room as left locally, regardless of if the
|
// we always mark the room as left locally, regardless of if the
|
||||||
// federated leave failed
|
// federated leave failed
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ use ruma::{
|
|||||||
},
|
},
|
||||||
assign,
|
assign,
|
||||||
};
|
};
|
||||||
use service::users::{DeviceToken, PreviousTokenAction};
|
use service::users::DeviceToken;
|
||||||
|
|
||||||
use crate::{Ruma, client_ip::ClientIp};
|
use crate::{Ruma, client_ip::ClientIp};
|
||||||
|
|
||||||
@@ -205,7 +205,7 @@ pub(crate) async fn login_route(
|
|||||||
let device_id = if let Some(existing_device_id) = existing_device_id {
|
let device_id = if let Some(existing_device_id) = existing_device_id {
|
||||||
services
|
services
|
||||||
.users
|
.users
|
||||||
.set_token(&user_id, &existing_device_id, token.clone(), PreviousTokenAction::Clear)
|
.set_token(&user_id, &existing_device_id, token.clone())
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
existing_device_id
|
existing_device_id
|
||||||
|
|||||||
@@ -1,12 +1,9 @@
|
|||||||
use axum::extract::State;
|
use axum::extract::State;
|
||||||
use conduwuit::{Err, Result};
|
use conduwuit::{Err, Result};
|
||||||
use ruma::{
|
use ruma::{
|
||||||
api::client::{
|
api::client::discovery::{
|
||||||
discovery::{
|
discover_homeserver::{self, HomeserverInfo},
|
||||||
discover_homeserver::{self, HomeserverInfo},
|
discover_policy_server, discover_support,
|
||||||
discover_policy_server, discover_support,
|
|
||||||
},
|
|
||||||
rtc,
|
|
||||||
},
|
},
|
||||||
assign,
|
assign,
|
||||||
};
|
};
|
||||||
@@ -40,25 +37,17 @@ pub(crate) async fn well_known_client(
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// # `GET /_matrix/client/v1/rtc/transports`
|
/// # `GET /_matrix/client/v1/rtc/transports`
|
||||||
///
|
|
||||||
/// Returns the list of MatrixRTC transports configured for this homeserver,
|
|
||||||
/// implementing the stable version of MSC4143.
|
|
||||||
pub(crate) async fn get_rtc_transports(
|
|
||||||
State(services): State<crate::State>,
|
|
||||||
_body: Ruma<rtc::transports::v1::Request>,
|
|
||||||
) -> Result<rtc::transports::v1::Response> {
|
|
||||||
Ok(rtc::transports::v1::Response::new(services.config.matrix_rtc.foci.clone()))
|
|
||||||
}
|
|
||||||
|
|
||||||
/// # `GET /_matrix/client/unstable/org.matrix.msc4143/rtc/transports`
|
/// # `GET /_matrix/client/unstable/org.matrix.msc4143/rtc/transports`
|
||||||
///
|
///
|
||||||
/// Unstable version of [`get_rtc_transports`], which names the response field
|
/// Returns the list of MatrixRTC foci (transports) configured for this
|
||||||
/// `rtc_transports` instead of `transports`.
|
/// homeserver, implementing MSC4143.
|
||||||
pub(crate) async fn get_rtc_transports_unstable(
|
pub(crate) async fn get_rtc_transports(
|
||||||
State(services): State<crate::State>,
|
State(services): State<crate::State>,
|
||||||
_body: Ruma<rtc::transports::msc4143::Request>,
|
_body: Ruma<ruma::api::client::rtc::transports::msc4143::Request>,
|
||||||
) -> Result<rtc::transports::msc4143::Response> {
|
) -> Result<ruma::api::client::rtc::transports::msc4143::Response> {
|
||||||
Ok(rtc::transports::msc4143::Response::new(services.config.matrix_rtc.foci.clone()))
|
Ok(ruma::api::client::rtc::transports::msc4143::Response::new(
|
||||||
|
services.config.matrix_rtc.foci.clone(),
|
||||||
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// # `GET /.well-known/matrix/support`
|
/// # `GET /.well-known/matrix/support`
|
||||||
|
|||||||
+1
-7
@@ -189,7 +189,6 @@ pub fn build(router: Router<State>, state: State) -> Router<State> {
|
|||||||
.ruma_route(&client::well_known_client)
|
.ruma_route(&client::well_known_client)
|
||||||
.ruma_route(&client::well_known_policy_server)
|
.ruma_route(&client::well_known_policy_server)
|
||||||
.ruma_route(&client::get_rtc_transports)
|
.ruma_route(&client::get_rtc_transports)
|
||||||
.ruma_route(&client::get_rtc_transports_unstable)
|
|
||||||
.ruma_route(&client::room_initial_sync_route)
|
.ruma_route(&client::room_initial_sync_route)
|
||||||
.ruma_route(&client::discover_rendezvous_route)
|
.ruma_route(&client::discover_rendezvous_route)
|
||||||
.ruma_route(&client::create_rendezvous_session_route)
|
.ruma_route(&client::create_rendezvous_session_route)
|
||||||
@@ -219,9 +218,7 @@ pub fn build(router: Router<State>, state: State) -> Router<State> {
|
|||||||
if config.allow_federation {
|
if config.allow_federation {
|
||||||
router = router
|
router = router
|
||||||
.ruma_route(&server::get_server_version_route)
|
.ruma_route(&server::get_server_version_route)
|
||||||
.ruma_route(&server::get_server_keys_route)
|
.route("/_matrix/key/v2/server", get(server::get_server_keys_route))
|
||||||
.ruma_route(&server::get_remote_server_keys_batch_route)
|
|
||||||
.ruma_route(&server::get_remote_server_keys_route)
|
|
||||||
.ruma_route(&server::get_public_rooms_route)
|
.ruma_route(&server::get_public_rooms_route)
|
||||||
.ruma_route(&server::get_public_rooms_filtered_route)
|
.ruma_route(&server::get_public_rooms_filtered_route)
|
||||||
.ruma_route(&server::send_transaction_message_route)
|
.ruma_route(&server::send_transaction_message_route)
|
||||||
@@ -248,9 +245,6 @@ pub fn build(router: Router<State>, state: State) -> Router<State> {
|
|||||||
.ruma_route(&server::get_content_route)
|
.ruma_route(&server::get_content_route)
|
||||||
.ruma_route(&server::get_content_thumbnail_route)
|
.ruma_route(&server::get_content_thumbnail_route)
|
||||||
.route("/_continuwuity/local_user_count", get(client::continuwuity_local_user_count));
|
.route("/_continuwuity/local_user_count", get(client::continuwuity_local_user_count));
|
||||||
if config.experiments.msc4556.is_enabled() {
|
|
||||||
router = router.ruma_route(&server::get_remote_server_keys_batch_v3_unstable_route);
|
|
||||||
}
|
|
||||||
if config.experiments.msc4560.is_enabled() {
|
if config.experiments.msc4560.is_enabled() {
|
||||||
router = router.ruma_route(&server::get_stripped_state_route);
|
router = router.ruma_route(&server::get_stripped_state_route);
|
||||||
}
|
}
|
||||||
|
|||||||
+6
-24
@@ -319,21 +319,6 @@ async fn check_access_token(
|
|||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
let session_info = services
|
|
||||||
.oauth
|
|
||||||
.get_session_info_for_device(&sender_user, &sender_device)
|
|
||||||
.await;
|
|
||||||
|
|
||||||
if session_info
|
|
||||||
.as_ref()
|
|
||||||
.is_some_and(service::oauth::SessionInfo::has_previous_refresh_token)
|
|
||||||
{
|
|
||||||
services
|
|
||||||
.oauth
|
|
||||||
.clear_previous_refresh_token(&sender_user, &sender_device)
|
|
||||||
.await;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Locked users can only use /logout and /logout/all
|
// Locked users can only use /logout and /logout/all
|
||||||
if services
|
if services
|
||||||
.users
|
.users
|
||||||
@@ -348,6 +333,12 @@ async fn check_access_token(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let session_info = services
|
||||||
|
.oauth
|
||||||
|
.get_session_info_for_device(&sender_user, &sender_device)
|
||||||
|
.await
|
||||||
|
.map(Box::new);
|
||||||
|
|
||||||
// Make sure the user has the right scopes to use the route
|
// Make sure the user has the right scopes to use the route
|
||||||
let mut user_scopes = if let Some(session_info) = &session_info {
|
let mut user_scopes = if let Some(session_info) = &session_info {
|
||||||
session_info.scopes()
|
session_info.scopes()
|
||||||
@@ -425,15 +416,6 @@ async fn check_access_token(
|
|||||||
sender_device,
|
sender_device,
|
||||||
appservice_info: Box::new(appservice_info),
|
appservice_info: Box::new(appservice_info),
|
||||||
})
|
})
|
||||||
} else if services.users.is_previous_token(token).await {
|
|
||||||
// Return a soft-logout for previous tokens. This is necessary
|
|
||||||
// to make token refreshing idempotent.
|
|
||||||
|
|
||||||
Err(Error::Request(
|
|
||||||
ErrorKind::UnknownToken(assign!(UnknownTokenErrorData::new(), { soft_logout: true })),
|
|
||||||
"This token has expired".into(),
|
|
||||||
StatusCode::UNAUTHORIZED,
|
|
||||||
))
|
|
||||||
} else {
|
} else {
|
||||||
Err(Error::Request(
|
Err(Error::Request(
|
||||||
ErrorKind::UnknownToken(UnknownTokenErrorData::new()),
|
ErrorKind::UnknownToken(UnknownTokenErrorData::new()),
|
||||||
|
|||||||
+63
-92
@@ -12,8 +12,8 @@ use conduwuit::{
|
|||||||
warn,
|
warn,
|
||||||
};
|
};
|
||||||
use ruma::{
|
use ruma::{
|
||||||
CanonicalJsonObject, CanonicalJsonValue, OwnedEventId, OwnedRoomId, OwnedUserId, RoomId,
|
CanonicalJsonObject, CanonicalJsonValue, OwnedEventId, OwnedRoomId, OwnedUserId, ServerName,
|
||||||
ServerName, UserId,
|
UserId,
|
||||||
api::{
|
api::{
|
||||||
error::{ErrorKind, IncompatibleRoomVersionErrorData},
|
error::{ErrorKind, IncompatibleRoomVersionErrorData},
|
||||||
federation::membership::{RawStrippedState, create_invite},
|
federation::membership::{RawStrippedState, create_invite},
|
||||||
@@ -22,7 +22,6 @@ use ruma::{
|
|||||||
room_version_rules::RoomVersionRules,
|
room_version_rules::RoomVersionRules,
|
||||||
};
|
};
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
use service::Services;
|
|
||||||
|
|
||||||
use crate::{Ruma, server::utils::validate_any_membership_event};
|
use crate::{Ruma, server::utils::validate_any_membership_event};
|
||||||
|
|
||||||
@@ -46,7 +45,7 @@ pub(crate) async fn create_invite_route(
|
|||||||
}
|
}
|
||||||
|
|
||||||
async fn create_invite(
|
async fn create_invite(
|
||||||
services: &Services,
|
services: &crate::State,
|
||||||
body: Ruma<create_invite::v2::Request>,
|
body: Ruma<create_invite::v2::Request>,
|
||||||
) -> Result<create_invite::v2::Response> {
|
) -> Result<create_invite::v2::Response> {
|
||||||
if !services.server.supported_room_version(&body.room_version) {
|
if !services.server.supported_room_version(&body.room_version) {
|
||||||
@@ -80,7 +79,7 @@ async fn create_invite(
|
|||||||
via=?body.via,
|
via=?body.via,
|
||||||
"Validating invite room state for invite request"
|
"Validating invite room state for invite request"
|
||||||
);
|
);
|
||||||
let (create_event_id, state) = validate_partial_membership_state(
|
let (create_event_id, state) = validate_invite_state(
|
||||||
services,
|
services,
|
||||||
&body.invite_room_state,
|
&body.invite_room_state,
|
||||||
&room_version_rules,
|
&room_version_rules,
|
||||||
@@ -261,7 +260,7 @@ async fn create_invite(
|
|||||||
///
|
///
|
||||||
/// [spec]: https://spec.matrix.org/v1.19/server-server-api/#put_matrixfederationv2inviteroomideventid
|
/// [spec]: https://spec.matrix.org/v1.19/server-server-api/#put_matrixfederationv2inviteroomideventid
|
||||||
async fn validate_invite_membership_event(
|
async fn validate_invite_membership_event(
|
||||||
services: &Services,
|
services: &crate::State,
|
||||||
body: &serde_json::value::RawValue,
|
body: &serde_json::value::RawValue,
|
||||||
room_version_rules: &RoomVersionRules,
|
room_version_rules: &RoomVersionRules,
|
||||||
origin: &ServerName,
|
origin: &ServerName,
|
||||||
@@ -300,111 +299,83 @@ async fn validate_invite_membership_event(
|
|||||||
Ok((pdu, sender_user, recipient_user))
|
Ok((pdu, sender_user, recipient_user))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Validates a single event from partial membership state (`invite_room_state`
|
|
||||||
/// or `knock_room_state`), returning its event ID, `(event_type, state_key)`,
|
|
||||||
/// and parsed canonical JSON.
|
|
||||||
pub(crate) async fn validate_partial_membership_event(
|
|
||||||
services: &Services,
|
|
||||||
event: &RawStrippedState,
|
|
||||||
room_version_rules: &RoomVersionRules,
|
|
||||||
room_id: &RoomId,
|
|
||||||
idx: usize,
|
|
||||||
) -> Result<(OwnedEventId, (StateEventType, StateKey), CanonicalJsonObject)> {
|
|
||||||
// Stripped state hasn't been sent over federation since v1.16.
|
|
||||||
let RawStrippedState::Pdu(raw_pdu) = event else {
|
|
||||||
debug!(%idx, "Partial membership state event is not a PDU");
|
|
||||||
return Err!(Request(InvalidParam(
|
|
||||||
"PDU in partial membership state (index {idx}) violates the room event format"
|
|
||||||
)));
|
|
||||||
};
|
|
||||||
let (state_event_room_id, state_event_id, state_event_json) = services
|
|
||||||
.rooms
|
|
||||||
.event_handler
|
|
||||||
.parse_incoming_pdu(raw_pdu, Some(room_version_rules))
|
|
||||||
.await
|
|
||||||
.map_err(|e| {
|
|
||||||
err!(Request(InvalidParam(debug_warn!(
|
|
||||||
"Invalid PDU in partial membership state: {e}"
|
|
||||||
))))
|
|
||||||
})?;
|
|
||||||
|
|
||||||
if state_event_room_id != room_id {
|
|
||||||
return Err!(Request(InvalidParam(debug_warn!(
|
|
||||||
%state_event_room_id,
|
|
||||||
%room_id,
|
|
||||||
"PDU in partial membership state ({state_event_id}) belongs to the wrong room"
|
|
||||||
))));
|
|
||||||
}
|
|
||||||
|
|
||||||
services
|
|
||||||
.server_keys
|
|
||||||
.verify_event_json(&state_event_json, room_version_rules)
|
|
||||||
.await
|
|
||||||
.map_err(|e| {
|
|
||||||
err!(Request(InvalidParam(
|
|
||||||
"Signature verification failed on partial membership state event: {e}"
|
|
||||||
)))
|
|
||||||
})?;
|
|
||||||
|
|
||||||
let Some(state_key) = state_event_json.get("state_key").and_then(|k| k.as_str()) else {
|
|
||||||
return Err!(Request(InvalidParam(debug_info!(
|
|
||||||
"PDU in partial membership state ({state_event_id}) is not a state event"
|
|
||||||
))));
|
|
||||||
};
|
|
||||||
let Some(event_type) = state_event_json.get("type").and_then(|k| k.as_str()) else {
|
|
||||||
return Err!(Request(InvalidParam(debug_warn!(
|
|
||||||
"PDU in partial membership state ({state_event_id}) is not an event?"
|
|
||||||
))));
|
|
||||||
};
|
|
||||||
|
|
||||||
let key = StateEventType::from(event_type).with_state_key(state_key);
|
|
||||||
if key.0 == StateEventType::RoomCreate {
|
|
||||||
// Ensure this is a legal create event.
|
|
||||||
let pdu_event = PduEvent::from_id_val(&state_event_id, state_event_json.clone())
|
|
||||||
.expect("must be able to create pdu event from event json");
|
|
||||||
debug!("Validating discovered create event in partial membership room state");
|
|
||||||
validate_invite_create_event(&pdu_event, room_version_rules).await?;
|
|
||||||
}
|
|
||||||
|
|
||||||
Ok((state_event_id, key, state_event_json))
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Validates the *invite state* of an invite request, per the steps listed
|
/// Validates the *invite state* of an invite request, per the steps listed
|
||||||
/// under the endpoint's [spec].
|
/// under the endpoint's [spec].
|
||||||
///
|
///
|
||||||
/// Returns the create event's event ID, and the partial state map.
|
/// Returns the create event's event ID, and the partial state map.
|
||||||
///
|
///
|
||||||
/// [spec]: https://spec.matrix.org/v1.19/server-server-api/#put_matrixfederationv2inviteroomideventid
|
/// [spec]: https://spec.matrix.org/v1.19/server-server-api/#put_matrixfederationv2inviteroomideventid
|
||||||
pub(crate) async fn validate_partial_membership_state(
|
async fn validate_invite_state(
|
||||||
services: &Services,
|
services: &crate::State,
|
||||||
invite_state: &[RawStrippedState],
|
invite_state: &[RawStrippedState],
|
||||||
room_version_rules: &RoomVersionRules,
|
room_version_rules: &RoomVersionRules,
|
||||||
room_id: OwnedRoomId,
|
room_id: OwnedRoomId,
|
||||||
) -> Result<(OwnedEventId, HashMap<(StateEventType, StateKey), CanonicalJsonObject>)> {
|
) -> Result<(OwnedEventId, HashMap<(StateEventType, StateKey), CanonicalJsonObject>)> {
|
||||||
trace!(?invite_state, "Raw partial membership state");
|
trace!(?invite_state, "Raw invite state");
|
||||||
let mut invite_state_map: HashMap<(StateEventType, StateKey), _> =
|
let mut invite_state_map: HashMap<(StateEventType, StateKey), _> =
|
||||||
HashMap::with_capacity(invite_state.len());
|
HashMap::with_capacity(invite_state.len());
|
||||||
let mut create_event_id: Option<OwnedEventId> = None;
|
let mut create_event_id: Option<OwnedEventId> = None;
|
||||||
|
|
||||||
for (idx, invite_state_event) in invite_state.iter().enumerate() {
|
for (idx, invite_state_event) in invite_state.iter().cloned().enumerate() {
|
||||||
trace!(%idx, ?invite_state_event, "Partial membership state event");
|
trace!(%idx, ?invite_state_event, "Invite state event");
|
||||||
let (state_event_id, key, state_event_json) = validate_partial_membership_event(
|
// Stripped state hasn't been sent over federation since v1.16.
|
||||||
services,
|
let RawStrippedState::Pdu(raw_pdu) = invite_state_event else {
|
||||||
invite_state_event,
|
debug!(%idx, "Invite state event is not a PDU");
|
||||||
room_version_rules,
|
return Err!(Request(InvalidParam(
|
||||||
&room_id,
|
"PDU in invite state (index {idx}) violates the room event format"
|
||||||
idx,
|
)));
|
||||||
)
|
};
|
||||||
.await?;
|
let (state_event_room_id, state_event_id, state_event_json) = services
|
||||||
|
.rooms
|
||||||
|
.event_handler
|
||||||
|
.parse_incoming_pdu(&raw_pdu, Some(room_version_rules))
|
||||||
|
.await
|
||||||
|
.map_err(|e| {
|
||||||
|
err!(Request(InvalidParam(debug_warn!("Invalid PDU in invite state: {e}"))))
|
||||||
|
})?;
|
||||||
|
|
||||||
|
if state_event_room_id != room_id {
|
||||||
|
return Err!(Request(InvalidParam(debug_warn!(
|
||||||
|
%state_event_room_id,
|
||||||
|
%room_id,
|
||||||
|
"PDU in invite state ({state_event_id}) belongs to the wrong room"
|
||||||
|
))));
|
||||||
|
}
|
||||||
|
|
||||||
|
services
|
||||||
|
.server_keys
|
||||||
|
.verify_event_json(&state_event_json, room_version_rules)
|
||||||
|
.await
|
||||||
|
.map_err(|e| {
|
||||||
|
err!(Request(InvalidParam("Signature verification failed on invite event: {e}")))
|
||||||
|
})?;
|
||||||
|
|
||||||
|
let Some(state_key) = state_event_json.get("state_key").and_then(|k| k.as_str()) else {
|
||||||
|
return Err!(Request(InvalidParam(debug_info!(
|
||||||
|
"PDU in invite state ({state_event_id}) is not a state event"
|
||||||
|
))));
|
||||||
|
};
|
||||||
|
let Some(event_type) = state_event_json.get("type").and_then(|k| k.as_str()) else {
|
||||||
|
return Err!(Request(InvalidParam(debug_warn!(
|
||||||
|
"PDU in invite state ({state_event_id}) is not an event?"
|
||||||
|
))));
|
||||||
|
};
|
||||||
|
|
||||||
|
let key = StateEventType::from(event_type).with_state_key(state_key);
|
||||||
match invite_state_map.entry(key) {
|
match invite_state_map.entry(key) {
|
||||||
| Entry::Occupied(entry) =>
|
| Entry::Occupied(entry) =>
|
||||||
return Err!(Request(InvalidParam(
|
return Err!(Request(InvalidParam(
|
||||||
"Duplicate state events in partial membership state for state key: {:?}",
|
"Duplicate state events in invite state for state key: {:?}",
|
||||||
entry.key(),
|
entry.key(),
|
||||||
))),
|
))),
|
||||||
| Entry::Vacant(entry) => {
|
| Entry::Vacant(entry) => {
|
||||||
if entry.key().0 == StateEventType::RoomCreate {
|
if entry.key().0 == StateEventType::RoomCreate {
|
||||||
|
// Ensure this is a legal create event.
|
||||||
|
let pdu_event =
|
||||||
|
PduEvent::from_id_val(&state_event_id, state_event_json.clone())
|
||||||
|
.expect("must be able to create pdu event from event json");
|
||||||
|
debug!("Validating discovered create event in invite room state");
|
||||||
|
validate_invite_create_event(&pdu_event, room_version_rules).await?;
|
||||||
create_event_id = Some(state_event_id);
|
create_event_id = Some(state_event_id);
|
||||||
}
|
}
|
||||||
entry.insert(state_event_json);
|
entry.insert(state_event_json);
|
||||||
@@ -414,7 +385,7 @@ pub(crate) async fn validate_partial_membership_state(
|
|||||||
let Some(create_event_id) = create_event_id else {
|
let Some(create_event_id) = create_event_id else {
|
||||||
return Err!(Request(InvalidParam(debug_warn!(
|
return Err!(Request(InvalidParam(debug_warn!(
|
||||||
parsed_state=?invite_state_map,
|
parsed_state=?invite_state_map,
|
||||||
"Partial membership state does not contain the m.room.create event"
|
"Invite state does not contain the m.room.create event"
|
||||||
))));
|
))));
|
||||||
};
|
};
|
||||||
invite_state_map.iter().try_for_each(|(key, event_json)| {
|
invite_state_map.iter().try_for_each(|(key, event_json)| {
|
||||||
@@ -425,7 +396,7 @@ pub(crate) async fn validate_partial_membership_state(
|
|||||||
)
|
)
|
||||||
.map_err(|e| {
|
.map_err(|e| {
|
||||||
err!(Request(InvalidParam(
|
err!(Request(InvalidParam(
|
||||||
"PDU in partial membership state for {key:?} violates the room event format: {e}"
|
"PDU in invite state for {key:?} violates the room event format: {e}"
|
||||||
)))
|
)))
|
||||||
})
|
})
|
||||||
})?;
|
})?;
|
||||||
@@ -443,7 +414,7 @@ struct MFederate {
|
|||||||
///
|
///
|
||||||
/// 1. It passes auth checks (aka is valid)
|
/// 1. It passes auth checks (aka is valid)
|
||||||
/// 2. The room is federated (there's no point persisting unfederated rooms)
|
/// 2. The room is federated (there's no point persisting unfederated rooms)
|
||||||
pub(crate) async fn validate_invite_create_event(
|
async fn validate_invite_create_event(
|
||||||
pdu: &PduEvent,
|
pdu: &PduEvent,
|
||||||
room_version_rules: &RoomVersionRules,
|
room_version_rules: &RoomVersionRules,
|
||||||
) -> Result {
|
) -> Result {
|
||||||
|
|||||||
+68
-295
@@ -1,316 +1,89 @@
|
|||||||
use std::{
|
use std::{collections::BTreeMap, mem::take, time::Duration};
|
||||||
collections::{BTreeMap, HashSet},
|
|
||||||
sync::Arc,
|
|
||||||
time::Instant,
|
|
||||||
};
|
|
||||||
|
|
||||||
use axum::extract::State;
|
use axum::{Json, extract::State, response::IntoResponse};
|
||||||
use conduwuit::{
|
use conduwuit::{Result, utils::timepoint_from_now};
|
||||||
Err, Result,
|
use futures::StreamExt;
|
||||||
config::experiments::ToggledExperiment,
|
|
||||||
debug_info,
|
|
||||||
utils::{ReadyExt, stream::automatic_width},
|
|
||||||
};
|
|
||||||
use ruma::{
|
use ruma::{
|
||||||
MilliSecondsSinceUnixEpoch, OwnedServerName, OwnedServerSigningKeyId,
|
MilliSecondsSinceUnixEpoch,
|
||||||
api::federation::discovery::{
|
api::{
|
||||||
ServerSigningKeys, get_remote_server_keys, get_remote_server_keys_batch,
|
OutgoingResponseExt,
|
||||||
get_remote_server_keys_batch::v2::QueryCriteria, get_server_keys,
|
federation::discovery::{OldVerifyKey, ServerSigningKeys, get_server_keys},
|
||||||
},
|
},
|
||||||
|
assign,
|
||||||
serde::Raw,
|
serde::Raw,
|
||||||
};
|
};
|
||||||
use service::server_keys::{self, in_one_week};
|
use service::{server_keys, server_keys::in_one_week};
|
||||||
|
|
||||||
use crate::router::Ruma;
|
|
||||||
|
|
||||||
/// # `GET /_matrix/key/v2/server`
|
/// # `GET /_matrix/key/v2/server`
|
||||||
///
|
///
|
||||||
/// Gets the public signing keys of this server.
|
/// Gets the public signing keys of this server.
|
||||||
pub(crate) async fn get_server_keys_route(
|
pub(crate) async fn get_server_keys_route(
|
||||||
State(services): State<crate::State>,
|
State(services): State<crate::State>,
|
||||||
_body: Ruma<get_server_keys::v2::Request>,
|
) -> Result<impl IntoResponse> {
|
||||||
) -> Result<get_server_keys::v2::Response> {
|
let server_name = services.globals.server_name();
|
||||||
services
|
let verify_keys = BTreeMap::from([services.server_keys.active_verify_key()]);
|
||||||
.server_keys
|
|
||||||
.build_server_keys_response()
|
|
||||||
.await
|
|
||||||
.map(get_server_keys::v2::Response::new)
|
|
||||||
}
|
|
||||||
|
|
||||||
const MAX_KEYS_PER_QUERY: usize = 16384;
|
let old_verify_keys = if let Some(k) = &services.config.old_verify_keys {
|
||||||
const MAX_SERVERS_PER_QUERY: usize = 4096;
|
k.to_owned()
|
||||||
|
|
||||||
/// # `POST /_matrix/key/v2/query`
|
|
||||||
///
|
|
||||||
/// Fetches remote server signing keys in bulk, seeding from the local server's
|
|
||||||
/// database.
|
|
||||||
///
|
|
||||||
/// This route applies a semaphore to slow down requests that query more signing
|
|
||||||
/// keys than is allowed by [MSC4556].
|
|
||||||
///
|
|
||||||
/// [MSC4556]: https://github.com/matrix-org/matrix-spec-proposals/pull/4556
|
|
||||||
pub(crate) async fn get_remote_server_keys_batch_route(
|
|
||||||
State(services): State<crate::State>,
|
|
||||||
body: Ruma<get_remote_server_keys_batch::v2::Request>,
|
|
||||||
) -> Result<get_remote_server_keys_batch::v2::Response> {
|
|
||||||
query_inner(&services, body.body.server_keys, true)
|
|
||||||
.await
|
|
||||||
.map(get_remote_server_keys_batch::v2::Response::new)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// # `POST /_matrix/key/unstable/org.continuwuity.msc4556/query`
|
|
||||||
/// ## `POST /_matrix/key/v3/query`
|
|
||||||
///
|
|
||||||
/// Fetches remote server signing keys in bulk, seeding from the local server's
|
|
||||||
/// database.
|
|
||||||
///
|
|
||||||
/// MSC4556: https://github.com/matrix-org/matrix-spec-proposals/pull/4556
|
|
||||||
pub(crate) async fn get_remote_server_keys_batch_v3_unstable_route(
|
|
||||||
State(services): State<crate::State>,
|
|
||||||
body: Ruma<ruminuwuity::federation::notary::unstable::Request>,
|
|
||||||
) -> Result<ruminuwuity::federation::notary::unstable::Response> {
|
|
||||||
query_inner(&services, body.body.server_keys, false)
|
|
||||||
.await
|
|
||||||
.map(ruminuwuity::federation::notary::unstable::Response::new)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Handles querying the server keys for `/_matrix/key/*/query`.
|
|
||||||
///
|
|
||||||
/// `v2` should be `true` if the request path is `/_matrix/key/v2/query` - this
|
|
||||||
/// will potentially apply a rate-limit to the request.
|
|
||||||
async fn query_inner(
|
|
||||||
services: &crate::State,
|
|
||||||
body: BTreeMap<OwnedServerName, BTreeMap<OwnedServerSigningKeyId, QueryCriteria>>,
|
|
||||||
v2: bool,
|
|
||||||
) -> Result<Vec<Raw<ServerSigningKeys>>> {
|
|
||||||
let start = (Instant::now(), MilliSecondsSinceUnixEpoch::now());
|
|
||||||
// If the remote server isn't asking for any keys, we can return an empty
|
|
||||||
// array immediately.
|
|
||||||
if body.is_empty() {
|
|
||||||
return Ok(Vec::new());
|
|
||||||
}
|
|
||||||
|
|
||||||
// Count how many keys are being requested.
|
|
||||||
// Each server incurs a cost of at least one, and then the count of each key
|
|
||||||
// being queried per-server.
|
|
||||||
let total_queried_servers = body.len();
|
|
||||||
let total_queried_keys = body
|
|
||||||
.values()
|
|
||||||
.fold(0_usize, |acc, q| acc.saturating_add(q.len().max(1)));
|
|
||||||
|
|
||||||
if !v2 && services.config.experiments.msc4556.is_enabled() {
|
|
||||||
// If we're on the v3 endpoint, we can apply these limits explicitly.
|
|
||||||
if total_queried_servers > MAX_SERVERS_PER_QUERY {
|
|
||||||
return Err!(Request(TooLarge(
|
|
||||||
"Too many server keys requested ({total_queried_servers} > \
|
|
||||||
{MAX_SERVERS_PER_QUERY})",
|
|
||||||
)));
|
|
||||||
}
|
|
||||||
if total_queried_keys > MAX_KEYS_PER_QUERY {
|
|
||||||
return Err!(Request(TooLarge(
|
|
||||||
"Too many keys requested ({total_queried_keys} > {MAX_KEYS_PER_QUERY})"
|
|
||||||
)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
let penalise =
|
|
||||||
total_queried_servers > MAX_SERVERS_PER_QUERY || total_queried_keys > MAX_KEYS_PER_QUERY;
|
|
||||||
|
|
||||||
debug_info!("Fetching {total_queried_keys} keys across {} servers", body.len());
|
|
||||||
let mut futs: tokio::task::JoinSet<_> = tokio::task::JoinSet::new();
|
|
||||||
|
|
||||||
// If we're on the v2 endpoint, we aren't allowed to reject the request.
|
|
||||||
// To avoid overloading the server, we'll apply a semaphore to limit how
|
|
||||||
// many futures can be active at a time.
|
|
||||||
let width = automatic_width();
|
|
||||||
|
|
||||||
let semaphore: Option<Arc<tokio::sync::Semaphore>> = if v2 && penalise {
|
|
||||||
Some(Arc::new(tokio::sync::Semaphore::new(width)))
|
|
||||||
} else {
|
} else {
|
||||||
None
|
// We need to figure out any old signing keys we've acquired from
|
||||||
};
|
// notaries.
|
||||||
|
let mut keys = services.server_keys.signing_keys_for(server_name);
|
||||||
for (server_name, queries) in body {
|
let mut old_keys = BTreeMap::new();
|
||||||
let server_keys = services.server_keys.clone();
|
while let Some(resp) = keys.next().await {
|
||||||
let semaphore = semaphore.clone();
|
// We need to verify that this response is still trusted based on
|
||||||
|
// the current configuration. It's possible we got this response
|
||||||
futs.spawn_on(
|
// from a notary who we no longer trust.
|
||||||
async move {
|
if resp.parsed.valid_until_ts > in_one_week() {
|
||||||
let _permit = if let Some(sem) = semaphore {
|
|
||||||
let cost = queries
|
|
||||||
.len()
|
|
||||||
.saturating_add(1)
|
|
||||||
.min(automatic_width())
|
|
||||||
.try_into()
|
|
||||||
.unwrap_or(u32::MAX);
|
|
||||||
|
|
||||||
sem.acquire_many_owned(cost).await.ok()
|
|
||||||
} else {
|
|
||||||
None
|
|
||||||
};
|
|
||||||
|
|
||||||
acquire_keys_as_notary(server_keys, server_name, queries, start.1).await
|
|
||||||
},
|
|
||||||
services.server.runtime(),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
let mut response = Vec::with_capacity(total_queried_keys);
|
|
||||||
|
|
||||||
while let Some(Ok(v)) = futs.join_next().await {
|
|
||||||
response.extend(v);
|
|
||||||
}
|
|
||||||
|
|
||||||
debug_info!(
|
|
||||||
elapsed=?start.0.elapsed(),
|
|
||||||
%total_queried_servers,
|
|
||||||
%total_queried_keys,
|
|
||||||
"Fetched {} key responses",
|
|
||||||
response.len()
|
|
||||||
);
|
|
||||||
Ok(response)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// `GET /_matrix/key/v2/query/{serverName}`
|
|
||||||
///
|
|
||||||
/// Fetches the latest keys for a specific server name.
|
|
||||||
pub(crate) async fn get_remote_server_keys_route(
|
|
||||||
State(services): State<crate::State>,
|
|
||||||
body: Ruma<get_remote_server_keys::v2::Request>,
|
|
||||||
) -> Result<get_remote_server_keys::v2::Response> {
|
|
||||||
let server_keys = acquire_keys_as_notary(
|
|
||||||
services.server_keys.clone(),
|
|
||||||
body.server_name.clone(),
|
|
||||||
BTreeMap::new(),
|
|
||||||
body.minimum_valid_until_ts,
|
|
||||||
)
|
|
||||||
.await;
|
|
||||||
|
|
||||||
Ok(get_remote_server_keys::v2::Response::new(server_keys))
|
|
||||||
}
|
|
||||||
|
|
||||||
#[tracing::instrument(skip(server_keys, queries, start))]
|
|
||||||
async fn acquire_keys_as_notary(
|
|
||||||
server_keys: Arc<server_keys::Service>,
|
|
||||||
remote: OwnedServerName,
|
|
||||||
queries: BTreeMap<OwnedServerSigningKeyId, QueryCriteria>,
|
|
||||||
start: MilliSecondsSinceUnixEpoch,
|
|
||||||
) -> Vec<Raw<ServerSigningKeys>> {
|
|
||||||
let mut candidate_remote_keys = Vec::with_capacity(queries.len().max(1));
|
|
||||||
|
|
||||||
// If we haven't contacted the origin recently, we need to do that now
|
|
||||||
// to update our caches, and we might as well use its response as a
|
|
||||||
// candidate.
|
|
||||||
if server_keys.origin_not_contacted_recently(&remote) {
|
|
||||||
let min_valid_ts = queries
|
|
||||||
.values()
|
|
||||||
.map(|criterion| criterion.minimum_valid_until_ts.unwrap_or(start))
|
|
||||||
.min()
|
|
||||||
.unwrap_or(start);
|
|
||||||
|
|
||||||
if let Ok(remote_keys) = server_keys
|
|
||||||
.origin_request(remote.clone(), min_valid_ts)
|
|
||||||
.await
|
|
||||||
{
|
|
||||||
debug_info!("Considering keys from origin response");
|
|
||||||
candidate_remote_keys.push(remote_keys);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if queries.is_empty() {
|
|
||||||
// The querying server wants all of the origin's keys. If we decided to
|
|
||||||
// contact it earlier, we can safely assume its response already
|
|
||||||
// includes all of its keys. Otherwise, we'll add all of our cached
|
|
||||||
// responses as candidates.
|
|
||||||
|
|
||||||
if candidate_remote_keys.is_empty() {
|
|
||||||
debug_info!("Querying server wants all keys, considering all cached key responses");
|
|
||||||
server_keys
|
|
||||||
.signing_keys_for(&remote)
|
|
||||||
.ready_for_each(|remote_keys| candidate_remote_keys.push(remote_keys))
|
|
||||||
.await;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// The querying server is asking for specific key IDs.
|
|
||||||
|
|
||||||
for key_id in queries.keys() {
|
|
||||||
if let Some(remote_keys) = server_keys.get_signing_key(&remote, key_id).await {
|
|
||||||
debug_info!(?key_id, "Considering cached response containing key");
|
|
||||||
|
|
||||||
candidate_remote_keys.push(remote_keys);
|
|
||||||
} else {
|
|
||||||
debug_info!(?key_id, "No cached response contains key");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Now we need to filter and sign the remote key responses.
|
|
||||||
|
|
||||||
// The signing key responses containing the keys the querying server wants.
|
|
||||||
let mut signed_remote_key_responses = Vec::with_capacity(queries.len().max(1));
|
|
||||||
|
|
||||||
// The key IDs we've already included in a response.
|
|
||||||
let mut signed_remote_key_ids = HashSet::with_capacity(queries.len().max(1));
|
|
||||||
|
|
||||||
for remote_keys in candidate_remote_keys {
|
|
||||||
// Skip this key response if it expires too far in the future.
|
|
||||||
if remote_keys.parsed.valid_until_ts > in_one_week() {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Determine which requested keys (or all keys when no specific keys
|
|
||||||
// were requested) are newly satisfied by this response.
|
|
||||||
let newly_satisfied: Vec<OwnedServerSigningKeyId> = if queries.is_empty() {
|
|
||||||
if remote_keys.parsed.valid_until_ts < start {
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
let trusted = services.config.trusted_servers.iter().any(|notary| {
|
||||||
remote_keys
|
server_keys::Service::verify_server_keys_response(
|
||||||
.all_key_ids()
|
&resp,
|
||||||
.filter(|key_id| !signed_remote_key_ids.contains(*key_id))
|
Some((notary.server_name(), notary.verify_keys())),
|
||||||
.map(ToOwned::to_owned)
|
)
|
||||||
.collect()
|
.is_ok()
|
||||||
} else {
|
});
|
||||||
queries
|
if !trusted {
|
||||||
.iter()
|
continue;
|
||||||
.filter_map(|(key_id, criterion)| {
|
}
|
||||||
if signed_remote_key_ids.contains(key_id) {
|
for (old_key_id, old_key) in resp.parsed.old_verify_keys {
|
||||||
return None;
|
if old_key.expired_ts > resp.parsed.valid_until_ts {
|
||||||
}
|
// This key expired in the future which is probably illegal
|
||||||
|
continue;
|
||||||
let minimum_valid_until_ts =
|
}
|
||||||
criterion.minimum_valid_until_ts.unwrap_or(start);
|
old_keys
|
||||||
|
.entry(old_key_id)
|
||||||
if remote_keys.parsed.valid_until_ts < minimum_valid_until_ts {
|
.and_modify(|current_old_key: &mut OldVerifyKey| {
|
||||||
return None;
|
// Use the lowest expiry timestamp
|
||||||
}
|
if current_old_key.expired_ts > old_key.expired_ts {
|
||||||
|
*current_old_key = old_key.clone();
|
||||||
let satisfied = remote_keys.parsed.verify_keys.contains_key(key_id)
|
}
|
||||||
|| remote_keys.parsed.old_verify_keys.get(key_id).is_some_and(
|
})
|
||||||
|old_key| {
|
.or_insert(old_key);
|
||||||
criterion
|
}
|
||||||
.minimum_valid_until_ts
|
|
||||||
.is_none_or(|min_ts| old_key.expired_ts >= min_ts)
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
satisfied.then(|| key_id.to_owned())
|
|
||||||
})
|
|
||||||
.collect()
|
|
||||||
};
|
|
||||||
|
|
||||||
if newly_satisfied.is_empty() {
|
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
|
old_keys
|
||||||
|
};
|
||||||
|
|
||||||
// This response is acceptable, let's sign and send it.
|
let server_key = assign!(ServerSigningKeys::new(server_name.to_owned(), valid_until_ts()), {
|
||||||
|
verify_keys,
|
||||||
|
old_verify_keys,
|
||||||
|
});
|
||||||
|
|
||||||
let signed_remote_keys = server_keys
|
let server_key = Raw::new(&server_key)?;
|
||||||
.self_sign_signing_keys(&remote, &remote_keys.raw)
|
let mut response = get_server_keys::v2::Response::new(server_key)
|
||||||
.expect("should be able to sign remote keys");
|
.try_into_http_response::<Vec<u8>>()
|
||||||
|
.map(|mut response| take(response.body_mut()))
|
||||||
|
.and_then(|body| serde_json::from_slice(&body).map_err(Into::into))?;
|
||||||
|
|
||||||
signed_remote_key_responses.push(signed_remote_keys);
|
services.server_keys.sign_json(&mut response)?;
|
||||||
signed_remote_key_ids.extend(newly_satisfied);
|
|
||||||
}
|
|
||||||
|
|
||||||
signed_remote_key_responses
|
Ok(Json(response))
|
||||||
|
}
|
||||||
|
|
||||||
|
fn valid_until_ts() -> MilliSecondsSinceUnixEpoch {
|
||||||
|
let dur = Duration::from_hours(12);
|
||||||
|
let timepoint = timepoint_from_now(dur).expect("SystemTime should not overflow");
|
||||||
|
MilliSecondsSinceUnixEpoch::from_system_time(timepoint).expect("UInt should not overflow")
|
||||||
}
|
}
|
||||||
@@ -63,7 +63,7 @@ pub(crate) async fn create_knock_event_v1_route(
|
|||||||
return Err!(Request(Forbidden("Room version does not support knocking.")));
|
return Err!(Request(Forbidden("Room version does not support knocking.")));
|
||||||
}
|
}
|
||||||
|
|
||||||
let (event, target_membership, sender, target) = validate_any_membership_event(
|
let (mut event, target_membership, sender, target) = validate_any_membership_event(
|
||||||
&services,
|
&services,
|
||||||
&body.pdu,
|
&body.pdu,
|
||||||
&room_version_rules,
|
&room_version_rules,
|
||||||
@@ -83,6 +83,8 @@ pub(crate) async fn create_knock_event_v1_route(
|
|||||||
return Err!(Request(InvalidParam("Sender does not match state key")));
|
return Err!(Request(InvalidParam("Sender does not match state key")));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
event.insert("event_id".to_owned(), body.event_id.as_str().into());
|
||||||
|
|
||||||
let pdu = PduEvent::from_id_val(&body.event_id, event.clone())
|
let pdu = PduEvent::from_id_val(&body.event_id, event.clone())
|
||||||
.map_err(|e| err!(Request(InvalidParam("Invalid knock event PDU: {e}"))))?;
|
.map_err(|e| err!(Request(InvalidParam("Invalid knock event PDU: {e}"))))?;
|
||||||
|
|
||||||
|
|||||||
@@ -84,7 +84,7 @@ impl AccessCheck<'_> {
|
|||||||
///
|
///
|
||||||
/// A resulting tuple of (PDU JSON, target membership state, sender, recipient).
|
/// A resulting tuple of (PDU JSON, target membership state, sender, recipient).
|
||||||
pub(crate) async fn validate_any_membership_event(
|
pub(crate) async fn validate_any_membership_event(
|
||||||
services: &Services,
|
services: &crate::State,
|
||||||
body: &serde_json::value::RawValue,
|
body: &serde_json::value::RawValue,
|
||||||
room_version_rules: &RoomVersionRules,
|
room_version_rules: &RoomVersionRules,
|
||||||
create_event_id: OwnedEventId,
|
create_event_id: OwnedEventId,
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ crate-type = [
|
|||||||
[dependencies]
|
[dependencies]
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
built = { version = "0.8", features = [] }
|
built = { version = "0.9", features = [] }
|
||||||
cargo_metadata = { version = "0.23.1" }
|
cargo_metadata = { version = "0.23.1" }
|
||||||
[lints]
|
[lints]
|
||||||
workspace = true
|
workspace = true
|
||||||
+4
-4
@@ -38,12 +38,12 @@ mimalloc = [
|
|||||||
]
|
]
|
||||||
jemalloc_conf = []
|
jemalloc_conf = []
|
||||||
jemalloc_prof = [
|
jemalloc_prof = [
|
||||||
"tikv-jemalloc-sys?/profiling",
|
"tikv-jemalloc-sys/profiling",
|
||||||
]
|
]
|
||||||
jemalloc_stats = [
|
jemalloc_stats = [
|
||||||
"tikv-jemalloc-sys?/stats",
|
"tikv-jemalloc-sys/stats",
|
||||||
"tikv-jemalloc-ctl?/stats",
|
"tikv-jemalloc-ctl/stats",
|
||||||
"tikv-jemallocator?/stats",
|
"tikv-jemallocator/stats",
|
||||||
]
|
]
|
||||||
perf_measurements = []
|
perf_measurements = []
|
||||||
release_max_log_level = [
|
release_max_log_level = [
|
||||||
|
|||||||
@@ -118,22 +118,6 @@ pub struct Experiments {
|
|||||||
/// default: false
|
/// default: false
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub msc4494: SimpleExperiment,
|
pub msc4494: SimpleExperiment,
|
||||||
/// MSC4556: Notary request limits
|
|
||||||
///
|
|
||||||
/// Creates a new key notary server route that has stricter limits on how
|
|
||||||
/// many signing keys can be requested in one query, to avoid a resource
|
|
||||||
/// exhaustion exploit vector in the existing key notary endpoint.
|
|
||||||
///
|
|
||||||
/// Continuwuity mitigates the exploit vector in the old notary endpoint
|
|
||||||
/// anyway, so you do not need to enable this to be protected.
|
|
||||||
///
|
|
||||||
/// Requires that remote servers support this MSC before it does anything.
|
|
||||||
///
|
|
||||||
/// https://github.com/matrix-org/matrix-spec-proposals/pull/4556
|
|
||||||
///
|
|
||||||
/// default: false
|
|
||||||
#[serde(default)]
|
|
||||||
pub msc4556: SimpleExperiment,
|
|
||||||
/// MSC4560: Stripped state requests over federation
|
/// MSC4560: Stripped state requests over federation
|
||||||
///
|
///
|
||||||
/// Implements a more efficient way for servers to acquire and serve
|
/// Implements a more efficient way for servers to acquire and serve
|
||||||
|
|||||||
+14
-14
@@ -1154,7 +1154,10 @@ pub struct Config {
|
|||||||
/// (trusted key notary servers), as well as serve as trusted servers for
|
/// (trusted key notary servers), as well as serve as trusted servers for
|
||||||
/// other operations like backfill and event fetching.
|
/// other operations like backfill and event fetching.
|
||||||
///
|
///
|
||||||
/// example: ["continuwuity.org", "matrix.org"]
|
/// Currently, continuwuity doesn't support inbound key requests, so
|
||||||
|
/// this list should only contain other Synapse servers.
|
||||||
|
///
|
||||||
|
/// example: ["matrix.org", "starstruck.systems"]
|
||||||
///
|
///
|
||||||
/// It is possible to restrict which signing keys trusted servers are
|
/// It is possible to restrict which signing keys trusted servers are
|
||||||
/// allowed to sign responses with. Without configuring this, all responses
|
/// allowed to sign responses with. Without configuring this, all responses
|
||||||
@@ -1191,7 +1194,7 @@ pub struct Config {
|
|||||||
/// empty list (`[]`) to operate without trusted server assistance, but this
|
/// empty list (`[]`) to operate without trusted server assistance, but this
|
||||||
/// is discouraged for performance and reliability reasons.
|
/// is discouraged for performance and reliability reasons.
|
||||||
///
|
///
|
||||||
/// default: ["continuwuity.org", "continuwuity.rocks", "matrix.org"]
|
/// default: ["matrix.org"]
|
||||||
#[serde(default = "default_trusted_servers")]
|
#[serde(default = "default_trusted_servers")]
|
||||||
pub trusted_servers: Vec<TrustedServer>,
|
pub trusted_servers: Vec<TrustedServer>,
|
||||||
|
|
||||||
@@ -2820,12 +2823,10 @@ pub struct OidcConfig {
|
|||||||
|
|
||||||
/// Additional scopes Continuwuity should request from the IDP. This may be
|
/// Additional scopes Continuwuity should request from the IDP. This may be
|
||||||
/// necessary to access certain claims. Continuwuity always requests the
|
/// necessary to access certain claims. Continuwuity always requests the
|
||||||
/// `openid` scope, regardless of the contents of this option,
|
/// `openid` scope.
|
||||||
/// and will also request the `profile` scope by default if this option is
|
|
||||||
/// not set.
|
|
||||||
///
|
///
|
||||||
/// default: ["profile"]
|
/// default: []
|
||||||
#[serde(default = "default_additional_scopes")]
|
#[serde(default)]
|
||||||
pub additional_scopes: Vec<Scope>,
|
pub additional_scopes: Vec<Scope>,
|
||||||
|
|
||||||
/// Additional trusted audiences that Continuwuity will accept in the `aud`
|
/// Additional trusted audiences that Continuwuity will accept in the `aud`
|
||||||
@@ -3261,11 +3262,12 @@ fn default_otlp_filter() -> String {
|
|||||||
fn default_tracing_flame_output_path() -> String { "./tracing.folded".to_owned() }
|
fn default_tracing_flame_output_path() -> String { "./tracing.folded".to_owned() }
|
||||||
|
|
||||||
fn default_trusted_servers() -> Vec<TrustedServer> {
|
fn default_trusted_servers() -> Vec<TrustedServer> {
|
||||||
let trusted_servers = vec![
|
// TODO(nex): Once we can be a notary, add maintainer(?) homeservers here.
|
||||||
ruma::owned_server_name!("continuwuity.org"),
|
// Rationale: Users are already running our code, arguably that's a higher
|
||||||
ruma::owned_server_name!("continuwuity.rocks"),
|
// level of trust than is assigned to notaries in the first place.
|
||||||
ruma::owned_server_name!("matrix.org"),
|
// We should still remind everyone that notaries are evil and out to get you
|
||||||
];
|
// and to replace this list with servers they actually trust.
|
||||||
|
let trusted_servers = vec![ruma::owned_server_name!("matrix.org")];
|
||||||
trusted_servers
|
trusted_servers
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(TrustedServer::Name)
|
.map(TrustedServer::Name)
|
||||||
@@ -3444,8 +3446,6 @@ fn default_unauthenticated_request_ratelimit<K: Hash + Eq + Clone>() -> PerMinut
|
|||||||
PerMinuteRatelimiter::new(Quota::per_minute(30.try_into().unwrap()))
|
PerMinuteRatelimiter::new(Quota::per_minute(30.try_into().unwrap()))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn default_additional_scopes() -> Vec<Scope> { vec![Scope::new("profile".to_owned())] }
|
|
||||||
|
|
||||||
// NOTE: This must be declared *after* every config struct in this file. The
|
// NOTE: This must be declared *after* every config struct in this file. The
|
||||||
// example config generator writes sections in macro expansion order, and the
|
// example config generator writes sections in macro expansion order, and the
|
||||||
// `global` section truncates the file, so declaring this module any earlier
|
// `global` section truncates the file, so declaring this module any earlier
|
||||||
|
|||||||
@@ -25,7 +25,6 @@ use serde_json::{
|
|||||||
value::{RawValue as RawJsonValue, to_raw_value as to_raw_json_value},
|
value::{RawValue as RawJsonValue, to_raw_value as to_raw_json_value},
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::test_utils::not_rejected;
|
|
||||||
use crate::{
|
use crate::{
|
||||||
matrix::{Event, Pdu, pdu::EventHash},
|
matrix::{Event, Pdu, pdu::EventHash},
|
||||||
state_res::{self as state_res, Error, Result, StateMap},
|
state_res::{self as state_res, Error, Result, StateMap},
|
||||||
@@ -79,7 +78,6 @@ fn resolution_shallow_auth_chain(c: &mut test::Bencher) {
|
|||||||
&auth_chain_sets,
|
&auth_chain_sets,
|
||||||
&fetch,
|
&fetch,
|
||||||
&exists,
|
&exists,
|
||||||
¬_rejected,
|
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
{
|
{
|
||||||
@@ -153,7 +151,6 @@ fn resolve_deeper_event_set(c: &mut test::Bencher) {
|
|||||||
&auth_chain_sets,
|
&auth_chain_sets,
|
||||||
&fetch,
|
&fetch,
|
||||||
&exists,
|
&exists,
|
||||||
¬_rejected,
|
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -75,33 +75,18 @@ type Result<T, E = Error> = crate::Result<T, E>;
|
|||||||
//#[tracing::instrument(level = "debug", skip(state_sets, auth_chain_sets,
|
//#[tracing::instrument(level = "debug", skip(state_sets, auth_chain_sets,
|
||||||
//#[tracing::instrument(level event_fetch))]
|
//#[tracing::instrument(level event_fetch))]
|
||||||
#[allow(clippy::cognitive_complexity)]
|
#[allow(clippy::cognitive_complexity)]
|
||||||
pub async fn resolve<
|
pub async fn resolve<'a, Pdu, Sets, SetIter, Hasher, Fetch, FetchFut, Exists, ExistsFut>(
|
||||||
'a,
|
|
||||||
Pdu,
|
|
||||||
Sets,
|
|
||||||
SetIter,
|
|
||||||
Hasher,
|
|
||||||
Fetch,
|
|
||||||
FetchFut,
|
|
||||||
Exists,
|
|
||||||
ExistsFut,
|
|
||||||
Rejected,
|
|
||||||
RejectedFut,
|
|
||||||
>(
|
|
||||||
room_version: &RoomVersionRules,
|
room_version: &RoomVersionRules,
|
||||||
state_sets: Sets,
|
state_sets: Sets,
|
||||||
auth_chain_sets: &'a [HashSet<OwnedEventId, Hasher>],
|
auth_chain_sets: &'a [HashSet<OwnedEventId, Hasher>],
|
||||||
event_fetch: &Fetch,
|
event_fetch: &Fetch,
|
||||||
event_exists: &Exists,
|
event_exists: &Exists,
|
||||||
is_rejected: &Rejected,
|
|
||||||
) -> Result<StateMap<OwnedEventId>>
|
) -> Result<StateMap<OwnedEventId>>
|
||||||
where
|
where
|
||||||
Fetch: Fn(OwnedEventId) -> FetchFut + Sync,
|
Fetch: Fn(OwnedEventId) -> FetchFut + Sync,
|
||||||
FetchFut: Future<Output = Option<Pdu>> + Send,
|
FetchFut: Future<Output = Option<Pdu>> + Send,
|
||||||
Exists: Fn(OwnedEventId) -> ExistsFut + Sync,
|
Exists: Fn(OwnedEventId) -> ExistsFut + Sync,
|
||||||
ExistsFut: Future<Output = bool> + Send,
|
ExistsFut: Future<Output = bool> + Send,
|
||||||
Rejected: Fn(OwnedEventId) -> RejectedFut + Sync,
|
|
||||||
RejectedFut: Future<Output = bool> + Send,
|
|
||||||
Sets: IntoIterator<IntoIter = SetIter> + Send,
|
Sets: IntoIterator<IntoIter = SetIter> + Send,
|
||||||
SetIter: Iterator<Item = &'a StateMap<OwnedEventId>> + Clone + Send,
|
SetIter: Iterator<Item = &'a StateMap<OwnedEventId>> + Clone + Send,
|
||||||
Hasher: BuildHasher + Send + Sync,
|
Hasher: BuildHasher + Send + Sync,
|
||||||
@@ -189,7 +174,6 @@ where
|
|||||||
sorted_control_levels.iter().stream().map(AsRef::as_ref),
|
sorted_control_levels.iter().stream().map(AsRef::as_ref),
|
||||||
initial_state,
|
initial_state,
|
||||||
&event_fetch,
|
&event_fetch,
|
||||||
is_rejected,
|
|
||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
@@ -230,7 +214,6 @@ where
|
|||||||
sorted_left_events.iter().stream().map(AsRef::as_ref),
|
sorted_left_events.iter().stream().map(AsRef::as_ref),
|
||||||
resolved_control, // The control events are added to the final resolved state
|
resolved_control, // The control events are added to the final resolved state
|
||||||
&event_fetch,
|
&event_fetch,
|
||||||
is_rejected,
|
|
||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
@@ -706,18 +689,15 @@ where
|
|||||||
/// the the `fetch_event` closure and verify each event using the
|
/// the the `fetch_event` closure and verify each event using the
|
||||||
/// `event_auth::auth_check` function.
|
/// `event_auth::auth_check` function.
|
||||||
#[tracing::instrument(level = "trace", skip_all)]
|
#[tracing::instrument(level = "trace", skip_all)]
|
||||||
async fn iterative_auth_check<'a, E, F, Fut, R, RFut, S>(
|
async fn iterative_auth_check<'a, E, F, Fut, S>(
|
||||||
room_version: &RoomVersionRules,
|
room_version: &RoomVersionRules,
|
||||||
events_to_check: S,
|
events_to_check: S,
|
||||||
unconflicted_state: StateMap<OwnedEventId>,
|
unconflicted_state: StateMap<OwnedEventId>,
|
||||||
fetch_event: &F,
|
fetch_event: &F,
|
||||||
is_rejected: &R,
|
|
||||||
) -> Result<StateMap<OwnedEventId>>
|
) -> Result<StateMap<OwnedEventId>>
|
||||||
where
|
where
|
||||||
F: Fn(OwnedEventId) -> Fut + Sync,
|
F: Fn(OwnedEventId) -> Fut + Sync,
|
||||||
Fut: Future<Output = Option<E>> + Send,
|
Fut: Future<Output = Option<E>> + Send,
|
||||||
R: Fn(OwnedEventId) -> RFut + Sync,
|
|
||||||
RFut: Future<Output = bool> + Send,
|
|
||||||
S: Stream<Item = &'a EventId> + Send + 'a,
|
S: Stream<Item = &'a EventId> + Send + 'a,
|
||||||
E: Event + Clone + Send + Sync,
|
E: Event + Clone + Send + Sync,
|
||||||
for<'b> &'b E: Event + Send,
|
for<'b> &'b E: Event + Send,
|
||||||
@@ -747,34 +727,18 @@ where
|
|||||||
|
|
||||||
trace!(set = ?auth_event_ids, "auth event IDs to fetch");
|
trace!(set = ?auth_event_ids, "auth event IDs to fetch");
|
||||||
|
|
||||||
let rejected_check_ids: HashSet<OwnedEventId> = auth_event_ids
|
let auth_events: HashMap<OwnedEventId, E> = auth_event_ids
|
||||||
.iter()
|
|
||||||
.chain(unconflicted_state.values())
|
|
||||||
.cloned()
|
|
||||||
.chain(events_to_check.iter().map(|e| e.event_id().to_owned()))
|
|
||||||
.collect();
|
|
||||||
|
|
||||||
let auth_events_fut = auth_event_ids
|
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.stream()
|
.stream()
|
||||||
.broad_filter_map(fetch_event)
|
.broad_filter_map(fetch_event)
|
||||||
.map(|auth_event| (auth_event.event_id().to_owned(), auth_event))
|
.map(|auth_event| (auth_event.event_id().to_owned(), auth_event))
|
||||||
.collect::<HashMap<OwnedEventId, E>>()
|
.collect()
|
||||||
.boxed();
|
.boxed()
|
||||||
|
.await;
|
||||||
let rejected_events_fut = rejected_check_ids
|
|
||||||
.into_iter()
|
|
||||||
.stream()
|
|
||||||
.broad_filter_map(|id| async move { is_rejected(id.clone()).await.then_some(id) })
|
|
||||||
.collect::<HashSet<OwnedEventId>>()
|
|
||||||
.boxed();
|
|
||||||
|
|
||||||
let (auth_events, rejected_events) = future::join(auth_events_fut, rejected_events_fut).await;
|
|
||||||
|
|
||||||
trace!(map = ?auth_events.keys().collect::<Vec<_>>(), "fetched auth events");
|
trace!(map = ?auth_events.keys().collect::<Vec<_>>(), "fetched auth events");
|
||||||
|
|
||||||
let auth_events = &auth_events;
|
let auth_events = &auth_events;
|
||||||
let rejected_events = &rejected_events;
|
|
||||||
// NOTE: in state resolution v2.1, auth checks should start with an empty
|
// NOTE: in state resolution v2.1, auth checks should start with an empty
|
||||||
// state map. It is the caller's job to do this. Previously, this function
|
// state map. It is the caller's job to do this. Previously, this function
|
||||||
// would force an empty state map in this case, and this resulted in power
|
// would force an empty state map in this case, and this resulted in power
|
||||||
@@ -783,7 +747,6 @@ where
|
|||||||
let mut resolved_state = unconflicted_state;
|
let mut resolved_state = unconflicted_state;
|
||||||
for event in events_to_check {
|
for event in events_to_check {
|
||||||
trace!(event_id = event.event_id().as_str(), "checking event");
|
trace!(event_id = event.event_id().as_str(), "checking event");
|
||||||
|
|
||||||
let state_key = event
|
let state_key = event
|
||||||
.state_key()
|
.state_key()
|
||||||
.ok_or_else(|| Error::InvalidPdu("State event had no state key".to_owned()))?;
|
.ok_or_else(|| Error::InvalidPdu("State event had no state key".to_owned()))?;
|
||||||
@@ -814,9 +777,8 @@ where
|
|||||||
}
|
}
|
||||||
for aid in event.auth_events() {
|
for aid in event.auth_events() {
|
||||||
if let Some(ev) = auth_events.get(aid) {
|
if let Some(ev) = auth_events.get(aid) {
|
||||||
if rejected_events.contains(aid) {
|
//TODO: synapse checks "rejected_reason" which is most likely
|
||||||
continue;
|
// related to soft-failing
|
||||||
}
|
|
||||||
trace!(event_id = aid.as_str(), "found auth event");
|
trace!(event_id = aid.as_str(), "found auth event");
|
||||||
auth_state.insert(
|
auth_state.insert(
|
||||||
ev.event_type()
|
ev.event_type()
|
||||||
@@ -835,9 +797,6 @@ where
|
|||||||
.stream()
|
.stream()
|
||||||
.ready_filter_map(|key| Some((key, resolved_state.get(key)?)))
|
.ready_filter_map(|key| Some((key, resolved_state.get(key)?)))
|
||||||
.filter_map(|(key, ev_id)| async move {
|
.filter_map(|(key, ev_id)| async move {
|
||||||
if rejected_events.contains(ev_id) {
|
|
||||||
return None;
|
|
||||||
}
|
|
||||||
if let Some(event) = auth_events.get(ev_id) {
|
if let Some(event) = auth_events.get(ev_id) {
|
||||||
Some((key, event.clone()))
|
Some((key, event.clone()))
|
||||||
} else {
|
} else {
|
||||||
@@ -845,6 +804,7 @@ where
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
.ready_for_each(|(key, event)| {
|
.ready_for_each(|(key, event)| {
|
||||||
|
//TODO: synapse checks "rejected_reason" is None here
|
||||||
auth_state.insert(key.to_owned(), event);
|
auth_state.insert(key.to_owned(), event);
|
||||||
})
|
})
|
||||||
.await;
|
.await;
|
||||||
@@ -1147,8 +1107,8 @@ mod tests {
|
|||||||
StateMap, is_power_event,
|
StateMap, is_power_event,
|
||||||
test_utils::{
|
test_utils::{
|
||||||
INITIAL_EVENTS, TestStore, alice, bob, charlie, do_check, ella, event_id,
|
INITIAL_EVENTS, TestStore, alice, bob, charlie, do_check, ella, event_id,
|
||||||
member_content_ban, member_content_join, not_rejected, room_id, to_init_pdu_event,
|
member_content_ban, member_content_join, room_id, to_init_pdu_event, to_pdu_event,
|
||||||
to_pdu_event, zara,
|
zara,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
use crate::{
|
use crate::{
|
||||||
@@ -1209,7 +1169,6 @@ mod tests {
|
|||||||
ordered_events.iter().map(AsRef::as_ref).stream(),
|
ordered_events.iter().map(AsRef::as_ref).stream(),
|
||||||
initial_state,
|
initial_state,
|
||||||
&fetcher,
|
&fetcher,
|
||||||
¬_rejected,
|
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
.unwrap();
|
.unwrap();
|
||||||
@@ -1220,172 +1179,6 @@ mod tests {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::test]
|
|
||||||
async fn iterative_auth_check_reauths_rejected_events() {
|
|
||||||
let mut events = INITIAL_EVENTS();
|
|
||||||
let initial_state = ["CREATE", "IPOWER", "IJR", "IMB"]
|
|
||||||
.into_iter()
|
|
||||||
.map(|id| {
|
|
||||||
let event = &events[&event_id(id)];
|
|
||||||
(
|
|
||||||
event
|
|
||||||
.event_type()
|
|
||||||
.with_state_key(event.state_key().unwrap()),
|
|
||||||
event.event_id.clone(),
|
|
||||||
)
|
|
||||||
})
|
|
||||||
.collect();
|
|
||||||
let leave = to_pdu_event(
|
|
||||||
"LEAVE",
|
|
||||||
bob(),
|
|
||||||
TimelineEventType::RoomMember,
|
|
||||||
Some(bob().as_str()),
|
|
||||||
to_raw_json_value(&json!({ "membership": "leave" })).unwrap(),
|
|
||||||
&["CREATE", "IPOWER", "IMB"],
|
|
||||||
&["IMB"],
|
|
||||||
);
|
|
||||||
let rejoin = to_pdu_event(
|
|
||||||
"REJOIN",
|
|
||||||
bob(),
|
|
||||||
TimelineEventType::RoomMember,
|
|
||||||
Some(bob().as_str()),
|
|
||||||
member_content_join(),
|
|
||||||
&["CREATE", "IPOWER", "IJR", "LEAVE"],
|
|
||||||
&["LEAVE"],
|
|
||||||
);
|
|
||||||
let ordered_events = [leave.event_id.clone(), rejoin.event_id.clone()];
|
|
||||||
for event in [leave, rejoin] {
|
|
||||||
events.insert(event.event_id.clone(), event);
|
|
||||||
}
|
|
||||||
let fetcher = |id: OwnedEventId| {
|
|
||||||
let events = &events;
|
|
||||||
async move { events.get(&id).cloned() }
|
|
||||||
};
|
|
||||||
let resolved = super::iterative_auth_check(
|
|
||||||
&RoomVersionRules::V6,
|
|
||||||
ordered_events.iter().map(AsRef::as_ref).stream(),
|
|
||||||
initial_state,
|
|
||||||
&fetcher,
|
|
||||||
&|id| async move { id == event_id("REJOIN") },
|
|
||||||
)
|
|
||||||
.await
|
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
assert_eq!(
|
|
||||||
resolved[&StateEventType::RoomMember.with_state_key(bob().as_str())],
|
|
||||||
event_id("REJOIN"),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[tokio::test]
|
|
||||||
async fn iterative_auth_check_ignores_rejected_auth_events() {
|
|
||||||
let mut events = INITIAL_EVENTS();
|
|
||||||
let initial_state = ["CREATE", "IPOWER"]
|
|
||||||
.into_iter()
|
|
||||||
.map(|id| {
|
|
||||||
let event = &events[&event_id(id)];
|
|
||||||
(
|
|
||||||
event
|
|
||||||
.event_type()
|
|
||||||
.with_state_key(event.state_key().unwrap()),
|
|
||||||
event.event_id.clone(),
|
|
||||||
)
|
|
||||||
})
|
|
||||||
.collect();
|
|
||||||
// Bob tries to join relying on IJR in auth_events, which is not in
|
|
||||||
// initial_state and is marked rejected.
|
|
||||||
let join = to_pdu_event(
|
|
||||||
"BOB_JOIN",
|
|
||||||
bob(),
|
|
||||||
TimelineEventType::RoomMember,
|
|
||||||
Some(bob().as_str()),
|
|
||||||
member_content_join(),
|
|
||||||
&["CREATE", "IPOWER", "IJR"],
|
|
||||||
&["IJR"],
|
|
||||||
);
|
|
||||||
let ordered_events = [join.event_id.clone()];
|
|
||||||
events.insert(join.event_id.clone(), join);
|
|
||||||
|
|
||||||
let fetcher = |id: OwnedEventId| {
|
|
||||||
let events = &events;
|
|
||||||
async move { events.get(&id).cloned() }
|
|
||||||
};
|
|
||||||
let resolved = super::iterative_auth_check(
|
|
||||||
&RoomVersionRules::V6,
|
|
||||||
ordered_events.iter().map(AsRef::as_ref).stream(),
|
|
||||||
initial_state,
|
|
||||||
&fetcher,
|
|
||||||
&|id| async move { id == event_id("IJR") },
|
|
||||||
)
|
|
||||||
.await
|
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
assert!(
|
|
||||||
!resolved.contains_key(&StateEventType::RoomMember.with_state_key(bob().as_str()))
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[tokio::test]
|
|
||||||
async fn iterative_auth_check_ignores_rejected_resolved_state() {
|
|
||||||
let mut events = INITIAL_EVENTS();
|
|
||||||
let ban_bob = to_pdu_event(
|
|
||||||
"BAN_BOB",
|
|
||||||
alice(),
|
|
||||||
TimelineEventType::RoomMember,
|
|
||||||
Some(bob().as_str()),
|
|
||||||
member_content_ban(),
|
|
||||||
&["CREATE", "IPOWER", "IMA", "IMB"],
|
|
||||||
&["IMB"],
|
|
||||||
);
|
|
||||||
let bob_leave = to_pdu_event(
|
|
||||||
"BOB_LEAVE",
|
|
||||||
bob(),
|
|
||||||
TimelineEventType::RoomMember,
|
|
||||||
Some(bob().as_str()),
|
|
||||||
to_raw_json_value(&json!({ "membership": "leave" })).unwrap(),
|
|
||||||
&["CREATE", "IPOWER", "IMB"],
|
|
||||||
&["IMB"],
|
|
||||||
);
|
|
||||||
let ordered_events = [bob_leave.event_id.clone()];
|
|
||||||
for event in [ban_bob, bob_leave] {
|
|
||||||
events.insert(event.event_id.clone(), event);
|
|
||||||
}
|
|
||||||
// initial_state has BAN_BOB for Bob's membership, but BAN_BOB is
|
|
||||||
// rejected, so Bob's auth check should fall back to IMB from
|
|
||||||
// BOB_LEAVE's auth_events and succeed.
|
|
||||||
let initial_state = ["CREATE", "IPOWER", "BAN_BOB"]
|
|
||||||
.into_iter()
|
|
||||||
.map(|id| {
|
|
||||||
let event = &events[&event_id(id)];
|
|
||||||
(
|
|
||||||
event
|
|
||||||
.event_type()
|
|
||||||
.with_state_key(event.state_key().unwrap()),
|
|
||||||
event.event_id.clone(),
|
|
||||||
)
|
|
||||||
})
|
|
||||||
.collect();
|
|
||||||
|
|
||||||
let fetcher = |id: OwnedEventId| {
|
|
||||||
let events = &events;
|
|
||||||
async move { events.get(&id).cloned() }
|
|
||||||
};
|
|
||||||
let resolved = super::iterative_auth_check(
|
|
||||||
&RoomVersionRules::V6,
|
|
||||||
ordered_events.iter().map(AsRef::as_ref).stream(),
|
|
||||||
initial_state,
|
|
||||||
&fetcher,
|
|
||||||
&|id| async move { id == event_id("BAN_BOB") },
|
|
||||||
)
|
|
||||||
.await
|
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
assert_eq!(
|
|
||||||
resolved.get(&StateEventType::RoomMember.with_state_key(bob().as_str())),
|
|
||||||
Some(&event_id("BOB_LEAVE")),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Events at the start of a room have no `m.room.power_levels` in their
|
/// Events at the start of a room have no `m.room.power_levels` in their
|
||||||
/// auth events, so the sender's power for sort ordering comes from the
|
/// auth events, so the sender's power for sort ordering comes from the
|
||||||
/// create event instead.
|
/// create event instead.
|
||||||
@@ -1522,7 +1315,6 @@ mod tests {
|
|||||||
sorted_power_events.iter().map(AsRef::as_ref).stream(),
|
sorted_power_events.iter().map(AsRef::as_ref).stream(),
|
||||||
HashMap::new(), // unconflicted events
|
HashMap::new(), // unconflicted events
|
||||||
&fetcher,
|
&fetcher,
|
||||||
¬_rejected,
|
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
.expect("iterative auth check failed on resolved events");
|
.expect("iterative auth check failed on resolved events");
|
||||||
@@ -1925,7 +1717,6 @@ mod tests {
|
|||||||
&auth_chain,
|
&auth_chain,
|
||||||
&fetcher,
|
&fetcher,
|
||||||
&exists,
|
&exists,
|
||||||
¬_rejected,
|
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
{
|
{
|
||||||
@@ -2044,7 +1835,6 @@ mod tests {
|
|||||||
&auth_chain,
|
&auth_chain,
|
||||||
&fetcher,
|
&fetcher,
|
||||||
&exists,
|
&exists,
|
||||||
¬_rejected,
|
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -141,7 +141,6 @@ pub(crate) async fn do_check(
|
|||||||
&auth_chain_sets,
|
&auth_chain_sets,
|
||||||
&fetch,
|
&fetch,
|
||||||
&exists,
|
&exists,
|
||||||
¬_rejected,
|
|
||||||
)
|
)
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
@@ -364,8 +363,6 @@ impl TestStore<Pdu> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) async fn not_rejected(_: OwnedEventId) -> bool { false }
|
|
||||||
|
|
||||||
pub(crate) fn event_id(id: &str) -> OwnedEventId {
|
pub(crate) fn event_id(id: &str) -> OwnedEventId {
|
||||||
if id.contains('$') {
|
if id.contains('$') {
|
||||||
return id.try_into().unwrap();
|
return id.try_into().unwrap();
|
||||||
|
|||||||
@@ -18,7 +18,6 @@ pub fn versions() -> Vec<String> {
|
|||||||
"v1.3".to_owned(),
|
"v1.3".to_owned(),
|
||||||
"v1.4".to_owned(),
|
"v1.4".to_owned(),
|
||||||
"v1.5".to_owned(),
|
"v1.5".to_owned(),
|
||||||
"v1.6".to_owned(),
|
|
||||||
"v1.8".to_owned(),
|
"v1.8".to_owned(),
|
||||||
"v1.11".to_owned(),
|
"v1.11".to_owned(),
|
||||||
"v1.12".to_owned(),
|
"v1.12".to_owned(),
|
||||||
@@ -38,7 +37,6 @@ pub fn unstable_features(experiments: &Experiments) -> BTreeMap<String, bool> {
|
|||||||
// MatrixRTC (https://github.com/matrix-org/matrix-spec-proposals/pull/4143)
|
// MatrixRTC (https://github.com/matrix-org/matrix-spec-proposals/pull/4143)
|
||||||
// Expected for spec v1.20/v2.0
|
// Expected for spec v1.20/v2.0
|
||||||
("org.matrix.msc4143".to_owned(), true),
|
("org.matrix.msc4143".to_owned(), true),
|
||||||
("org.matrix.msc4143.stable".to_owned(), true),
|
|
||||||
// Simplified Sliding sync (https://github.com/matrix-org/matrix-spec-proposals/pull/4186)
|
// Simplified Sliding sync (https://github.com/matrix-org/matrix-spec-proposals/pull/4186)
|
||||||
// Expected for spec v1.20/v2.0
|
// Expected for spec v1.20/v2.0
|
||||||
("org.matrix.simplified_msc3575".to_owned(), true),
|
("org.matrix.simplified_msc3575".to_owned(), true),
|
||||||
|
|||||||
@@ -21,7 +21,6 @@ pub struct Instruments {
|
|||||||
pub sender_transaction_duration: Histogram<f64>,
|
pub sender_transaction_duration: Histogram<f64>,
|
||||||
pub sender_events: Counter<u64>,
|
pub sender_events: Counter<u64>,
|
||||||
pub sender_events_queued: Counter<u64>,
|
pub sender_events_queued: Counter<u64>,
|
||||||
pub sender_panics: Counter<u64>,
|
|
||||||
|
|
||||||
pub media_write_size: Histogram<u64>,
|
pub media_write_size: Histogram<u64>,
|
||||||
pub media_read_size: Histogram<u64>,
|
pub media_read_size: Histogram<u64>,
|
||||||
@@ -117,11 +116,6 @@ impl Instruments {
|
|||||||
.with_description("PDUs and EDUs queued for sending")
|
.with_description("PDUs and EDUs queued for sending")
|
||||||
.with_unit("{event}")
|
.with_unit("{event}")
|
||||||
.build(),
|
.build(),
|
||||||
sender_panics: meter
|
|
||||||
.u64_counter("continuwuity.sender.panics")
|
|
||||||
.with_description("Panics caught in outgoing transactions and sender workers")
|
|
||||||
.with_unit("{panic}")
|
|
||||||
.build(),
|
|
||||||
|
|
||||||
media_write_size: size(
|
media_write_size: size(
|
||||||
"continuwuity.media.write.size",
|
"continuwuity.media.write.size",
|
||||||
|
|||||||
@@ -407,10 +407,6 @@ pub(super) static MAPS: &[Descriptor] = &[
|
|||||||
name: "userdeviceid_token",
|
name: "userdeviceid_token",
|
||||||
..descriptor::RANDOM_SMALL
|
..descriptor::RANDOM_SMALL
|
||||||
},
|
},
|
||||||
Descriptor {
|
|
||||||
name: "userdeviceid_previoustoken",
|
|
||||||
..descriptor::RANDOM_SMALL
|
|
||||||
},
|
|
||||||
Descriptor {
|
Descriptor {
|
||||||
name: "userdevicesessionid_uiaainfo",
|
name: "userdevicesessionid_uiaainfo",
|
||||||
..descriptor::RANDOM_SMALL
|
..descriptor::RANDOM_SMALL
|
||||||
|
|||||||
+1
-1
@@ -48,7 +48,6 @@ assets = [
|
|||||||
[features]
|
[features]
|
||||||
default = [
|
default = [
|
||||||
"standard",
|
"standard",
|
||||||
"jemalloc",
|
|
||||||
"ring",
|
"ring",
|
||||||
"bindgen-runtime", # replace with bindgen-static on alpine
|
"bindgen-runtime", # replace with bindgen-static on alpine
|
||||||
]
|
]
|
||||||
@@ -58,6 +57,7 @@ standard = [
|
|||||||
"element_hacks",
|
"element_hacks",
|
||||||
"gzip_compression",
|
"gzip_compression",
|
||||||
"io_uring",
|
"io_uring",
|
||||||
|
"jemalloc",
|
||||||
"jemalloc_conf",
|
"jemalloc_conf",
|
||||||
"journald",
|
"journald",
|
||||||
"media_thumbnail",
|
"media_thumbnail",
|
||||||
|
|||||||
@@ -32,11 +32,6 @@ pub fn run() -> Result<()> {
|
|||||||
pub fn run_with_args(args: &Args) -> Result<()> {
|
pub fn run_with_args(args: &Args) -> Result<()> {
|
||||||
// Spawn deadlock detection thread
|
// Spawn deadlock detection thread
|
||||||
deadlock::spawn();
|
deadlock::spawn();
|
||||||
#[cfg(not(any(feature = "jemalloc", feature = "mimalloc")))]
|
|
||||||
conduwuit_core::warn!(
|
|
||||||
"Your build configuration does not have a non-system allocator enabled. This may result \
|
|
||||||
in decreased performance."
|
|
||||||
);
|
|
||||||
|
|
||||||
// Because we're not using rustls default-tls, we have to initialise a TLS
|
// Because we're not using rustls default-tls, we have to initialise a TLS
|
||||||
// provider
|
// provider
|
||||||
|
|||||||
@@ -1 +0,0 @@
|
|||||||
pub mod notary;
|
|
||||||
@@ -1,56 +0,0 @@
|
|||||||
//! `POST /_matrix/key/*/query`
|
|
||||||
//!
|
|
||||||
//! Endpoint to query signing keys through other (notary) servers.
|
|
||||||
|
|
||||||
pub mod unstable {
|
|
||||||
use std::collections::BTreeMap;
|
|
||||||
|
|
||||||
use ruma::{
|
|
||||||
OwnedServerName, OwnedServerSigningKeyId,
|
|
||||||
api::{
|
|
||||||
federation::{
|
|
||||||
authentication::ServerSignatures,
|
|
||||||
discovery::{ServerSigningKeys, get_remote_server_keys_batch::v2::QueryCriteria},
|
|
||||||
},
|
|
||||||
request, response,
|
|
||||||
},
|
|
||||||
metadata,
|
|
||||||
serde::Raw,
|
|
||||||
};
|
|
||||||
|
|
||||||
metadata! {
|
|
||||||
method: POST,
|
|
||||||
rate_limited: true,
|
|
||||||
authentication: ServerSignatures,
|
|
||||||
path: "/_matrix/key/unstable/org.continuwuity.msc4556/query",
|
|
||||||
}
|
|
||||||
|
|
||||||
#[request]
|
|
||||||
pub struct Request {
|
|
||||||
pub server_keys:
|
|
||||||
BTreeMap<OwnedServerName, BTreeMap<OwnedServerSigningKeyId, QueryCriteria>>,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[response]
|
|
||||||
pub struct Response {
|
|
||||||
pub server_keys: Vec<Raw<ServerSigningKeys>>,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Request {
|
|
||||||
#[must_use]
|
|
||||||
pub fn new(
|
|
||||||
server_keys: BTreeMap<
|
|
||||||
OwnedServerName,
|
|
||||||
BTreeMap<OwnedServerSigningKeyId, QueryCriteria>,
|
|
||||||
>,
|
|
||||||
) -> Self {
|
|
||||||
Self { server_keys }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Response {
|
|
||||||
/// Creates a new `Response` with the given keys.
|
|
||||||
#[must_use]
|
|
||||||
pub fn new(server_keys: Vec<Raw<ServerSigningKeys>>) -> Self { Self { server_keys } }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -6,5 +6,3 @@ pub mod invite_permission_config;
|
|||||||
pub mod meowlnir_antispam;
|
pub mod meowlnir_antispam;
|
||||||
pub mod policy;
|
pub mod policy;
|
||||||
pub mod pushers;
|
pub mod pushers;
|
||||||
|
|
||||||
pub mod federation;
|
|
||||||
@@ -105,7 +105,6 @@ itertools.workspace = true
|
|||||||
log.workspace = true
|
log.workspace = true
|
||||||
loole.workspace = true
|
loole.workspace = true
|
||||||
lru-cache.workspace = true
|
lru-cache.workspace = true
|
||||||
mime.workspace = true
|
|
||||||
nonzero_ext.workspace = true
|
nonzero_ext.workspace = true
|
||||||
p256.workspace = true
|
p256.workspace = true
|
||||||
regex.workspace = true
|
regex.workspace = true
|
||||||
|
|||||||
@@ -111,7 +111,7 @@ impl crate::Service for Service {
|
|||||||
.local_address(url_preview_bind_addr)
|
.local_address(url_preview_bind_addr)
|
||||||
.timeout(Duration::from_secs(config.url_preview_timeout))
|
.timeout(Duration::from_secs(config.url_preview_timeout))
|
||||||
.redirect(redirect::Policy::limited(3))
|
.redirect(redirect::Policy::limited(3))
|
||||||
.user_agent(url_preview_user_agent.replace("<version>", conduwuit::version_ua()))
|
.user_agent(url_preview_user_agent)
|
||||||
.build()?,
|
.build()?,
|
||||||
|
|
||||||
external_resource: base(config, reqwest_dns_resolver.clone())?
|
external_resource: base(config, reqwest_dns_resolver.clone())?
|
||||||
|
|||||||
@@ -223,8 +223,6 @@ impl Data {
|
|||||||
x => x,
|
x => x,
|
||||||
};*/
|
};*/
|
||||||
|
|
||||||
// TODO(nex): Oh my god this is awful when can we kill it
|
|
||||||
|
|
||||||
let title = match values
|
let title = match values
|
||||||
.next()
|
.next()
|
||||||
.and_then(|b| String::from_utf8(b.to_vec()).ok())
|
.and_then(|b| String::from_utf8(b.to_vec()).ok())
|
||||||
@@ -323,11 +321,6 @@ impl Data {
|
|||||||
video_height,
|
video_height,
|
||||||
audio,
|
audio,
|
||||||
audio_size,
|
audio_size,
|
||||||
..Default::default() /* TODO(nex,silversys): This weird manual field
|
|
||||||
* de/serialisation just needs replacing with JSON storage to
|
|
||||||
* avoid this mess. This is consequently intentionally
|
|
||||||
* dropping information added later (like image alt text).
|
|
||||||
* I'll do it later. */
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+90
-345
@@ -7,79 +7,29 @@
|
|||||||
|
|
||||||
use std::time::SystemTime;
|
use std::time::SystemTime;
|
||||||
|
|
||||||
#[cfg(feature = "url_preview")]
|
|
||||||
use conduwuit::info;
|
|
||||||
use conduwuit::{Err, Result, debug, err, utils::response::LimitReadExt};
|
use conduwuit::{Err, Result, debug, err, utils::response::LimitReadExt};
|
||||||
use ipaddress::IPAddress;
|
use ipaddress::IPAddress;
|
||||||
use mime::Mime;
|
|
||||||
use ruma::OwnedMxcUri;
|
use ruma::OwnedMxcUri;
|
||||||
use serde::{Serialize, Serializer};
|
use serde::Serialize;
|
||||||
use url::Url;
|
use url::Url;
|
||||||
|
|
||||||
use super::Service;
|
use super::Service;
|
||||||
use crate::media::mxc::Mxc;
|
use crate::media::mxc::Mxc;
|
||||||
|
|
||||||
// serde `serialize_with` passes `&Option<T>` for `Option<T>` fields.
|
#[derive(Serialize, Default)]
|
||||||
#[allow(clippy::ref_option)]
|
|
||||||
fn serialize_mime<S: Serializer>(mime: &Option<Mime>, serializer: S) -> Result<S::Ok, S::Error> {
|
|
||||||
match mime {
|
|
||||||
| Some(m) => serializer.serialize_str(m.as_ref()),
|
|
||||||
| None => serializer.serialize_none(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Serialize, Default, Debug)]
|
|
||||||
pub struct UrlPreviewData {
|
pub struct UrlPreviewData {
|
||||||
// From https://ogp.me/
|
|
||||||
/// The title of your object as it should appear within the graph
|
|
||||||
/// "The Rock".
|
|
||||||
#[serde(skip_serializing_if = "Option::is_none", rename(serialize = "og:title"))]
|
#[serde(skip_serializing_if = "Option::is_none", rename(serialize = "og:title"))]
|
||||||
pub title: Option<String>,
|
pub title: Option<String>,
|
||||||
|
|
||||||
/// The type of your object, e.g., "video.movie".
|
|
||||||
#[serde(skip_serializing_if = "String::is_empty", rename(serialize = "og:type"))]
|
|
||||||
pub site_type: String,
|
|
||||||
/// The canonical URL of your object that will be used as its permanent ID
|
|
||||||
/// in the graph.
|
|
||||||
#[serde(skip_serializing_if = "Option::is_none", rename(serialize = "og:url"))]
|
|
||||||
pub url: Option<String>,
|
|
||||||
/// A one to two sentence description of your object.
|
|
||||||
#[serde(skip_serializing_if = "Option::is_none", rename(serialize = "og:description"))]
|
#[serde(skip_serializing_if = "Option::is_none", rename(serialize = "og:description"))]
|
||||||
pub description: Option<String>,
|
pub description: Option<String>,
|
||||||
/// The word that appears before this object's title in a sentence.
|
|
||||||
#[serde(skip_serializing_if = "Option::is_none", rename(serialize = "og:determiner"))]
|
|
||||||
pub determiner: Option<String>,
|
|
||||||
/// The locale these tags are marked up in
|
|
||||||
#[serde(skip_serializing_if = "Option::is_none", rename(serialize = "og:locale"))]
|
|
||||||
pub locale: Option<String>,
|
|
||||||
/// If your object is part of a larger web site, the name which should be
|
|
||||||
/// displayed for the overall site.
|
|
||||||
#[serde(skip_serializing_if = "Option::is_none", rename(serialize = "og:site_name"))]
|
|
||||||
pub site_name: Option<String>,
|
|
||||||
|
|
||||||
/// An image URL which should represent your object within the graph.
|
|
||||||
#[serde(skip_serializing_if = "Option::is_none", rename(serialize = "og:image"))]
|
#[serde(skip_serializing_if = "Option::is_none", rename(serialize = "og:image"))]
|
||||||
pub image: Option<String>,
|
pub image: Option<String>,
|
||||||
/// A MIME type for this image.
|
|
||||||
#[serde(
|
|
||||||
skip_serializing_if = "Option::is_none",
|
|
||||||
serialize_with = "serialize_mime",
|
|
||||||
rename(serialize = "og:image:type")
|
|
||||||
)]
|
|
||||||
pub image_type: Option<Mime>,
|
|
||||||
#[serde(skip_serializing_if = "Option::is_none", rename(serialize = "matrix:image:size"))]
|
#[serde(skip_serializing_if = "Option::is_none", rename(serialize = "matrix:image:size"))]
|
||||||
pub image_size: Option<usize>,
|
pub image_size: Option<usize>,
|
||||||
/// The number of pixels wide.
|
|
||||||
#[serde(skip_serializing_if = "Option::is_none", rename(serialize = "og:image:width"))]
|
#[serde(skip_serializing_if = "Option::is_none", rename(serialize = "og:image:width"))]
|
||||||
pub image_width: Option<u32>,
|
pub image_width: Option<u32>,
|
||||||
/// The number of pixels high.
|
|
||||||
#[serde(skip_serializing_if = "Option::is_none", rename(serialize = "og:image:height"))]
|
#[serde(skip_serializing_if = "Option::is_none", rename(serialize = "og:image:height"))]
|
||||||
pub image_height: Option<u32>,
|
pub image_height: Option<u32>,
|
||||||
/// A description of what is in the image (not a caption).
|
|
||||||
#[serde(skip_serializing_if = "Option::is_none", rename(serialize = "og:image:alt"))]
|
|
||||||
pub image_alt: Option<String>,
|
|
||||||
|
|
||||||
/// A URL to a video file that complements this object.
|
|
||||||
#[serde(skip_serializing_if = "Option::is_none", rename(serialize = "og:video"))]
|
#[serde(skip_serializing_if = "Option::is_none", rename(serialize = "og:video"))]
|
||||||
pub video: Option<String>,
|
pub video: Option<String>,
|
||||||
#[serde(skip_serializing_if = "Option::is_none", rename(serialize = "matrix:video:size"))]
|
#[serde(skip_serializing_if = "Option::is_none", rename(serialize = "matrix:video:size"))]
|
||||||
@@ -88,15 +38,6 @@ pub struct UrlPreviewData {
|
|||||||
pub video_width: Option<u32>,
|
pub video_width: Option<u32>,
|
||||||
#[serde(skip_serializing_if = "Option::is_none", rename(serialize = "og:video:height"))]
|
#[serde(skip_serializing_if = "Option::is_none", rename(serialize = "og:video:height"))]
|
||||||
pub video_height: Option<u32>,
|
pub video_height: Option<u32>,
|
||||||
#[serde(
|
|
||||||
skip_serializing_if = "Option::is_none",
|
|
||||||
serialize_with = "serialize_mime",
|
|
||||||
rename(serialize = "og:video:type")
|
|
||||||
)]
|
|
||||||
pub video_type: Option<Mime>,
|
|
||||||
#[serde(skip_serializing_if = "Option::is_none", rename(serialize = "og:video:alt"))]
|
|
||||||
pub video_alt: Option<String>,
|
|
||||||
/// A URL to an audio file to accompany this object.
|
|
||||||
#[serde(skip_serializing_if = "Option::is_none", rename(serialize = "og:audio"))]
|
#[serde(skip_serializing_if = "Option::is_none", rename(serialize = "og:audio"))]
|
||||||
pub audio: Option<String>,
|
pub audio: Option<String>,
|
||||||
#[serde(skip_serializing_if = "Option::is_none", rename(serialize = "matrix:audio:size"))]
|
#[serde(skip_serializing_if = "Option::is_none", rename(serialize = "matrix:audio:size"))]
|
||||||
@@ -137,39 +78,43 @@ impl Service {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async fn request_url_preview(&self, url: &Url) -> Result<UrlPreviewData> {
|
async fn request_url_preview(&self, url: &Url) -> Result<UrlPreviewData> {
|
||||||
self.check_url_ip(url.as_str())?;
|
if let Ok(ip) = IPAddress::parse(url.host_str().expect("URL previously validated")) {
|
||||||
|
if !self.services.client.valid_cidr_range(&ip) {
|
||||||
|
return Err!(Request(Forbidden("Requesting from this address is forbidden")));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
let client = &self.services.client.url_preview;
|
let client = &self.services.client.url_preview;
|
||||||
let response = client.head(url.as_str()).send().await?;
|
let response = client.head(url.as_str()).send().await?;
|
||||||
|
|
||||||
debug!(%url, "URL preview response headers: {:?}", response.headers());
|
debug!(%url, "URL preview response headers: {:?}", response.headers());
|
||||||
|
|
||||||
self.check_response_ip(&response)?;
|
if let Some(remote_addr) = response.remote_addr() {
|
||||||
if !response.status().is_success() {
|
debug!(%url, "URL preview response remote address: {:?}", remote_addr);
|
||||||
return Err!(Request(Unknown(
|
|
||||||
"URL preview request returned HTTP {}",
|
if let Ok(ip) = IPAddress::parse(remote_addr.ip().to_string()) {
|
||||||
response.status()
|
if !self.services.client.valid_cidr_range(&ip) {
|
||||||
)));
|
return Err!(Request(Forbidden("Requesting from this address is forbidden")));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let Some(content_type) = response.headers().get(reqwest::header::CONTENT_TYPE) else {
|
let Some(content_type) = response.headers().get(reqwest::header::CONTENT_TYPE) else {
|
||||||
return Err!(Request(Unknown(
|
return Err!(Request(Unknown("Unknown or invalid Content-Type header")));
|
||||||
"Response contains unknown, invalid, or missing Content-Type header"
|
|
||||||
)));
|
|
||||||
};
|
};
|
||||||
|
|
||||||
let content_type: Mime = content_type
|
let content_type = content_type
|
||||||
.to_str()
|
.to_str()
|
||||||
.map_err(|e| err!(Request(Unknown("Unknown or invalid Content-Type header: {e}"))))?
|
|
||||||
.parse()
|
|
||||||
.map_err(|e| err!(Request(Unknown("Unknown or invalid Content-Type header: {e}"))))?;
|
.map_err(|e| err!(Request(Unknown("Unknown or invalid Content-Type header: {e}"))))?;
|
||||||
|
|
||||||
let data = match (content_type.type_(), content_type.subtype()) {
|
let data = match content_type {
|
||||||
| (mime::TEXT, mime::HTML) => self.download_html(url.as_str()).await?,
|
| html if html.starts_with("text/html") => self.download_html(url.as_str()).await?,
|
||||||
| (mime::IMAGE, _) => self.download_image(url.as_str()).await?,
|
| img if img.starts_with("image/") => self.download_image(url.as_str(), None).await?,
|
||||||
| (mime::VIDEO, _) => self.download_video(url.as_str()).await?,
|
| video if video.starts_with("video/") =>
|
||||||
| (mime::AUDIO, _) => self.download_audio(url.as_str()).await?,
|
self.download_video(url.as_str(), None).await?,
|
||||||
| _ => return Err!(Request(Unknown("Unsupported Content-Type: {content_type}"))),
|
| audio if audio.starts_with("audio/") =>
|
||||||
|
self.download_audio(url.as_str(), None).await?,
|
||||||
|
| _ => return Err!(Request(Unknown("Unsupported Content-Type"))),
|
||||||
};
|
};
|
||||||
|
|
||||||
self.set_url_preview(url.as_str(), &data).await?;
|
self.set_url_preview(url.as_str(), &data).await?;
|
||||||
@@ -178,16 +123,19 @@ impl Service {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "url_preview")]
|
#[cfg(feature = "url_preview")]
|
||||||
pub async fn download_image(&self, url: &str) -> Result<UrlPreviewData> {
|
pub async fn download_image(
|
||||||
|
&self,
|
||||||
|
url: &str,
|
||||||
|
preview_data: Option<UrlPreviewData>,
|
||||||
|
) -> Result<UrlPreviewData> {
|
||||||
use conduwuit::utils::random_string;
|
use conduwuit::utils::random_string;
|
||||||
use image::ImageReader;
|
use image::ImageReader;
|
||||||
|
|
||||||
let mut preview_data = UrlPreviewData::default();
|
use crate::media::mxc::Mxc;
|
||||||
|
|
||||||
self.check_url_ip(url)?;
|
let mut preview_data = preview_data.unwrap_or_default();
|
||||||
|
|
||||||
let response = self.services.client.url_preview.get(url).send().await?;
|
let response = self.services.client.url_preview.get(url).send().await?;
|
||||||
self.check_response_ip(&response)?;
|
|
||||||
if !response.status().is_success() {
|
if !response.status().is_success() {
|
||||||
return Err!(Request(Unknown("Image download returned HTTP {}", response.status())));
|
return Err!(Request(Unknown("Image download returned HTTP {}", response.status())));
|
||||||
}
|
}
|
||||||
@@ -209,13 +157,13 @@ impl Service {
|
|||||||
.ok_or_else(|| err!(Request(Unknown("Downloaded file is not a supported image"))))?
|
.ok_or_else(|| err!(Request(Unknown("Downloaded file is not a supported image"))))?
|
||||||
.to_mime_type();
|
.to_mime_type();
|
||||||
|
|
||||||
let (width, height) = reader.into_dimensions().map_err(|error| {
|
if preview_data.image_height.is_none() || preview_data.image_width.is_none() {
|
||||||
err!(Request(Unknown("Failed to read preview image dimensions: {error}")))
|
let (width, height) = reader.into_dimensions().map_err(|error| {
|
||||||
})?;
|
err!(Request(Unknown("Failed to read preview image dimensions: {error}")))
|
||||||
preview_data.image_width = Some(width);
|
})?;
|
||||||
preview_data.image_height = Some(height);
|
preview_data.image_width.get_or_insert(width);
|
||||||
preview_data.image_size = Some(image.len());
|
preview_data.image_height.get_or_insert(height);
|
||||||
preview_data.image_type = content_type.parse().ok();
|
}
|
||||||
|
|
||||||
let mxc = Mxc {
|
let mxc = Mxc {
|
||||||
server_name: self.services.globals.server_name(),
|
server_name: self.services.globals.server_name(),
|
||||||
@@ -231,9 +179,12 @@ impl Service {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "url_preview")]
|
#[cfg(feature = "url_preview")]
|
||||||
#[tracing::instrument(skip(self))]
|
pub async fn download_video(
|
||||||
pub async fn download_video(&self, url: &str) -> Result<UrlPreviewData> {
|
&self,
|
||||||
let mut preview_data = UrlPreviewData::default();
|
url: &str,
|
||||||
|
preview_data: Option<UrlPreviewData>,
|
||||||
|
) -> Result<UrlPreviewData> {
|
||||||
|
let mut preview_data = preview_data.unwrap_or_default();
|
||||||
|
|
||||||
if self.services.globals.url_preview_allow_audio_video() {
|
if self.services.globals.url_preview_allow_audio_video() {
|
||||||
let (url, size) = self.download_media(url).await?;
|
let (url, size) = self.download_media(url).await?;
|
||||||
@@ -245,9 +196,12 @@ impl Service {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "url_preview")]
|
#[cfg(feature = "url_preview")]
|
||||||
#[tracing::instrument(skip(self))]
|
pub async fn download_audio(
|
||||||
pub async fn download_audio(&self, url: &str) -> Result<UrlPreviewData> {
|
&self,
|
||||||
let mut preview_data = UrlPreviewData::default();
|
url: &str,
|
||||||
|
preview_data: Option<UrlPreviewData>,
|
||||||
|
) -> Result<UrlPreviewData> {
|
||||||
|
let mut preview_data = preview_data.unwrap_or_default();
|
||||||
|
|
||||||
if self.services.globals.url_preview_allow_audio_video() {
|
if self.services.globals.url_preview_allow_audio_video() {
|
||||||
let (url, size) = self.download_media(url).await?;
|
let (url, size) = self.download_media(url).await?;
|
||||||
@@ -258,18 +212,11 @@ impl Service {
|
|||||||
Ok(preview_data)
|
Ok(preview_data)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(skip(self))]
|
|
||||||
pub async fn download_media(&self, url: &str) -> Result<(OwnedMxcUri, usize)> {
|
pub async fn download_media(&self, url: &str) -> Result<(OwnedMxcUri, usize)> {
|
||||||
use conduwuit::utils::random_string;
|
use conduwuit::utils::random_string;
|
||||||
use http::header::CONTENT_TYPE;
|
use http::header::CONTENT_TYPE;
|
||||||
|
|
||||||
self.check_url_ip(url)?;
|
|
||||||
|
|
||||||
let response = self.services.client.url_preview.get(url).send().await?;
|
let response = self.services.client.url_preview.get(url).send().await?;
|
||||||
self.check_response_ip(&response)?;
|
|
||||||
if !response.status().is_success() {
|
|
||||||
return Err!(Request(Unknown("Media download returned HTTP {}", response.status())));
|
|
||||||
}
|
|
||||||
let content_type = response.headers().get(CONTENT_TYPE).cloned();
|
let content_type = response.headers().get(CONTENT_TYPE).cloned();
|
||||||
let media = response
|
let media = response
|
||||||
.limit_read(
|
.limit_read(
|
||||||
@@ -295,32 +242,41 @@ impl Service {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(feature = "url_preview"))]
|
#[cfg(not(feature = "url_preview"))]
|
||||||
pub fn download_image(&self, _url: &str) -> impl Future<Output = Result<UrlPreviewData>> {
|
pub async fn download_image(
|
||||||
std::future::ready(Err!(FeatureDisabled("url_preview")))
|
&self,
|
||||||
|
_url: &str,
|
||||||
|
_preview_data: Option<UrlPreviewData>,
|
||||||
|
) -> Result<UrlPreviewData> {
|
||||||
|
Err!(FeatureDisabled("url_preview"))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(feature = "url_preview"))]
|
#[cfg(not(feature = "url_preview"))]
|
||||||
pub fn download_video(&self, _url: &str) -> impl Future<Output = Result<UrlPreviewData>> {
|
pub async fn download_video(
|
||||||
std::future::ready(Err!(FeatureDisabled("url_preview")))
|
&self,
|
||||||
|
_url: &str,
|
||||||
|
_preview_data: Option<UrlPreviewData>,
|
||||||
|
) -> Result<UrlPreviewData> {
|
||||||
|
Err!(FeatureDisabled("url_preview"))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(feature = "url_preview"))]
|
#[cfg(not(feature = "url_preview"))]
|
||||||
pub fn download_audio(&self, _url: &str) -> impl Future<Output = Result<UrlPreviewData>> {
|
pub async fn download_audio(
|
||||||
std::future::ready(Err!(FeatureDisabled("url_preview")))
|
&self,
|
||||||
|
_url: &str,
|
||||||
|
_preview_data: Option<UrlPreviewData>,
|
||||||
|
) -> Result<UrlPreviewData> {
|
||||||
|
Err!(FeatureDisabled("url_preview"))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "url_preview")]
|
#[cfg(feature = "url_preview")]
|
||||||
#[tracing::instrument(skip(self))]
|
|
||||||
async fn download_html(&self, url: &str) -> Result<UrlPreviewData> {
|
async fn download_html(&self, url: &str) -> Result<UrlPreviewData> {
|
||||||
use webpage::HTML;
|
use webpage::HTML;
|
||||||
|
|
||||||
let client = &self.services.client.url_preview;
|
let client = &self.services.client.url_preview;
|
||||||
let response = client.get(url).send().await?;
|
let body = client
|
||||||
self.check_response_ip(&response)?;
|
.get(url)
|
||||||
if !response.status().is_success() {
|
.send()
|
||||||
return Err!(Request(Unknown("HTML download returned HTTP {}", response.status())));
|
.await?
|
||||||
}
|
|
||||||
let body = response
|
|
||||||
.limit_read_text(
|
.limit_read_text(
|
||||||
self.services
|
self.services
|
||||||
.server
|
.server
|
||||||
@@ -330,138 +286,39 @@ impl Service {
|
|||||||
.expect("u64 should fit in usize"),
|
.expect("u64 should fit in usize"),
|
||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
let Ok(html) = HTML::from_string(body, Some(url.to_owned()))
|
let Ok(html) = HTML::from_string(body.clone(), Some(url.to_owned())) else {
|
||||||
.inspect_err(|e| debug!(error=?e, "Failed to parse HTML data"))
|
|
||||||
else {
|
|
||||||
return Err!(Request(Unknown("Failed to parse HTML")));
|
return Err!(Request(Unknown("Failed to parse HTML")));
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut preview_data = UrlPreviewData::from(&html.opengraph);
|
let mut preview_data = UrlPreviewData::default();
|
||||||
debug!(parsed=?preview_data, deserialised=?html.opengraph, "Parsed opengraph data");
|
|
||||||
|
|
||||||
let base_url = Url::parse(url).ok();
|
if let Some(obj) = html.opengraph.images.first() {
|
||||||
let resolve_asset_url = |asset_url: &str| -> String {
|
preview_data = self.download_image(&obj.url, Some(preview_data)).await?;
|
||||||
base_url
|
|
||||||
.as_ref()
|
|
||||||
.and_then(|base| base.join(asset_url).ok())
|
|
||||||
.map_or_else(|| asset_url.to_owned(), Into::into)
|
|
||||||
};
|
|
||||||
|
|
||||||
if let Some(obj) = html
|
|
||||||
.opengraph
|
|
||||||
.images
|
|
||||||
.first()
|
|
||||||
.filter(|obj| !obj.url.is_empty())
|
|
||||||
{
|
|
||||||
let asset_url = resolve_asset_url(&obj.url);
|
|
||||||
info!(%asset_url, "Downloading preview image");
|
|
||||||
if let Ok(image_data) = self.download_image(&asset_url).await.inspect_err(
|
|
||||||
|e| info!(error=?e, %asset_url, "Could not download URL preview image"),
|
|
||||||
) {
|
|
||||||
preview_data.image = image_data.image;
|
|
||||||
preview_data.image_size = image_data.image_size;
|
|
||||||
// Prioritise what the top-level site specified, falling back to
|
|
||||||
// detected params.
|
|
||||||
preview_data.image_width = preview_data.image_width.or(image_data.image_width);
|
|
||||||
preview_data.image_height = preview_data.image_height.or(image_data.image_height);
|
|
||||||
preview_data.image_type = preview_data.image_type.or(image_data.image_type);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(obj) = html
|
if let Some(obj) = html.opengraph.videos.first() {
|
||||||
.opengraph
|
preview_data = self.download_video(&obj.url, Some(preview_data)).await?;
|
||||||
.videos
|
preview_data.video_width = obj.properties.get("width").and_then(|v| v.parse().ok());
|
||||||
.first()
|
preview_data.video_height = obj.properties.get("height").and_then(|v| v.parse().ok());
|
||||||
.filter(|obj| !obj.url.is_empty())
|
|
||||||
{
|
|
||||||
let asset_url = resolve_asset_url(&obj.url);
|
|
||||||
info!(%asset_url, "Downloading preview video");
|
|
||||||
if let Ok(video_data) = self.download_video(&asset_url).await.inspect_err(
|
|
||||||
|e| info!(error=?e, %asset_url, "Could not download URL preview video"),
|
|
||||||
) {
|
|
||||||
preview_data.video = video_data.video;
|
|
||||||
preview_data.video_size = video_data.video_size;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(obj) = html
|
if let Some(obj) = html.opengraph.audios.first() {
|
||||||
.opengraph
|
preview_data = self.download_audio(&obj.url, Some(preview_data)).await?;
|
||||||
.audios
|
|
||||||
.first()
|
|
||||||
.filter(|obj| !obj.url.is_empty())
|
|
||||||
{
|
|
||||||
let asset_url = resolve_asset_url(&obj.url);
|
|
||||||
info!(%asset_url, "Downloading URL preview audio");
|
|
||||||
if let Ok(audio_data) = self.download_audio(&asset_url).await.inspect_err(
|
|
||||||
|e| info!(error=?e, %asset_url, "Could not download URL preview audio"),
|
|
||||||
) {
|
|
||||||
preview_data.audio = audio_data.audio;
|
|
||||||
preview_data.audio_size = audio_data.audio_size;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Provide defaults for some params
|
let props = html.opengraph.properties;
|
||||||
preview_data.title = preview_data.title.or(html.title);
|
|
||||||
preview_data.description = preview_data.description.or(html.description);
|
|
||||||
preview_data.url = preview_data.url.or_else(|| Some(url.to_owned()));
|
|
||||||
|
|
||||||
// We remove og:image:*, og:video:*, and og:audio:* if their respective
|
/* use OpenGraph title/description, but fall back to HTML if not
|
||||||
// prior-level properties are not present.
|
* available */
|
||||||
// We do this here instead of in the From<> impl because we can't know
|
preview_data.title = props.get("title").cloned().or(html.title);
|
||||||
// if we'll be able to fetch the media to convert it to an mxc that
|
preview_data.description = props.get("description").cloned().or(html.description);
|
||||||
// point.
|
|
||||||
if preview_data.image.is_none() {
|
|
||||||
preview_data.image_type = None;
|
|
||||||
preview_data.image_alt = None;
|
|
||||||
preview_data.image_height = None;
|
|
||||||
preview_data.image_width = None;
|
|
||||||
preview_data.image_size = None;
|
|
||||||
}
|
|
||||||
if preview_data.video.is_none() {
|
|
||||||
preview_data.video_type = None;
|
|
||||||
preview_data.video_alt = None;
|
|
||||||
preview_data.video_height = None;
|
|
||||||
preview_data.video_width = None;
|
|
||||||
preview_data.video_size = None;
|
|
||||||
}
|
|
||||||
if preview_data.audio.is_none() {
|
|
||||||
preview_data.audio_size = None;
|
|
||||||
}
|
|
||||||
|
|
||||||
Ok(preview_data)
|
Ok(preview_data)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(feature = "url_preview"))]
|
#[cfg(not(feature = "url_preview"))]
|
||||||
#[allow(clippy::unused_self)]
|
async fn download_html(&self, _url: &str) -> Result<UrlPreviewData> {
|
||||||
fn download_html(&self, _url: &str) -> impl Future<Output = Result<UrlPreviewData>> {
|
Err!(FeatureDisabled("url_preview"))
|
||||||
std::future::ready(Err!(FeatureDisabled("url_preview")))
|
|
||||||
}
|
|
||||||
|
|
||||||
fn check_url_ip(&self, url: &str) -> Result<()> {
|
|
||||||
let parsed = Url::parse(url)
|
|
||||||
.map_err(|e| err!(Request(InvalidParam("Requested URL is not valid: {e}"))))?;
|
|
||||||
let Some(host) = parsed.host_str() else {
|
|
||||||
return Err!(Request(InvalidParam("Requested URL does not have a host")));
|
|
||||||
};
|
|
||||||
if let Ok(ip) = IPAddress::parse(host) {
|
|
||||||
if !self.services.client.valid_cidr_range(&ip) {
|
|
||||||
return Err!(Request(Forbidden("Requesting from this address is forbidden")));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
fn check_response_ip(&self, response: &reqwest::Response) -> Result<()> {
|
|
||||||
if let Some(remote_addr) = response.remote_addr() {
|
|
||||||
debug!(url = %response.url(), "URL preview response remote address: {:?}", remote_addr);
|
|
||||||
|
|
||||||
if let Ok(ip) = IPAddress::parse(remote_addr.ip().to_string()) {
|
|
||||||
if !self.services.client.valid_cidr_range(&ip) {
|
|
||||||
return Err!(Request(Forbidden("Requesting from this address is forbidden")));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Ok(())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn url_preview_allowed(&self, url: &Url) -> bool {
|
pub fn url_preview_allowed(&self, url: &Url) -> bool {
|
||||||
@@ -586,115 +443,3 @@ impl Service {
|
|||||||
false
|
false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "url_preview")]
|
|
||||||
impl From<&webpage::Opengraph> for UrlPreviewData {
|
|
||||||
fn from(og: &webpage::Opengraph) -> Self {
|
|
||||||
Self {
|
|
||||||
title: og.properties.get("title").cloned(),
|
|
||||||
description: og.properties.get("description").cloned(),
|
|
||||||
site_type: og.og_type.clone(),
|
|
||||||
url: og.properties.get("url").cloned(),
|
|
||||||
determiner: og.properties.get("determiner").cloned(),
|
|
||||||
locale: og.properties.get("locale").cloned(),
|
|
||||||
site_name: og.properties.get("site_name").cloned(),
|
|
||||||
image_type: og
|
|
||||||
.images
|
|
||||||
.first()
|
|
||||||
.and_then(|img| img.properties.get("type").and_then(|t| t.parse().ok())),
|
|
||||||
image_width: og
|
|
||||||
.images
|
|
||||||
.first()
|
|
||||||
.and_then(|img| img.properties.get("width").and_then(|w| w.parse().ok())),
|
|
||||||
image_height: og
|
|
||||||
.images
|
|
||||||
.first()
|
|
||||||
.and_then(|img| img.properties.get("height").and_then(|h| h.parse().ok())),
|
|
||||||
image_alt: og
|
|
||||||
.images
|
|
||||||
.first()
|
|
||||||
.and_then(|img| img.properties.get("alt").cloned()),
|
|
||||||
video_type: og
|
|
||||||
.videos
|
|
||||||
.first()
|
|
||||||
.and_then(|vid| vid.properties.get("type"))
|
|
||||||
.and_then(|t| t.parse().ok()),
|
|
||||||
video_width: og
|
|
||||||
.videos
|
|
||||||
.first()
|
|
||||||
.and_then(|vid| vid.properties.get("width"))
|
|
||||||
.and_then(|w| w.parse().ok()),
|
|
||||||
video_height: og
|
|
||||||
.videos
|
|
||||||
.first()
|
|
||||||
.and_then(|vid| vid.properties.get("height"))
|
|
||||||
.and_then(|h| h.parse().ok()),
|
|
||||||
video_alt: og
|
|
||||||
.videos
|
|
||||||
.first()
|
|
||||||
.and_then(|vid| vid.properties.get("alt").cloned()),
|
|
||||||
..Default::default()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(test)]
|
|
||||||
mod tests {
|
|
||||||
#[cfg(feature = "url_preview")]
|
|
||||||
#[test]
|
|
||||||
fn test_urlpreviewdata_parses_correctly() {
|
|
||||||
use webpage::HTML;
|
|
||||||
|
|
||||||
use super::UrlPreviewData;
|
|
||||||
let html = r#"
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<meta property="og:title" content="Test Title" />
|
|
||||||
<meta property="og:description" content="Test Description" />
|
|
||||||
<meta property="og:image" content="https://example.com/image.png" />
|
|
||||||
<meta property="og:url" content="https://example.com/index.html" />
|
|
||||||
<meta property="og:type" content="org.continuwuity.other" />
|
|
||||||
<meta property="og:site_name" content="Example Site" />
|
|
||||||
<meta property="og:image:alt" content="An example image" />
|
|
||||||
<meta property="og:image:type" content="image/png" />
|
|
||||||
<meta property="og:image:height" content="69" />
|
|
||||||
<meta property="og:image:width" content="420" />
|
|
||||||
<meta property="og:video" content="https://example.com/video.mp4" />
|
|
||||||
<meta property="og:audio" content="https://example.com/audio.ogg" />
|
|
||||||
</head>
|
|
||||||
<body></body>
|
|
||||||
</html>
|
|
||||||
"#;
|
|
||||||
|
|
||||||
let parsed_html =
|
|
||||||
HTML::from_string(html.to_owned(), Some("https://example.com".to_owned()))
|
|
||||||
.expect("Failed to parse HTML");
|
|
||||||
|
|
||||||
let data = UrlPreviewData::from(&parsed_html.opengraph);
|
|
||||||
|
|
||||||
assert_eq!(data.title, Some("Test Title".to_owned()));
|
|
||||||
assert_eq!(data.description, Some("Test Description".to_owned()));
|
|
||||||
assert_eq!(
|
|
||||||
data.image, None,
|
|
||||||
"UrlPreviewData should not inherit HTTP/S URL from URL preview"
|
|
||||||
);
|
|
||||||
assert_eq!(
|
|
||||||
data.video, None,
|
|
||||||
"UrlPreviewData should not inherit HTTP/S URL from URL preview"
|
|
||||||
);
|
|
||||||
assert_eq!(
|
|
||||||
data.audio, None,
|
|
||||||
"UrlPreviewData should not inherit HTTP/S URL from URL preview"
|
|
||||||
);
|
|
||||||
assert_eq!(data.url, Some("https://example.com/index.html".to_owned()));
|
|
||||||
assert_eq!(data.site_type, "org.continuwuity.other".to_owned());
|
|
||||||
assert_eq!(data.site_name, Some("Example Site".to_owned()));
|
|
||||||
assert_eq!(data.image_alt, Some("An example image".to_owned()));
|
|
||||||
assert_eq!(data.image_type, Some("image/png".parse().unwrap()));
|
|
||||||
assert_eq!(data.image_height, Some(69));
|
|
||||||
assert_eq!(data.image_width, Some(420));
|
|
||||||
assert_eq!(data.image_size, None, "*_size must be None when pulling from opengraph");
|
|
||||||
assert_eq!(data.video_size, None, "*_size must be None when pulling from opengraph");
|
|
||||||
assert_eq!(data.audio_size, None, "*_size must be None when pulling from opengraph");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -18,28 +18,6 @@ impl Services {
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
self.gauge(
|
|
||||||
"continuwuity.sender.requests",
|
|
||||||
"Estimated outgoing requests stored as queued or in flight",
|
|
||||||
"{request}",
|
|
||||||
|services, observer| {
|
|
||||||
for (state, count) in services.sending.db.request_counts() {
|
|
||||||
if let Some(count) = count {
|
|
||||||
observer.observe(count, &[KeyValue::new("state", state)]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
self.gauge(
|
|
||||||
"continuwuity.sender.workers",
|
|
||||||
"Running sender workers",
|
|
||||||
"{worker}",
|
|
||||||
|services, observer| {
|
|
||||||
observe(observer, services.sending.workers_alive(), &[]);
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
self.gauge(
|
self.gauge(
|
||||||
"continuwuity.federation.incoming.transactions.active",
|
"continuwuity.federation.incoming.transactions.active",
|
||||||
"Incoming federation transactions currently being processed",
|
"Incoming federation transactions currently being processed",
|
||||||
|
|||||||
@@ -13,8 +13,6 @@ mod migrations;
|
|||||||
mod service;
|
mod service;
|
||||||
pub mod services;
|
pub mod services;
|
||||||
pub mod state;
|
pub mod state;
|
||||||
#[cfg(test)]
|
|
||||||
mod test_utils;
|
|
||||||
|
|
||||||
pub mod account_data;
|
pub mod account_data;
|
||||||
pub mod admin;
|
pub mod admin;
|
||||||
|
|||||||
+18
-139
@@ -1,6 +1,5 @@
|
|||||||
use std::{
|
use std::{
|
||||||
collections::{BTreeSet, HashMap},
|
collections::{BTreeSet, HashMap},
|
||||||
fmt::Write,
|
|
||||||
sync::Arc,
|
sync::Arc,
|
||||||
time::{Duration, SystemTime},
|
time::{Duration, SystemTime},
|
||||||
};
|
};
|
||||||
@@ -9,9 +8,8 @@ use base64::Engine;
|
|||||||
use conduwuit::{
|
use conduwuit::{
|
||||||
Result, SyncMutex,
|
Result, SyncMutex,
|
||||||
config::experiments::ToggledExperiment,
|
config::experiments::ToggledExperiment,
|
||||||
error, info,
|
info,
|
||||||
utils::{self, MutexMap, hash::sha256},
|
utils::{self, hash::sha256},
|
||||||
warn,
|
|
||||||
};
|
};
|
||||||
use database::{Deserialized, Json, Map};
|
use database::{Deserialized, Json, Map};
|
||||||
use itertools::Itertools;
|
use itertools::Itertools;
|
||||||
@@ -31,25 +29,15 @@ use crate::{
|
|||||||
ResponseMode, TokenRequest, TokenRequestType, TokenResponse, TokenType,
|
ResponseMode, TokenRequest, TokenRequestType, TokenResponse, TokenType,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
users::{self, DeviceToken, PreviousTokenAction},
|
users::{self, DeviceToken},
|
||||||
};
|
};
|
||||||
|
|
||||||
pub mod client_metadata;
|
pub mod client_metadata;
|
||||||
pub mod grant;
|
pub mod grant;
|
||||||
|
|
||||||
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
|
|
||||||
struct SessionLockKey(OwnedUserId, OwnedDeviceId);
|
|
||||||
|
|
||||||
impl From<&(&UserId, &DeviceId)> for SessionLockKey {
|
|
||||||
fn from((user_id, device_id): &(&UserId, &DeviceId)) -> Self {
|
|
||||||
Self((*user_id).to_owned(), (*device_id).to_owned())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub struct Service {
|
pub struct Service {
|
||||||
services: Services,
|
services: Services,
|
||||||
db: Data,
|
db: Data,
|
||||||
session_mutex: MutexMap<SessionLockKey, ()>,
|
|
||||||
tickets: SyncMutex<HashMap<String, HashMap<OAuthTicket, SystemTime>>>,
|
tickets: SyncMutex<HashMap<String, HashMap<OAuthTicket, SystemTime>>>,
|
||||||
pending_auth_code_grants: SyncMutex<LruCache<String, PendingAuthCodeGrant>>,
|
pending_auth_code_grants: SyncMutex<LruCache<String, PendingAuthCodeGrant>>,
|
||||||
pending_device_code_grants: SyncMutex<LruCache<String, PendingDeviceCodeGrant>>,
|
pending_device_code_grants: SyncMutex<LruCache<String, PendingDeviceCodeGrant>>,
|
||||||
@@ -67,7 +55,7 @@ struct Services {
|
|||||||
config: Dep<config::Service>,
|
config: Dep<config::Service>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Deserialize, Serialize)]
|
#[derive(Debug, Deserialize, Serialize)]
|
||||||
pub struct SessionInfo {
|
pub struct SessionInfo {
|
||||||
pub client_id: String,
|
pub client_id: String,
|
||||||
#[serde(deserialize_with = "client_metadata::btreeset_skip_err")]
|
#[serde(deserialize_with = "client_metadata::btreeset_skip_err")]
|
||||||
@@ -76,8 +64,6 @@ pub struct SessionInfo {
|
|||||||
temporary_scopes: BTreeSet<OAuthClientScope>,
|
temporary_scopes: BTreeSet<OAuthClientScope>,
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
current_refresh_token: String,
|
current_refresh_token: String,
|
||||||
#[serde(default)]
|
|
||||||
previous_refresh_token: Option<String>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl SessionInfo {
|
impl SessionInfo {
|
||||||
@@ -85,18 +71,6 @@ impl SessionInfo {
|
|||||||
pub fn scopes(&self) -> BTreeSet<OAuthClientScope> {
|
pub fn scopes(&self) -> BTreeSet<OAuthClientScope> {
|
||||||
self.scopes.union(&self.temporary_scopes).cloned().collect()
|
self.scopes.union(&self.temporary_scopes).cloned().collect()
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
|
||||||
pub fn has_previous_refresh_token(&self) -> bool { self.previous_refresh_token.is_some() }
|
|
||||||
|
|
||||||
#[must_use]
|
|
||||||
pub fn scope_string(&self, device_id: &DeviceId) -> String {
|
|
||||||
let mut scopes = self.scopes().iter().join(" ");
|
|
||||||
|
|
||||||
let _ = write!(scopes, " urn:matrix:client:device:{device_id}");
|
|
||||||
|
|
||||||
scopes
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Deserialize, Serialize)]
|
#[derive(Debug, Deserialize, Serialize)]
|
||||||
@@ -197,7 +171,6 @@ impl crate::Service for Service {
|
|||||||
userdeviceid_oauthsessioninfo: args.db["userdeviceid_oauthsessioninfo"].clone(),
|
userdeviceid_oauthsessioninfo: args.db["userdeviceid_oauthsessioninfo"].clone(),
|
||||||
refreshtoken_refreshtokeninfo: args.db["refreshtoken_refreshtokeninfo"].clone(),
|
refreshtoken_refreshtokeninfo: args.db["refreshtoken_refreshtokeninfo"].clone(),
|
||||||
},
|
},
|
||||||
session_mutex: MutexMap::new(),
|
|
||||||
tickets: SyncMutex::default(),
|
tickets: SyncMutex::default(),
|
||||||
pending_auth_code_grants: SyncMutex::new(LruCache::new(Self::MAX_PENDING_GRANTS)),
|
pending_auth_code_grants: SyncMutex::new(LruCache::new(Self::MAX_PENDING_GRANTS)),
|
||||||
pending_device_code_grants: SyncMutex::new(LruCache::new(Self::MAX_PENDING_GRANTS)),
|
pending_device_code_grants: SyncMutex::new(LruCache::new(Self::MAX_PENDING_GRANTS)),
|
||||||
@@ -273,26 +246,6 @@ impl Service {
|
|||||||
.ok()
|
.ok()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Clear a session's previous refresh token, if it has one.
|
|
||||||
pub async fn clear_previous_refresh_token(&self, user_id: &UserId, device_id: &DeviceId) {
|
|
||||||
let _lock = self.session_mutex.lock(&(user_id, device_id)).await;
|
|
||||||
|
|
||||||
let Some(mut session_info) = self.get_session_info_for_device(user_id, device_id).await
|
|
||||||
else {
|
|
||||||
return;
|
|
||||||
};
|
|
||||||
|
|
||||||
if let Some(previous_refresh_token) = session_info.previous_refresh_token.take() {
|
|
||||||
self.db
|
|
||||||
.refreshtoken_refreshtokeninfo
|
|
||||||
.remove(&previous_refresh_token);
|
|
||||||
|
|
||||||
self.db
|
|
||||||
.userdeviceid_oauthsessioninfo
|
|
||||||
.put((user_id, device_id), Json(session_info));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub async fn request_authorization_code(
|
pub async fn request_authorization_code(
|
||||||
&self,
|
&self,
|
||||||
authorizing_user: OwnedUserId,
|
authorizing_user: OwnedUserId,
|
||||||
@@ -620,11 +573,6 @@ impl Service {
|
|||||||
.device_id
|
.device_id
|
||||||
.ok_or_else(|| OAuthError::invalid_grant("No device ID scope supplied"))?;
|
.ok_or_else(|| OAuthError::invalid_grant("No device ID scope supplied"))?;
|
||||||
|
|
||||||
let _lock = self
|
|
||||||
.session_mutex
|
|
||||||
.lock(&(&*authorizing_user, &*device_id))
|
|
||||||
.await;
|
|
||||||
|
|
||||||
let session_info = if self
|
let session_info = if self
|
||||||
.services
|
.services
|
||||||
.users
|
.users
|
||||||
@@ -658,12 +606,7 @@ impl Service {
|
|||||||
|
|
||||||
self.services
|
self.services
|
||||||
.users
|
.users
|
||||||
.set_token(
|
.set_token(&authorizing_user, &device_id, access_token.clone())
|
||||||
&authorizing_user,
|
|
||||||
&device_id,
|
|
||||||
access_token.clone(),
|
|
||||||
PreviousTokenAction::Replace,
|
|
||||||
)
|
|
||||||
.await
|
.await
|
||||||
.expect("should be able to set access token");
|
.expect("should be able to set access token");
|
||||||
|
|
||||||
@@ -702,7 +645,6 @@ impl Service {
|
|||||||
SessionInfo {
|
SessionInfo {
|
||||||
client_id: client_id.clone(),
|
client_id: client_id.clone(),
|
||||||
current_refresh_token: Self::generate_token(),
|
current_refresh_token: Self::generate_token(),
|
||||||
previous_refresh_token: None,
|
|
||||||
scopes: requested_scopes.scopes,
|
scopes: requested_scopes.scopes,
|
||||||
temporary_scopes: BTreeSet::new(),
|
temporary_scopes: BTreeSet::new(),
|
||||||
}
|
}
|
||||||
@@ -750,85 +692,25 @@ impl Service {
|
|||||||
|
|
||||||
assert_eq!(&client_id, &refresh_token_info.client_id, "refresh token client id mismatch");
|
assert_eq!(&client_id, &refresh_token_info.client_id, "refresh token client id mismatch");
|
||||||
|
|
||||||
let _lock = self
|
let mut session_info = self
|
||||||
.session_mutex
|
|
||||||
.lock(&(&*refresh_token_info.user_id, &*refresh_token_info.device_id))
|
|
||||||
.await;
|
|
||||||
|
|
||||||
let Some(mut session_info) = self
|
|
||||||
.get_session_info_for_device(
|
.get_session_info_for_device(
|
||||||
&refresh_token_info.user_id,
|
&refresh_token_info.user_id,
|
||||||
&refresh_token_info.device_id,
|
&refresh_token_info.device_id,
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
else {
|
.expect("session info should exist");
|
||||||
warn!(
|
|
||||||
user_id = ?refresh_token_info.user_id,
|
|
||||||
device_id = ?refresh_token_info.device_id,
|
|
||||||
"Refresh token exists for a missing OAuth session"
|
|
||||||
);
|
|
||||||
self.db.refreshtoken_refreshtokeninfo.remove(&refresh_token);
|
|
||||||
return Err(OAuthError::invalid_grant("Invalid refresh token"));
|
|
||||||
};
|
|
||||||
|
|
||||||
assert_eq!(&client_id, &session_info.client_id, "session info client id mismatch");
|
assert_eq!(&client_id, &session_info.client_id, "session info client id mismatch");
|
||||||
|
|
||||||
let new_refresh_token = Self::generate_token();
|
// TODO: this doesn't include the device ID "scope", do any clients rely
|
||||||
|
// on that?
|
||||||
let previous_token_action = if refresh_token == session_info.current_refresh_token {
|
let scope = session_info.scopes.iter().join(" ");
|
||||||
// The client is refreshing with their current refresh token.
|
|
||||||
// We need to generate a new refresh token and save this token as
|
|
||||||
// the previous one.
|
|
||||||
|
|
||||||
session_info
|
|
||||||
.current_refresh_token
|
|
||||||
.clone_from(&new_refresh_token);
|
|
||||||
|
|
||||||
// Remove the old previous token if it's set. This can only happen
|
|
||||||
// if the client decides to refresh twice in a row without using its
|
|
||||||
// new access token, since we'll also do this when the new access
|
|
||||||
// token is used for the first time.
|
|
||||||
if let Some(previous_refresh_token) = session_info.previous_refresh_token {
|
|
||||||
self.db
|
|
||||||
.refreshtoken_refreshtokeninfo
|
|
||||||
.remove(&previous_refresh_token);
|
|
||||||
}
|
|
||||||
|
|
||||||
session_info.previous_refresh_token = Some(refresh_token);
|
|
||||||
PreviousTokenAction::Replace
|
|
||||||
} else if Some(&refresh_token) == session_info.previous_refresh_token.as_ref() {
|
|
||||||
// The client is refreshing with their previous refresh token,
|
|
||||||
// probably because they didn't get the new one we made for them. We
|
|
||||||
// need to make a second new one, but we don't touch the existing
|
|
||||||
// previous one in case they don't get the second new one either.
|
|
||||||
|
|
||||||
// Wipe the current token, we're going to make a new one.
|
|
||||||
self.db
|
|
||||||
.refreshtoken_refreshtokeninfo
|
|
||||||
.remove(&session_info.current_refresh_token);
|
|
||||||
|
|
||||||
session_info
|
|
||||||
.current_refresh_token
|
|
||||||
.clone_from(&new_refresh_token);
|
|
||||||
PreviousTokenAction::Preserve
|
|
||||||
} else {
|
|
||||||
// The client is trying to use a refresh token that isn't their
|
|
||||||
// current or previous one, but still has information in the
|
|
||||||
// database. Clean up the stale entry and reject the grant.
|
|
||||||
error!(
|
|
||||||
user_id = ?refresh_token_info.user_id,
|
|
||||||
device_id = ?refresh_token_info.device_id,
|
|
||||||
"Refresh token is neither current nor previous for its session"
|
|
||||||
);
|
|
||||||
self.db.refreshtoken_refreshtokeninfo.remove(&refresh_token);
|
|
||||||
return Err(OAuthError::invalid_grant("Invalid refresh token"));
|
|
||||||
};
|
|
||||||
|
|
||||||
session_info.temporary_scopes.clear();
|
|
||||||
|
|
||||||
let scope = session_info.scope_string(&refresh_token_info.device_id);
|
|
||||||
|
|
||||||
let new_access_token = DeviceToken::new_random().with_max_age(Self::ACCESS_TOKEN_MAX_AGE);
|
let new_access_token = DeviceToken::new_random().with_max_age(Self::ACCESS_TOKEN_MAX_AGE);
|
||||||
|
let new_refresh_token = Self::generate_token();
|
||||||
|
session_info
|
||||||
|
.current_refresh_token
|
||||||
|
.clone_from(&new_refresh_token);
|
||||||
|
|
||||||
self.services
|
self.services
|
||||||
.users
|
.users
|
||||||
@@ -836,16 +718,19 @@ impl Service {
|
|||||||
&refresh_token_info.user_id,
|
&refresh_token_info.user_id,
|
||||||
&refresh_token_info.device_id,
|
&refresh_token_info.device_id,
|
||||||
new_access_token.clone(),
|
new_access_token.clone(),
|
||||||
previous_token_action,
|
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
.expect("should be able to set token");
|
.expect("should be able to set token");
|
||||||
|
|
||||||
|
session_info.temporary_scopes.clear();
|
||||||
|
|
||||||
self.db.userdeviceid_oauthsessioninfo.put(
|
self.db.userdeviceid_oauthsessioninfo.put(
|
||||||
(&refresh_token_info.user_id, &refresh_token_info.device_id),
|
(&refresh_token_info.user_id, &refresh_token_info.device_id),
|
||||||
Json(session_info),
|
Json(session_info),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
self.db.refreshtoken_refreshtokeninfo.remove(&refresh_token);
|
||||||
|
drop(refresh_token);
|
||||||
self.db
|
self.db
|
||||||
.refreshtoken_refreshtokeninfo
|
.refreshtoken_refreshtokeninfo
|
||||||
.raw_put(&new_refresh_token, Json(refresh_token_info));
|
.raw_put(&new_refresh_token, Json(refresh_token_info));
|
||||||
@@ -860,18 +745,12 @@ impl Service {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub async fn remove_session(&self, user_id: &UserId, device_id: &DeviceId) {
|
pub async fn remove_session(&self, user_id: &UserId, device_id: &DeviceId) {
|
||||||
let _lock = self.session_mutex.lock(&(user_id, device_id)).await;
|
|
||||||
let session_info = self.get_session_info_for_device(user_id, device_id).await;
|
let session_info = self.get_session_info_for_device(user_id, device_id).await;
|
||||||
|
|
||||||
if let Some(session_info) = session_info {
|
if let Some(session_info) = session_info {
|
||||||
self.db
|
self.db
|
||||||
.refreshtoken_refreshtokeninfo
|
.refreshtoken_refreshtokeninfo
|
||||||
.remove(&session_info.current_refresh_token);
|
.remove(&session_info.current_refresh_token);
|
||||||
if let Some(previous_refresh_token) = session_info.previous_refresh_token {
|
|
||||||
self.db
|
|
||||||
.refreshtoken_refreshtokeninfo
|
|
||||||
.remove(&previous_refresh_token);
|
|
||||||
}
|
|
||||||
self.db
|
self.db
|
||||||
.userdeviceid_oauthsessioninfo
|
.userdeviceid_oauthsessioninfo
|
||||||
.del((user_id, device_id));
|
.del((user_id, device_id));
|
||||||
|
|||||||
@@ -109,19 +109,12 @@ impl super::Service {
|
|||||||
{
|
{
|
||||||
let event_fetch = |event_id| self.event_fetch(event_id);
|
let event_fetch = |event_id| self.event_fetch(event_id);
|
||||||
let event_exists = |event_id| self.event_exists(event_id);
|
let event_exists = |event_id| self.event_exists(event_id);
|
||||||
let is_rejected = |event_id: OwnedEventId| async move {
|
|
||||||
self.services
|
|
||||||
.pdu_metadata
|
|
||||||
.is_event_rejected(&event_id)
|
|
||||||
.await
|
|
||||||
};
|
|
||||||
state_res::resolve(
|
state_res::resolve(
|
||||||
room_version_rules,
|
room_version_rules,
|
||||||
state_sets,
|
state_sets,
|
||||||
auth_chain_sets,
|
auth_chain_sets,
|
||||||
&event_fetch,
|
&event_fetch,
|
||||||
&event_exists,
|
&event_exists,
|
||||||
&is_rejected,
|
|
||||||
)
|
)
|
||||||
.map_err(|e| err!(error!("State resolution failed: {e:?}")))
|
.map_err(|e| err!(error!("State resolution failed: {e:?}")))
|
||||||
.await
|
.await
|
||||||
|
|||||||
@@ -1,10 +1,14 @@
|
|||||||
use conduwuit::PduEvent;
|
use std::sync::Arc;
|
||||||
|
|
||||||
|
use conduwuit::{
|
||||||
|
Config, PduEvent, Server,
|
||||||
|
log::{Log, LogLevelReloadHandles},
|
||||||
|
metrics::Metrics,
|
||||||
|
};
|
||||||
use futures::StreamExt;
|
use futures::StreamExt;
|
||||||
use ruma::{RoomId, RoomVersionId, events::StateEventType};
|
use ruma::{RoomId, RoomVersionId, events::StateEventType};
|
||||||
use serde_json::json;
|
use serde_json::json;
|
||||||
|
|
||||||
use crate::test_utils::test_services;
|
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
async fn admitted_joins_do_not_disappear_after_a_merge() {
|
async fn admitted_joins_do_not_disappear_after_a_merge() {
|
||||||
use conduwuit::matrix::PartialPdu;
|
use conduwuit::matrix::PartialPdu;
|
||||||
@@ -16,7 +20,7 @@ async fn admitted_joins_do_not_disappear_after_a_merge() {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
let (services, path, _database) = test_services().await;
|
let (services, path) = test_services().await;
|
||||||
let alice = UserId::parse("@alice:test.example").unwrap();
|
let alice = UserId::parse("@alice:test.example").unwrap();
|
||||||
let bob = UserId::parse("@bob:bob.example").unwrap();
|
let bob = UserId::parse("@bob:bob.example").unwrap();
|
||||||
let charlie = UserId::parse("@charlie:charlie.example").unwrap();
|
let charlie = UserId::parse("@charlie:charlie.example").unwrap();
|
||||||
@@ -208,6 +212,35 @@ async fn admitted_joins_do_not_disappear_after_a_merge() {
|
|||||||
assert_eq!(results, [true, true], "both joined users must be able to send messages");
|
assert_eq!(results, [true, true], "both joined users must be able to send messages");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async fn test_services() -> (Arc<crate::Services>, std::path::PathBuf) {
|
||||||
|
let _ = rustls::crypto::ring::default_provider().install_default();
|
||||||
|
let path = std::env::temp_dir()
|
||||||
|
.join(format!("continuwuity-shared-state-{:016x}", rand::random::<u64>()));
|
||||||
|
std::fs::create_dir(&path).unwrap();
|
||||||
|
let config: Config = serde_json::from_value(json!({
|
||||||
|
"server_name": "test.example",
|
||||||
|
"database_path": path,
|
||||||
|
"db_cache_capacity_mb": 16.0,
|
||||||
|
"rocksdb_write_buffer_capacity_mb": 4.0,
|
||||||
|
"allow_local_presence": false,
|
||||||
|
"dns_servers": ["127.0.0.1"],
|
||||||
|
"allow_invalid_tls_certificates_yes_i_know_what_the_fuck_i_am_doing_with_this_and_i_know_this_is_insecure": true
|
||||||
|
}))
|
||||||
|
.unwrap();
|
||||||
|
let runtime = tokio::runtime::Handle::current();
|
||||||
|
let server = Arc::new(Server::new(
|
||||||
|
config,
|
||||||
|
Some(runtime.clone()),
|
||||||
|
Log {
|
||||||
|
reload: LogLevelReloadHandles::default(),
|
||||||
|
capture: Arc::default(),
|
||||||
|
},
|
||||||
|
Metrics::new(Some(runtime), opentelemetry::global::meter("test"), None),
|
||||||
|
));
|
||||||
|
let services = crate::Services::build(server).await.unwrap();
|
||||||
|
(services, path)
|
||||||
|
}
|
||||||
|
|
||||||
fn cache_key(
|
fn cache_key(
|
||||||
services: &crate::Services,
|
services: &crate::Services,
|
||||||
server: &ruma::ServerName,
|
server: &ruma::ServerName,
|
||||||
|
|||||||
@@ -7,13 +7,15 @@ use ruma::{
|
|||||||
OwnedServerName, RoomId, UserId,
|
OwnedServerName, RoomId, UserId,
|
||||||
api::federation::membership::RawStrippedState,
|
api::federation::membership::RawStrippedState,
|
||||||
events::{
|
events::{
|
||||||
GlobalAccountDataEventType, RoomAccountDataEventType, StateEventType,
|
AnyStrippedStateEvent, GlobalAccountDataEventType, RoomAccountDataEventType,
|
||||||
|
StateEventType,
|
||||||
direct::DirectEvent,
|
direct::DirectEvent,
|
||||||
room::{
|
room::{
|
||||||
create::RoomCreateEventContent,
|
create::RoomCreateEventContent,
|
||||||
member::{MembershipState, RoomMemberEventContent},
|
member::{MembershipState, RoomMemberEventContent},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
serde::Raw,
|
||||||
};
|
};
|
||||||
use ruminuwuity::invite_permission_config::FilterLevel;
|
use ruminuwuity::invite_permission_config::FilterLevel;
|
||||||
|
|
||||||
@@ -121,18 +123,6 @@ impl super::Service {
|
|||||||
self.mark_as_invited(user_id, room_id, pdu.sender(), invite_state, None)
|
self.mark_as_invited(user_id, room_id, pdu.sender(), invite_state, None)
|
||||||
.await?;
|
.await?;
|
||||||
},
|
},
|
||||||
| MembershipState::Knock => {
|
|
||||||
let knocked_state = if is_local {
|
|
||||||
self.services
|
|
||||||
.state
|
|
||||||
.summary_stripped(pdu, room_id, user_id, false)
|
|
||||||
.await
|
|
||||||
} else {
|
|
||||||
vec![]
|
|
||||||
};
|
|
||||||
|
|
||||||
self.mark_as_knocked(user_id, room_id, knocked_state);
|
|
||||||
},
|
|
||||||
| MembershipState::Leave | MembershipState::Ban => {
|
| MembershipState::Leave | MembershipState::Ban => {
|
||||||
self.mark_as_left(user_id, room_id, Some(pdu.clone())).await;
|
self.mark_as_left(user_id, room_id, Some(pdu.clone())).await;
|
||||||
},
|
},
|
||||||
@@ -284,7 +274,7 @@ impl super::Service {
|
|||||||
&self,
|
&self,
|
||||||
user_id: &UserId,
|
user_id: &UserId,
|
||||||
room_id: &RoomId,
|
room_id: &RoomId,
|
||||||
knocked_state: Vec<RawStrippedState>,
|
knocked_state: Option<Vec<Raw<AnyStrippedStateEvent>>>,
|
||||||
) {
|
) {
|
||||||
let userroom_id = (user_id, room_id);
|
let userroom_id = (user_id, room_id);
|
||||||
let userroom_id = serialize_key(userroom_id).expect("failed to serialize userroom_id");
|
let userroom_id = serialize_key(userroom_id).expect("failed to serialize userroom_id");
|
||||||
@@ -294,7 +284,7 @@ impl super::Service {
|
|||||||
|
|
||||||
self.db
|
self.db
|
||||||
.userroomid_knockedstate
|
.userroomid_knockedstate
|
||||||
.raw_put(&userroom_id, Json(knocked_state));
|
.raw_put(&userroom_id, Json(knocked_state.unwrap_or_default()));
|
||||||
self.db
|
self.db
|
||||||
.roomuserid_knockedcount
|
.roomuserid_knockedcount
|
||||||
.raw_aput::<8, _, _>(&roomuser_id, self.services.globals.next_count().unwrap());
|
.raw_aput::<8, _, _>(&roomuser_id, self.services.globals.next_count().unwrap());
|
||||||
|
|||||||
+27
-73
@@ -3,7 +3,6 @@ use std::{fmt::Debug, sync::Arc};
|
|||||||
use conduwuit::{
|
use conduwuit::{
|
||||||
Error, Result, at, utils,
|
Error, Result, at, utils,
|
||||||
utils::{ReadyExt, stream::TryIgnore},
|
utils::{ReadyExt, stream::TryIgnore},
|
||||||
warn,
|
|
||||||
};
|
};
|
||||||
use database::{Database, Deserialized, Map};
|
use database::{Database, Deserialized, Map};
|
||||||
use futures::{Stream, StreamExt};
|
use futures::{Stream, StreamExt};
|
||||||
@@ -170,51 +169,6 @@ impl Data {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Destinations with at least one queued request not yet in flight.
|
|
||||||
///
|
|
||||||
/// Seeks past each destination's key prefix so large per-destination
|
|
||||||
/// backlogs are skipped in O(destinations) seeks rather than scanning
|
|
||||||
/// every queued event.
|
|
||||||
pub(super) async fn queued_destinations(&self) -> Vec<Destination> {
|
|
||||||
let mut dests = Vec::new();
|
|
||||||
let mut cursor = Vec::new();
|
|
||||||
|
|
||||||
while let Some(key) = self
|
|
||||||
.servernameevent_data
|
|
||||||
.raw_keys_from(&cursor)
|
|
||||||
.ignore_err()
|
|
||||||
.next()
|
|
||||||
.await
|
|
||||||
{
|
|
||||||
match parse_destination(key) {
|
|
||||||
| Ok((dest, _)) => {
|
|
||||||
let prefix = dest.get_prefix();
|
|
||||||
dests.push(dest);
|
|
||||||
let Some(next) = next_prefix(&prefix) else {
|
|
||||||
break;
|
|
||||||
};
|
|
||||||
cursor = next;
|
|
||||||
},
|
|
||||||
| Err(e) => {
|
|
||||||
warn!(?key, "invalid queued request key: {e}");
|
|
||||||
cursor = key.to_vec();
|
|
||||||
cursor.push(0);
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
dests
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Estimated number of requests waiting to be sent and in flight.
|
|
||||||
pub(crate) fn request_counts(&self) -> [(&'static str, Option<u64>); 2] {
|
|
||||||
[
|
|
||||||
("queued", &self.servernameevent_data),
|
|
||||||
("active", &self.servercurrentevent_data),
|
|
||||||
]
|
|
||||||
.map(|(state, map)| (state, map.property_integer(c"rocksdb.estimate-num-keys").ok()))
|
|
||||||
}
|
|
||||||
|
|
||||||
pub(super) fn set_latest_educount(&self, server_name: &ServerName, last_count: u64) {
|
pub(super) fn set_latest_educount(&self, server_name: &ServerName, last_count: u64) {
|
||||||
self.servername_educount.raw_put(server_name, last_count);
|
self.servername_educount.raw_put(server_name, last_count);
|
||||||
}
|
}
|
||||||
@@ -228,17 +182,9 @@ impl Data {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Smallest byte slice strictly greater than every key starting with `prefix`.
|
fn parse_servercurrentevent(key: &[u8], value: &[u8]) -> Result<(Destination, SendingEvent)> {
|
||||||
fn next_prefix(prefix: &[u8]) -> Option<Vec<u8>> {
|
|
||||||
let pos = prefix.iter().rposition(|&b| b < u8::MAX)?;
|
|
||||||
let mut next = prefix[..=pos].to_vec();
|
|
||||||
next[pos] = next[pos].saturating_add(1);
|
|
||||||
Some(next)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn parse_destination(key: &[u8]) -> Result<(Destination, &[u8])> {
|
|
||||||
// Appservices start with a plus
|
// Appservices start with a plus
|
||||||
if key.starts_with(b"+") {
|
Ok::<_, Error>(if key.starts_with(b"+") {
|
||||||
let mut parts = key[1..].splitn(2, |&b| b == 0xFF);
|
let mut parts = key[1..].splitn(2, |&b| b == 0xFF);
|
||||||
|
|
||||||
let server = parts.next().expect("splitn always returns one element");
|
let server = parts.next().expect("splitn always returns one element");
|
||||||
@@ -250,7 +196,14 @@ fn parse_destination(key: &[u8]) -> Result<(Destination, &[u8])> {
|
|||||||
Error::bad_database("Invalid server bytes in server_currenttransaction")
|
Error::bad_database("Invalid server bytes in server_currenttransaction")
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
Ok((Destination::Appservice(server), event))
|
(
|
||||||
|
Destination::Appservice(server),
|
||||||
|
if value.is_empty() {
|
||||||
|
SendingEvent::Pdu(event.into())
|
||||||
|
} else {
|
||||||
|
SendingEvent::Edu(value.into())
|
||||||
|
},
|
||||||
|
)
|
||||||
} else if key.starts_with(b"$") {
|
} else if key.starts_with(b"$") {
|
||||||
let mut parts = key[1..].splitn(3, |&b| b == 0xFF);
|
let mut parts = key[1..].splitn(3, |&b| b == 0xFF);
|
||||||
|
|
||||||
@@ -270,7 +223,15 @@ fn parse_destination(key: &[u8]) -> Result<(Destination, &[u8])> {
|
|||||||
.next()
|
.next()
|
||||||
.ok_or_else(|| Error::bad_database("Invalid bytes in servercurrentpdus."))?;
|
.ok_or_else(|| Error::bad_database("Invalid bytes in servercurrentpdus."))?;
|
||||||
|
|
||||||
Ok((Destination::Push(user_id, pushkey_string), event))
|
(
|
||||||
|
Destination::Push(user_id, pushkey_string),
|
||||||
|
if value.is_empty() {
|
||||||
|
SendingEvent::Pdu(event.into())
|
||||||
|
} else {
|
||||||
|
// I'm pretty sure this should never be called
|
||||||
|
SendingEvent::Edu(value.into())
|
||||||
|
},
|
||||||
|
)
|
||||||
} else {
|
} else {
|
||||||
let mut parts = key.splitn(2, |&b| b == 0xFF);
|
let mut parts = key.splitn(2, |&b| b == 0xFF);
|
||||||
|
|
||||||
@@ -283,22 +244,15 @@ fn parse_destination(key: &[u8]) -> Result<(Destination, &[u8])> {
|
|||||||
Error::bad_database("Invalid server bytes in server_currenttransaction")
|
Error::bad_database("Invalid server bytes in server_currenttransaction")
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
Ok((
|
(
|
||||||
Destination::Federation(ServerName::parse(&server).map_err(|_| {
|
Destination::Federation(ServerName::parse(&server).map_err(|_| {
|
||||||
Error::bad_database("Invalid server string in server_currenttransaction")
|
Error::bad_database("Invalid server string in server_currenttransaction")
|
||||||
})?),
|
})?),
|
||||||
event,
|
if value.is_empty() {
|
||||||
))
|
SendingEvent::Pdu(event.into())
|
||||||
}
|
} else {
|
||||||
}
|
SendingEvent::Edu(value.into())
|
||||||
|
},
|
||||||
fn parse_servercurrentevent(key: &[u8], value: &[u8]) -> Result<(Destination, SendingEvent)> {
|
)
|
||||||
let (dest, event) = parse_destination(key)?;
|
})
|
||||||
let event = if value.is_empty() {
|
|
||||||
SendingEvent::Pdu(event.into())
|
|
||||||
} else {
|
|
||||||
SendingEvent::Edu(value.into())
|
|
||||||
};
|
|
||||||
|
|
||||||
Ok((dest, event))
|
|
||||||
}
|
}
|
||||||
+25
-115
@@ -3,19 +3,12 @@ mod appservice;
|
|||||||
mod data;
|
mod data;
|
||||||
mod dest;
|
mod dest;
|
||||||
mod sender;
|
mod sender;
|
||||||
#[cfg(test)]
|
|
||||||
mod tests;
|
|
||||||
|
|
||||||
use std::{
|
use std::{
|
||||||
collections::HashMap,
|
|
||||||
fmt::Debug,
|
fmt::Debug,
|
||||||
hash::{DefaultHasher, Hash, Hasher},
|
hash::{DefaultHasher, Hash, Hasher},
|
||||||
iter::once,
|
iter::once,
|
||||||
sync::{
|
sync::Arc,
|
||||||
Arc,
|
|
||||||
atomic::{AtomicUsize, Ordering},
|
|
||||||
},
|
|
||||||
time::{Duration, Instant},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
use async_trait::async_trait;
|
use async_trait::async_trait;
|
||||||
@@ -26,7 +19,7 @@ use conduwuit::{
|
|||||||
utils::{ReadyExt, TryReadyExt, available_parallelism, math::usize_from_u64_truncated},
|
utils::{ReadyExt, TryReadyExt, available_parallelism, math::usize_from_u64_truncated},
|
||||||
warn,
|
warn,
|
||||||
};
|
};
|
||||||
use futures::{FutureExt, Stream, StreamExt, stream::FuturesUnordered};
|
use futures::{FutureExt, Stream, StreamExt};
|
||||||
use ruma::{
|
use ruma::{
|
||||||
OwnedServerName, RoomId, ServerName, UserId,
|
OwnedServerName, RoomId, ServerName, UserId,
|
||||||
api::{
|
api::{
|
||||||
@@ -34,7 +27,7 @@ use ruma::{
|
|||||||
federation::authentication::ServerSignatures, path_builder::PathBuilder,
|
federation::authentication::ServerSignatures, path_builder::PathBuilder,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
use tokio::{task, task::JoinSet, time::sleep};
|
use tokio::{task, task::JoinSet};
|
||||||
|
|
||||||
use self::data::Data;
|
use self::data::Data;
|
||||||
pub use self::{
|
pub use self::{
|
||||||
@@ -56,7 +49,6 @@ pub struct Service {
|
|||||||
server: Arc<Server>,
|
server: Arc<Server>,
|
||||||
services: Services,
|
services: Services,
|
||||||
channels: Vec<(loole::Sender<Msg>, loole::Receiver<Msg>)>,
|
channels: Vec<(loole::Sender<Msg>, loole::Receiver<Msg>)>,
|
||||||
workers_alive: AtomicUsize,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
struct Services {
|
struct Services {
|
||||||
@@ -95,8 +87,6 @@ pub type EduVec = SmallVec<[EduBuf; EDU_VEC_CAP]>;
|
|||||||
|
|
||||||
const EDU_BUF_CAP: usize = 128;
|
const EDU_BUF_CAP: usize = 128;
|
||||||
const EDU_VEC_CAP: usize = 1;
|
const EDU_VEC_CAP: usize = 1;
|
||||||
const WORKER_RESTART_DELAY: Duration = Duration::from_millis(2500);
|
|
||||||
const WORKER_RESTART_DELAY_MAX: Duration = Duration::from_secs(30);
|
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl crate::Service for Service {
|
impl crate::Service for Service {
|
||||||
@@ -121,67 +111,36 @@ impl crate::Service for Service {
|
|||||||
federation: args.depend::<federation::Service>("federation"),
|
federation: args.depend::<federation::Service>("federation"),
|
||||||
},
|
},
|
||||||
channels: (0..num_senders).map(|_| loole::unbounded()).collect(),
|
channels: (0..num_senders).map(|_| loole::unbounded()).collect(),
|
||||||
workers_alive: AtomicUsize::new(0),
|
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn worker(self: Arc<Self>) -> Result {
|
async fn worker(self: Arc<Self>) -> Result {
|
||||||
if self.server.config.startup_netburst {
|
let mut senders =
|
||||||
self.dispatch_queued(None).await;
|
self.channels
|
||||||
}
|
.iter()
|
||||||
|
.enumerate()
|
||||||
let num_senders = self.channels.len();
|
.fold(JoinSet::new(), |mut joinset, (id, _)| {
|
||||||
let mut senders = JoinSet::new();
|
let self_ = self.clone();
|
||||||
let mut shards = HashMap::new();
|
let worker = self_.sender(id);
|
||||||
let mut started = vec![Instant::now(); num_senders];
|
let worker = if self.unconstrained() {
|
||||||
let mut failures = vec![0_u32; num_senders];
|
task::unconstrained(worker).boxed()
|
||||||
let mut restarts = FuturesUnordered::new();
|
|
||||||
for id in 0..num_senders {
|
|
||||||
self.spawn_sender(&mut senders, &mut shards, id, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
loop {
|
|
||||||
tokio::select! {
|
|
||||||
Some(ret) = senders.join_next_with_id() => {
|
|
||||||
self.workers_alive.fetch_sub(1, Ordering::Relaxed);
|
|
||||||
let (task_id, panicked) = match &ret {
|
|
||||||
| Ok((task_id, _)) => (*task_id, false),
|
|
||||||
| Err(error) => (error.id(), error.is_panic()),
|
|
||||||
};
|
|
||||||
let shard = shards.remove(&task_id).expect("sender worker has a shard");
|
|
||||||
|
|
||||||
if panicked {
|
|
||||||
self.server
|
|
||||||
.metrics
|
|
||||||
.instruments
|
|
||||||
.sender_panics
|
|
||||||
.add(1, &[KeyValue::new("scope", "worker")]);
|
|
||||||
}
|
|
||||||
|
|
||||||
if self.channels[shard].1.is_closed() || !self.server.running() {
|
|
||||||
debug!(shard, ?ret, "sender worker finished");
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// A worker that ran a while before failing starts over from
|
|
||||||
// the shortest delay.
|
|
||||||
failures[shard] = if started[shard].elapsed() > WORKER_RESTART_DELAY_MAX {
|
|
||||||
1
|
|
||||||
} else {
|
} else {
|
||||||
failures[shard].saturating_add(1)
|
worker.boxed()
|
||||||
};
|
};
|
||||||
let delay = restart_delay(failures[shard]);
|
|
||||||
error!(shard, ?ret, ?delay, "sender worker unexpectedly finished, restarting");
|
let runtime = self.server.runtime();
|
||||||
restarts.push(sleep(delay).map(move |()| shard));
|
let _abort = joinset.spawn_on(worker, runtime);
|
||||||
|
joinset
|
||||||
|
});
|
||||||
|
|
||||||
|
while let Some(ret) = senders.join_next_with_id().await {
|
||||||
|
match ret {
|
||||||
|
| Ok((id, error)) => {
|
||||||
|
debug!(?id, ?error, "sender worker finished");
|
||||||
},
|
},
|
||||||
Some(shard) = restarts.next() => {
|
| Err(error) => {
|
||||||
if !self.channels[shard].1.is_closed() && self.server.running() {
|
error!(id = ?error.id(), ?error, "sender worker failed");
|
||||||
started[shard] = Instant::now();
|
|
||||||
self.spawn_sender(&mut senders, &mut shards, shard, true);
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
() = self.server.until_shutdown(), if !restarts.is_empty() => restarts.clear(),
|
|
||||||
else => break,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -202,25 +161,6 @@ impl crate::Service for Service {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Service {
|
impl Service {
|
||||||
fn spawn_sender(
|
|
||||||
self: &Arc<Self>,
|
|
||||||
senders: &mut JoinSet<Result>,
|
|
||||||
shards: &mut HashMap<task::Id, usize>,
|
|
||||||
id: usize,
|
|
||||||
restarted: bool,
|
|
||||||
) {
|
|
||||||
let worker = self.clone().sender(id, restarted);
|
|
||||||
let worker = if crate::Service::unconstrained(&**self) {
|
|
||||||
task::unconstrained(worker).boxed()
|
|
||||||
} else {
|
|
||||||
worker.boxed()
|
|
||||||
};
|
|
||||||
|
|
||||||
let handle = senders.spawn_on(worker, self.server.runtime());
|
|
||||||
shards.insert(handle.id(), id);
|
|
||||||
self.workers_alive.fetch_add(1, Ordering::Relaxed);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[tracing::instrument(skip(self, pdu_id, user, pushkey), level = "debug")]
|
#[tracing::instrument(skip(self, pdu_id, user, pushkey), level = "debug")]
|
||||||
pub fn send_pdu_push(&self, pdu_id: &RawPduId, user: &UserId, pushkey: String) -> Result {
|
pub fn send_pdu_push(&self, pdu_id: &RawPduId, user: &UserId, pushkey: String) -> Result {
|
||||||
let dest = Destination::Push(user.to_owned(), pushkey);
|
let dest = Destination::Push(user.to_owned(), pushkey);
|
||||||
@@ -540,32 +480,10 @@ impl Service {
|
|||||||
sender.send(msg).map_err(|e| err!("{e}"))
|
sender.send(msg).map_err(|e| err!("{e}"))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Wakes workers for every destination that has unsent queued requests, so
|
|
||||||
/// a backlog with nothing in flight is drained without waiting for a new
|
|
||||||
/// event. Uses `SendingEvent::Flush` so a message racing with already-
|
|
||||||
/// buffered channel items cannot re-insert and duplicate a sent request.
|
|
||||||
async fn dispatch_queued(&self, shard: Option<usize>) {
|
|
||||||
for dest in self.db.queued_destinations().await {
|
|
||||||
let id = self.shard_id(&dest);
|
|
||||||
if shard.is_none_or(|shard| shard == id) {
|
|
||||||
self.channels[id]
|
|
||||||
.0
|
|
||||||
.send(Msg {
|
|
||||||
dest,
|
|
||||||
event: SendingEvent::Flush,
|
|
||||||
queue_id: Vec::new(),
|
|
||||||
})
|
|
||||||
.ok();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn queue_depth(&self) -> usize {
|
pub fn queue_depth(&self) -> usize {
|
||||||
self.channels.iter().map(|(sender, _)| sender.len()).sum()
|
self.channels.iter().map(|(sender, _)| sender.len()).sum()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn workers_alive(&self) -> usize { self.workers_alive.load(Ordering::Relaxed) }
|
|
||||||
|
|
||||||
pub(super) fn shard_id(&self, dest: &Destination) -> usize {
|
pub(super) fn shard_id(&self, dest: &Destination) -> usize {
|
||||||
if self.channels.len() <= 1 {
|
if self.channels.len() <= 1 {
|
||||||
return 0;
|
return 0;
|
||||||
@@ -601,11 +519,3 @@ fn num_senders(args: &crate::Args<'_>) -> usize {
|
|||||||
worker_count.clamp(MIN_SENDERS, max_senders)
|
worker_count.clamp(MIN_SENDERS, max_senders)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Delay before restarting a worker after its `failures`-th consecutive
|
|
||||||
/// failure, doubling each time.
|
|
||||||
fn restart_delay(failures: u32) -> Duration {
|
|
||||||
WORKER_RESTART_DELAY
|
|
||||||
.saturating_mul(2_u32.saturating_pow(failures.saturating_sub(1)))
|
|
||||||
.min(WORKER_RESTART_DELAY_MAX)
|
|
||||||
}
|
|
||||||
@@ -1,7 +1,6 @@
|
|||||||
use std::{
|
use std::{
|
||||||
collections::{BTreeMap, HashMap, HashSet},
|
collections::{BTreeMap, HashMap, HashSet},
|
||||||
fmt::Debug,
|
fmt::Debug,
|
||||||
panic::AssertUnwindSafe,
|
|
||||||
sync::{
|
sync::{
|
||||||
Arc,
|
Arc,
|
||||||
atomic::{AtomicU64, AtomicUsize, Ordering},
|
atomic::{AtomicU64, AtomicUsize, Ordering},
|
||||||
@@ -56,17 +55,11 @@ use serde_json::value::{RawValue as RawJsonValue, to_raw_value};
|
|||||||
|
|
||||||
use super::{Destination, EduBuf, EduVec, Msg, SendingEvent, Service, data::QueueItem};
|
use super::{Destination, EduBuf, EduVec, Msg, SendingEvent, Service, data::QueueItem};
|
||||||
|
|
||||||
#[cfg(test)]
|
|
||||||
mod tests;
|
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
enum TransactionStatus {
|
enum TransactionStatus {
|
||||||
Running,
|
Running,
|
||||||
/// Number of times failed, time of last failure, and whether local backoff
|
Failed(u32, Instant), // number of times failed, time of last failure
|
||||||
/// applies even for federation destinations (e.g. after a local panic when
|
Retrying(u32), // number of times failed
|
||||||
/// the remote was not marked unhealthy).
|
|
||||||
Failed(u32, Instant, bool),
|
|
||||||
Retrying(u32), // number of times failed
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type SendingError = (Destination, Box<Error>);
|
type SendingError = (Destination, Box<Error>);
|
||||||
@@ -85,18 +78,12 @@ pub const EDU_LIMIT: usize = 100;
|
|||||||
|
|
||||||
impl Service {
|
impl Service {
|
||||||
#[tracing::instrument(skip(self), level = "debug")]
|
#[tracing::instrument(skip(self), level = "debug")]
|
||||||
pub(super) async fn sender(self: Arc<Self>, id: usize, restarted: bool) -> Result {
|
pub(super) async fn sender(self: Arc<Self>, id: usize) -> Result {
|
||||||
let mut statuses: CurTransactionStatus = CurTransactionStatus::new();
|
let mut statuses: CurTransactionStatus = CurTransactionStatus::new();
|
||||||
let mut futures: SendingFutures<'_> = FuturesUnordered::new();
|
let mut futures: SendingFutures<'_> = FuturesUnordered::new();
|
||||||
|
|
||||||
// The previous worker of this shard may have dropped requests it had
|
|
||||||
// taken from the channel.
|
|
||||||
if restarted {
|
|
||||||
self.dispatch_queued(Some(id)).await;
|
|
||||||
}
|
|
||||||
|
|
||||||
info!(shard = id, "Running startup netburst");
|
info!(shard = id, "Running startup netburst");
|
||||||
self.startup_netburst(id, restarted, &mut futures, &mut statuses)
|
self.startup_netburst(id, &mut futures, &mut statuses)
|
||||||
.boxed()
|
.boxed()
|
||||||
.await;
|
.await;
|
||||||
info!(shard = id, "Finished startup netburst");
|
info!(shard = id, "Finished startup netburst");
|
||||||
@@ -155,12 +142,7 @@ impl Service {
|
|||||||
) {
|
) {
|
||||||
match response {
|
match response {
|
||||||
| Ok(dest) => self.handle_response_ok(&dest, futures, statuses).await,
|
| Ok(dest) => self.handle_response_ok(&dest, futures, statuses).await,
|
||||||
// A bug on our side, not the remote's fault: retry with local
|
|
||||||
// backoff without marking the remote unhealthy.
|
|
||||||
| Err((dest, e)) if e.is_panic() =>
|
|
||||||
Self::handle_response_err(dest, statuses, &e, true),
|
|
||||||
| Err((dest, e)) => {
|
| Err((dest, e)) => {
|
||||||
let mut local_backoff = false;
|
|
||||||
if let Destination::Federation(dest) = &dest {
|
if let Destination::Federation(dest) = &dest {
|
||||||
if self.services.federation.should_mark_stale(&e)
|
if self.services.federation.should_mark_stale(&e)
|
||||||
|| e.status_code() == StatusCode::NOT_FOUND
|
|| e.status_code() == StatusCode::NOT_FOUND
|
||||||
@@ -171,30 +153,22 @@ impl Service {
|
|||||||
} else if e.status_code() != StatusCode::OK {
|
} else if e.status_code() != StatusCode::OK {
|
||||||
debug!("{dest} is now unhealthy due to error response: {e:?}");
|
debug!("{dest} is now unhealthy due to error response: {e:?}");
|
||||||
self.services.federation.hit_unhealthy(dest.clone(), None);
|
self.services.federation.hit_unhealthy(dest.clone(), None);
|
||||||
} else {
|
|
||||||
local_backoff = true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Self::handle_response_err(dest, statuses, &e, local_backoff);
|
Self::handle_response_err(dest, statuses, &e);
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Handles a response error, incrementing the backoff factor.
|
/// Handles a response error, incrementing the backoff factor.
|
||||||
fn handle_response_err(
|
fn handle_response_err(dest: Destination, statuses: &mut CurTransactionStatus, er: &Error) {
|
||||||
dest: Destination,
|
|
||||||
statuses: &mut CurTransactionStatus,
|
|
||||||
er: &Error,
|
|
||||||
local_backoff: bool,
|
|
||||||
) {
|
|
||||||
debug!(dest = ?dest, "{er:?}");
|
debug!(dest = ?dest, "{er:?}");
|
||||||
let dest2 = dest.clone();
|
let dest2 = dest.clone();
|
||||||
statuses.entry(dest).and_modify(|e| {
|
statuses.entry(dest).and_modify(|e| {
|
||||||
*e = match e {
|
*e = match e {
|
||||||
| TransactionStatus::Running =>
|
| TransactionStatus::Running => TransactionStatus::Failed(1, Instant::now()),
|
||||||
TransactionStatus::Failed(1, Instant::now(), local_backoff),
|
|
||||||
| &mut TransactionStatus::Retrying(ref n) =>
|
| &mut TransactionStatus::Retrying(ref n) =>
|
||||||
TransactionStatus::Failed(n.saturating_add(1), Instant::now(), local_backoff),
|
TransactionStatus::Failed(n.saturating_add(1), Instant::now()),
|
||||||
| TransactionStatus::Failed(..) => {
|
| TransactionStatus::Failed(..) => {
|
||||||
panic!(
|
panic!(
|
||||||
"Request to {dest2:?} that was not even running ({e:?}) failed: {er:?}"
|
"Request to {dest2:?} that was not even running ({e:?}) failed: {er:?}"
|
||||||
@@ -300,8 +274,7 @@ impl Service {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Performs startup netburst, which sends any previously queued up but not
|
/// Performs startup netburst, which sends any previously queued up but not
|
||||||
/// yet sent requests immediately. A restarted worker always resends its
|
/// yet sent requests immediately.
|
||||||
/// shard's requests in flight.
|
|
||||||
#[tracing::instrument(
|
#[tracing::instrument(
|
||||||
name = "netburst",
|
name = "netburst",
|
||||||
level = "debug",
|
level = "debug",
|
||||||
@@ -312,11 +285,9 @@ impl Service {
|
|||||||
async fn startup_netburst<'a>(
|
async fn startup_netburst<'a>(
|
||||||
&'a self,
|
&'a self,
|
||||||
id: usize,
|
id: usize,
|
||||||
restarted: bool,
|
|
||||||
futures: &mut SendingFutures<'a>,
|
futures: &mut SendingFutures<'a>,
|
||||||
statuses: &mut CurTransactionStatus,
|
statuses: &mut CurTransactionStatus,
|
||||||
) {
|
) {
|
||||||
let delivering = restarted || self.server.config.startup_netburst;
|
|
||||||
let keep =
|
let keep =
|
||||||
usize::try_from(self.server.config.startup_netburst_keep).unwrap_or(usize::MAX);
|
usize::try_from(self.server.config.startup_netburst_keep).unwrap_or(usize::MAX);
|
||||||
let mut txns = HashMap::<Destination, Vec<SendingEvent>>::new();
|
let mut txns = HashMap::<Destination, Vec<SendingEvent>>::new();
|
||||||
@@ -331,7 +302,7 @@ impl Service {
|
|||||||
let over_budget =
|
let over_budget =
|
||||||
self.server.config.startup_netburst_keep >= 0 && entry.len() >= keep;
|
self.server.config.startup_netburst_keep >= 0 && entry.len() >= keep;
|
||||||
|
|
||||||
if over_budget && !self.survives_netburst_trim(&event, delivering).await {
|
if over_budget && !self.survives_netburst_trim(&event).await {
|
||||||
warn!(
|
warn!(
|
||||||
startup_netburst_keep = self.server.config.startup_netburst_keep,
|
startup_netburst_keep = self.server.config.startup_netburst_keep,
|
||||||
queue_size = entry.len(),
|
queue_size = entry.len(),
|
||||||
@@ -344,12 +315,8 @@ impl Service {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if !delivering {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (dest, events) in txns {
|
for (dest, events) in txns {
|
||||||
if !events.is_empty() {
|
if self.server.config.startup_netburst && !events.is_empty() {
|
||||||
statuses.insert(dest.clone(), TransactionStatus::Running);
|
statuses.insert(dest.clone(), TransactionStatus::Running);
|
||||||
futures.push(self.send_events(dest, events));
|
futures.push(self.send_events(dest, events));
|
||||||
}
|
}
|
||||||
@@ -357,10 +324,10 @@ impl Service {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Whether this event skips the netburst budget, which MSC4354 asks of
|
/// Whether this event skips the netburst budget, which MSC4354 asks of
|
||||||
/// still-sticky events. Only a delivering netburst drains this queue, so
|
/// still-sticky events. Only netburst delivers this queue, so with it
|
||||||
/// when nothing will deliver it there is nothing to keep the event for.
|
/// disabled there is nothing to keep the event for.
|
||||||
async fn survives_netburst_trim(&self, event: &SendingEvent, delivering: bool) -> bool {
|
async fn survives_netburst_trim(&self, event: &SendingEvent) -> bool {
|
||||||
if !delivering {
|
if !self.server.config.startup_netburst {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -458,17 +425,12 @@ impl Service {
|
|||||||
allow = false; // already running
|
allow = false; // already running
|
||||||
trace!("Transaction is already running for {dest:?}");
|
trace!("Transaction is already running for {dest:?}");
|
||||||
},
|
},
|
||||||
| TransactionStatus::Failed(tries, time, local_backoff) => {
|
| TransactionStatus::Failed(tries, _) => {
|
||||||
if *local_backoff
|
if allow {
|
||||||
&& time.elapsed() < self.server.config.sender_retry_backoff(*tries)
|
|
||||||
{
|
|
||||||
allow = false;
|
|
||||||
trace!("{dest:?} is in local backoff, refusing send");
|
|
||||||
} else {
|
|
||||||
*e = TransactionStatus::Retrying(*tries);
|
*e = TransactionStatus::Retrying(*tries);
|
||||||
trace!("Previous transaction failed for {dest:?} ({e:?}), will retry");
|
trace!("Previous transaction failed for {dest:?} ({e:?}), will retry");
|
||||||
retry = true;
|
|
||||||
}
|
}
|
||||||
|
retry = true;
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -487,7 +449,7 @@ impl Service {
|
|||||||
statuses
|
statuses
|
||||||
.entry(dest.clone())
|
.entry(dest.clone())
|
||||||
.and_modify(|e| match e {
|
.and_modify(|e| match e {
|
||||||
| TransactionStatus::Failed(tries, time, _) => {
|
| TransactionStatus::Failed(tries, time) => {
|
||||||
let retry_after = self.server.config.sender_retry_backoff(*tries);
|
let retry_after = self.server.config.sender_retry_backoff(*tries);
|
||||||
if time.elapsed() < retry_after {
|
if time.elapsed() < retry_after {
|
||||||
debug_warn!("Not retrying destination for another {retry_after:?}");
|
debug_warn!("Not retrying destination for another {retry_after:?}");
|
||||||
@@ -810,7 +772,6 @@ impl Service {
|
|||||||
});
|
});
|
||||||
|
|
||||||
let start = Instant::now();
|
let start = Instant::now();
|
||||||
let panic_dest = dest.clone();
|
|
||||||
let send = match dest {
|
let send = match dest {
|
||||||
| Destination::Federation(server) =>
|
| Destination::Federation(server) =>
|
||||||
self.send_events_dest_federation(server, events).boxed(),
|
self.send_events_dest_federation(server, events).boxed(),
|
||||||
@@ -819,42 +780,24 @@ impl Service {
|
|||||||
self.send_events_dest_push(user_id, pushkey, events).boxed(),
|
self.send_events_dest_push(user_id, pushkey, events).boxed(),
|
||||||
};
|
};
|
||||||
|
|
||||||
AssertUnwindSafe(send)
|
send.inspect(move |result| {
|
||||||
.catch_unwind()
|
let instruments = &self.server.metrics.instruments;
|
||||||
.map(move |result| {
|
let outcome =
|
||||||
result.unwrap_or_else(|panic| {
|
KeyValue::new("outcome", if result.is_ok() { "success" } else { "failure" });
|
||||||
let error = Error::from_panic(panic);
|
instruments
|
||||||
error!(dest = ?panic_dest, ?error, "Panicked while sending transaction");
|
.sender_transaction_duration
|
||||||
self.server
|
.record(start.elapsed().as_secs_f64(), &[destination.clone(), outcome.clone()]);
|
||||||
.metrics
|
for (kind, count) in [("pdu", pdus), ("edu", edus)] {
|
||||||
.instruments
|
if count > 0 {
|
||||||
.sender_panics
|
instruments.sender_events.add(count, &[
|
||||||
.add(1, &[KeyValue::new("scope", "transaction")]);
|
|
||||||
|
|
||||||
Err((panic_dest, Box::new(error)))
|
|
||||||
})
|
|
||||||
})
|
|
||||||
.inspect(move |result| {
|
|
||||||
let instruments = &self.server.metrics.instruments;
|
|
||||||
let outcome =
|
|
||||||
KeyValue::new("outcome", if result.is_ok() { "success" } else { "failure" });
|
|
||||||
instruments
|
|
||||||
.sender_transaction_duration
|
|
||||||
.record(start.elapsed().as_secs_f64(), &[
|
|
||||||
destination.clone(),
|
destination.clone(),
|
||||||
|
KeyValue::new("kind", kind),
|
||||||
outcome.clone(),
|
outcome.clone(),
|
||||||
]);
|
]);
|
||||||
for (kind, count) in [("pdu", pdus), ("edu", edus)] {
|
|
||||||
if count > 0 {
|
|
||||||
instruments.sender_events.add(count, &[
|
|
||||||
destination.clone(),
|
|
||||||
KeyValue::new("kind", kind),
|
|
||||||
outcome.clone(),
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
})
|
}
|
||||||
.boxed()
|
})
|
||||||
|
.boxed()
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(
|
#[tracing::instrument(
|
||||||
|
|||||||
@@ -1,198 +0,0 @@
|
|||||||
use std::iter::once;
|
|
||||||
|
|
||||||
use conduwuit::{
|
|
||||||
Error,
|
|
||||||
matrix::{PartialPdu, pdu::sticky},
|
|
||||||
};
|
|
||||||
use futures::{StreamExt, stream::FuturesUnordered};
|
|
||||||
use ruma::{RoomId, UserId, events::sticky::StickyDurationMs, server_name};
|
|
||||||
use serde_json::{json, value::to_raw_value};
|
|
||||||
|
|
||||||
use super::{CurTransactionStatus, TransactionStatus};
|
|
||||||
use crate::{
|
|
||||||
sending::{Destination, EduBuf, SendingEvent},
|
|
||||||
test_utils::{test_services, test_services_with},
|
|
||||||
};
|
|
||||||
|
|
||||||
#[tokio::test]
|
|
||||||
async fn panicked_transaction_is_kept_for_retry_without_blaming_the_remote() {
|
|
||||||
let (services, path, _database) = test_services().await;
|
|
||||||
let sending = &services.sending;
|
|
||||||
let server = server_name!("remote.example");
|
|
||||||
let dest = Destination::Federation(server.to_owned());
|
|
||||||
let event = SendingEvent::Edu(EduBuf::from_slice(br#"{"edu_type":"m.typing"}"#));
|
|
||||||
|
|
||||||
sending.db.queue_requests(once((&event, &dest)));
|
|
||||||
let in_flight: Vec<_> = sending.db.queued_requests(&dest).collect().await;
|
|
||||||
sending.db.mark_as_active(in_flight.iter());
|
|
||||||
|
|
||||||
let mut futures = FuturesUnordered::new();
|
|
||||||
let mut statuses = CurTransactionStatus::from([(dest.clone(), TransactionStatus::Running)]);
|
|
||||||
let panic = Error::from_panic(Box::new("boom"));
|
|
||||||
sending
|
|
||||||
.handle_response(Err((dest.clone(), Box::new(panic))), &mut futures, &mut statuses)
|
|
||||||
.await;
|
|
||||||
|
|
||||||
let active: Vec<_> = sending
|
|
||||||
.db
|
|
||||||
.active_requests_for(&dest)
|
|
||||||
.map(|(key, _)| key)
|
|
||||||
.collect()
|
|
||||||
.await;
|
|
||||||
let retry_after = sending.services.federation.retry_after(server);
|
|
||||||
let sending_next = futures.len();
|
|
||||||
let failed = matches!(statuses.get(&dest), Some(TransactionStatus::Failed(1, _, true)));
|
|
||||||
let immediate_retry = sending.should_attempt_send(&dest, &mut statuses).unwrap();
|
|
||||||
|
|
||||||
drop(futures);
|
|
||||||
drop(services);
|
|
||||||
std::fs::remove_dir_all(path).unwrap();
|
|
||||||
assert_eq!(
|
|
||||||
active,
|
|
||||||
in_flight
|
|
||||||
.into_iter()
|
|
||||||
.map(|(key, _)| key)
|
|
||||||
.collect::<Vec<_>>()
|
|
||||||
);
|
|
||||||
assert_eq!(sending_next, 0);
|
|
||||||
assert!(failed);
|
|
||||||
assert_eq!(immediate_retry, (false, false));
|
|
||||||
assert_eq!(retry_after, None);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[tokio::test]
|
|
||||||
async fn restarted_worker_resends_trimmed_in_flight_requests() {
|
|
||||||
let (services, path, _database) =
|
|
||||||
test_services_with(json!({ "startup_netburst_keep": 1 })).await;
|
|
||||||
let sending = &services.sending;
|
|
||||||
let dest = Destination::Federation(server_name!("remote.example").to_owned());
|
|
||||||
let event = SendingEvent::Edu(EduBuf::from_slice(br#"{"edu_type":"m.typing"}"#));
|
|
||||||
|
|
||||||
for _ in 0..3 {
|
|
||||||
sending.db.queue_requests(once((&event, &dest)));
|
|
||||||
}
|
|
||||||
let queued: Vec<_> = sending.db.queued_requests(&dest).collect().await;
|
|
||||||
sending.db.mark_as_active(queued.iter());
|
|
||||||
|
|
||||||
let id = sending.shard_id(&dest);
|
|
||||||
let mut futures = FuturesUnordered::new();
|
|
||||||
let mut statuses = CurTransactionStatus::new();
|
|
||||||
sending
|
|
||||||
.startup_netburst(id, true, &mut futures, &mut statuses)
|
|
||||||
.await;
|
|
||||||
let active = sending.db.active_requests_for(&dest).count().await;
|
|
||||||
let sending_now = futures.len();
|
|
||||||
|
|
||||||
drop(futures);
|
|
||||||
drop(services);
|
|
||||||
std::fs::remove_dir_all(path).unwrap();
|
|
||||||
assert_eq!(active, 1);
|
|
||||||
assert_eq!(sending_now, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[tokio::test]
|
|
||||||
async fn restarted_worker_keeps_sticky_events_when_startup_netburst_is_disabled() {
|
|
||||||
let (services, path, _database) =
|
|
||||||
test_services_with(json!({ "startup_netburst": false, "startup_netburst_keep": 0 }))
|
|
||||||
.await;
|
|
||||||
let alice = UserId::parse("@alice:test.example").unwrap();
|
|
||||||
let bootstrap = services
|
|
||||||
.rooms
|
|
||||||
.state
|
|
||||||
.mutex
|
|
||||||
.lock("!bootstrap:test.example")
|
|
||||||
.await;
|
|
||||||
let create_id = services
|
|
||||||
.rooms
|
|
||||||
.timeline
|
|
||||||
.build_and_append_pdu(
|
|
||||||
PartialPdu {
|
|
||||||
event_type: "m.room.create".into(),
|
|
||||||
content: to_raw_value(&json!({ "room_version": "12" })).unwrap(),
|
|
||||||
state_key: Some("".into()),
|
|
||||||
..Default::default()
|
|
||||||
},
|
|
||||||
&alice,
|
|
||||||
None,
|
|
||||||
&bootstrap,
|
|
||||||
)
|
|
||||||
.await
|
|
||||||
.unwrap();
|
|
||||||
drop(bootstrap);
|
|
||||||
|
|
||||||
let room = RoomId::parse(create_id.as_str().replacen('$', "!", 1)).unwrap();
|
|
||||||
let lock = services.rooms.state.mutex.lock(&room).await;
|
|
||||||
services
|
|
||||||
.rooms
|
|
||||||
.timeline
|
|
||||||
.build_and_append_pdu(
|
|
||||||
PartialPdu {
|
|
||||||
event_type: "m.room.member".into(),
|
|
||||||
content: to_raw_value(&json!({ "membership": "join" })).unwrap(),
|
|
||||||
state_key: Some(alice.as_str().into()),
|
|
||||||
..Default::default()
|
|
||||||
},
|
|
||||||
&alice,
|
|
||||||
Some(&room),
|
|
||||||
&lock,
|
|
||||||
)
|
|
||||||
.await
|
|
||||||
.unwrap();
|
|
||||||
let sticky_id = services
|
|
||||||
.rooms
|
|
||||||
.timeline
|
|
||||||
.build_and_append_pdu(
|
|
||||||
PartialPdu {
|
|
||||||
event_type: "m.room.message".into(),
|
|
||||||
content: to_raw_value(&json!({ "msgtype": "m.text", "body": "sticky" })).unwrap(),
|
|
||||||
sticky: Some(sticky::object(StickyDurationMs::new_clamped(600_000_u32))),
|
|
||||||
..Default::default()
|
|
||||||
},
|
|
||||||
&alice,
|
|
||||||
Some(&room),
|
|
||||||
&lock,
|
|
||||||
)
|
|
||||||
.await
|
|
||||||
.unwrap();
|
|
||||||
drop(lock);
|
|
||||||
|
|
||||||
let raw_pdu_id = services
|
|
||||||
.rooms
|
|
||||||
.timeline
|
|
||||||
.get_pdu_id(&sticky_id)
|
|
||||||
.await
|
|
||||||
.unwrap();
|
|
||||||
let sending = &services.sending;
|
|
||||||
let dest = Destination::Federation(server_name!("remote.example").to_owned());
|
|
||||||
let event = SendingEvent::Pdu(raw_pdu_id);
|
|
||||||
|
|
||||||
sending.db.queue_requests(once((&event, &dest)));
|
|
||||||
let queued: Vec<_> = sending.db.queued_requests(&dest).collect().await;
|
|
||||||
sending.db.mark_as_active(queued.iter());
|
|
||||||
|
|
||||||
let id = sending.shard_id(&dest);
|
|
||||||
let mut futures = FuturesUnordered::new();
|
|
||||||
let mut statuses = CurTransactionStatus::new();
|
|
||||||
sending
|
|
||||||
.startup_netburst(id, true, &mut futures, &mut statuses)
|
|
||||||
.await;
|
|
||||||
let active_after_restart = sending.db.active_requests_for(&dest).count().await;
|
|
||||||
let sending_after_restart = futures.len();
|
|
||||||
|
|
||||||
drop(futures);
|
|
||||||
let mut futures = FuturesUnordered::new();
|
|
||||||
let mut statuses = CurTransactionStatus::new();
|
|
||||||
sending
|
|
||||||
.startup_netburst(id, false, &mut futures, &mut statuses)
|
|
||||||
.await;
|
|
||||||
let active_after_startup = sending.db.active_requests_for(&dest).count().await;
|
|
||||||
let sending_after_startup = futures.len();
|
|
||||||
|
|
||||||
drop(futures);
|
|
||||||
drop(services);
|
|
||||||
std::fs::remove_dir_all(path).unwrap();
|
|
||||||
assert_eq!(active_after_restart, 1);
|
|
||||||
assert_eq!(sending_after_restart, 1);
|
|
||||||
assert_eq!(active_after_startup, 0);
|
|
||||||
assert_eq!(sending_after_startup, 0);
|
|
||||||
}
|
|
||||||
@@ -1,41 +0,0 @@
|
|||||||
use std::{iter::once, time::Duration};
|
|
||||||
|
|
||||||
use futures::StreamExt;
|
|
||||||
use ruma::server_name;
|
|
||||||
|
|
||||||
use super::{Destination, EduBuf, SendingEvent, restart_delay};
|
|
||||||
use crate::test_utils::test_services;
|
|
||||||
|
|
||||||
#[tokio::test]
|
|
||||||
async fn queued_destinations_lists_each_destination_with_unsent_requests() {
|
|
||||||
let (services, path, _database) = test_services().await;
|
|
||||||
let db = &services.sending.db;
|
|
||||||
let queued_sub = Destination::Federation(server_name!("queued.example.org").to_owned());
|
|
||||||
let queued = Destination::Federation(server_name!("queued.example").to_owned());
|
|
||||||
let appservice = Destination::Appservice("bridge".to_owned());
|
|
||||||
let active = Destination::Federation(server_name!("active.example").to_owned());
|
|
||||||
let event = SendingEvent::Edu(EduBuf::from_slice(br#"{"edu_type":"m.typing"}"#));
|
|
||||||
|
|
||||||
db.queue_requests(once((&event, &queued)));
|
|
||||||
db.queue_requests(once((&event, &queued)));
|
|
||||||
db.queue_requests(once((&event, &queued_sub)));
|
|
||||||
db.queue_requests(once((&event, &appservice)));
|
|
||||||
db.queue_requests(once((&event, &active)));
|
|
||||||
let in_flight: Vec<_> = db.queued_requests(&active).collect().await;
|
|
||||||
db.mark_as_active(in_flight.iter());
|
|
||||||
|
|
||||||
let dests = db.queued_destinations().await;
|
|
||||||
|
|
||||||
drop(services);
|
|
||||||
std::fs::remove_dir_all(path).unwrap();
|
|
||||||
assert_eq!(dests, [appservice, queued_sub, queued]);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn restart_delay_doubles_up_to_the_cap() {
|
|
||||||
assert_eq!(restart_delay(1), Duration::from_millis(2500));
|
|
||||||
assert_eq!(restart_delay(2), Duration::from_secs(5));
|
|
||||||
assert_eq!(restart_delay(4), Duration::from_secs(20));
|
|
||||||
assert_eq!(restart_delay(5), Duration::from_secs(30));
|
|
||||||
assert_eq!(restart_delay(u32::MAX), Duration::from_secs(30));
|
|
||||||
}
|
|
||||||
@@ -158,7 +158,7 @@ impl super::Service {
|
|||||||
|
|
||||||
if let Some(server_keys) = self.get_signing_key(origin, key_id).await
|
if let Some(server_keys) = self.get_signing_key(origin, key_id).await
|
||||||
&& let Some(key) =
|
&& let Some(key) =
|
||||||
verify_key_from_response(key_id, &server_keys.parsed, min_valid_ts)
|
verify_key_from_response(key_id, &server_keys, min_valid_ts)
|
||||||
{
|
{
|
||||||
trace!(%origin, %key_id, ?min_valid_ts, "Verify key exists locally");
|
trace!(%origin, %key_id, ?min_valid_ts, "Verify key exists locally");
|
||||||
Self::track_one_result(
|
Self::track_one_result(
|
||||||
@@ -242,6 +242,7 @@ impl super::Service {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
trace!(?origin_response.raw, "Got signing key response from origin");
|
trace!(?origin_response.raw, "Got signing key response from origin");
|
||||||
|
self.add_signing_keys(&origin_response);
|
||||||
Self::track_result(&mut result, &mut still_missing, &origin_response.parsed);
|
Self::track_result(&mut result, &mut still_missing, &origin_response.parsed);
|
||||||
if still_missing.is_empty() {
|
if still_missing.is_empty() {
|
||||||
break;
|
break;
|
||||||
@@ -300,6 +301,7 @@ impl super::Service {
|
|||||||
continue;
|
continue;
|
||||||
};
|
};
|
||||||
trace!(response=?res.raw, "Got signing key response from origin");
|
trace!(response=?res.raw, "Got signing key response from origin");
|
||||||
|
self.add_signing_keys(&res);
|
||||||
Self::track_result(&mut result, &mut still_missing, &res.parsed);
|
Self::track_result(&mut result, &mut still_missing, &res.parsed);
|
||||||
if still_missing.is_empty() {
|
if still_missing.is_empty() {
|
||||||
break;
|
break;
|
||||||
@@ -385,7 +387,7 @@ impl super::Service {
|
|||||||
if let Some(vk) = self
|
if let Some(vk) = self
|
||||||
.get_signing_key(origin, key_id)
|
.get_signing_key(origin, key_id)
|
||||||
.await
|
.await
|
||||||
.and_then(|ssk| verify_key_from_response(key_id, &ssk.parsed, min_valid_ts))
|
.and_then(|ssk| verify_key_from_response(key_id, &ssk, min_valid_ts))
|
||||||
{
|
{
|
||||||
trace!("Found verify key locally");
|
trace!("Found verify key locally");
|
||||||
return Some(vk);
|
return Some(vk);
|
||||||
@@ -399,6 +401,7 @@ impl super::Service {
|
|||||||
.ok()?;
|
.ok()?;
|
||||||
|
|
||||||
verify_key_from_response(key_id, &response.parsed, min_valid_ts)
|
verify_key_from_response(key_id, &response.parsed, min_valid_ts)
|
||||||
|
.inspect(|_| self.add_signing_keys(&response))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,43 +5,32 @@ mod sign;
|
|||||||
mod util;
|
mod util;
|
||||||
mod verify;
|
mod verify;
|
||||||
|
|
||||||
use std::{
|
use std::{collections::BTreeMap, sync::Arc};
|
||||||
collections::{BTreeMap, HashMap},
|
|
||||||
sync::Arc,
|
|
||||||
time::{Duration, Instant},
|
|
||||||
};
|
|
||||||
|
|
||||||
use assign::assign;
|
|
||||||
use async_trait::async_trait;
|
|
||||||
use conduwuit::{
|
use conduwuit::{
|
||||||
Result, Server, SyncRwLock, debug_info,
|
Result, Server,
|
||||||
utils::{IterStream, ReadyExt, stream::TryIgnore, timepoint_from_now, to_canonical_object},
|
utils::{IterStream, ReadyExt, stream::TryIgnore},
|
||||||
};
|
};
|
||||||
use database::{Deserialized, Ignore, Interfix, Json, Map};
|
use database::{Deserialized, Ignore, Interfix, Json, Map};
|
||||||
use futures::{Stream, StreamExt};
|
use futures::{Stream, StreamExt};
|
||||||
pub use request::in_one_week;
|
pub use request::in_one_week;
|
||||||
use ruma::{
|
use ruma::{
|
||||||
CanonicalJsonObject, MilliSecondsSinceUnixEpoch, OwnedServerName, OwnedServerSigningKeyId,
|
CanonicalJsonObject, MilliSecondsSinceUnixEpoch, OwnedServerSigningKeyId, ServerName,
|
||||||
ServerName, ServerSigningKeyId,
|
ServerSigningKeyId,
|
||||||
api::federation::discovery::{OldVerifyKey, ServerSigningKeys, VerifyKey},
|
api::federation::discovery::{ServerSigningKeys, VerifyKey},
|
||||||
room_version_rules::RoomVersionRules,
|
room_version_rules::RoomVersionRules,
|
||||||
serde::Raw,
|
serde::Raw,
|
||||||
signatures::{Ed25519KeyPair, PublicKeyMap, PublicKeySet},
|
signatures::{Ed25519KeyPair, PublicKeyMap, PublicKeySet},
|
||||||
};
|
};
|
||||||
use serde_json::value::to_raw_value;
|
|
||||||
use verify::IncomingServerKeys;
|
use verify::IncomingServerKeys;
|
||||||
pub use verify::strip_extraneous_signatures;
|
|
||||||
|
|
||||||
use crate::{Dep, globals, sending, server_keys::util::required_keys};
|
use crate::{Dep, globals, sending, server_keys::util::required_keys};
|
||||||
|
|
||||||
const VALID_UNTIL_TS_DURATION: Duration = Duration::from_hours(12);
|
|
||||||
|
|
||||||
pub struct Service {
|
pub struct Service {
|
||||||
keypair: Box<Ed25519KeyPair>,
|
keypair: Box<Ed25519KeyPair>,
|
||||||
verify_keys: VerifyKeys,
|
verify_keys: VerifyKeys,
|
||||||
services: Services,
|
services: Services,
|
||||||
db: Data,
|
db: Data,
|
||||||
last_lookup: SyncRwLock<HashMap<OwnedServerName, Instant>>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
struct Services {
|
struct Services {
|
||||||
@@ -58,7 +47,6 @@ pub type VerifyKeys = BTreeMap<OwnedServerSigningKeyId, VerifyKey>;
|
|||||||
pub type PubKeyMap = PublicKeyMap;
|
pub type PubKeyMap = PublicKeyMap;
|
||||||
pub type PubKeys = PublicKeySet;
|
pub type PubKeys = PublicKeySet;
|
||||||
|
|
||||||
#[async_trait]
|
|
||||||
impl crate::Service for Service {
|
impl crate::Service for Service {
|
||||||
fn build(args: crate::Args<'_>) -> Result<Arc<Self>> {
|
fn build(args: crate::Args<'_>) -> Result<Arc<Self>> {
|
||||||
let (keypair, verify_keys) = keypair::init(args.db)?;
|
let (keypair, verify_keys) = keypair::init(args.db)?;
|
||||||
@@ -75,12 +63,9 @@ impl crate::Service for Service {
|
|||||||
db: Data {
|
db: Data {
|
||||||
servernamekeyid_response: args.db["servernamekeyid_response"].clone(),
|
servernamekeyid_response: args.db["servernamekeyid_response"].clone(),
|
||||||
},
|
},
|
||||||
last_lookup: SyncRwLock::new(HashMap::new()),
|
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn clear_cache(&self) { self.last_lookup.write().clear(); }
|
|
||||||
|
|
||||||
fn name(&self) -> &str { crate::service::make_name(std::module_path!()) }
|
fn name(&self) -> &str { crate::service::make_name(std::module_path!()) }
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -148,9 +133,7 @@ impl Service {
|
|||||||
key_id: &ServerSigningKeyId,
|
key_id: &ServerSigningKeyId,
|
||||||
minimum_valid_ts: MilliSecondsSinceUnixEpoch,
|
minimum_valid_ts: MilliSecondsSinceUnixEpoch,
|
||||||
) -> bool {
|
) -> bool {
|
||||||
let Some(IncomingServerKeys { parsed: keys, .. }) =
|
let Some(keys) = self.get_signing_key(origin, key_id).await else {
|
||||||
self.get_signing_key(origin, key_id).await
|
|
||||||
else {
|
|
||||||
// We have no keys for this server
|
// We have no keys for this server
|
||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
@@ -178,13 +161,12 @@ impl Service {
|
|||||||
&self,
|
&self,
|
||||||
origin: &ServerName,
|
origin: &ServerName,
|
||||||
key_id: &ServerSigningKeyId,
|
key_id: &ServerSigningKeyId,
|
||||||
) -> Option<IncomingServerKeys> {
|
) -> Option<ServerSigningKeys> {
|
||||||
self.db
|
self.db
|
||||||
.servernamekeyid_response
|
.servernamekeyid_response
|
||||||
.qry(&(origin.as_str(), key_id.as_str()))
|
.qry(&(origin.as_str(), key_id.as_str()))
|
||||||
.await
|
.await
|
||||||
.deserialized::<Raw<ServerSigningKeys>>()
|
.deserialized::<ServerSigningKeys>()
|
||||||
.and_then(|r| r.try_into().map_err(Into::into))
|
|
||||||
.ok()
|
.ok()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -206,8 +188,6 @@ impl Service {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the stored server signing keys responses for the origin.
|
/// Returns the stored server signing keys responses for the origin.
|
||||||
///
|
|
||||||
/// Does not imply that the stored responses are still in-date.
|
|
||||||
pub fn signing_keys_for<'a>(
|
pub fn signing_keys_for<'a>(
|
||||||
&'a self,
|
&'a self,
|
||||||
origin: &'a ServerName,
|
origin: &'a ServerName,
|
||||||
@@ -219,114 +199,4 @@ impl Service {
|
|||||||
.map(|(_, v): (Ignore, Raw<ServerSigningKeys>)| v.try_into().map_err(Into::into))
|
.map(|(_, v): (Ignore, Raw<ServerSigningKeys>)| v.try_into().map_err(Into::into))
|
||||||
.ignore_err()
|
.ignore_err()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Determines if the server may contact the origin server to fetch keys
|
|
||||||
/// when acting as a notary server. This limits origin lookups to once per
|
|
||||||
/// minute, which prevents amplification attacks.
|
|
||||||
#[must_use]
|
|
||||||
pub fn origin_not_contacted_recently(&self, server_name: &ServerName) -> bool {
|
|
||||||
if server_name == self.services.server.name {
|
|
||||||
// We always intercept origin requests to us with
|
|
||||||
// build_server_keys_response, so this is equivalent to
|
|
||||||
// calling `/_matrix/key/v2/server`.
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
self.last_lookup
|
|
||||||
.read()
|
|
||||||
.get(server_name)
|
|
||||||
.is_none_or(|last| last.elapsed() >= Duration::from_mins(1))
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Generates a signing key response to serve to `/_matrix/key/v2/server`.
|
|
||||||
pub async fn build_server_keys_response(&self) -> Result<Raw<ServerSigningKeys>> {
|
|
||||||
let verify_keys = BTreeMap::from([self.active_verify_key()]);
|
|
||||||
let old_verify_keys = match &self.services.server.config.old_verify_keys {
|
|
||||||
| Some(old_verify_keys) => old_verify_keys.to_owned(),
|
|
||||||
| None => self.discover_old_signing_keys().await,
|
|
||||||
};
|
|
||||||
let valid_until_ts = timepoint_from_now(VALID_UNTIL_TS_DURATION)
|
|
||||||
.ok()
|
|
||||||
.and_then(MilliSecondsSinceUnixEpoch::from_system_time)
|
|
||||||
.expect("key validity period must be before the heat death of the universe");
|
|
||||||
let server_keys = assign!(
|
|
||||||
ServerSigningKeys::new(self.services.server.name.clone(), valid_until_ts),
|
|
||||||
{verify_keys, old_verify_keys}
|
|
||||||
);
|
|
||||||
let mut canonical_obj = to_canonical_object(&server_keys)?;
|
|
||||||
self.sign_json(&mut canonical_obj)
|
|
||||||
.and_then(|()| to_raw_value(&canonical_obj).map_err(Into::into))
|
|
||||||
.map(Raw::from_json)
|
|
||||||
}
|
|
||||||
|
|
||||||
async fn discover_old_signing_keys(&self) -> BTreeMap<OwnedServerSigningKeyId, OldVerifyKey> {
|
|
||||||
let now = MilliSecondsSinceUnixEpoch::now();
|
|
||||||
let mut keys = self.signing_keys_for(&self.services.server.name);
|
|
||||||
let mut old_keys = BTreeMap::new();
|
|
||||||
while let Some(resp) = keys.next().await {
|
|
||||||
// We need to verify that this response is still trusted based on
|
|
||||||
// the current configuration. It's possible we got this response
|
|
||||||
// from a notary who we no longer trust.
|
|
||||||
if resp.parsed.valid_until_ts > in_one_week() || resp.parsed.valid_until_ts < now {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
let trusted = self
|
|
||||||
.services
|
|
||||||
.server
|
|
||||||
.config
|
|
||||||
.trusted_servers
|
|
||||||
.iter()
|
|
||||||
.any(|notary| {
|
|
||||||
Self::verify_server_keys_response(
|
|
||||||
&resp,
|
|
||||||
Some((notary.server_name(), notary.verify_keys())),
|
|
||||||
)
|
|
||||||
.is_ok()
|
|
||||||
});
|
|
||||||
if !trusted {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
for (old_key_id, old_key) in resp.parsed.old_verify_keys {
|
|
||||||
if old_key.expired_ts > resp.parsed.valid_until_ts {
|
|
||||||
// This key expired in the future which is probably illegal
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
old_keys
|
|
||||||
.entry(old_key_id)
|
|
||||||
.and_modify(|current_old_key: &mut OldVerifyKey| {
|
|
||||||
// Use the lowest expiry timestamp
|
|
||||||
if current_old_key.expired_ts > old_key.expired_ts {
|
|
||||||
*current_old_key = old_key.clone();
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.or_insert(old_key);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
old_keys
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Canonicalize and sign another server's signing keys.
|
|
||||||
pub fn self_sign_signing_keys(
|
|
||||||
&self,
|
|
||||||
remote_server: &ServerName,
|
|
||||||
remote_keys: &Raw<ServerSigningKeys>,
|
|
||||||
) -> Result<Raw<ServerSigningKeys>> {
|
|
||||||
let this_server = self.services.globals.server_name();
|
|
||||||
|
|
||||||
let mut canonical = to_canonical_object(remote_keys)?;
|
|
||||||
|
|
||||||
if remote_server == this_server {
|
|
||||||
debug_info!(
|
|
||||||
%remote_server,
|
|
||||||
object=?remote_keys,
|
|
||||||
"Refusing to sign our own signing keys response (should already be signed)"
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
self.sign_json(&mut canonical)?;
|
|
||||||
|
|
||||||
strip_extraneous_signatures(&mut canonical, remote_server, &[this_server]);
|
|
||||||
}
|
|
||||||
|
|
||||||
Ok(Raw::<ServerSigningKeys>::from_json(to_raw_value(&canonical)?))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
use std::{collections::BTreeMap, time::Instant};
|
use std::collections::BTreeMap;
|
||||||
|
|
||||||
use conduwuit::{Err, Result, trace, utils::millis_since_unix_epoch, warn};
|
use conduwuit::{Err, Result, trace, utils::millis_since_unix_epoch, warn};
|
||||||
use ruma::{
|
use ruma::{
|
||||||
@@ -31,23 +31,6 @@ impl super::Service {
|
|||||||
) -> Result<IncomingServerKeys> {
|
) -> Result<IncomingServerKeys> {
|
||||||
use get_server_keys::v2::Request;
|
use get_server_keys::v2::Request;
|
||||||
|
|
||||||
if target == self.services.server.name {
|
|
||||||
return self
|
|
||||||
.build_server_keys_response()
|
|
||||||
.await
|
|
||||||
.and_then(|r| r.try_into().map_err(Into::into));
|
|
||||||
}
|
|
||||||
|
|
||||||
// N.B. The "last lookup" is written before the request is actually made
|
|
||||||
// to prevent concurrent notary requests from spawning... concurrent
|
|
||||||
// origin requests, especially if the origin is slow.
|
|
||||||
// This has the downside that, if the origin is temporarily unreachable
|
|
||||||
// (including if we're backing off from it), the notary might take an
|
|
||||||
// additional minute to recover compared to the rest of the server. This
|
|
||||||
// is deemed acceptable.
|
|
||||||
self.last_lookup
|
|
||||||
.write()
|
|
||||||
.insert(target.clone(), Instant::now());
|
|
||||||
let raw_server_key = self
|
let raw_server_key = self
|
||||||
.services
|
.services
|
||||||
.sending
|
.sending
|
||||||
@@ -83,8 +66,6 @@ impl super::Service {
|
|||||||
)));
|
)));
|
||||||
}
|
}
|
||||||
|
|
||||||
self.add_signing_keys(&server_signing_key);
|
|
||||||
|
|
||||||
Ok(server_signing_key)
|
Ok(server_signing_key)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,8 +2,7 @@ use conduwuit::{
|
|||||||
Err, Result, matrix::event::gen_event_id_canonical_json, trace, utils::to_canonical_object,
|
Err, Result, matrix::event::gen_event_id_canonical_json, trace, utils::to_canonical_object,
|
||||||
};
|
};
|
||||||
use ruma::{
|
use ruma::{
|
||||||
CanonicalJsonObject, CanonicalJsonValue, OwnedEventId, ServerName, ServerSigningKeyId,
|
CanonicalJsonObject, CanonicalJsonValue, OwnedEventId, ServerName, SigningKeyAlgorithm,
|
||||||
SigningKeyAlgorithm,
|
|
||||||
api::federation::discovery::ServerSigningKeys,
|
api::federation::discovery::ServerSigningKeys,
|
||||||
room_version_rules::RoomVersionRules,
|
room_version_rules::RoomVersionRules,
|
||||||
serde::{Base64, Raw, base64::Standard},
|
serde::{Base64, Raw, base64::Standard},
|
||||||
@@ -36,17 +35,6 @@ impl TryFrom<&Raw<ServerSigningKeys>> for IncomingServerKeys {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl IncomingServerKeys {
|
|
||||||
/// Returns an iterator of every key ID in this key response.
|
|
||||||
pub fn all_key_ids(&self) -> impl Iterator<Item = &ServerSigningKeyId> {
|
|
||||||
self.parsed
|
|
||||||
.verify_keys
|
|
||||||
.keys()
|
|
||||||
.chain(self.parsed.old_verify_keys.keys())
|
|
||||||
.map(|key| &**key)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl super::Service {
|
impl super::Service {
|
||||||
/// Validates the incoming event only using locally known verification keys.
|
/// Validates the incoming event only using locally known verification keys.
|
||||||
/// Inserts the calculated event ID into the event_id field upon success.
|
/// Inserts the calculated event ID into the event_id field upon success.
|
||||||
@@ -119,7 +107,7 @@ impl super::Service {
|
|||||||
pubkey_map.insert(incoming.parsed.server_name.to_string(), set);
|
pubkey_map.insert(incoming.parsed.server_name.to_string(), set);
|
||||||
|
|
||||||
let mut canonical = to_canonical_object(&incoming.raw)?;
|
let mut canonical = to_canonical_object(&incoming.raw)?;
|
||||||
strip_extraneous_signatures(&mut canonical, &incoming.parsed.server_name, &[]);
|
Self::strip_extraneous_signatures(&mut canonical, &incoming.parsed.server_name, &[]);
|
||||||
ruma::signatures::verify_json(&pubkey_map, &canonical).map_err(Into::into)
|
ruma::signatures::verify_json(&pubkey_map, &canonical).map_err(Into::into)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -175,30 +163,22 @@ impl super::Service {
|
|||||||
"No valid signature from {notary_name} present on signing keys response"
|
"No valid signature from {notary_name} present on signing keys response"
|
||||||
)))
|
)))
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/// Removes extraneous signatures from the signature map. This is done to avoid
|
fn strip_extraneous_signatures(
|
||||||
/// leaking the signatures from notaries we've used, in case the response is
|
canonical: &mut CanonicalJsonObject,
|
||||||
/// being forwarded to a third party. This also reduces the risk of accidentally
|
origin: &ServerName,
|
||||||
/// trusting a notary's signature as the origin's signature if `notaries` is
|
notaries: &[&ServerName],
|
||||||
/// empty.
|
) {
|
||||||
///
|
canonical.entry("signatures".to_owned()).and_modify(|sigs| {
|
||||||
/// Infallible & mutates the original canonical JSON object. Signatures by
|
sigs.as_object_mut().map(|s| {
|
||||||
/// server names that cannot be parsed are always removed.
|
s.retain(|server_name, _| {
|
||||||
pub fn strip_extraneous_signatures(
|
let Ok(server_name) = ServerName::parse(server_name) else { return false };
|
||||||
canonical: &mut CanonicalJsonObject,
|
origin == server_name || notaries.iter().any(|ns| *ns == server_name)
|
||||||
origin: &ServerName,
|
});
|
||||||
notaries: &[&ServerName],
|
Some(s)
|
||||||
) {
|
|
||||||
canonical.entry("signatures".to_owned()).and_modify(|sigs| {
|
|
||||||
sigs.as_object_mut().map(|s| {
|
|
||||||
s.retain(|server_name, _| {
|
|
||||||
let Ok(server_name) = ServerName::parse(server_name) else { return false };
|
|
||||||
origin == server_name || notaries.iter().any(|ns| *ns == server_name)
|
|
||||||
});
|
});
|
||||||
Some(s)
|
|
||||||
});
|
});
|
||||||
});
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
|||||||
@@ -1,52 +0,0 @@
|
|||||||
use std::{path::PathBuf, sync::Arc};
|
|
||||||
|
|
||||||
use conduwuit::{
|
|
||||||
Config, Server,
|
|
||||||
log::{Log, LogLevelReloadHandles},
|
|
||||||
metrics::Metrics,
|
|
||||||
};
|
|
||||||
use serde_json::json;
|
|
||||||
use tokio::sync::{Mutex, MutexGuard};
|
|
||||||
|
|
||||||
/// RocksDB's default `Env` is shared by the whole process and closing a
|
|
||||||
/// database stops its background threads, so tests must not keep databases
|
|
||||||
/// open in parallel. Hold the returned guard until the services are dropped.
|
|
||||||
static DATABASE: Mutex<()> = Mutex::const_new(());
|
|
||||||
|
|
||||||
type TestServices = (Arc<crate::Services>, PathBuf, MutexGuard<'static, ()>);
|
|
||||||
|
|
||||||
pub(crate) async fn test_services() -> TestServices { test_services_with(json!({})).await }
|
|
||||||
|
|
||||||
pub(crate) async fn test_services_with(overrides: serde_json::Value) -> TestServices {
|
|
||||||
let guard = DATABASE.lock().await;
|
|
||||||
let _ = rustls::crypto::ring::default_provider().install_default();
|
|
||||||
let path = std::env::temp_dir()
|
|
||||||
.join(format!("continuwuity-shared-state-{:016x}", rand::random::<u64>()));
|
|
||||||
std::fs::create_dir(&path).unwrap();
|
|
||||||
let mut config = json!({
|
|
||||||
"server_name": "test.example",
|
|
||||||
"database_path": path,
|
|
||||||
"db_cache_capacity_mb": 16.0,
|
|
||||||
"rocksdb_write_buffer_capacity_mb": 4.0,
|
|
||||||
"allow_local_presence": false,
|
|
||||||
"dns_servers": ["127.0.0.1"],
|
|
||||||
"allow_invalid_tls_certificates_yes_i_know_what_the_fuck_i_am_doing_with_this_and_i_know_this_is_insecure": true
|
|
||||||
});
|
|
||||||
config
|
|
||||||
.as_object_mut()
|
|
||||||
.unwrap()
|
|
||||||
.extend(overrides.as_object().unwrap().clone());
|
|
||||||
let config: Config = serde_json::from_value(config).unwrap();
|
|
||||||
let runtime = tokio::runtime::Handle::current();
|
|
||||||
let server = Arc::new(Server::new(
|
|
||||||
config,
|
|
||||||
Some(runtime.clone()),
|
|
||||||
Log {
|
|
||||||
reload: LogLevelReloadHandles::default(),
|
|
||||||
capture: Arc::default(),
|
|
||||||
},
|
|
||||||
Metrics::new(Some(runtime), opentelemetry::global::meter("test"), None),
|
|
||||||
));
|
|
||||||
let services = crate::Services::build(server).await.unwrap();
|
|
||||||
(services, path, guard)
|
|
||||||
}
|
|
||||||
@@ -348,8 +348,8 @@ impl Service {
|
|||||||
.compatibility_mode()
|
.compatibility_mode()
|
||||||
.uiaa_available()
|
.uiaa_available()
|
||||||
{
|
{
|
||||||
return Err!(Request(Forbidden(
|
return Err!(Request(Unrecognized(
|
||||||
"User-interactive authentication is not available on this server."
|
"User-interactive authentication is unavailable on this server"
|
||||||
)));
|
)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -632,12 +632,6 @@ impl super::Service {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Discard this device's previous token entry if the current token
|
|
||||||
// isn't expired.
|
|
||||||
self.db
|
|
||||||
.userdeviceid_previoustoken
|
|
||||||
.del((&user_id, &device_id));
|
|
||||||
|
|
||||||
Some((user_id, device_id, AccessTokenStatus::Valid))
|
Some((user_id, device_id, AccessTokenStatus::Valid))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -17,18 +17,6 @@ use serde_json::json;
|
|||||||
|
|
||||||
use crate::users::increment;
|
use crate::users::increment;
|
||||||
|
|
||||||
#[derive(Clone, Copy, Debug)]
|
|
||||||
pub enum PreviousTokenAction {
|
|
||||||
/// Discard any previously saved access token for this device.
|
|
||||||
Clear,
|
|
||||||
/// Save the replaced access token as the previous token, overwriting any
|
|
||||||
/// existing one.
|
|
||||||
Replace,
|
|
||||||
/// Keep an existing previous access token if one is already saved;
|
|
||||||
/// otherwise save the replaced access token.
|
|
||||||
Preserve,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct DeviceToken {
|
pub struct DeviceToken {
|
||||||
@@ -83,8 +71,7 @@ impl super::Service {
|
|||||||
self.db.userdeviceid_metadata.put(key, Json(device));
|
self.db.userdeviceid_metadata.put(key, Json(device));
|
||||||
|
|
||||||
if let Some(token) = token {
|
if let Some(token) = token {
|
||||||
self.set_token(user_id, &device_id, token, PreviousTokenAction::Clear)
|
self.set_token(user_id, &device_id, token).await?;
|
||||||
.await?;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(device_id)
|
Ok(device_id)
|
||||||
@@ -105,7 +92,6 @@ impl super::Service {
|
|||||||
self.db.token_userdeviceid.remove(&old_token);
|
self.db.token_userdeviceid.remove(&old_token);
|
||||||
self.db.userdeviceid_tokenexpires.del(userdeviceid);
|
self.db.userdeviceid_tokenexpires.del(userdeviceid);
|
||||||
}
|
}
|
||||||
self.db.userdeviceid_previoustoken.del(userdeviceid);
|
|
||||||
|
|
||||||
// Remove todevice events
|
// Remove todevice events
|
||||||
let prefix = (user_id, device_id, Interfix);
|
let prefix = (user_id, device_id, Interfix);
|
||||||
@@ -178,7 +164,6 @@ impl super::Service {
|
|||||||
user_id: &UserId,
|
user_id: &UserId,
|
||||||
device_id: &DeviceId,
|
device_id: &DeviceId,
|
||||||
DeviceToken { token, max_age }: DeviceToken,
|
DeviceToken { token, max_age }: DeviceToken,
|
||||||
previous_token_action: PreviousTokenAction,
|
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
let key = (user_id, device_id);
|
let key = (user_id, device_id);
|
||||||
if self.db.userdeviceid_metadata.qry(&key).await.is_err() {
|
if self.db.userdeviceid_metadata.qry(&key).await.is_err() {
|
||||||
@@ -199,23 +184,8 @@ impl super::Service {
|
|||||||
// Remove old token
|
// Remove old token
|
||||||
if let Ok(old_token) = self.db.userdeviceid_token.qry(&key).await {
|
if let Ok(old_token) = self.db.userdeviceid_token.qry(&key).await {
|
||||||
self.db.token_userdeviceid.remove(&old_token);
|
self.db.token_userdeviceid.remove(&old_token);
|
||||||
|
self.db.userdeviceid_tokenexpires.remove(&old_token);
|
||||||
// It will be removed from userdeviceid_token by the insert later
|
// It will be removed from userdeviceid_token by the insert later
|
||||||
|
|
||||||
match previous_token_action {
|
|
||||||
| PreviousTokenAction::Clear => {
|
|
||||||
self.db.userdeviceid_previoustoken.del(key);
|
|
||||||
},
|
|
||||||
| PreviousTokenAction::Replace => {
|
|
||||||
self.db.userdeviceid_previoustoken.put_raw(key, &old_token);
|
|
||||||
},
|
|
||||||
| PreviousTokenAction::Preserve => {
|
|
||||||
if !self.db.userdeviceid_previoustoken.contains(&key).await {
|
|
||||||
self.db.userdeviceid_previoustoken.put_raw(key, &old_token);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
}
|
|
||||||
} else if matches!(previous_token_action, PreviousTokenAction::Clear) {
|
|
||||||
self.db.userdeviceid_previoustoken.del(key);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Assign token to user device combination
|
// Assign token to user device combination
|
||||||
@@ -237,17 +207,6 @@ impl super::Service {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns whether the provided token was previously used by a device
|
|
||||||
/// before a token refresh, and therefore should cause a soft-logout.
|
|
||||||
pub async fn is_previous_token(&self, token: &str) -> bool {
|
|
||||||
self.db
|
|
||||||
.userdeviceid_previoustoken
|
|
||||||
.stream::<Ignore, String>()
|
|
||||||
.ignore_err()
|
|
||||||
.ready_any(|(_, previous_token)| previous_token == token)
|
|
||||||
.await
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Pushes a new to-device event into a device's inbox.
|
/// Pushes a new to-device event into a device's inbox.
|
||||||
pub async fn add_to_device_event(
|
pub async fn add_to_device_event(
|
||||||
&self,
|
&self,
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ use std::{mem, sync::Arc};
|
|||||||
pub use account::{AccessTokenStatus, AccountStatus};
|
pub use account::{AccessTokenStatus, AccountStatus};
|
||||||
use conduwuit::{Err, Error, Result, err, utils};
|
use conduwuit::{Err, Error, Result, err, utils};
|
||||||
use database::Map;
|
use database::Map;
|
||||||
pub use device::{DeviceToken, PreviousTokenAction};
|
pub use device::DeviceToken;
|
||||||
pub use profile::ProfileFieldChange;
|
pub use profile::ProfileFieldChange;
|
||||||
use ruma::{UserId, api::error::ErrorKind, encryption::CrossSigningKey, serde::Raw};
|
use ruma::{UserId, api::error::ErrorKind, encryption::CrossSigningKey, serde::Raw};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
@@ -83,7 +83,6 @@ struct Data {
|
|||||||
userdeviceid_tokenexpires: Arc<Map>,
|
userdeviceid_tokenexpires: Arc<Map>,
|
||||||
userdeviceid_metadata: Arc<Map>,
|
userdeviceid_metadata: Arc<Map>,
|
||||||
userdeviceid_token: Arc<Map>,
|
userdeviceid_token: Arc<Map>,
|
||||||
userdeviceid_previoustoken: Arc<Map>,
|
|
||||||
userfilterid_filter: Arc<Map>,
|
userfilterid_filter: Arc<Map>,
|
||||||
userid_avatarurl: Arc<Map>,
|
userid_avatarurl: Arc<Map>,
|
||||||
userid_deactivated: Arc<Map>,
|
userid_deactivated: Arc<Map>,
|
||||||
@@ -135,7 +134,6 @@ impl crate::Service for Service {
|
|||||||
remoteuserid_remoteuser: args.db["remoteuserid_remoteuser"].clone(),
|
remoteuserid_remoteuser: args.db["remoteuserid_remoteuser"].clone(),
|
||||||
userdeviceid_metadata: args.db["userdeviceid_metadata"].clone(),
|
userdeviceid_metadata: args.db["userdeviceid_metadata"].clone(),
|
||||||
userdeviceid_token: args.db["userdeviceid_token"].clone(),
|
userdeviceid_token: args.db["userdeviceid_token"].clone(),
|
||||||
userdeviceid_previoustoken: args.db["userdeviceid_previoustoken"].clone(),
|
|
||||||
userfilterid_filter: args.db["userfilterid_filter"].clone(),
|
userfilterid_filter: args.db["userfilterid_filter"].clone(),
|
||||||
userid_avatarurl: args.db["userid_avatarurl"].clone(),
|
userid_avatarurl: args.db["userid_avatarurl"].clone(),
|
||||||
userid_deactivated: args.db["userid_deactivated"].clone(),
|
userid_deactivated: args.db["userid_deactivated"].clone(),
|
||||||
|
|||||||
@@ -29,7 +29,6 @@
|
|||||||
--card-bg: oklch(from var(--panel-bg) var(--background-lightness) c h);
|
--card-bg: oklch(from var(--panel-bg) var(--background-lightness) c h);
|
||||||
|
|
||||||
--rp-home-background-bg: radial-gradient(42.12% 56.13% at 100% 0%, oklch(from var(--c2) var(--background-lightness) c h) 0%, #fff0 100%), radial-gradient(42.01% 79.63% at 52.86% 0%, #d9ff5333 0%, #fff0 100%), radial-gradient(79.67% 58.09% at 0% 0%, oklch(from var(--c1) var(--background-lightness) c h) 0%, #fff0 100%), var(--rp-c-bg);
|
--rp-home-background-bg: radial-gradient(42.12% 56.13% at 100% 0%, oklch(from var(--c2) var(--background-lightness) c h) 0%, #fff0 100%), radial-gradient(42.01% 79.63% at 52.86% 0%, #d9ff5333 0%, #fff0 100%), radial-gradient(79.67% 58.09% at 0% 0%, oklch(from var(--c1) var(--background-lightness) c h) 0%, #fff0 100%), var(--rp-c-bg);
|
||||||
--rp-banner-background: linear-gradient(279deg, var(--rp-c-brand-dark) 35.21%, var(--rp-c-brand-light) 63.34%);
|
|
||||||
|
|
||||||
--rp-c-divider: rgba(0, 0, 0, 0.2);
|
--rp-c-divider: rgba(0, 0, 0, 0.2);
|
||||||
--rp-c-divider-light: rgba(0, 0, 0, 0.1);
|
--rp-c-divider-light: rgba(0, 0, 0, 0.1);
|
||||||
|
|||||||
+4
-22
@@ -1,28 +1,10 @@
|
|||||||
import { Banner, HomeLayout as BasicHomeLayout, Layout as BasicLayout, DocContent } from "@rspress/core/theme-original";
|
import { HomeLayout as BasicHomeLayout, DocContent } from "@rspress/core/theme-original";
|
||||||
import { useFrontmatter, useSite } from '@rspress/core/runtime';
|
|
||||||
|
import { useFrontmatter } from '@rspress/core/runtime';
|
||||||
interface HomeLayoutProps {
|
interface HomeLayoutProps {
|
||||||
components?: Record<string, React.FC>;
|
components?: Record<string, React.FC>;
|
||||||
}
|
}
|
||||||
|
|
||||||
const Layout = () => {
|
|
||||||
const { site } = useSite();
|
|
||||||
const sitePath: string = site.base;
|
|
||||||
const prNumber: string = sitePath.substring(sitePath.indexOf("@") + 1, sitePath.lastIndexOf("/"));
|
|
||||||
|
|
||||||
return (
|
|
||||||
<BasicLayout
|
|
||||||
beforeNav={
|
|
||||||
sitePath != "/" ? (
|
|
||||||
<Banner
|
|
||||||
href={`https://forgejo.ellis.link/continuwuation/continuwuity/pulls/${prNumber}`}
|
|
||||||
message={`Documentation preview for PR #${prNumber}`}
|
|
||||||
/>
|
|
||||||
) : null
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
function HomeLayout(props: HomeLayoutProps) {
|
function HomeLayout(props: HomeLayoutProps) {
|
||||||
console.log(props)
|
console.log(props)
|
||||||
|
|
||||||
@@ -59,6 +41,6 @@ function HomeLayout(props: HomeLayoutProps) {
|
|||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
export { HomeLayout, Layout };
|
export { HomeLayout };
|
||||||
export * from "@rspress/core/theme-original";
|
export * from "@rspress/core/theme-original";
|
||||||
import "./index.css";
|
import "./index.css";
|
||||||
Reference in new issue
Block a user