mirror of
https://github.com/matrix-org/dendrite.git
synced 2025-12-15 10:53:09 -06:00
Merge branch 'master' of https://github.com/matrix-org/dendrite
This commit is contained in:
commit
0bc3510532
|
|
@ -2,7 +2,7 @@ version: 2
|
||||||
jobs:
|
jobs:
|
||||||
dendrite:
|
dendrite:
|
||||||
docker:
|
docker:
|
||||||
- image: anoa/sytest-dendrite
|
- image: matrixdotorg/sytest-dendrite
|
||||||
working_directory: /src
|
working_directory: /src
|
||||||
steps:
|
steps:
|
||||||
- checkout
|
- checkout
|
||||||
|
|
@ -10,7 +10,7 @@ jobs:
|
||||||
# Set up dendrite
|
# Set up dendrite
|
||||||
- run:
|
- run:
|
||||||
name: Build Dendrite
|
name: Build Dendrite
|
||||||
command: go get github.com/constabulary/gb/... && gb build
|
command: ./build.sh
|
||||||
- run:
|
- run:
|
||||||
name: Copy custom dendrite config
|
name: Copy custom dendrite config
|
||||||
command: cp .circleci/dendrite-config.yaml dendrite.yaml
|
command: cp .circleci/dendrite-config.yaml dendrite.yaml
|
||||||
|
|
|
||||||
4
.gitignore
vendored
4
.gitignore
vendored
|
|
@ -18,6 +18,7 @@
|
||||||
/_obj
|
/_obj
|
||||||
/_test
|
/_test
|
||||||
/vendor/bin
|
/vendor/bin
|
||||||
|
/docker/build
|
||||||
|
|
||||||
# Architecture specific extensions/prefixes
|
# Architecture specific extensions/prefixes
|
||||||
*.[568vq]
|
*.[568vq]
|
||||||
|
|
@ -39,3 +40,6 @@ _testmain.go
|
||||||
*.pem
|
*.pem
|
||||||
*.key
|
*.key
|
||||||
*.crt
|
*.crt
|
||||||
|
|
||||||
|
# Default configuration file
|
||||||
|
dendrite.yaml
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,7 @@
|
||||||
language: go
|
language: go
|
||||||
go:
|
go:
|
||||||
- 1.8.x
|
|
||||||
- 1.9.x
|
|
||||||
- 1.10.x
|
|
||||||
- 1.11.x
|
- 1.11.x
|
||||||
|
- 1.12.x
|
||||||
|
|
||||||
env:
|
env:
|
||||||
- TEST_SUITE="lint"
|
- TEST_SUITE="lint"
|
||||||
|
|
@ -25,9 +23,6 @@ cache:
|
||||||
directories:
|
directories:
|
||||||
- .downloads
|
- .downloads
|
||||||
|
|
||||||
install:
|
|
||||||
- go get github.com/constabulary/gb/...
|
|
||||||
|
|
||||||
script:
|
script:
|
||||||
- ./scripts/travis-test.sh
|
- ./scripts/travis-test.sh
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -12,11 +12,13 @@ See [INSTALL.md](INSTALL.md) for instructions on setting up a running dev
|
||||||
instance of dendrite, and [CODE_STYLE.md](CODE_STYLE.md) for the code style
|
instance of dendrite, and [CODE_STYLE.md](CODE_STYLE.md) for the code style
|
||||||
guide.
|
guide.
|
||||||
|
|
||||||
We use `gb` for managing our dependencies, so `gb build` and `gb test` is how
|
As of May 2019, we're not using `gb` anymore, which is the tool we had been
|
||||||
to build dendrite and run the unit tests respectively. Be aware that a list of
|
using for managing our dependencies. We're now using Go modules. To build
|
||||||
all dendrite packages is the expected output for all tests succeeding with `gb
|
Dendrite, run the `build.sh` script at the root of this repository (which runs
|
||||||
test`. There are also [scripts](scripts) for [linting](scripts/find-lint.sh)
|
`go install` under the hood), and to run unit tests, run `go test ./...` (which
|
||||||
and doing a [build/test/lint run](scripts/build-test-lint.sh).
|
should pick up any unit test and run it). There are also [scripts](scripts) for
|
||||||
|
[linting](scripts/find-lint.sh) and doing a [build/test/lint
|
||||||
|
run](scripts/build-test-lint.sh).
|
||||||
|
|
||||||
|
|
||||||
## Picking Things To Do
|
## Picking Things To Do
|
||||||
|
|
@ -33,28 +35,15 @@ nonetheless fairly well-contained.
|
||||||
We ask people who are familiar with Dendrite to leave the [good first issue](https://github.com/matrix-org/dendrite/labels/good%20first%20issue)
|
We ask people who are familiar with Dendrite to leave the [good first issue](https://github.com/matrix-org/dendrite/labels/good%20first%20issue)
|
||||||
issues so that there is always a way for new people to come and get involved.
|
issues so that there is always a way for new people to come and get involved.
|
||||||
|
|
||||||
## Contributing to dependencies
|
|
||||||
|
|
||||||
Dependencies are located in `vendor/src` and are managed by `gb`. If you need
|
|
||||||
to make some changes in those directories, you first need to open a PR in the
|
|
||||||
dependency repository. Once your PR is merged, you need to run `gb vendor
|
|
||||||
update $repo_url` (example: `gb vendor update github.com/matrix-org/gomatrix`)
|
|
||||||
in the dendrite repository to update the dependency.
|
|
||||||
|
|
||||||
You can then create a commit containing only the modified vendor files (along
|
|
||||||
with the `vendor/manifest` file), name it with the command you just ran (ie
|
|
||||||
`gb vendor update github.com/matrix-org/gomatrix`), and open a PR on Dendrite.
|
|
||||||
|
|
||||||
## Getting Help
|
## Getting Help
|
||||||
|
|
||||||
For questions related to developing on Dendrite we have a dedicated room on
|
For questions related to developing on Dendrite we have a dedicated room on
|
||||||
Matrix [#dendrite-dev:matrix.org](https://riot.im/develop/#/room/#dendrite-dev:matrix.org)
|
Matrix [#dendrite-dev:matrix.org](https://matrix.to/#/#dendrite-dev:matrix.org)
|
||||||
where we're happy to help.
|
where we're happy to help.
|
||||||
|
|
||||||
For more general questions please use [#dendrite:matrix.org](https://riot.im/develop/#/room/#dendrite:matrix.org).
|
For more general questions please use [#dendrite:matrix.org](https://matrix.to/#/#dendrite:matrix.org).
|
||||||
|
|
||||||
## Sign off
|
## Sign off
|
||||||
|
|
||||||
We ask that everyone who contributes to the project signs off their
|
We ask that everyone who contributes to the project signs off their
|
||||||
contributions, in accordance with the [DCO](https://github.com/matrix-org/matrix-doc/blob/master/CONTRIBUTING.rst#sign-off).
|
contributions, in accordance with the [DCO](https://github.com/matrix-org/matrix-doc/blob/master/CONTRIBUTING.rst#sign-off).
|
||||||
|
|
||||||
|
|
|
||||||
13
INSTALL.md
13
INSTALL.md
|
|
@ -12,7 +12,7 @@ Dendrite can be run in one of two configurations:
|
||||||
|
|
||||||
## Requirements
|
## Requirements
|
||||||
|
|
||||||
- Go 1.8+
|
- Go 1.11+
|
||||||
- Postgres 9.5+
|
- Postgres 9.5+
|
||||||
- For Kafka (optional if using the monolith server):
|
- For Kafka (optional if using the monolith server):
|
||||||
- Unix-based system (https://kafka.apache.org/documentation/#os)
|
- Unix-based system (https://kafka.apache.org/documentation/#os)
|
||||||
|
|
@ -22,7 +22,7 @@ Dendrite can be run in one of two configurations:
|
||||||
|
|
||||||
## Setting up a development environment
|
## Setting up a development environment
|
||||||
|
|
||||||
Assumes Go 1.8 and JDK 1.8 are already installed and are on PATH.
|
Assumes Go 1.10+ and JDK 1.8+ are already installed and are on PATH.
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# Get the code
|
# Get the code
|
||||||
|
|
@ -30,8 +30,7 @@ git clone https://github.com/matrix-org/dendrite
|
||||||
cd dendrite
|
cd dendrite
|
||||||
|
|
||||||
# Build it
|
# Build it
|
||||||
go get github.com/constabulary/gb/...
|
./build.sh
|
||||||
gb build
|
|
||||||
```
|
```
|
||||||
|
|
||||||
If using Kafka, install and start it (c.f. [scripts/install-local-kafka.sh](scripts/install-local-kafka.sh)):
|
If using Kafka, install and start it (c.f. [scripts/install-local-kafka.sh](scripts/install-local-kafka.sh)):
|
||||||
|
|
@ -95,13 +94,15 @@ test -f matrix_key.pem || ./bin/generate-keys -private-key matrix_key.pem
|
||||||
|
|
||||||
Create config file, based on `dendrite-config.yaml`. Call it `dendrite.yaml`. Things that will need editing include *at least*:
|
Create config file, based on `dendrite-config.yaml`. Call it `dendrite.yaml`. Things that will need editing include *at least*:
|
||||||
* `server_name`
|
* `server_name`
|
||||||
* `database/*`
|
* `database/*` (All lines in the database section must have the username and password of the user created with the `createuser` command above. eg:`dendrite:password@localhost`)
|
||||||
|
|
||||||
|
|
||||||
## Starting a monolith server
|
## Starting a monolith server
|
||||||
|
|
||||||
It is possible to use 'naffka' as an in-process replacement to Kafka when using
|
It is possible to use 'naffka' as an in-process replacement to Kafka when using
|
||||||
the monolith server. To do this, set `use_naffka: true` in `dendrite.yaml`.
|
the monolith server. To do this, set `use_naffka: true` in `dendrite.yaml` and uncomment
|
||||||
|
the necessary line related to naffka in the `database` section. Be sure to update the
|
||||||
|
database username and password if needed.
|
||||||
|
|
||||||
The monolith server can be started as shown below. By default it listens for
|
The monolith server can be started as shown below. By default it listens for
|
||||||
HTTP connections on port 8008, so point your client at
|
HTTP connections on port 8008, so point your client at
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
# Dendrite [](https://travis-ci.org/matrix-org/dendrite)
|
# Dendrite [](https://travis-ci.org/matrix-org/dendrite) [](https://matrix.to/#/#dendrite-dev:matrix.org) [](https://matrix.to/#/#dendrite:matrix.org)
|
||||||
|
|
||||||
Dendrite will be a matrix homeserver written in go.
|
Dendrite will be a matrix homeserver written in go.
|
||||||
|
|
||||||
|
|
@ -17,9 +17,11 @@ We aim to try and make it as easy as possible to jump in.
|
||||||
# Discussion
|
# Discussion
|
||||||
|
|
||||||
For questions about Dendrite we have a dedicated room on Matrix
|
For questions about Dendrite we have a dedicated room on Matrix
|
||||||
[#dendrite:matrix.org](https://riot.im/develop/#/room/#dendrite:matrix.org).
|
[#dendrite:matrix.org](https://matrix.to/#/#dendrite:matrix.org).
|
||||||
|
Development discussion should happen in
|
||||||
|
[#dendrite-dev:matrix.org](https://matrix.to/#/#dendrite-dev:matrix.org).
|
||||||
|
|
||||||
# Progress
|
# Progress
|
||||||
|
|
||||||
There's plenty still to do to make Dendrite usable! We're tracking progress in
|
There's plenty still to do to make Dendrite usable! We're tracking progress in
|
||||||
a [spreadsheet](https://docs.google.com/spreadsheets/d/1tkMNpIpPjvuDJWjPFbw_xzNzOHBA-Hp50Rkpcr43xTw).
|
a [project board](https://github.com/matrix-org/dendrite/projects/2).
|
||||||
|
|
|
||||||
3
build.sh
Executable file
3
build.sh
Executable file
|
|
@ -0,0 +1,3 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
GOBIN=$PWD/`dirname $0`/bin go install -v ./cmd/...
|
||||||
|
|
@ -65,12 +65,6 @@ type Data struct {
|
||||||
func VerifyUserFromRequest(
|
func VerifyUserFromRequest(
|
||||||
req *http.Request, data Data,
|
req *http.Request, data Data,
|
||||||
) (*authtypes.Device, *util.JSONResponse) {
|
) (*authtypes.Device, *util.JSONResponse) {
|
||||||
// Try to find local user from device database
|
|
||||||
dev, devErr := verifyAccessToken(req, data.DeviceDB)
|
|
||||||
if devErr == nil {
|
|
||||||
return dev, verifyUserParameters(req)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Try to find the Application Service user
|
// Try to find the Application Service user
|
||||||
token, err := ExtractAccessToken(req)
|
token, err := ExtractAccessToken(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
@ -128,6 +122,12 @@ func VerifyUserFromRequest(
|
||||||
return &dev, nil
|
return &dev, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Try to find local user from device database
|
||||||
|
dev, devErr := verifyAccessToken(req, data.DeviceDB)
|
||||||
|
if devErr == nil {
|
||||||
|
return dev, verifyUserParameters(req)
|
||||||
|
}
|
||||||
|
|
||||||
return nil, &util.JSONResponse{
|
return nil, &util.JSONResponse{
|
||||||
Code: http.StatusUnauthorized,
|
Code: http.StatusUnauthorized,
|
||||||
JSON: jsonerror.UnknownToken("Unrecognized access token"),
|
JSON: jsonerror.UnknownToken("Unrecognized access token"),
|
||||||
|
|
@ -118,30 +118,32 @@ func (r joinRoomReq) joinRoomByID(roomID string) util.JSONResponse {
|
||||||
if err := r.queryAPI.QueryInvitesForUser(r.req.Context(), &queryReq, &queryRes); err != nil {
|
if err := r.queryAPI.QueryInvitesForUser(r.req.Context(), &queryReq, &queryRes); err != nil {
|
||||||
return httputil.LogThenError(r.req, err)
|
return httputil.LogThenError(r.req, err)
|
||||||
}
|
}
|
||||||
if len(queryRes.InviteSenderUserIDs) == 0 {
|
|
||||||
// TODO: We might need to support clients which erroneously try to join
|
|
||||||
// the room by ID even when they are not invited.
|
|
||||||
// This can be done by removing this check and falling through to
|
|
||||||
// joinRoomUsingServers passing an empty list since joinRoomUserServers
|
|
||||||
// will check if we are already in the room first.
|
|
||||||
return util.JSONResponse{
|
|
||||||
Code: http.StatusForbidden,
|
|
||||||
JSON: jsonerror.Forbidden("You are not invited to the room"),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
servers := []gomatrixserverlib.ServerName{}
|
servers := []gomatrixserverlib.ServerName{}
|
||||||
seenBefore := map[gomatrixserverlib.ServerName]bool{}
|
seenInInviterIDs := map[gomatrixserverlib.ServerName]bool{}
|
||||||
for _, userID := range queryRes.InviteSenderUserIDs {
|
for _, userID := range queryRes.InviteSenderUserIDs {
|
||||||
_, domain, err := gomatrixserverlib.SplitID('@', userID)
|
_, domain, err := gomatrixserverlib.SplitID('@', userID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return httputil.LogThenError(r.req, err)
|
return httputil.LogThenError(r.req, err)
|
||||||
}
|
}
|
||||||
if !seenBefore[domain] {
|
if !seenInInviterIDs[domain] {
|
||||||
servers = append(servers, domain)
|
servers = append(servers, domain)
|
||||||
seenBefore[domain] = true
|
seenInInviterIDs[domain] = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Also add the domain extracted from the roomID as a last resort to join
|
||||||
|
// in case the client is erroneously trying to join by ID without an invite
|
||||||
|
// or all previous attempts at domains extracted from the inviter IDs fail
|
||||||
|
// Note: It's no guarantee we'll succeed because a room isn't bound to the domain in its ID
|
||||||
|
_, domain, err := gomatrixserverlib.SplitID('!', roomID)
|
||||||
|
if err != nil {
|
||||||
|
return httputil.LogThenError(r.req, err)
|
||||||
|
}
|
||||||
|
if domain != r.cfg.Matrix.ServerName && !seenInInviterIDs[domain] {
|
||||||
|
servers = append(servers, domain)
|
||||||
|
}
|
||||||
|
|
||||||
return r.joinRoomUsingServers(roomID, servers)
|
return r.joinRoomUsingServers(roomID, servers)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -77,7 +77,11 @@ func Setup(
|
||||||
v1mux := apiMux.PathPrefix(pathPrefixV1).Subrouter()
|
v1mux := apiMux.PathPrefix(pathPrefixV1).Subrouter()
|
||||||
unstableMux := apiMux.PathPrefix(pathPrefixUnstable).Subrouter()
|
unstableMux := apiMux.PathPrefix(pathPrefixUnstable).Subrouter()
|
||||||
|
|
||||||
authData := auth.Data{accountDB, deviceDB, cfg.Derived.ApplicationServices}
|
authData := auth.Data{
|
||||||
|
AccountDB: accountDB,
|
||||||
|
DeviceDB: deviceDB,
|
||||||
|
AppServices: cfg.Derived.ApplicationServices,
|
||||||
|
}
|
||||||
|
|
||||||
r0mux.Handle("/createRoom",
|
r0mux.Handle("/createRoom",
|
||||||
common.MakeAuthAPI("createRoom", authData, func(req *http.Request, device *authtypes.Device) util.JSONResponse {
|
common.MakeAuthAPI("createRoom", authData, func(req *http.Request, device *authtypes.Device) util.JSONResponse {
|
||||||
|
|
@ -139,6 +139,6 @@ func writeEvent(event gomatrixserverlib.Event) {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
panic(fmt.Errorf("Format %q is not valid, must be %q or %q", format, "InputRoomEvent", "Event"))
|
panic(fmt.Errorf("Format %q is not valid, must be %q or %q", *format, "InputRoomEvent", "Event"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -41,7 +41,7 @@ var (
|
||||||
// Postgres docker container name (for running psql). If not set, psql must be in PATH.
|
// Postgres docker container name (for running psql). If not set, psql must be in PATH.
|
||||||
postgresContainerName = os.Getenv("POSTGRES_CONTAINER")
|
postgresContainerName = os.Getenv("POSTGRES_CONTAINER")
|
||||||
// Test image to be uploaded/downloaded
|
// Test image to be uploaded/downloaded
|
||||||
testJPEG = test.Defaulting(os.Getenv("TEST_JPEG_PATH"), "src/github.com/matrix-org/dendrite/cmd/mediaapi-integration-tests/totem.jpg")
|
testJPEG = test.Defaulting(os.Getenv("TEST_JPEG_PATH"), "cmd/mediaapi-integration-tests/totem.jpg")
|
||||||
kafkaURI = test.Defaulting(os.Getenv("KAFKA_URIS"), "localhost:9092")
|
kafkaURI = test.Defaulting(os.Getenv("KAFKA_URIS"), "localhost:9092")
|
||||||
)
|
)
|
||||||
|
|
||||||
|
Before Width: | Height: | Size: 1.8 MiB After Width: | Height: | Size: 1.8 MiB |
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue