mirror of
https://github.com/matrix-org/dendrite.git
synced 2025-12-23 23:03:10 -06:00
Merge branch 'master' into add-last-seen
This commit is contained in:
commit
73389f3145
89
CHANGES.md
Normal file
89
CHANGES.md
Normal file
|
|
@ -0,0 +1,89 @@
|
|||
# Dendrite 0.1.0 (2020-10-08)
|
||||
|
||||
First versioned release of Dendrite.
|
||||
|
||||
## Client-Server API Features
|
||||
|
||||
### Account registration and management
|
||||
- Registration: By password only.
|
||||
- Login: By password only. No fallback.
|
||||
- Logout: Yes.
|
||||
- Change password: Yes.
|
||||
- Link email/msisdn to account: No.
|
||||
- Deactivate account: Yes.
|
||||
- Check if username is available: Yes.
|
||||
- Account data: Yes.
|
||||
- OpenID: No.
|
||||
|
||||
### Rooms
|
||||
- Room creation: Yes, including presets.
|
||||
- Joining rooms: Yes, including by alias or `?server_name=`.
|
||||
- Event sending: Yes, including transaction IDs.
|
||||
- Aliases: Yes.
|
||||
- Published room directory: Yes.
|
||||
- Kicking users: Yes.
|
||||
- Banning users: Yes.
|
||||
- Inviting users: Yes, but not third-party invites.
|
||||
- Forgetting rooms: No.
|
||||
- Room versions: All (v1 - v6)
|
||||
- Tagging: Yes.
|
||||
|
||||
### User management
|
||||
- User directory: Basic support.
|
||||
- Ignoring users: No.
|
||||
- Groups/Communities: No.
|
||||
|
||||
### Device management
|
||||
- Creating devices: Yes.
|
||||
- Deleting devices: Yes.
|
||||
- Send-to-device messaging: Yes.
|
||||
|
||||
### Sync
|
||||
- Filters: Timeline limit only. Rest unimplemented.
|
||||
- Deprecated `/events` and `/initialSync`: No.
|
||||
|
||||
### Room events
|
||||
- Typing: Yes.
|
||||
- Receipts: No.
|
||||
- Read Markers: No.
|
||||
- Presence: No.
|
||||
- Content repository (attachments): Yes.
|
||||
- History visibility: No, defaults to `joined`.
|
||||
- Push notifications: No.
|
||||
- Event context: No.
|
||||
- Reporting content: No.
|
||||
|
||||
### End-to-End Encryption
|
||||
- Uploading device keys: Yes.
|
||||
- Downloading device keys: Yes.
|
||||
- Claiming one-time keys: Yes.
|
||||
- Querying key changes: Yes.
|
||||
- Cross-Signing: No.
|
||||
|
||||
### Misc
|
||||
- Server-side search: No.
|
||||
- Guest access: Partial.
|
||||
- Room previews: No, partial support for Peeking via MSC2753.
|
||||
- Third-Party networks: No.
|
||||
- Server notices: No.
|
||||
- Policy lists: No.
|
||||
|
||||
## Federation Features
|
||||
- Querying keys (incl. notary): Yes.
|
||||
- Server ACLs: Yes.
|
||||
- Sending transactions: Yes.
|
||||
- Joining rooms: Yes.
|
||||
- Inviting to rooms: Yes, but not third-party invites.
|
||||
- Leaving rooms: Yes.
|
||||
- Content repository: Yes.
|
||||
- Backfilling / get_missing_events: Yes.
|
||||
- Retrieving state of the room (`/state` and `/state_ids`): Yes.
|
||||
- Public rooms: Yes.
|
||||
- Querying profile data: Yes.
|
||||
- Device management: Yes.
|
||||
- Send-to-Device messaging: Yes.
|
||||
- Querying/Claiming E2E Keys: Yes.
|
||||
- Typing: Yes.
|
||||
- Presence: No.
|
||||
- Receipts: No.
|
||||
- OpenID: No.
|
||||
50
README.md
50
README.md
|
|
@ -1,6 +1,28 @@
|
|||
# Dendrite [](https://buildkite.com/matrix-dot-org/dendrite) [](https://matrix.to/#/#dendrite:matrix.org) [](https://matrix.to/#/#dendrite-dev:matrix.org)
|
||||
|
||||
Dendrite is a second-generation Matrix homeserver written in Go!
|
||||
Dendrite is a second-generation Matrix homeserver written in Go.
|
||||
It intends to provide an **efficient**, **reliable** and **scalable** alternative to Synapse:
|
||||
- Efficient: A small memory footprint with better baseline performance than an out-of-the-box Synapse.
|
||||
- Reliable: Implements the Matrix specification as written, using the
|
||||
[same test suite](https://github.com/matrix-org/sytest) as Synapse as well as
|
||||
a [brand new Go test suite](https://github.com/matrix-org/complement).
|
||||
- Scalable: can run on multiple machines and eventually scale to massive homeserver deployments.
|
||||
|
||||
|
||||
As of October 2020, Dendrite has now entered **beta** which means:
|
||||
- Dendrite is ready for early adopters. We recommend running in Monolith mode with a PostgreSQL database.
|
||||
- Dendrite has periodic semver releases. We intend to release new versions as we land significant features.
|
||||
- Dendrite supports database schema upgrades between releases. This means you should never lose your messages when upgrading Dendrite.
|
||||
- Breaking changes will not occur on minor releases. This means you can safely upgrade Dendrite without modifying your database or config file.
|
||||
|
||||
This does not mean:
|
||||
- Dendrite is bug-free. It has not yet been battle-tested in the real world and so will be error prone initially.
|
||||
- All of the CS/Federation APIs are implemented. We are tracking progress via a script called 'Are We Synapse Yet?'. In particular,
|
||||
read receipts, presence and push notifications are entirely missing from Dendrite. See [CHANGES.md](CHANGES.md) for updates.
|
||||
- Dendrite is ready for massive homeserver deployments. You cannot shard each microservice, only run each one on a different machine.
|
||||
|
||||
Currently, we expect Dendrite to function well for small (10s/100s of users) homeserver deployments as well as P2P Matrix nodes in-browser or on mobile devices.
|
||||
In the future, we will be able to scale up to gigantic servers (equivalent to matrix.org) via polylith mode.
|
||||
|
||||
Join us in:
|
||||
|
||||
|
|
@ -8,9 +30,26 @@ Join us in:
|
|||
- **[#dendrite-dev:matrix.org](https://matrix.to/#/#dendrite-dev:matrix.org)** - The place for developers, where all Dendrite development discussion happens
|
||||
- **[#dendrite-alerts:matrix.org](https://matrix.to/#/#dendrite-alerts:matrix.org)** - Release notifications and important info, highly recommended for all Dendrite server admins
|
||||
|
||||
## Quick start
|
||||
## Requirements
|
||||
|
||||
Requires Go 1.13+ and SQLite3 (Postgres is also supported):
|
||||
To build Dendrite, you will need Go 1.13 or later.
|
||||
|
||||
For a usable federating Dendrite deployment, you will also need:
|
||||
- A domain name (or subdomain)
|
||||
- A valid TLS certificate issued by a trusted authority for that domain
|
||||
- SRV records or a well-known file pointing to your deployment
|
||||
|
||||
Also recommended are:
|
||||
- A PostgreSQL database engine, which will perform better than SQLite with many users and/or larger rooms
|
||||
- A reverse proxy server, such as nginx, configured [like this sample](https://github.com/matrix-org/dendrite/blob/master/docs/nginx/monolith-sample.conf)
|
||||
|
||||
The [Federation Tester](https://federationtester.matrix.org) can be used to verify your deployment.
|
||||
|
||||
## Get started
|
||||
|
||||
If you wish to build a fully-federating Dendrite instance, see [INSTALL.md](docs/INSTALL.md). For running in Docker, see [build/docker](build/docker).
|
||||
|
||||
The following instructions are enough to get Dendrite started as a non-federating test deployment using self-signed certificates and SQLite databases:
|
||||
|
||||
```bash
|
||||
$ git clone https://github.com/matrix-org/dendrite
|
||||
|
|
@ -30,14 +69,13 @@ $ go build ./cmd/dendrite-monolith-server
|
|||
$ ./dendrite-monolith-server --tls-cert server.crt --tls-key server.key --config dendrite.yaml
|
||||
```
|
||||
|
||||
Then point your favourite Matrix client at `http://localhost:8008`. For full installation information, see
|
||||
[INSTALL.md](docs/INSTALL.md). For running in Docker, see [build/docker](build/docker).
|
||||
Then point your favourite Matrix client at `http://localhost:8008`.
|
||||
|
||||
## Progress
|
||||
|
||||
We use a script called Are We Synapse Yet which checks Sytest compliance rates. Sytest is a black-box homeserver
|
||||
test rig with around 900 tests. The script works out how many of these tests are passing on Dendrite and it
|
||||
updates with CI. As of August 2020 we're at around 52% CS API coverage and 65% Federation coverage, though check
|
||||
updates with CI. As of October 2020 we're at around 56% CS API coverage and 77% Federation coverage, though check
|
||||
CI for the latest numbers. In practice, this means you can communicate locally and via federation with Synapse
|
||||
servers such as matrix.org reasonably well. There's a long list of features that are not implemented, notably:
|
||||
- Receipts
|
||||
|
|
|
|||
|
|
@ -16,7 +16,9 @@ package httputil
|
|||
|
||||
import (
|
||||
"encoding/json"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"unicode/utf8"
|
||||
|
||||
"github.com/matrix-org/dendrite/clientapi/jsonerror"
|
||||
"github.com/matrix-org/util"
|
||||
|
|
@ -25,7 +27,23 @@ import (
|
|||
// UnmarshalJSONRequest into the given interface pointer. Returns an error JSON response if
|
||||
// there was a problem unmarshalling. Calling this function consumes the request body.
|
||||
func UnmarshalJSONRequest(req *http.Request, iface interface{}) *util.JSONResponse {
|
||||
if err := json.NewDecoder(req.Body).Decode(iface); err != nil {
|
||||
// encoding/json allows invalid utf-8, matrix does not
|
||||
// https://matrix.org/docs/spec/client_server/r0.6.1#api-standards
|
||||
body, err := ioutil.ReadAll(req.Body)
|
||||
if err != nil {
|
||||
util.GetLogger(req.Context()).WithError(err).Error("ioutil.ReadAll failed")
|
||||
resp := jsonerror.InternalServerError()
|
||||
return &resp
|
||||
}
|
||||
|
||||
if !utf8.Valid(body) {
|
||||
return &util.JSONResponse{
|
||||
Code: http.StatusBadRequest,
|
||||
JSON: jsonerror.NotJSON("Body contains invalid UTF-8"),
|
||||
}
|
||||
}
|
||||
|
||||
if err := json.Unmarshal(body, iface); err != nil {
|
||||
// TODO: We may want to suppress the Error() return in production? It's useful when
|
||||
// debugging because an error will be produced for both invalid/malformed JSON AND
|
||||
// valid JSON with incorrect types for values.
|
||||
|
|
|
|||
|
|
@ -20,8 +20,10 @@ import (
|
|||
"io/ioutil"
|
||||
"net/http"
|
||||
|
||||
"github.com/matrix-org/dendrite/clientapi/httputil"
|
||||
"github.com/matrix-org/dendrite/clientapi/jsonerror"
|
||||
"github.com/matrix-org/dendrite/clientapi/producers"
|
||||
roomserverAPI "github.com/matrix-org/dendrite/roomserver/api"
|
||||
"github.com/matrix-org/dendrite/userapi/api"
|
||||
|
||||
"github.com/matrix-org/util"
|
||||
|
|
@ -91,6 +93,13 @@ func SaveAccountData(
|
|||
}
|
||||
}
|
||||
|
||||
if dataType == "m.fully_read" {
|
||||
return util.JSONResponse{
|
||||
Code: http.StatusForbidden,
|
||||
JSON: jsonerror.Forbidden("Unable to set read marker"),
|
||||
}
|
||||
}
|
||||
|
||||
body, err := ioutil.ReadAll(req.Body)
|
||||
if err != nil {
|
||||
util.GetLogger(req.Context()).WithError(err).Error("ioutil.ReadAll failed")
|
||||
|
|
@ -112,7 +121,7 @@ func SaveAccountData(
|
|||
}
|
||||
dataRes := api.InputAccountDataResponse{}
|
||||
if err := userAPI.InputAccountData(req.Context(), &dataReq, &dataRes); err != nil {
|
||||
util.GetLogger(req.Context()).WithError(err).Error("userAPI.QueryAccountData failed")
|
||||
util.GetLogger(req.Context()).WithError(err).Error("userAPI.InputAccountData failed")
|
||||
return util.ErrorResponse(err)
|
||||
}
|
||||
|
||||
|
|
@ -127,3 +136,67 @@ func SaveAccountData(
|
|||
JSON: struct{}{},
|
||||
}
|
||||
}
|
||||
|
||||
type readMarkerJSON struct {
|
||||
FullyRead string `json:"m.fully_read"`
|
||||
Read string `json:"m.read"`
|
||||
}
|
||||
|
||||
type fullyReadEvent struct {
|
||||
EventID string `json:"event_id"`
|
||||
}
|
||||
|
||||
// SaveReadMarker implements POST /rooms/{roomId}/read_markers
|
||||
func SaveReadMarker(
|
||||
req *http.Request, userAPI api.UserInternalAPI, rsAPI roomserverAPI.RoomserverInternalAPI,
|
||||
syncProducer *producers.SyncAPIProducer, device *api.Device, roomID string,
|
||||
) util.JSONResponse {
|
||||
// Verify that the user is a member of this room
|
||||
resErr := checkMemberInRoom(req.Context(), rsAPI, device.UserID, roomID)
|
||||
if resErr != nil {
|
||||
return *resErr
|
||||
}
|
||||
|
||||
var r readMarkerJSON
|
||||
resErr = httputil.UnmarshalJSONRequest(req, &r)
|
||||
if resErr != nil {
|
||||
return *resErr
|
||||
}
|
||||
|
||||
if r.FullyRead == "" {
|
||||
return util.JSONResponse{
|
||||
Code: http.StatusBadRequest,
|
||||
JSON: jsonerror.BadJSON("Missing m.fully_read mandatory field"),
|
||||
}
|
||||
}
|
||||
|
||||
data, err := json.Marshal(fullyReadEvent{EventID: r.FullyRead})
|
||||
if err != nil {
|
||||
return jsonerror.InternalServerError()
|
||||
}
|
||||
|
||||
dataReq := api.InputAccountDataRequest{
|
||||
UserID: device.UserID,
|
||||
DataType: "m.fully_read",
|
||||
RoomID: roomID,
|
||||
AccountData: data,
|
||||
}
|
||||
dataRes := api.InputAccountDataResponse{}
|
||||
if err := userAPI.InputAccountData(req.Context(), &dataReq, &dataRes); err != nil {
|
||||
util.GetLogger(req.Context()).WithError(err).Error("userAPI.InputAccountData failed")
|
||||
return util.ErrorResponse(err)
|
||||
}
|
||||
|
||||
if err := syncProducer.SendData(device.UserID, roomID, "m.fully_read"); err != nil {
|
||||
util.GetLogger(req.Context()).WithError(err).Error("syncProducer.SendData failed")
|
||||
return jsonerror.InternalServerError()
|
||||
}
|
||||
|
||||
// TODO handle the read receipt that may be included in the read marker
|
||||
// See https://matrix.org/docs/spec/client_server/r0.6.0#post-matrix-client-r0-rooms-roomid-read-markers
|
||||
|
||||
return util.JSONResponse{
|
||||
Code: http.StatusOK,
|
||||
JSON: struct{}{},
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,11 +15,11 @@
|
|||
package routing
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
|
||||
"github.com/matrix-org/dendrite/clientapi/auth"
|
||||
"github.com/matrix-org/dendrite/clientapi/httputil"
|
||||
"github.com/matrix-org/dendrite/clientapi/jsonerror"
|
||||
"github.com/matrix-org/dendrite/userapi/api"
|
||||
userapi "github.com/matrix-org/dendrite/userapi/api"
|
||||
|
|
@ -121,9 +121,8 @@ func UpdateDeviceByID(
|
|||
|
||||
payload := deviceUpdateJSON{}
|
||||
|
||||
if err := json.NewDecoder(req.Body).Decode(&payload); err != nil {
|
||||
util.GetLogger(req.Context()).WithError(err).Error("json.NewDecoder.Decode failed")
|
||||
return jsonerror.InternalServerError()
|
||||
if resErr := httputil.UnmarshalJSONRequest(req, &payload); resErr != nil {
|
||||
return *resErr
|
||||
}
|
||||
|
||||
var performRes api.PerformDeviceUpdateResponse
|
||||
|
|
@ -211,9 +210,8 @@ func DeleteDevices(
|
|||
ctx := req.Context()
|
||||
payload := devicesDeleteJSON{}
|
||||
|
||||
if err := json.NewDecoder(req.Body).Decode(&payload); err != nil {
|
||||
util.GetLogger(ctx).WithError(err).Error("json.NewDecoder.Decode failed")
|
||||
return jsonerror.InternalServerError()
|
||||
if resErr := httputil.UnmarshalJSONRequest(req, &payload); resErr != nil {
|
||||
return *resErr
|
||||
}
|
||||
|
||||
defer req.Body.Close() // nolint: errcheck
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ import (
|
|||
appserviceAPI "github.com/matrix-org/dendrite/appservice/api"
|
||||
"github.com/matrix-org/dendrite/clientapi/api"
|
||||
"github.com/matrix-org/dendrite/clientapi/auth"
|
||||
clientutil "github.com/matrix-org/dendrite/clientapi/httputil"
|
||||
"github.com/matrix-org/dendrite/clientapi/jsonerror"
|
||||
"github.com/matrix-org/dendrite/clientapi/producers"
|
||||
eduServerAPI "github.com/matrix-org/dendrite/eduserver/api"
|
||||
|
|
@ -659,8 +660,9 @@ func Setup(
|
|||
SearchString string `json:"search_term"`
|
||||
Limit int `json:"limit"`
|
||||
}{}
|
||||
if err := json.NewDecoder(req.Body).Decode(&postContent); err != nil {
|
||||
return util.ErrorResponse(err)
|
||||
|
||||
if resErr := clientutil.UnmarshalJSONRequest(req, &postContent); resErr != nil {
|
||||
return *resErr
|
||||
}
|
||||
return *SearchUserDirectory(
|
||||
req.Context(),
|
||||
|
|
@ -695,12 +697,15 @@ func Setup(
|
|||
).Methods(http.MethodGet, http.MethodOptions)
|
||||
|
||||
r0mux.Handle("/rooms/{roomID}/read_markers",
|
||||
httputil.MakeExternalAPI("rooms_read_markers", func(req *http.Request) util.JSONResponse {
|
||||
httputil.MakeAuthAPI("rooms_read_markers", userAPI, func(req *http.Request, device *userapi.Device) util.JSONResponse {
|
||||
if r := rateLimits.rateLimit(req); r != nil {
|
||||
return *r
|
||||
}
|
||||
// TODO: return the read_markers.
|
||||
return util.JSONResponse{Code: http.StatusOK, JSON: struct{}{}}
|
||||
vars, err := httputil.URLDecodeMapValues(mux.Vars(req))
|
||||
if err != nil {
|
||||
return util.ErrorResponse(err)
|
||||
}
|
||||
return SaveReadMarker(req, userAPI, rsAPI, syncProducer, device, vars["roomID"])
|
||||
}),
|
||||
).Methods(http.MethodPost, http.MethodOptions)
|
||||
|
||||
|
|
|
|||
|
|
@ -120,7 +120,10 @@ Assuming that Postgres 9.5 (or later) is installed:
|
|||
|
||||
Each Dendrite server requires unique server keys.
|
||||
|
||||
Generate the self-signed SSL certificate for federation and the server signing key:
|
||||
In order for an instance to federate correctly, you should have a valid
|
||||
certificate issued by a trusted authority, and private key to match. If you
|
||||
don't and just want to test locally, generate the self-signed SSL certificate
|
||||
for federation and the server signing key:
|
||||
|
||||
```bash
|
||||
./bin/generate-keys --private-key matrix_key.pem --tls-cert server.crt --tls-key server.key
|
||||
|
|
@ -267,12 +270,12 @@ This manages end-to-end encryption keys for users.
|
|||
./bin/dendrite-key-server --config dendrite.yaml
|
||||
```
|
||||
|
||||
#### Server Key server
|
||||
#### Signing key server
|
||||
|
||||
This manages signing keys for servers.
|
||||
|
||||
```bash
|
||||
./bin/dendrite-server-key-api-server --config dendrite.yaml
|
||||
./bin/dendrite-signing-key-server --config dendrite.yaml
|
||||
```
|
||||
|
||||
#### EDU server
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ var build string
|
|||
|
||||
const (
|
||||
VersionMajor = 0
|
||||
VersionMinor = 0
|
||||
VersionMinor = 1
|
||||
VersionPatch = 0
|
||||
VersionTag = "" // example: "rc1"
|
||||
)
|
||||
|
|
|
|||
|
|
@ -296,7 +296,7 @@ func (u *latestEventsUpdater) calculateLatest(
|
|||
referenced, err := u.updater.IsReferenced(newEvent.EventReference)
|
||||
if err != nil {
|
||||
logrus.WithError(err).Errorf("Failed to retrieve event reference for %q", newEvent.EventReference.EventID)
|
||||
} else if !referenced {
|
||||
} else if !referenced || len(newLatest) == 0 {
|
||||
newLatest = append(newLatest, newEvent)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -456,6 +456,9 @@ After changing password, can log in with new password
|
|||
After changing password, existing session still works
|
||||
After changing password, different sessions can optionally be kept
|
||||
After changing password, a different session no longer works by default
|
||||
Read markers appear in incremental v2 /sync
|
||||
Read markers appear in initial v2 /sync
|
||||
Read markers can be updated
|
||||
Local users can peek into world_readable rooms by room ID
|
||||
We can't peek into rooms with shared history_visibility
|
||||
We can't peek into rooms with invited history_visibility
|
||||
|
|
@ -474,5 +477,6 @@ Inbound federation rejects invite rejections which include invalid JSON for room
|
|||
GET /capabilities is present and well formed for registered user
|
||||
m.room.history_visibility == "joined" allows/forbids appropriately for Guest users
|
||||
m.room.history_visibility == "joined" allows/forbids appropriately for Real users
|
||||
POST rejects invalid utf-8 in JSON
|
||||
Users cannot kick users who have already left a room
|
||||
A prev_batch token from incremental sync can be used in the v1 messages API
|
||||
|
|
|
|||
Loading…
Reference in a new issue