mirror of
https://github.com/hoernschen/dendrite.git
synced 2024-12-25 14:38:28 +00:00
Add configuration option for sliding sync when hosting /.well-known/matrix/client (#3189)
Adds the `org.matrix.msc3575.proxy` field (used for configuring sliding sync) to /.well-known/matrix/client when Dendrite is serving that endpoint and `well_known_sliding_sync_proxy` has been configured. ie. Config values of: ``` yaml global: well_known_client_name: https://example.com well_known_sliding_sync_proxy: https://syncv3.example.com ``` results in a /.well-known/matrix/client of: ``` json { "m.homeserver": { "base_url": "https://example.com" }, "org.matrix.msc3575.proxy": { "url": "https://syncv3.example.com" } } ``` If `well_known_sliding_sync_proxy` is not provided, the json provided by /.well-known/matrix/client does not include the proxy field. ie. ``` json { "m.homeserver": { "base_url": "https://example.com" } } ```
This commit is contained in:
parent
9b5be6b9c5
commit
1c4ec67bb6
2 changed files with 30 additions and 11 deletions
|
@ -44,6 +44,19 @@ import (
|
|||
"github.com/matrix-org/dendrite/setup/jetstream"
|
||||
)
|
||||
|
||||
type WellKnownClientHomeserver struct {
|
||||
BaseUrl string `json:"base_url"`
|
||||
}
|
||||
|
||||
type WellKnownSlidingSyncProxy struct {
|
||||
Url string `json:"url"`
|
||||
}
|
||||
|
||||
type WellKnownClientResponse struct {
|
||||
Homeserver WellKnownClientHomeserver `json:"m.homeserver"`
|
||||
SlidingSyncProxy *WellKnownSlidingSyncProxy `json:"org.matrix.msc3575.proxy,omitempty"`
|
||||
}
|
||||
|
||||
// Setup registers HTTP handlers with the given ServeMux. It also supplies the given http.Client
|
||||
// to clients which need to make outbound HTTP requests.
|
||||
//
|
||||
|
@ -96,20 +109,22 @@ func Setup(
|
|||
|
||||
if cfg.Matrix.WellKnownClientName != "" {
|
||||
logrus.Infof("Setting m.homeserver base_url as %s at /.well-known/matrix/client", cfg.Matrix.WellKnownClientName)
|
||||
if cfg.Matrix.WellKnownSlidingSyncProxy != "" {
|
||||
logrus.Infof("Setting org.matrix.msc3575.proxy url as %s at /.well-known/matrix/client", cfg.Matrix.WellKnownSlidingSyncProxy)
|
||||
}
|
||||
wkMux.Handle("/client", httputil.MakeExternalAPI("wellknown", func(r *http.Request) util.JSONResponse {
|
||||
response := WellKnownClientResponse{
|
||||
Homeserver: WellKnownClientHomeserver{cfg.Matrix.WellKnownClientName},
|
||||
}
|
||||
if cfg.Matrix.WellKnownSlidingSyncProxy != "" {
|
||||
response.SlidingSyncProxy = &WellKnownSlidingSyncProxy{
|
||||
Url: cfg.Matrix.WellKnownSlidingSyncProxy,
|
||||
}
|
||||
}
|
||||
|
||||
return util.JSONResponse{
|
||||
Code: http.StatusOK,
|
||||
JSON: struct {
|
||||
HomeserverName struct {
|
||||
BaseUrl string `json:"base_url"`
|
||||
} `json:"m.homeserver"`
|
||||
}{
|
||||
HomeserverName: struct {
|
||||
BaseUrl string `json:"base_url"`
|
||||
}{
|
||||
BaseUrl: cfg.Matrix.WellKnownClientName,
|
||||
},
|
||||
},
|
||||
JSON: response,
|
||||
}
|
||||
})).Methods(http.MethodGet, http.MethodOptions)
|
||||
}
|
||||
|
|
|
@ -48,6 +48,10 @@ type Global struct {
|
|||
// The server name to delegate client-server communications to, with optional port
|
||||
WellKnownClientName string `yaml:"well_known_client_name"`
|
||||
|
||||
// The server name to delegate sliding sync communications to, with optional port.
|
||||
// Requires `well_known_client_name` to also be configured.
|
||||
WellKnownSlidingSyncProxy string `yaml:"well_known_sliding_sync_proxy"`
|
||||
|
||||
// Disables federation. Dendrite will not be able to make any outbound HTTP requests
|
||||
// to other servers and the federation API will not be exposed.
|
||||
DisableFederation bool `yaml:"disable_federation"`
|
||||
|
|
Loading…
Reference in a new issue