2017-05-19 17:06:41 +02:00
|
|
|
// Copyright 2017 Vector Creations Ltd
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
// you may not use this file except in compliance with the License.
|
|
|
|
// You may obtain a copy of the License at
|
|
|
|
//
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
//
|
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
// limitations under the License.
|
|
|
|
|
|
|
|
package routing
|
|
|
|
|
|
|
|
import (
|
2017-08-03 16:10:39 +02:00
|
|
|
"net/http"
|
|
|
|
|
2017-05-19 17:06:41 +02:00
|
|
|
"github.com/gorilla/mux"
|
2018-08-20 11:45:17 +02:00
|
|
|
appserviceAPI "github.com/matrix-org/dendrite/appservice/api"
|
2017-09-13 14:31:46 +02:00
|
|
|
"github.com/matrix-org/dendrite/clientapi/auth/storage/accounts"
|
2018-06-26 12:32:43 +02:00
|
|
|
"github.com/matrix-org/dendrite/clientapi/auth/storage/devices"
|
2017-06-07 15:32:53 +02:00
|
|
|
"github.com/matrix-org/dendrite/clientapi/producers"
|
2017-09-04 14:14:01 +02:00
|
|
|
"github.com/matrix-org/dendrite/common"
|
2017-06-19 16:21:04 +02:00
|
|
|
"github.com/matrix-org/dendrite/common/config"
|
2019-12-20 14:24:57 +01:00
|
|
|
federationSenderAPI "github.com/matrix-org/dendrite/federationsender/api"
|
2018-08-08 17:17:09 +02:00
|
|
|
roomserverAPI "github.com/matrix-org/dendrite/roomserver/api"
|
2017-06-07 15:32:53 +02:00
|
|
|
"github.com/matrix-org/gomatrixserverlib"
|
2017-05-19 17:06:41 +02:00
|
|
|
"github.com/matrix-org/util"
|
|
|
|
)
|
|
|
|
|
|
|
|
const (
|
2017-06-07 15:32:53 +02:00
|
|
|
pathPrefixV2Keys = "/_matrix/key/v2"
|
|
|
|
pathPrefixV1Federation = "/_matrix/federation/v1"
|
2019-12-20 15:41:32 +01:00
|
|
|
pathPrefixV2Federation = "/_matrix/federation/v2"
|
2017-05-19 17:06:41 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
// Setup registers HTTP handlers with the given ServeMux.
|
2019-07-03 17:38:50 +02:00
|
|
|
//
|
|
|
|
// Due to Setup being used to call many other functions, a gocyclo nolint is
|
|
|
|
// applied:
|
|
|
|
// nolint: gocyclo
|
2017-06-07 15:32:53 +02:00
|
|
|
func Setup(
|
2017-08-03 16:10:39 +02:00
|
|
|
apiMux *mux.Router,
|
2020-02-11 12:18:12 +01:00
|
|
|
cfg *config.Dendrite,
|
2020-05-01 11:48:17 +02:00
|
|
|
rsAPI roomserverAPI.RoomserverInternalAPI,
|
2018-08-20 11:45:17 +02:00
|
|
|
asAPI appserviceAPI.AppServiceQueryAPI,
|
2017-06-07 15:32:53 +02:00
|
|
|
producer *producers.RoomserverProducer,
|
2020-03-30 17:40:28 +02:00
|
|
|
eduProducer *producers.EDUServerProducer,
|
2020-04-29 12:34:31 +02:00
|
|
|
federationSenderAPI federationSenderAPI.FederationSenderInternalAPI,
|
2017-06-07 15:32:53 +02:00
|
|
|
keys gomatrixserverlib.KeyRing,
|
|
|
|
federation *gomatrixserverlib.FederationClient,
|
2020-02-13 18:27:33 +01:00
|
|
|
accountDB accounts.Database,
|
|
|
|
deviceDB devices.Database,
|
2017-06-07 15:32:53 +02:00
|
|
|
) {
|
2017-05-19 17:06:41 +02:00
|
|
|
v2keysmux := apiMux.PathPrefix(pathPrefixV2Keys).Subrouter()
|
2017-06-07 15:32:53 +02:00
|
|
|
v1fedmux := apiMux.PathPrefix(pathPrefixV1Federation).Subrouter()
|
2019-12-20 15:41:32 +01:00
|
|
|
v2fedmux := apiMux.PathPrefix(pathPrefixV2Federation).Subrouter()
|
2017-05-19 17:06:41 +02:00
|
|
|
|
2017-09-28 15:50:40 +02:00
|
|
|
localKeys := common.MakeExternalAPI("localkeys", func(req *http.Request) util.JSONResponse {
|
2017-10-25 12:27:44 +02:00
|
|
|
return LocalKeys(cfg)
|
2017-05-25 17:08:28 +02:00
|
|
|
})
|
|
|
|
|
|
|
|
// Ignore the {keyID} argument as we only have a single server key so we always
|
|
|
|
// return that key.
|
|
|
|
// Even if we had more than one server key, we would probably still ignore the
|
|
|
|
// {keyID} argument and always return a response containing all of the keys.
|
2018-03-13 16:55:45 +01:00
|
|
|
v2keysmux.Handle("/server/{keyID}", localKeys).Methods(http.MethodGet)
|
|
|
|
v2keysmux.Handle("/server/", localKeys).Methods(http.MethodGet)
|
2019-08-19 19:01:53 +02:00
|
|
|
v2keysmux.Handle("/server", localKeys).Methods(http.MethodGet)
|
2017-05-19 17:06:41 +02:00
|
|
|
|
2019-07-18 09:41:29 +02:00
|
|
|
v1fedmux.Handle("/send/{txnID}", common.MakeFedAPI(
|
2017-09-04 14:14:01 +02:00
|
|
|
"federation_send", cfg.Matrix.ServerName, keys,
|
|
|
|
func(httpReq *http.Request, request *gomatrixserverlib.FederationRequest) util.JSONResponse {
|
2019-07-03 17:38:50 +02:00
|
|
|
vars, err := common.URLDecodeMapValues(mux.Vars(httpReq))
|
|
|
|
if err != nil {
|
|
|
|
return util.ErrorResponse(err)
|
|
|
|
}
|
2017-10-11 19:16:53 +02:00
|
|
|
return Send(
|
2017-09-04 14:14:01 +02:00
|
|
|
httpReq, request, gomatrixserverlib.TransactionID(vars["txnID"]),
|
2020-05-01 11:48:17 +02:00
|
|
|
cfg, rsAPI, producer, eduProducer, keys, federation,
|
2017-06-07 15:32:53 +02:00
|
|
|
)
|
|
|
|
},
|
2018-03-13 16:55:45 +01:00
|
|
|
)).Methods(http.MethodPut, http.MethodOptions)
|
2017-08-23 16:13:47 +02:00
|
|
|
|
2020-04-03 15:29:06 +02:00
|
|
|
v2fedmux.Handle("/invite/{roomID}/{eventID}", common.MakeFedAPI(
|
2017-09-04 14:14:01 +02:00
|
|
|
"federation_invite", cfg.Matrix.ServerName, keys,
|
|
|
|
func(httpReq *http.Request, request *gomatrixserverlib.FederationRequest) util.JSONResponse {
|
2019-07-03 17:38:50 +02:00
|
|
|
vars, err := common.URLDecodeMapValues(mux.Vars(httpReq))
|
|
|
|
if err != nil {
|
|
|
|
return util.ErrorResponse(err)
|
|
|
|
}
|
2017-10-11 19:16:53 +02:00
|
|
|
return Invite(
|
2017-09-04 14:14:01 +02:00
|
|
|
httpReq, request, vars["roomID"], vars["eventID"],
|
2017-08-23 16:13:47 +02:00
|
|
|
cfg, producer, keys,
|
|
|
|
)
|
|
|
|
},
|
2018-03-13 16:55:45 +01:00
|
|
|
)).Methods(http.MethodPut, http.MethodOptions)
|
2017-09-06 13:38:22 +02:00
|
|
|
|
2017-09-28 15:50:40 +02:00
|
|
|
v1fedmux.Handle("/3pid/onbind", common.MakeExternalAPI("3pid_onbind",
|
2017-09-11 20:08:24 +02:00
|
|
|
func(req *http.Request) util.JSONResponse {
|
2020-05-01 11:48:17 +02:00
|
|
|
return CreateInvitesFrom3PIDInvites(req, rsAPI, asAPI, cfg, producer, federation, accountDB)
|
2017-09-08 16:17:12 +02:00
|
|
|
},
|
2018-03-13 16:55:45 +01:00
|
|
|
)).Methods(http.MethodPost, http.MethodOptions)
|
2017-09-08 16:17:12 +02:00
|
|
|
|
2017-09-12 18:15:13 +02:00
|
|
|
v1fedmux.Handle("/exchange_third_party_invite/{roomID}", common.MakeFedAPI(
|
|
|
|
"exchange_third_party_invite", cfg.Matrix.ServerName, keys,
|
|
|
|
func(httpReq *http.Request, request *gomatrixserverlib.FederationRequest) util.JSONResponse {
|
2019-07-03 17:38:50 +02:00
|
|
|
vars, err := common.URLDecodeMapValues(mux.Vars(httpReq))
|
|
|
|
if err != nil {
|
|
|
|
return util.ErrorResponse(err)
|
|
|
|
}
|
2017-10-11 19:16:53 +02:00
|
|
|
return ExchangeThirdPartyInvite(
|
2020-05-01 11:48:17 +02:00
|
|
|
httpReq, request, vars["roomID"], rsAPI, cfg, federation, producer,
|
2017-09-12 18:15:13 +02:00
|
|
|
)
|
|
|
|
},
|
2018-03-13 16:55:45 +01:00
|
|
|
)).Methods(http.MethodPut, http.MethodOptions)
|
2017-09-12 18:15:13 +02:00
|
|
|
|
2017-09-06 13:38:22 +02:00
|
|
|
v1fedmux.Handle("/event/{eventID}", common.MakeFedAPI(
|
|
|
|
"federation_get_event", cfg.Matrix.ServerName, keys,
|
|
|
|
func(httpReq *http.Request, request *gomatrixserverlib.FederationRequest) util.JSONResponse {
|
2019-07-03 17:38:50 +02:00
|
|
|
vars, err := common.URLDecodeMapValues(mux.Vars(httpReq))
|
|
|
|
if err != nil {
|
|
|
|
return util.ErrorResponse(err)
|
|
|
|
}
|
2017-10-25 12:27:44 +02:00
|
|
|
return GetEvent(
|
2020-05-01 11:48:17 +02:00
|
|
|
httpReq.Context(), request, rsAPI, vars["eventID"], cfg.Matrix.ServerName,
|
2017-09-06 13:38:22 +02:00
|
|
|
)
|
|
|
|
},
|
2018-03-13 16:55:45 +01:00
|
|
|
)).Methods(http.MethodGet)
|
2017-09-25 12:16:47 +02:00
|
|
|
|
2018-07-11 12:13:04 +02:00
|
|
|
v1fedmux.Handle("/state/{roomID}", common.MakeFedAPI(
|
2020-03-14 21:08:54 +01:00
|
|
|
"federation_get_state", cfg.Matrix.ServerName, keys,
|
2018-06-22 12:46:19 +02:00
|
|
|
func(httpReq *http.Request, request *gomatrixserverlib.FederationRequest) util.JSONResponse {
|
2019-07-03 17:38:50 +02:00
|
|
|
vars, err := common.URLDecodeMapValues(mux.Vars(httpReq))
|
|
|
|
if err != nil {
|
|
|
|
return util.ErrorResponse(err)
|
|
|
|
}
|
2018-06-22 12:46:19 +02:00
|
|
|
return GetState(
|
2020-05-01 11:48:17 +02:00
|
|
|
httpReq.Context(), request, rsAPI, vars["roomID"],
|
2018-06-22 12:46:19 +02:00
|
|
|
)
|
|
|
|
},
|
|
|
|
)).Methods(http.MethodGet)
|
|
|
|
|
2018-07-11 12:13:04 +02:00
|
|
|
v1fedmux.Handle("/state_ids/{roomID}", common.MakeFedAPI(
|
2020-03-14 21:08:54 +01:00
|
|
|
"federation_get_state_ids", cfg.Matrix.ServerName, keys,
|
2018-06-22 12:46:19 +02:00
|
|
|
func(httpReq *http.Request, request *gomatrixserverlib.FederationRequest) util.JSONResponse {
|
2019-07-03 17:38:50 +02:00
|
|
|
vars, err := common.URLDecodeMapValues(mux.Vars(httpReq))
|
|
|
|
if err != nil {
|
|
|
|
return util.ErrorResponse(err)
|
|
|
|
}
|
2018-06-22 12:46:19 +02:00
|
|
|
return GetStateIDs(
|
2020-05-01 11:48:17 +02:00
|
|
|
httpReq.Context(), request, rsAPI, vars["roomID"],
|
2018-06-22 12:46:19 +02:00
|
|
|
)
|
|
|
|
},
|
|
|
|
)).Methods(http.MethodGet)
|
|
|
|
|
2020-03-14 21:08:54 +01:00
|
|
|
v1fedmux.Handle("/event_auth/{roomID}/{eventID}", common.MakeFedAPI(
|
|
|
|
"federation_get_event_auth", cfg.Matrix.ServerName, keys,
|
|
|
|
func(httpReq *http.Request, request *gomatrixserverlib.FederationRequest) util.JSONResponse {
|
|
|
|
vars := mux.Vars(httpReq)
|
|
|
|
return GetEventAuth(
|
2020-05-01 11:48:17 +02:00
|
|
|
httpReq.Context(), request, rsAPI, vars["roomID"], vars["eventID"],
|
2020-03-14 21:08:54 +01:00
|
|
|
)
|
|
|
|
},
|
|
|
|
)).Methods(http.MethodGet)
|
|
|
|
|
2018-08-07 15:41:50 +02:00
|
|
|
v1fedmux.Handle("/query/directory", common.MakeFedAPI(
|
2017-11-20 15:33:49 +01:00
|
|
|
"federation_query_room_alias", cfg.Matrix.ServerName, keys,
|
|
|
|
func(httpReq *http.Request, request *gomatrixserverlib.FederationRequest) util.JSONResponse {
|
|
|
|
return RoomAliasToID(
|
2020-05-01 11:48:17 +02:00
|
|
|
httpReq, federation, cfg, rsAPI, federationSenderAPI,
|
2017-11-20 15:33:49 +01:00
|
|
|
)
|
|
|
|
},
|
2018-03-13 16:55:45 +01:00
|
|
|
)).Methods(http.MethodGet)
|
2017-11-20 15:33:49 +01:00
|
|
|
|
2017-11-05 19:03:54 +01:00
|
|
|
v1fedmux.Handle("/query/profile", common.MakeFedAPI(
|
|
|
|
"federation_query_profile", cfg.Matrix.ServerName, keys,
|
|
|
|
func(httpReq *http.Request, request *gomatrixserverlib.FederationRequest) util.JSONResponse {
|
|
|
|
return GetProfile(
|
2018-08-20 11:45:17 +02:00
|
|
|
httpReq, accountDB, cfg, asAPI,
|
2017-11-05 19:03:54 +01:00
|
|
|
)
|
|
|
|
},
|
2018-03-13 16:55:45 +01:00
|
|
|
)).Methods(http.MethodGet)
|
2017-11-05 19:03:54 +01:00
|
|
|
|
2018-07-25 14:58:10 +02:00
|
|
|
v1fedmux.Handle("/user/devices/{userID}", common.MakeFedAPI(
|
|
|
|
"federation_user_devices", cfg.Matrix.ServerName, keys,
|
2018-06-26 12:32:43 +02:00
|
|
|
func(httpReq *http.Request, request *gomatrixserverlib.FederationRequest) util.JSONResponse {
|
2019-07-03 17:38:50 +02:00
|
|
|
vars, err := common.URLDecodeMapValues(mux.Vars(httpReq))
|
|
|
|
if err != nil {
|
|
|
|
return util.ErrorResponse(err)
|
|
|
|
}
|
2018-06-26 12:32:43 +02:00
|
|
|
return GetUserDevices(
|
|
|
|
httpReq, deviceDB, vars["userID"],
|
|
|
|
)
|
|
|
|
},
|
|
|
|
)).Methods(http.MethodGet)
|
|
|
|
|
Federation for v3/v4 rooms (#954)
* Update gomatrixserverlib
* Default to room version 4
* Update gomatrixserverlib
* Limit prev_events and auth_events
* Fix auth_events, prev_events
* Fix linter issues
* Update gomatrixserverlib
* Fix getState
* Update sytest-whitelist
* Squashed commit of the following:
commit 067b87506357c996fd6ddb11271db9469ad4ce80
Author: Neil Alexander <neilalexander@users.noreply.github.com>
Date: Fri Apr 3 14:29:06 2020 +0100
Invites v2 endpoint (#952)
* Start converting v1 invite endpoint to v2
* Update gomatrixserverlib
* Early federationsender code for sending invites
* Sending invites sorta happens now
* Populate invite request with stripped state
* Remodel a bit, don't reflect received invites
* Handle invite_room_state
* Handle room versions a bit better
* Update gomatrixserverlib
* Tweak order in destinationQueue.next
* Revert check in processMessage
* Tweak federation sender destination queue code a bit
* Add comments
commit 955244c09298d0e6c870377dad3af2ffa1f5e578
Author: Ben B <benne@klimlive.de>
Date: Fri Apr 3 12:40:50 2020 +0200
use custom http client instead of the http DefaultClient (#823)
This commit replaces the default client from the http lib with a custom one.
The previously used default client doesn't come with a timeout. This could cause
unwanted locks.
That solution chosen here creates a http client in the base component dendrite
with a constant timeout of 30 seconds. If it should be necessary to overwrite
this, we could include the timeout in the dendrite configuration.
Here it would be a good idea to extend the type "Address" by a timeout and
create an http client for each service.
Closes #820
Signed-off-by: Benedikt Bongartz <benne@klimlive.de>
Co-authored-by: Kegsay <kegan@matrix.org>
* Update sytest-whitelist, sytest-blacklist
* Update go.mod/go.sum
* Add some error wrapping for debug
* Add a NOTSPEC to common/events.go
* Perform state resolution at send_join
* Set default room version to v2 again
* Tweak GetCapabilities
* Add comments to ResolveConflictsAdhoc
* Update sytest-blacklist
* go mod tidy
* Update sytest-whitelist, sytest-blacklist
* Update versions
* Updates from review comments
* Update sytest-blacklist, sytest-whitelist
* Check room versions compatible at make_join, add some comments, update gomatrixserverlib, other tweaks
* Set default room version back to v2
* Update gomatrixserverlib, sytest-whitelist
2020-04-09 16:46:06 +02:00
|
|
|
v1fedmux.Handle("/make_join/{roomID}/{eventID}", common.MakeFedAPI(
|
2017-11-29 10:38:56 +01:00
|
|
|
"federation_make_join", cfg.Matrix.ServerName, keys,
|
|
|
|
func(httpReq *http.Request, request *gomatrixserverlib.FederationRequest) util.JSONResponse {
|
2019-07-03 17:38:50 +02:00
|
|
|
vars, err := common.URLDecodeMapValues(mux.Vars(httpReq))
|
|
|
|
if err != nil {
|
|
|
|
return util.ErrorResponse(err)
|
|
|
|
}
|
2017-11-29 10:38:56 +01:00
|
|
|
roomID := vars["roomID"]
|
Federation for v3/v4 rooms (#954)
* Update gomatrixserverlib
* Default to room version 4
* Update gomatrixserverlib
* Limit prev_events and auth_events
* Fix auth_events, prev_events
* Fix linter issues
* Update gomatrixserverlib
* Fix getState
* Update sytest-whitelist
* Squashed commit of the following:
commit 067b87506357c996fd6ddb11271db9469ad4ce80
Author: Neil Alexander <neilalexander@users.noreply.github.com>
Date: Fri Apr 3 14:29:06 2020 +0100
Invites v2 endpoint (#952)
* Start converting v1 invite endpoint to v2
* Update gomatrixserverlib
* Early federationsender code for sending invites
* Sending invites sorta happens now
* Populate invite request with stripped state
* Remodel a bit, don't reflect received invites
* Handle invite_room_state
* Handle room versions a bit better
* Update gomatrixserverlib
* Tweak order in destinationQueue.next
* Revert check in processMessage
* Tweak federation sender destination queue code a bit
* Add comments
commit 955244c09298d0e6c870377dad3af2ffa1f5e578
Author: Ben B <benne@klimlive.de>
Date: Fri Apr 3 12:40:50 2020 +0200
use custom http client instead of the http DefaultClient (#823)
This commit replaces the default client from the http lib with a custom one.
The previously used default client doesn't come with a timeout. This could cause
unwanted locks.
That solution chosen here creates a http client in the base component dendrite
with a constant timeout of 30 seconds. If it should be necessary to overwrite
this, we could include the timeout in the dendrite configuration.
Here it would be a good idea to extend the type "Address" by a timeout and
create an http client for each service.
Closes #820
Signed-off-by: Benedikt Bongartz <benne@klimlive.de>
Co-authored-by: Kegsay <kegan@matrix.org>
* Update sytest-whitelist, sytest-blacklist
* Update go.mod/go.sum
* Add some error wrapping for debug
* Add a NOTSPEC to common/events.go
* Perform state resolution at send_join
* Set default room version to v2 again
* Tweak GetCapabilities
* Add comments to ResolveConflictsAdhoc
* Update sytest-blacklist
* go mod tidy
* Update sytest-whitelist, sytest-blacklist
* Update versions
* Updates from review comments
* Update sytest-blacklist, sytest-whitelist
* Check room versions compatible at make_join, add some comments, update gomatrixserverlib, other tweaks
* Set default room version back to v2
* Update gomatrixserverlib, sytest-whitelist
2020-04-09 16:46:06 +02:00
|
|
|
eventID := vars["eventID"]
|
|
|
|
queryVars := httpReq.URL.Query()
|
|
|
|
remoteVersions := []gomatrixserverlib.RoomVersion{}
|
|
|
|
if vers, ok := queryVars["ver"]; ok {
|
|
|
|
// The remote side supplied a ?=ver so use that to build up the list
|
|
|
|
// of supported room versions
|
|
|
|
for _, v := range vers {
|
|
|
|
remoteVersions = append(remoteVersions, gomatrixserverlib.RoomVersion(v))
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// The remote side didn't supply a ?ver= so just assume that they only
|
|
|
|
// support room version 1, as per the spec
|
|
|
|
// https://matrix.org/docs/spec/server_server/r0.1.3#get-matrix-federation-v1-make-join-roomid-userid
|
|
|
|
remoteVersions = append(remoteVersions, gomatrixserverlib.RoomVersionV1)
|
|
|
|
}
|
2017-11-29 10:38:56 +01:00
|
|
|
return MakeJoin(
|
2020-05-01 11:48:17 +02:00
|
|
|
httpReq, request, cfg, rsAPI, roomID, eventID, remoteVersions,
|
2017-11-29 10:38:56 +01:00
|
|
|
)
|
|
|
|
},
|
2018-03-13 16:55:45 +01:00
|
|
|
)).Methods(http.MethodGet)
|
2017-11-29 10:38:56 +01:00
|
|
|
|
Federation for v3/v4 rooms (#954)
* Update gomatrixserverlib
* Default to room version 4
* Update gomatrixserverlib
* Limit prev_events and auth_events
* Fix auth_events, prev_events
* Fix linter issues
* Update gomatrixserverlib
* Fix getState
* Update sytest-whitelist
* Squashed commit of the following:
commit 067b87506357c996fd6ddb11271db9469ad4ce80
Author: Neil Alexander <neilalexander@users.noreply.github.com>
Date: Fri Apr 3 14:29:06 2020 +0100
Invites v2 endpoint (#952)
* Start converting v1 invite endpoint to v2
* Update gomatrixserverlib
* Early federationsender code for sending invites
* Sending invites sorta happens now
* Populate invite request with stripped state
* Remodel a bit, don't reflect received invites
* Handle invite_room_state
* Handle room versions a bit better
* Update gomatrixserverlib
* Tweak order in destinationQueue.next
* Revert check in processMessage
* Tweak federation sender destination queue code a bit
* Add comments
commit 955244c09298d0e6c870377dad3af2ffa1f5e578
Author: Ben B <benne@klimlive.de>
Date: Fri Apr 3 12:40:50 2020 +0200
use custom http client instead of the http DefaultClient (#823)
This commit replaces the default client from the http lib with a custom one.
The previously used default client doesn't come with a timeout. This could cause
unwanted locks.
That solution chosen here creates a http client in the base component dendrite
with a constant timeout of 30 seconds. If it should be necessary to overwrite
this, we could include the timeout in the dendrite configuration.
Here it would be a good idea to extend the type "Address" by a timeout and
create an http client for each service.
Closes #820
Signed-off-by: Benedikt Bongartz <benne@klimlive.de>
Co-authored-by: Kegsay <kegan@matrix.org>
* Update sytest-whitelist, sytest-blacklist
* Update go.mod/go.sum
* Add some error wrapping for debug
* Add a NOTSPEC to common/events.go
* Perform state resolution at send_join
* Set default room version to v2 again
* Tweak GetCapabilities
* Add comments to ResolveConflictsAdhoc
* Update sytest-blacklist
* go mod tidy
* Update sytest-whitelist, sytest-blacklist
* Update versions
* Updates from review comments
* Update sytest-blacklist, sytest-whitelist
* Check room versions compatible at make_join, add some comments, update gomatrixserverlib, other tweaks
* Set default room version back to v2
* Update gomatrixserverlib, sytest-whitelist
2020-04-09 16:46:06 +02:00
|
|
|
v2fedmux.Handle("/send_join/{roomID}/{eventID}", common.MakeFedAPI(
|
2017-11-29 10:38:56 +01:00
|
|
|
"federation_send_join", cfg.Matrix.ServerName, keys,
|
|
|
|
func(httpReq *http.Request, request *gomatrixserverlib.FederationRequest) util.JSONResponse {
|
2019-07-03 17:38:50 +02:00
|
|
|
vars, err := common.URLDecodeMapValues(mux.Vars(httpReq))
|
|
|
|
if err != nil {
|
|
|
|
return util.ErrorResponse(err)
|
|
|
|
}
|
2017-11-29 10:38:56 +01:00
|
|
|
roomID := vars["roomID"]
|
Federation for v3/v4 rooms (#954)
* Update gomatrixserverlib
* Default to room version 4
* Update gomatrixserverlib
* Limit prev_events and auth_events
* Fix auth_events, prev_events
* Fix linter issues
* Update gomatrixserverlib
* Fix getState
* Update sytest-whitelist
* Squashed commit of the following:
commit 067b87506357c996fd6ddb11271db9469ad4ce80
Author: Neil Alexander <neilalexander@users.noreply.github.com>
Date: Fri Apr 3 14:29:06 2020 +0100
Invites v2 endpoint (#952)
* Start converting v1 invite endpoint to v2
* Update gomatrixserverlib
* Early federationsender code for sending invites
* Sending invites sorta happens now
* Populate invite request with stripped state
* Remodel a bit, don't reflect received invites
* Handle invite_room_state
* Handle room versions a bit better
* Update gomatrixserverlib
* Tweak order in destinationQueue.next
* Revert check in processMessage
* Tweak federation sender destination queue code a bit
* Add comments
commit 955244c09298d0e6c870377dad3af2ffa1f5e578
Author: Ben B <benne@klimlive.de>
Date: Fri Apr 3 12:40:50 2020 +0200
use custom http client instead of the http DefaultClient (#823)
This commit replaces the default client from the http lib with a custom one.
The previously used default client doesn't come with a timeout. This could cause
unwanted locks.
That solution chosen here creates a http client in the base component dendrite
with a constant timeout of 30 seconds. If it should be necessary to overwrite
this, we could include the timeout in the dendrite configuration.
Here it would be a good idea to extend the type "Address" by a timeout and
create an http client for each service.
Closes #820
Signed-off-by: Benedikt Bongartz <benne@klimlive.de>
Co-authored-by: Kegsay <kegan@matrix.org>
* Update sytest-whitelist, sytest-blacklist
* Update go.mod/go.sum
* Add some error wrapping for debug
* Add a NOTSPEC to common/events.go
* Perform state resolution at send_join
* Set default room version to v2 again
* Tweak GetCapabilities
* Add comments to ResolveConflictsAdhoc
* Update sytest-blacklist
* go mod tidy
* Update sytest-whitelist, sytest-blacklist
* Update versions
* Updates from review comments
* Update sytest-blacklist, sytest-whitelist
* Check room versions compatible at make_join, add some comments, update gomatrixserverlib, other tweaks
* Set default room version back to v2
* Update gomatrixserverlib, sytest-whitelist
2020-04-09 16:46:06 +02:00
|
|
|
eventID := vars["eventID"]
|
2017-11-29 10:38:56 +01:00
|
|
|
return SendJoin(
|
2020-05-01 11:48:17 +02:00
|
|
|
httpReq, request, cfg, rsAPI, producer, keys, roomID, eventID,
|
2017-11-29 10:38:56 +01:00
|
|
|
)
|
|
|
|
},
|
2018-03-13 16:55:45 +01:00
|
|
|
)).Methods(http.MethodPut)
|
2017-11-29 10:38:56 +01:00
|
|
|
|
Federation for v3/v4 rooms (#954)
* Update gomatrixserverlib
* Default to room version 4
* Update gomatrixserverlib
* Limit prev_events and auth_events
* Fix auth_events, prev_events
* Fix linter issues
* Update gomatrixserverlib
* Fix getState
* Update sytest-whitelist
* Squashed commit of the following:
commit 067b87506357c996fd6ddb11271db9469ad4ce80
Author: Neil Alexander <neilalexander@users.noreply.github.com>
Date: Fri Apr 3 14:29:06 2020 +0100
Invites v2 endpoint (#952)
* Start converting v1 invite endpoint to v2
* Update gomatrixserverlib
* Early federationsender code for sending invites
* Sending invites sorta happens now
* Populate invite request with stripped state
* Remodel a bit, don't reflect received invites
* Handle invite_room_state
* Handle room versions a bit better
* Update gomatrixserverlib
* Tweak order in destinationQueue.next
* Revert check in processMessage
* Tweak federation sender destination queue code a bit
* Add comments
commit 955244c09298d0e6c870377dad3af2ffa1f5e578
Author: Ben B <benne@klimlive.de>
Date: Fri Apr 3 12:40:50 2020 +0200
use custom http client instead of the http DefaultClient (#823)
This commit replaces the default client from the http lib with a custom one.
The previously used default client doesn't come with a timeout. This could cause
unwanted locks.
That solution chosen here creates a http client in the base component dendrite
with a constant timeout of 30 seconds. If it should be necessary to overwrite
this, we could include the timeout in the dendrite configuration.
Here it would be a good idea to extend the type "Address" by a timeout and
create an http client for each service.
Closes #820
Signed-off-by: Benedikt Bongartz <benne@klimlive.de>
Co-authored-by: Kegsay <kegan@matrix.org>
* Update sytest-whitelist, sytest-blacklist
* Update go.mod/go.sum
* Add some error wrapping for debug
* Add a NOTSPEC to common/events.go
* Perform state resolution at send_join
* Set default room version to v2 again
* Tweak GetCapabilities
* Add comments to ResolveConflictsAdhoc
* Update sytest-blacklist
* go mod tidy
* Update sytest-whitelist, sytest-blacklist
* Update versions
* Updates from review comments
* Update sytest-blacklist, sytest-whitelist
* Check room versions compatible at make_join, add some comments, update gomatrixserverlib, other tweaks
* Set default room version back to v2
* Update gomatrixserverlib, sytest-whitelist
2020-04-09 16:46:06 +02:00
|
|
|
v1fedmux.Handle("/make_leave/{roomID}/{eventID}", common.MakeFedAPI(
|
2018-07-11 12:07:44 +02:00
|
|
|
"federation_make_leave", cfg.Matrix.ServerName, keys,
|
|
|
|
func(httpReq *http.Request, request *gomatrixserverlib.FederationRequest) util.JSONResponse {
|
2019-07-03 17:38:50 +02:00
|
|
|
vars, err := common.URLDecodeMapValues(mux.Vars(httpReq))
|
|
|
|
if err != nil {
|
|
|
|
return util.ErrorResponse(err)
|
|
|
|
}
|
2018-07-11 12:07:44 +02:00
|
|
|
roomID := vars["roomID"]
|
Federation for v3/v4 rooms (#954)
* Update gomatrixserverlib
* Default to room version 4
* Update gomatrixserverlib
* Limit prev_events and auth_events
* Fix auth_events, prev_events
* Fix linter issues
* Update gomatrixserverlib
* Fix getState
* Update sytest-whitelist
* Squashed commit of the following:
commit 067b87506357c996fd6ddb11271db9469ad4ce80
Author: Neil Alexander <neilalexander@users.noreply.github.com>
Date: Fri Apr 3 14:29:06 2020 +0100
Invites v2 endpoint (#952)
* Start converting v1 invite endpoint to v2
* Update gomatrixserverlib
* Early federationsender code for sending invites
* Sending invites sorta happens now
* Populate invite request with stripped state
* Remodel a bit, don't reflect received invites
* Handle invite_room_state
* Handle room versions a bit better
* Update gomatrixserverlib
* Tweak order in destinationQueue.next
* Revert check in processMessage
* Tweak federation sender destination queue code a bit
* Add comments
commit 955244c09298d0e6c870377dad3af2ffa1f5e578
Author: Ben B <benne@klimlive.de>
Date: Fri Apr 3 12:40:50 2020 +0200
use custom http client instead of the http DefaultClient (#823)
This commit replaces the default client from the http lib with a custom one.
The previously used default client doesn't come with a timeout. This could cause
unwanted locks.
That solution chosen here creates a http client in the base component dendrite
with a constant timeout of 30 seconds. If it should be necessary to overwrite
this, we could include the timeout in the dendrite configuration.
Here it would be a good idea to extend the type "Address" by a timeout and
create an http client for each service.
Closes #820
Signed-off-by: Benedikt Bongartz <benne@klimlive.de>
Co-authored-by: Kegsay <kegan@matrix.org>
* Update sytest-whitelist, sytest-blacklist
* Update go.mod/go.sum
* Add some error wrapping for debug
* Add a NOTSPEC to common/events.go
* Perform state resolution at send_join
* Set default room version to v2 again
* Tweak GetCapabilities
* Add comments to ResolveConflictsAdhoc
* Update sytest-blacklist
* go mod tidy
* Update sytest-whitelist, sytest-blacklist
* Update versions
* Updates from review comments
* Update sytest-blacklist, sytest-whitelist
* Check room versions compatible at make_join, add some comments, update gomatrixserverlib, other tweaks
* Set default room version back to v2
* Update gomatrixserverlib, sytest-whitelist
2020-04-09 16:46:06 +02:00
|
|
|
eventID := vars["eventID"]
|
2018-07-11 12:07:44 +02:00
|
|
|
return MakeLeave(
|
2020-05-01 11:48:17 +02:00
|
|
|
httpReq, request, cfg, rsAPI, roomID, eventID,
|
2018-07-11 12:07:44 +02:00
|
|
|
)
|
|
|
|
},
|
|
|
|
)).Methods(http.MethodGet)
|
|
|
|
|
Federation for v3/v4 rooms (#954)
* Update gomatrixserverlib
* Default to room version 4
* Update gomatrixserverlib
* Limit prev_events and auth_events
* Fix auth_events, prev_events
* Fix linter issues
* Update gomatrixserverlib
* Fix getState
* Update sytest-whitelist
* Squashed commit of the following:
commit 067b87506357c996fd6ddb11271db9469ad4ce80
Author: Neil Alexander <neilalexander@users.noreply.github.com>
Date: Fri Apr 3 14:29:06 2020 +0100
Invites v2 endpoint (#952)
* Start converting v1 invite endpoint to v2
* Update gomatrixserverlib
* Early federationsender code for sending invites
* Sending invites sorta happens now
* Populate invite request with stripped state
* Remodel a bit, don't reflect received invites
* Handle invite_room_state
* Handle room versions a bit better
* Update gomatrixserverlib
* Tweak order in destinationQueue.next
* Revert check in processMessage
* Tweak federation sender destination queue code a bit
* Add comments
commit 955244c09298d0e6c870377dad3af2ffa1f5e578
Author: Ben B <benne@klimlive.de>
Date: Fri Apr 3 12:40:50 2020 +0200
use custom http client instead of the http DefaultClient (#823)
This commit replaces the default client from the http lib with a custom one.
The previously used default client doesn't come with a timeout. This could cause
unwanted locks.
That solution chosen here creates a http client in the base component dendrite
with a constant timeout of 30 seconds. If it should be necessary to overwrite
this, we could include the timeout in the dendrite configuration.
Here it would be a good idea to extend the type "Address" by a timeout and
create an http client for each service.
Closes #820
Signed-off-by: Benedikt Bongartz <benne@klimlive.de>
Co-authored-by: Kegsay <kegan@matrix.org>
* Update sytest-whitelist, sytest-blacklist
* Update go.mod/go.sum
* Add some error wrapping for debug
* Add a NOTSPEC to common/events.go
* Perform state resolution at send_join
* Set default room version to v2 again
* Tweak GetCapabilities
* Add comments to ResolveConflictsAdhoc
* Update sytest-blacklist
* go mod tidy
* Update sytest-whitelist, sytest-blacklist
* Update versions
* Updates from review comments
* Update sytest-blacklist, sytest-whitelist
* Check room versions compatible at make_join, add some comments, update gomatrixserverlib, other tweaks
* Set default room version back to v2
* Update gomatrixserverlib, sytest-whitelist
2020-04-09 16:46:06 +02:00
|
|
|
v2fedmux.Handle("/send_leave/{roomID}/{eventID}", common.MakeFedAPI(
|
2018-07-11 12:07:44 +02:00
|
|
|
"federation_send_leave", cfg.Matrix.ServerName, keys,
|
|
|
|
func(httpReq *http.Request, request *gomatrixserverlib.FederationRequest) util.JSONResponse {
|
2019-07-03 17:38:50 +02:00
|
|
|
vars, err := common.URLDecodeMapValues(mux.Vars(httpReq))
|
|
|
|
if err != nil {
|
|
|
|
return util.ErrorResponse(err)
|
|
|
|
}
|
2018-07-11 12:07:44 +02:00
|
|
|
roomID := vars["roomID"]
|
Federation for v3/v4 rooms (#954)
* Update gomatrixserverlib
* Default to room version 4
* Update gomatrixserverlib
* Limit prev_events and auth_events
* Fix auth_events, prev_events
* Fix linter issues
* Update gomatrixserverlib
* Fix getState
* Update sytest-whitelist
* Squashed commit of the following:
commit 067b87506357c996fd6ddb11271db9469ad4ce80
Author: Neil Alexander <neilalexander@users.noreply.github.com>
Date: Fri Apr 3 14:29:06 2020 +0100
Invites v2 endpoint (#952)
* Start converting v1 invite endpoint to v2
* Update gomatrixserverlib
* Early federationsender code for sending invites
* Sending invites sorta happens now
* Populate invite request with stripped state
* Remodel a bit, don't reflect received invites
* Handle invite_room_state
* Handle room versions a bit better
* Update gomatrixserverlib
* Tweak order in destinationQueue.next
* Revert check in processMessage
* Tweak federation sender destination queue code a bit
* Add comments
commit 955244c09298d0e6c870377dad3af2ffa1f5e578
Author: Ben B <benne@klimlive.de>
Date: Fri Apr 3 12:40:50 2020 +0200
use custom http client instead of the http DefaultClient (#823)
This commit replaces the default client from the http lib with a custom one.
The previously used default client doesn't come with a timeout. This could cause
unwanted locks.
That solution chosen here creates a http client in the base component dendrite
with a constant timeout of 30 seconds. If it should be necessary to overwrite
this, we could include the timeout in the dendrite configuration.
Here it would be a good idea to extend the type "Address" by a timeout and
create an http client for each service.
Closes #820
Signed-off-by: Benedikt Bongartz <benne@klimlive.de>
Co-authored-by: Kegsay <kegan@matrix.org>
* Update sytest-whitelist, sytest-blacklist
* Update go.mod/go.sum
* Add some error wrapping for debug
* Add a NOTSPEC to common/events.go
* Perform state resolution at send_join
* Set default room version to v2 again
* Tweak GetCapabilities
* Add comments to ResolveConflictsAdhoc
* Update sytest-blacklist
* go mod tidy
* Update sytest-whitelist, sytest-blacklist
* Update versions
* Updates from review comments
* Update sytest-blacklist, sytest-whitelist
* Check room versions compatible at make_join, add some comments, update gomatrixserverlib, other tweaks
* Set default room version back to v2
* Update gomatrixserverlib, sytest-whitelist
2020-04-09 16:46:06 +02:00
|
|
|
eventID := vars["eventID"]
|
2018-07-11 12:07:44 +02:00
|
|
|
return SendLeave(
|
Federation for v3/v4 rooms (#954)
* Update gomatrixserverlib
* Default to room version 4
* Update gomatrixserverlib
* Limit prev_events and auth_events
* Fix auth_events, prev_events
* Fix linter issues
* Update gomatrixserverlib
* Fix getState
* Update sytest-whitelist
* Squashed commit of the following:
commit 067b87506357c996fd6ddb11271db9469ad4ce80
Author: Neil Alexander <neilalexander@users.noreply.github.com>
Date: Fri Apr 3 14:29:06 2020 +0100
Invites v2 endpoint (#952)
* Start converting v1 invite endpoint to v2
* Update gomatrixserverlib
* Early federationsender code for sending invites
* Sending invites sorta happens now
* Populate invite request with stripped state
* Remodel a bit, don't reflect received invites
* Handle invite_room_state
* Handle room versions a bit better
* Update gomatrixserverlib
* Tweak order in destinationQueue.next
* Revert check in processMessage
* Tweak federation sender destination queue code a bit
* Add comments
commit 955244c09298d0e6c870377dad3af2ffa1f5e578
Author: Ben B <benne@klimlive.de>
Date: Fri Apr 3 12:40:50 2020 +0200
use custom http client instead of the http DefaultClient (#823)
This commit replaces the default client from the http lib with a custom one.
The previously used default client doesn't come with a timeout. This could cause
unwanted locks.
That solution chosen here creates a http client in the base component dendrite
with a constant timeout of 30 seconds. If it should be necessary to overwrite
this, we could include the timeout in the dendrite configuration.
Here it would be a good idea to extend the type "Address" by a timeout and
create an http client for each service.
Closes #820
Signed-off-by: Benedikt Bongartz <benne@klimlive.de>
Co-authored-by: Kegsay <kegan@matrix.org>
* Update sytest-whitelist, sytest-blacklist
* Update go.mod/go.sum
* Add some error wrapping for debug
* Add a NOTSPEC to common/events.go
* Perform state resolution at send_join
* Set default room version to v2 again
* Tweak GetCapabilities
* Add comments to ResolveConflictsAdhoc
* Update sytest-blacklist
* go mod tidy
* Update sytest-whitelist, sytest-blacklist
* Update versions
* Updates from review comments
* Update sytest-blacklist, sytest-whitelist
* Check room versions compatible at make_join, add some comments, update gomatrixserverlib, other tweaks
* Set default room version back to v2
* Update gomatrixserverlib, sytest-whitelist
2020-04-09 16:46:06 +02:00
|
|
|
httpReq, request, cfg, producer, keys, roomID, eventID,
|
2018-07-11 12:07:44 +02:00
|
|
|
)
|
|
|
|
},
|
|
|
|
)).Methods(http.MethodPut)
|
|
|
|
|
2017-09-28 15:50:40 +02:00
|
|
|
v1fedmux.Handle("/version", common.MakeExternalAPI(
|
2017-09-25 12:16:47 +02:00
|
|
|
"federation_version",
|
|
|
|
func(httpReq *http.Request) util.JSONResponse {
|
2017-10-25 12:27:44 +02:00
|
|
|
return Version()
|
2017-09-25 12:16:47 +02:00
|
|
|
},
|
2018-03-13 16:55:45 +01:00
|
|
|
)).Methods(http.MethodGet)
|
2018-06-26 12:25:49 +02:00
|
|
|
|
2019-01-14 11:20:19 +01:00
|
|
|
v1fedmux.Handle("/get_missing_events/{roomID}", common.MakeFedAPI(
|
2018-06-26 12:25:49 +02:00
|
|
|
"federation_get_missing_events", cfg.Matrix.ServerName, keys,
|
|
|
|
func(httpReq *http.Request, request *gomatrixserverlib.FederationRequest) util.JSONResponse {
|
2019-07-03 17:38:50 +02:00
|
|
|
vars, err := common.URLDecodeMapValues(mux.Vars(httpReq))
|
|
|
|
if err != nil {
|
|
|
|
return util.ErrorResponse(err)
|
|
|
|
}
|
2020-05-01 11:48:17 +02:00
|
|
|
return GetMissingEvents(httpReq, request, rsAPI, vars["roomID"])
|
2018-06-26 12:25:49 +02:00
|
|
|
},
|
2019-01-14 11:20:19 +01:00
|
|
|
)).Methods(http.MethodPost)
|
2018-11-07 12:38:01 +01:00
|
|
|
|
2019-07-18 09:41:29 +02:00
|
|
|
v1fedmux.Handle("/backfill/{roomID}", common.MakeFedAPI(
|
2018-11-07 12:38:01 +01:00
|
|
|
"federation_backfill", cfg.Matrix.ServerName, keys,
|
|
|
|
func(httpReq *http.Request, request *gomatrixserverlib.FederationRequest) util.JSONResponse {
|
2019-07-03 17:38:50 +02:00
|
|
|
vars, err := common.URLDecodeMapValues(mux.Vars(httpReq))
|
|
|
|
if err != nil {
|
|
|
|
return util.ErrorResponse(err)
|
|
|
|
}
|
2020-05-01 11:48:17 +02:00
|
|
|
return Backfill(httpReq, request, rsAPI, vars["roomID"], cfg)
|
2018-11-07 12:38:01 +01:00
|
|
|
},
|
|
|
|
)).Methods(http.MethodGet)
|
2017-05-19 17:06:41 +02:00
|
|
|
}
|