mirror of
https://github.com/1f349/dendrite.git
synced 2024-11-08 18:16:59 +00:00
Use HTTP APIs when -api specified (#1057)
This commit is contained in:
parent
fe82e1f725
commit
fbdcfdd256
@ -27,6 +27,7 @@ import (
|
||||
"github.com/matrix-org/dendrite/federationsender"
|
||||
"github.com/matrix-org/dendrite/internal"
|
||||
"github.com/matrix-org/dendrite/internal/basecomponent"
|
||||
"github.com/matrix-org/dendrite/internal/config"
|
||||
"github.com/matrix-org/dendrite/internal/keydb"
|
||||
"github.com/matrix-org/dendrite/internal/transactions"
|
||||
"github.com/matrix-org/dendrite/keyserver"
|
||||
@ -44,11 +45,23 @@ var (
|
||||
httpsBindAddr = flag.String("https-bind-address", ":8448", "The HTTPS listening port for the server")
|
||||
certFile = flag.String("tls-cert", "", "The PEM formatted X509 certificate to use for TLS")
|
||||
keyFile = flag.String("tls-key", "", "The PEM private key to use for TLS")
|
||||
enableHTTPAPIs = flag.Bool("api", false, "Expose internal HTTP APIs in monolith mode")
|
||||
enableHTTPAPIs = flag.Bool("api", false, "Use HTTP APIs instead of short-circuiting (warning: exposes API endpoints!)")
|
||||
)
|
||||
|
||||
func main() {
|
||||
cfg := basecomponent.ParseMonolithFlags()
|
||||
if *enableHTTPAPIs {
|
||||
// If the HTTP APIs are enabled then we need to update the Listen
|
||||
// statements in the configuration so that we know where to find
|
||||
// the API endpoints. They'll listen on the same port as the monolith
|
||||
// itself.
|
||||
addr := config.Address(*httpBindAddr)
|
||||
cfg.Listen.RoomServer = addr
|
||||
cfg.Listen.EDUServer = addr
|
||||
cfg.Listen.AppServiceAPI = addr
|
||||
cfg.Listen.FederationSender = addr
|
||||
}
|
||||
|
||||
base := basecomponent.NewBaseDendrite(cfg, "Monolith", *enableHTTPAPIs)
|
||||
defer base.Close() // nolint: errcheck
|
||||
|
||||
@ -61,15 +74,30 @@ func main() {
|
||||
rsAPI := roomserver.SetupRoomServerComponent(
|
||||
base, keyRing, federation,
|
||||
)
|
||||
if base.EnableHTTPAPIs {
|
||||
rsAPI = base.CreateHTTPRoomserverAPIs()
|
||||
}
|
||||
|
||||
eduInputAPI := eduserver.SetupEDUServerComponent(
|
||||
base, cache.New(),
|
||||
)
|
||||
if base.EnableHTTPAPIs {
|
||||
eduInputAPI = base.CreateHTTPEDUServerAPIs()
|
||||
}
|
||||
|
||||
asAPI := appservice.SetupAppServiceAPIComponent(
|
||||
base, accountDB, deviceDB, federation, rsAPI, transactions.New(),
|
||||
)
|
||||
if base.EnableHTTPAPIs {
|
||||
asAPI = base.CreateHTTPAppServiceAPIs()
|
||||
}
|
||||
|
||||
fsAPI := federationsender.SetupFederationSenderComponent(
|
||||
base, federation, rsAPI, &keyRing,
|
||||
)
|
||||
if base.EnableHTTPAPIs {
|
||||
fsAPI = base.CreateHTTPFederationSenderAPIs()
|
||||
}
|
||||
rsAPI.SetFederationSenderAPI(fsAPI)
|
||||
|
||||
clientapi.SetupClientAPIComponent(
|
||||
@ -77,6 +105,7 @@ func main() {
|
||||
federation, &keyRing, rsAPI,
|
||||
eduInputAPI, asAPI, transactions.New(), fsAPI,
|
||||
)
|
||||
|
||||
keyserver.SetupKeyServerComponent(
|
||||
base, deviceDB, accountDB,
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user