mirror of
https://github.com/1f349/dendrite.git
synced 2024-11-25 13:11:37 +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/federationsender"
|
||||||
"github.com/matrix-org/dendrite/internal"
|
"github.com/matrix-org/dendrite/internal"
|
||||||
"github.com/matrix-org/dendrite/internal/basecomponent"
|
"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/keydb"
|
||||||
"github.com/matrix-org/dendrite/internal/transactions"
|
"github.com/matrix-org/dendrite/internal/transactions"
|
||||||
"github.com/matrix-org/dendrite/keyserver"
|
"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")
|
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")
|
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")
|
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() {
|
func main() {
|
||||||
cfg := basecomponent.ParseMonolithFlags()
|
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)
|
base := basecomponent.NewBaseDendrite(cfg, "Monolith", *enableHTTPAPIs)
|
||||||
defer base.Close() // nolint: errcheck
|
defer base.Close() // nolint: errcheck
|
||||||
|
|
||||||
@ -61,15 +74,30 @@ func main() {
|
|||||||
rsAPI := roomserver.SetupRoomServerComponent(
|
rsAPI := roomserver.SetupRoomServerComponent(
|
||||||
base, keyRing, federation,
|
base, keyRing, federation,
|
||||||
)
|
)
|
||||||
|
if base.EnableHTTPAPIs {
|
||||||
|
rsAPI = base.CreateHTTPRoomserverAPIs()
|
||||||
|
}
|
||||||
|
|
||||||
eduInputAPI := eduserver.SetupEDUServerComponent(
|
eduInputAPI := eduserver.SetupEDUServerComponent(
|
||||||
base, cache.New(),
|
base, cache.New(),
|
||||||
)
|
)
|
||||||
|
if base.EnableHTTPAPIs {
|
||||||
|
eduInputAPI = base.CreateHTTPEDUServerAPIs()
|
||||||
|
}
|
||||||
|
|
||||||
asAPI := appservice.SetupAppServiceAPIComponent(
|
asAPI := appservice.SetupAppServiceAPIComponent(
|
||||||
base, accountDB, deviceDB, federation, rsAPI, transactions.New(),
|
base, accountDB, deviceDB, federation, rsAPI, transactions.New(),
|
||||||
)
|
)
|
||||||
|
if base.EnableHTTPAPIs {
|
||||||
|
asAPI = base.CreateHTTPAppServiceAPIs()
|
||||||
|
}
|
||||||
|
|
||||||
fsAPI := federationsender.SetupFederationSenderComponent(
|
fsAPI := federationsender.SetupFederationSenderComponent(
|
||||||
base, federation, rsAPI, &keyRing,
|
base, federation, rsAPI, &keyRing,
|
||||||
)
|
)
|
||||||
|
if base.EnableHTTPAPIs {
|
||||||
|
fsAPI = base.CreateHTTPFederationSenderAPIs()
|
||||||
|
}
|
||||||
rsAPI.SetFederationSenderAPI(fsAPI)
|
rsAPI.SetFederationSenderAPI(fsAPI)
|
||||||
|
|
||||||
clientapi.SetupClientAPIComponent(
|
clientapi.SetupClientAPIComponent(
|
||||||
@ -77,6 +105,7 @@ func main() {
|
|||||||
federation, &keyRing, rsAPI,
|
federation, &keyRing, rsAPI,
|
||||||
eduInputAPI, asAPI, transactions.New(), fsAPI,
|
eduInputAPI, asAPI, transactions.New(), fsAPI,
|
||||||
)
|
)
|
||||||
|
|
||||||
keyserver.SetupKeyServerComponent(
|
keyserver.SetupKeyServerComponent(
|
||||||
base, deviceDB, accountDB,
|
base, deviceDB, accountDB,
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user