diff --git a/build/gobind/monolith.go b/build/gobind/monolith.go index a4803396f..71a638b43 100644 --- a/build/gobind/monolith.go +++ b/build/gobind/monolith.go @@ -8,6 +8,7 @@ import ( "net/http" "time" + "github.com/gorilla/mux" "github.com/matrix-org/dendrite/appservice" "github.com/matrix-org/dendrite/cmd/dendrite-demo-yggdrasil/signing" "github.com/matrix-org/dendrite/cmd/dendrite-demo-yggdrasil/yggconn" @@ -18,6 +19,7 @@ import ( "github.com/matrix-org/dendrite/federationsender" "github.com/matrix-org/dendrite/federationsender/api" "github.com/matrix-org/dendrite/internal/config" + "github.com/matrix-org/dendrite/internal/httputil" "github.com/matrix-org/dendrite/internal/setup" "github.com/matrix-org/dendrite/keyserver" "github.com/matrix-org/dendrite/roomserver" @@ -169,7 +171,21 @@ func (m *DendriteMonolith) Start() { ygg, fsAPI, federation, ), } - monolith.AddAllPublicRoutes(base.PublicAPIMux) + monolith.AddAllPublicRoutes( + base.ExternalClientAPIMux, + base.ExternalFederationAPIMux, + base.ExternalKeyAPIMux, + base.ExternalMediaAPIMux, + ) + + httpRouter := mux.NewRouter() + httpRouter.PathPrefix(httputil.InternalPathPrefix).Handler(base.InternalAPIMux) + httpRouter.PathPrefix(httputil.ExternalClientPathPrefix).Handler(base.ExternalClientAPIMux) + httpRouter.PathPrefix(httputil.ExternalMediaPathPrefix).Handler(base.ExternalMediaAPIMux) + + yggRouter := mux.NewRouter() + httpRouter.PathPrefix(httputil.ExternalFederationPathPrefix).Handler(base.ExternalClientAPIMux) + httpRouter.PathPrefix(httputil.ExternalMediaPathPrefix).Handler(base.ExternalMediaAPIMux) // Build both ends of a HTTP multiplex. m.httpServer = &http.Server{ @@ -181,7 +197,7 @@ func (m *DendriteMonolith) Start() { BaseContext: func(_ net.Listener) context.Context { return context.Background() }, - Handler: base.PublicAPIMux, + Handler: yggRouter, } go func() { @@ -189,8 +205,8 @@ func (m *DendriteMonolith) Start() { m.logger.Fatal(m.httpServer.Serve(ygg)) }() go func() { - m.logger.Info("Listening on ", m.BaseURL()) - m.logger.Fatal(m.httpServer.Serve(m.listener)) + logrus.Info("Listening on ", m.listener.Addr()) + logrus.Fatal(http.Serve(m.listener, httpRouter)) }() go func() { logrus.Info("Sending wake-up message to known nodes") diff --git a/clientapi/routing/routing.go b/clientapi/routing/routing.go index 883b473bf..4c96280b6 100644 --- a/clientapi/routing/routing.go +++ b/clientapi/routing/routing.go @@ -40,9 +40,9 @@ import ( "github.com/matrix-org/util" ) -const pathPrefixV1 = "/client/api/v1" -const pathPrefixR0 = "/client/r0" -const pathPrefixUnstable = "/client/unstable" +const pathPrefixV1 = "/api/v1" +const pathPrefixR0 = "/r0" +const pathPrefixUnstable = "/unstable" // Setup registers HTTP handlers with the given ServeMux. It also supplies the given http.Client // to clients which need to make outbound HTTP requests. @@ -68,7 +68,7 @@ func Setup( ) { userInteractiveAuth := auth.NewUserInteractive(accountDB.GetAccountByPassword, cfg) - publicAPIMux.Handle("/client/versions", + publicAPIMux.Handle("/versions", httputil.MakeExternalAPI("versions", func(req *http.Request) util.JSONResponse { return util.JSONResponse{ Code: http.StatusOK, diff --git a/cmd/dendrite-client-api-server/main.go b/cmd/dendrite-client-api-server/main.go index 6efe86a7c..9b7913784 100644 --- a/cmd/dendrite-client-api-server/main.go +++ b/cmd/dendrite-client-api-server/main.go @@ -39,7 +39,7 @@ func main() { keyAPI := base.KeyServerHTTPClient() clientapi.AddPublicRoutes( - base.PublicAPIMux, &base.Cfg.ClientAPI, base.KafkaProducer, deviceDB, accountDB, federation, + base.ExternalClientAPIMux, &base.Cfg.ClientAPI, base.KafkaProducer, deviceDB, accountDB, federation, rsAPI, eduInputAPI, asQuery, stateAPI, transactions.New(), fsAPI, userAPI, keyAPI, nil, ) diff --git a/cmd/dendrite-demo-libp2p/main.go b/cmd/dendrite-demo-libp2p/main.go index 5379a7cd8..f73241312 100644 --- a/cmd/dendrite-demo-libp2p/main.go +++ b/cmd/dendrite-demo-libp2p/main.go @@ -23,6 +23,7 @@ import ( "os" "time" + "github.com/gorilla/mux" gostream "github.com/libp2p/go-libp2p-gostream" p2phttp "github.com/libp2p/go-libp2p-http" p2pdisc "github.com/libp2p/go-libp2p/p2p/discovery" @@ -31,6 +32,7 @@ import ( "github.com/matrix-org/dendrite/eduserver" "github.com/matrix-org/dendrite/federationsender" "github.com/matrix-org/dendrite/internal/config" + "github.com/matrix-org/dendrite/internal/httputil" "github.com/matrix-org/dendrite/internal/setup" "github.com/matrix-org/dendrite/keyserver" "github.com/matrix-org/dendrite/roomserver" @@ -189,13 +191,28 @@ func main() { KeyAPI: keyAPI, ExtPublicRoomsProvider: provider, } - monolith.AddAllPublicRoutes(base.Base.PublicAPIMux) + monolith.AddAllPublicRoutes( + base.Base.ExternalClientAPIMux, + base.Base.ExternalFederationAPIMux, + base.Base.ExternalKeyAPIMux, + base.Base.ExternalMediaAPIMux, + ) + + httpRouter := mux.NewRouter() + httpRouter.PathPrefix(httputil.InternalPathPrefix).Handler(base.Base.InternalAPIMux) + httpRouter.PathPrefix(httputil.ExternalClientPathPrefix).Handler(base.Base.ExternalClientAPIMux) + httpRouter.PathPrefix(httputil.ExternalMediaPathPrefix).Handler(base.Base.ExternalMediaAPIMux) + + libp2pRouter := mux.NewRouter() + httpRouter.PathPrefix(httputil.ExternalFederationPathPrefix).Handler(base.Base.ExternalClientAPIMux) + httpRouter.PathPrefix(httputil.ExternalKeyPathPrefix).Handler(base.Base.ExternalClientAPIMux) + httpRouter.PathPrefix(httputil.ExternalMediaPathPrefix).Handler(base.Base.ExternalMediaAPIMux) // Expose the matrix APIs directly rather than putting them under a /api path. go func() { httpBindAddr := fmt.Sprintf(":%d", *instancePort) logrus.Info("Listening on ", httpBindAddr) - logrus.Fatal(http.ListenAndServe(httpBindAddr, base.Base.PublicAPIMux)) + logrus.Fatal(http.ListenAndServe(httpBindAddr, httpRouter)) }() // Expose the matrix APIs also via libp2p if base.LibP2P != nil { @@ -208,7 +225,7 @@ func main() { defer func() { logrus.Fatal(listener.Close()) }() - logrus.Fatal(http.Serve(listener, base.Base.PublicAPIMux)) + logrus.Fatal(http.Serve(listener, libp2pRouter)) }() } diff --git a/cmd/dendrite-demo-yggdrasil/main.go b/cmd/dendrite-demo-yggdrasil/main.go index 1014912ca..52fe07422 100644 --- a/cmd/dendrite-demo-yggdrasil/main.go +++ b/cmd/dendrite-demo-yggdrasil/main.go @@ -23,6 +23,7 @@ import ( "net/http" "time" + "github.com/gorilla/mux" "github.com/matrix-org/dendrite/appservice" "github.com/matrix-org/dendrite/cmd/dendrite-demo-yggdrasil/embed" "github.com/matrix-org/dendrite/cmd/dendrite-demo-yggdrasil/signing" @@ -35,6 +36,7 @@ import ( "github.com/matrix-org/dendrite/federationsender/api" "github.com/matrix-org/dendrite/internal" "github.com/matrix-org/dendrite/internal/config" + "github.com/matrix-org/dendrite/internal/httputil" "github.com/matrix-org/dendrite/internal/setup" "github.com/matrix-org/dendrite/keyserver" "github.com/matrix-org/dendrite/roomserver" @@ -131,7 +133,7 @@ func main() { rsComponent.SetFederationSenderAPI(fsAPI) - embed.Embed(base.PublicAPIMux, *instancePort, "Yggdrasil Demo") + embed.Embed(base.ExternalClientAPIMux, *instancePort, "Yggdrasil Demo") monolith := setup.Monolith{ Config: base.Cfg, @@ -154,7 +156,21 @@ func main() { ygg, fsAPI, federation, ), } - monolith.AddAllPublicRoutes(base.PublicAPIMux) + monolith.AddAllPublicRoutes( + base.ExternalClientAPIMux, + base.ExternalFederationAPIMux, + base.ExternalKeyAPIMux, + base.ExternalMediaAPIMux, + ) + + httpRouter := mux.NewRouter() + httpRouter.PathPrefix(httputil.InternalPathPrefix).Handler(base.InternalAPIMux) + httpRouter.PathPrefix(httputil.ExternalClientPathPrefix).Handler(base.ExternalClientAPIMux) + httpRouter.PathPrefix(httputil.ExternalMediaPathPrefix).Handler(base.ExternalMediaAPIMux) + + yggRouter := mux.NewRouter() + httpRouter.PathPrefix(httputil.ExternalFederationPathPrefix).Handler(base.ExternalClientAPIMux) + httpRouter.PathPrefix(httputil.ExternalMediaPathPrefix).Handler(base.ExternalMediaAPIMux) // Build both ends of a HTTP multiplex. httpServer := &http.Server{ @@ -166,7 +182,7 @@ func main() { BaseContext: func(_ net.Listener) context.Context { return context.Background() }, - Handler: base.PublicAPIMux, + Handler: yggRouter, } go func() { @@ -176,7 +192,7 @@ func main() { go func() { httpBindAddr := fmt.Sprintf(":%d", *instancePort) logrus.Info("Listening on ", httpBindAddr) - logrus.Fatal(http.ListenAndServe(httpBindAddr, base.PublicAPIMux)) + logrus.Fatal(http.ListenAndServe(httpBindAddr, httpRouter)) }() go func() { logrus.Info("Sending wake-up message to known nodes") diff --git a/cmd/dendrite-federation-api-server/main.go b/cmd/dendrite-federation-api-server/main.go index 1753d43c8..8d31c09ae 100644 --- a/cmd/dendrite-federation-api-server/main.go +++ b/cmd/dendrite-federation-api-server/main.go @@ -33,7 +33,8 @@ func main() { keyAPI := base.KeyServerHTTPClient() federationapi.AddPublicRoutes( - base.PublicAPIMux, &base.Cfg.FederationAPI, userAPI, federation, keyRing, + base.ExternalFederationAPIMux, base.ExternalKeyAPIMux, + &base.Cfg.FederationAPI, userAPI, federation, keyRing, rsAPI, fsAPI, base.EDUServerClient(), base.CurrentStateAPIClient(), keyAPI, ) diff --git a/cmd/dendrite-media-api-server/main.go b/cmd/dendrite-media-api-server/main.go index 7a2d44c0b..7e870cbb7 100644 --- a/cmd/dendrite-media-api-server/main.go +++ b/cmd/dendrite-media-api-server/main.go @@ -28,7 +28,7 @@ func main() { userAPI := base.UserAPIClient() client := gomatrixserverlib.NewClient(cfg.FederationSender.DisableTLSValidation) - mediaapi.AddPublicRoutes(base.PublicAPIMux, &base.Cfg.MediaAPI, userAPI, client) + mediaapi.AddPublicRoutes(base.ExternalMediaAPIMux, &base.Cfg.MediaAPI, userAPI, client) base.SetupAndServeHTTP( base.Cfg.MediaAPI.InternalAPI.Listen, diff --git a/cmd/dendrite-monolith-server/main.go b/cmd/dendrite-monolith-server/main.go index cca50c10a..b81fac13b 100644 --- a/cmd/dendrite-monolith-server/main.go +++ b/cmd/dendrite-monolith-server/main.go @@ -145,7 +145,12 @@ func main() { UserAPI: userAPI, KeyAPI: keyAPI, } - monolith.AddAllPublicRoutes(base.PublicAPIMux) + monolith.AddAllPublicRoutes( + base.ExternalClientAPIMux, + base.ExternalFederationAPIMux, + base.ExternalKeyAPIMux, + base.ExternalMediaAPIMux, + ) // Expose the matrix APIs directly rather than putting them under a /api path. go func() { diff --git a/cmd/dendrite-sync-api-server/main.go b/cmd/dendrite-sync-api-server/main.go index 4b041e0a7..83aafc653 100644 --- a/cmd/dendrite-sync-api-server/main.go +++ b/cmd/dendrite-sync-api-server/main.go @@ -30,8 +30,10 @@ func main() { rsAPI := base.RoomserverHTTPClient() syncapi.AddPublicRoutes( - base.PublicAPIMux, base.KafkaConsumer, userAPI, rsAPI, base.KeyServerHTTPClient(), base.CurrentStateAPIClient(), - federation, &cfg.SyncAPI) + base.ExternalClientAPIMux, base.KafkaConsumer, userAPI, rsAPI, + base.KeyServerHTTPClient(), base.CurrentStateAPIClient(), + federation, &cfg.SyncAPI, + ) base.SetupAndServeHTTP( base.Cfg.SyncAPI.InternalAPI.Listen, diff --git a/cmd/dendritejs/main.go b/cmd/dendritejs/main.go index 70abcb4ba..540912af2 100644 --- a/cmd/dendritejs/main.go +++ b/cmd/dendritejs/main.go @@ -235,18 +235,28 @@ func main() { //ServerKeyAPI: serverKeyAPI, ExtPublicRoomsProvider: p2pPublicRoomProvider, } - monolith.AddAllPublicRoutes(base.PublicAPIMux) + monolith.AddAllPublicRoutes( + base.ExternalClientAPIMux, + base.ExternalFederationAPIMux, + base.ExternalKeyAPIMux, + base.ExternalMediaAPIMux, + ) - router := mux.NewRouter() - router.PathPrefix(httputil.InternalPathPrefix).Handler(base.InternalAPIMux) - router.PathPrefix(httputil.PublicPathPrefix).Handler(base.PublicAPIMux) + httpRouter := mux.NewRouter() + httpRouter.PathPrefix(httputil.InternalPathPrefix).Handler(base.InternalAPIMux) + httpRouter.PathPrefix(httputil.ExternalClientPathPrefix).Handler(base.ExternalClientAPIMux) + httpRouter.PathPrefix(httputil.ExternalMediaPathPrefix).Handler(base.ExternalMediaAPIMux) + + libp2pRouter := mux.NewRouter() + httpRouter.PathPrefix(httputil.ExternalFederationPathPrefix).Handler(base.ExternalClientAPIMux) + httpRouter.PathPrefix(httputil.ExternalMediaPathPrefix).Handler(base.ExternalMediaAPIMux) // Expose the matrix APIs via libp2p-js - for federation traffic if node != nil { go func() { logrus.Info("Listening on libp2p-js host ID ", node.Id) s := JSServer{ - Mux: base.PublicAPIMux, + Mux: libp2pRouter, } s.ListenAndServe("p2p") }() @@ -256,7 +266,7 @@ func main() { go func() { logrus.Info("Listening for service-worker fetch traffic") s := JSServer{ - Mux: router, + Mux: httpRouter, } s.ListenAndServe("fetch") }() diff --git a/federationapi/federationapi.go b/federationapi/federationapi.go index e838e8e35..9193685a8 100644 --- a/federationapi/federationapi.go +++ b/federationapi/federationapi.go @@ -30,7 +30,7 @@ import ( // AddPublicRoutes sets up and registers HTTP handlers on the base API muxes for the FederationAPI component. func AddPublicRoutes( - router *mux.Router, + fedRouter, keyRouter *mux.Router, cfg *config.FederationAPI, userAPI userapi.UserInternalAPI, federation *gomatrixserverlib.FederationClient, @@ -42,7 +42,7 @@ func AddPublicRoutes( keyAPI keyserverAPI.KeyInternalAPI, ) { routing.Setup( - router, cfg, rsAPI, + fedRouter, keyRouter, cfg, rsAPI, eduAPI, federationSenderAPI, keyRing, federation, userAPI, stateAPI, keyAPI, ) diff --git a/federationapi/federationapi_test.go b/federationapi/federationapi_test.go index e73dcd29e..55c77f9c4 100644 --- a/federationapi/federationapi_test.go +++ b/federationapi/federationapi_test.go @@ -31,8 +31,8 @@ func TestRoomsV3URLEscapeDoNot404(t *testing.T) { fsAPI := base.FederationSenderHTTPClient() // TODO: This is pretty fragile, as if anything calls anything on these nils this test will break. // Unfortunately, it makes little sense to instantiate these dependencies when we just want to test routing. - federationapi.AddPublicRoutes(base.PublicAPIMux, &cfg.FederationAPI, nil, nil, keyRing, nil, fsAPI, nil, nil, nil) - baseURL, cancel := test.ListenAndServe(t, base.PublicAPIMux, true) + federationapi.AddPublicRoutes(base.ExternalFederationAPIMux, base.ExternalKeyAPIMux, &cfg.FederationAPI, nil, nil, keyRing, nil, fsAPI, nil, nil, nil) + baseURL, cancel := test.ListenAndServe(t, base.ExternalFederationAPIMux, true) defer cancel() serverName := gomatrixserverlib.ServerName(strings.TrimPrefix(baseURL, "https://")) diff --git a/federationapi/routing/routing.go b/federationapi/routing/routing.go index 027827fa6..619296488 100644 --- a/federationapi/routing/routing.go +++ b/federationapi/routing/routing.go @@ -32,9 +32,9 @@ import ( ) const ( - pathPrefixV2Keys = "/key/v2" - pathPrefixV1Federation = "/federation/v1" - pathPrefixV2Federation = "/federation/v2" + pathPrefixV2Keys = "/v2" + pathPrefixV1Federation = "/v1" + pathPrefixV2Federation = "/v2" ) // Setup registers HTTP handlers with the given ServeMux. @@ -46,7 +46,7 @@ const ( // applied: // nolint: gocyclo func Setup( - publicAPIMux *mux.Router, + fedMux, keyMux *mux.Router, cfg *config.FederationAPI, rsAPI roomserverAPI.RoomserverInternalAPI, eduAPI eduserverAPI.EDUServerInputAPI, @@ -57,9 +57,9 @@ func Setup( stateAPI currentstateAPI.CurrentStateInternalAPI, keyAPI keyserverAPI.KeyInternalAPI, ) { - v2keysmux := publicAPIMux.PathPrefix(pathPrefixV2Keys).Subrouter() - v1fedmux := publicAPIMux.PathPrefix(pathPrefixV1Federation).Subrouter() - v2fedmux := publicAPIMux.PathPrefix(pathPrefixV2Federation).Subrouter() + v2keysmux := keyMux.PathPrefix(pathPrefixV2Keys).Subrouter() + v1fedmux := fedMux.PathPrefix(pathPrefixV1Federation).Subrouter() + v2fedmux := fedMux.PathPrefix(pathPrefixV2Federation).Subrouter() wakeup := &httputil.FederationWakeups{ FsAPI: fsAPI, diff --git a/internal/httputil/paths.go b/internal/httputil/paths.go index 728b5a871..b85f01b57 100644 --- a/internal/httputil/paths.go +++ b/internal/httputil/paths.go @@ -15,6 +15,9 @@ package httputil const ( - PublicPathPrefix = "/_matrix/" - InternalPathPrefix = "/api/" + ExternalClientPathPrefix = "/_matrix/client/" + ExternalFederationPathPrefix = "/_matrix/federation/" + ExternalKeyPathPrefix = "/_matrix/key/" + ExternalMediaPathPrefix = "/_matrix/media/" + InternalPathPrefix = "/api/" ) diff --git a/internal/setup/base.go b/internal/setup/base.go index f54f15190..1be7a560c 100644 --- a/internal/setup/base.go +++ b/internal/setup/base.go @@ -62,18 +62,19 @@ import ( // should only be used during start up. // Must be closed when shutting down. type BaseDendrite struct { - componentName string - tracerCloser io.Closer - - // PublicAPIMux should be used to register new public matrix api endpoints - PublicAPIMux *mux.Router - InternalAPIMux *mux.Router - UseHTTPAPIs bool - httpClient *http.Client - Cfg *config.Dendrite - Caches *caching.Caches - KafkaConsumer sarama.Consumer - KafkaProducer sarama.SyncProducer + componentName string + tracerCloser io.Closer + ExternalClientAPIMux *mux.Router + ExternalFederationAPIMux *mux.Router + ExternalKeyAPIMux *mux.Router + ExternalMediaAPIMux *mux.Router + InternalAPIMux *mux.Router + UseHTTPAPIs bool + httpClient *http.Client + Cfg *config.Dendrite + Caches *caching.Caches + KafkaConsumer sarama.Consumer + KafkaProducer sarama.SyncProducer } const HTTPServerTimeout = time.Minute * 5 @@ -136,16 +137,19 @@ func NewBaseDendrite(cfg *config.Dendrite, componentName string, useHTTPAPIs boo // are not inadvertently reading paths without cleaning, else this could introduce a // directory traversal attack e.g /../../../etc/passwd return &BaseDendrite{ - componentName: componentName, - UseHTTPAPIs: useHTTPAPIs, - tracerCloser: closer, - Cfg: cfg, - Caches: cache, - PublicAPIMux: mux.NewRouter().SkipClean(true).PathPrefix(httputil.PublicPathPrefix).Subrouter().UseEncodedPath(), - InternalAPIMux: mux.NewRouter().SkipClean(true).PathPrefix(httputil.InternalPathPrefix).Subrouter().UseEncodedPath(), - httpClient: &client, - KafkaConsumer: kafkaConsumer, - KafkaProducer: kafkaProducer, + componentName: componentName, + UseHTTPAPIs: useHTTPAPIs, + tracerCloser: closer, + Cfg: cfg, + Caches: cache, + ExternalClientAPIMux: mux.NewRouter().SkipClean(true).PathPrefix(httputil.ExternalClientPathPrefix).Subrouter().UseEncodedPath(), + ExternalFederationAPIMux: mux.NewRouter().SkipClean(true).PathPrefix(httputil.ExternalFederationPathPrefix).Subrouter().UseEncodedPath(), + ExternalKeyAPIMux: mux.NewRouter().SkipClean(true).PathPrefix(httputil.ExternalKeyPathPrefix).Subrouter().UseEncodedPath(), + ExternalMediaAPIMux: mux.NewRouter().SkipClean(true).PathPrefix(httputil.ExternalMediaPathPrefix).Subrouter().UseEncodedPath(), + InternalAPIMux: mux.NewRouter().SkipClean(true).PathPrefix(httputil.InternalPathPrefix).Subrouter().UseEncodedPath(), + httpClient: &client, + KafkaConsumer: kafkaConsumer, + KafkaProducer: kafkaProducer, } } @@ -293,7 +297,11 @@ func (b *BaseDendrite) SetupAndServeHTTP( } internalRouter.PathPrefix(httputil.InternalPathPrefix).Handler(b.InternalAPIMux) - externalRouter.PathPrefix(httputil.PublicPathPrefix).Handler(b.PublicAPIMux) + + externalRouter.PathPrefix(httputil.ExternalClientPathPrefix).Handler(b.ExternalClientAPIMux) + externalRouter.PathPrefix(httputil.ExternalKeyPathPrefix).Handler(b.ExternalKeyAPIMux) + externalRouter.PathPrefix(httputil.ExternalFederationPathPrefix).Handler(b.ExternalFederationAPIMux) + externalRouter.PathPrefix(httputil.ExternalMediaPathPrefix).Handler(b.ExternalMediaAPIMux) go func() { defer close(block) diff --git a/internal/setup/monolith.go b/internal/setup/monolith.go index 92bbca72a..5e6c8fcfc 100644 --- a/internal/setup/monolith.go +++ b/internal/setup/monolith.go @@ -63,21 +63,21 @@ type Monolith struct { } // AddAllPublicRoutes attaches all public paths to the given router -func (m *Monolith) AddAllPublicRoutes(publicMux *mux.Router) { +func (m *Monolith) AddAllPublicRoutes(csMux, ssMux, keyMux, mediaMux *mux.Router) { clientapi.AddPublicRoutes( - publicMux, &m.Config.ClientAPI, m.KafkaProducer, m.DeviceDB, m.AccountDB, + csMux, &m.Config.ClientAPI, m.KafkaProducer, m.DeviceDB, m.AccountDB, m.FedClient, m.RoomserverAPI, m.EDUInternalAPI, m.AppserviceAPI, m.StateAPI, transactions.New(), m.FederationSenderAPI, m.UserAPI, m.KeyAPI, m.ExtPublicRoomsProvider, ) federationapi.AddPublicRoutes( - publicMux, &m.Config.FederationAPI, m.UserAPI, m.FedClient, + ssMux, keyMux, &m.Config.FederationAPI, m.UserAPI, m.FedClient, m.KeyRing, m.RoomserverAPI, m.FederationSenderAPI, m.EDUInternalAPI, m.StateAPI, m.KeyAPI, ) - mediaapi.AddPublicRoutes(publicMux, &m.Config.MediaAPI, m.UserAPI, m.Client) + mediaapi.AddPublicRoutes(mediaMux, &m.Config.MediaAPI, m.UserAPI, m.Client) syncapi.AddPublicRoutes( - publicMux, m.KafkaConsumer, m.UserAPI, m.RoomserverAPI, + csMux, m.KafkaConsumer, m.UserAPI, m.RoomserverAPI, m.KeyAPI, m.StateAPI, m.FedClient, &m.Config.SyncAPI, ) }