mirror of
https://github.com/matrix-org/dendrite.git
synced 2025-12-21 13:53:09 -06:00
Break apart client/federation/key/media muxes
This commit is contained in:
parent
8382a9dcc2
commit
89ab97be74
|
|
@ -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")
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -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))
|
||||
}()
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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")
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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() {
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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")
|
||||
}()
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -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://"))
|
||||
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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/"
|
||||
)
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue