Add pinecone demo toggle for dis/enabling relaying for other nodes

This commit is contained in:
Devon Hudson 2023-01-29 12:26:16 -07:00
parent 63df85db6d
commit 0f998e3af3
No known key found for this signature in database
GPG key ID: CD06B18E77F6A628
13 changed files with 119 additions and 25 deletions

View file

@ -27,6 +27,7 @@ import (
"github.com/matrix-org/dendrite/setup/config"
"github.com/matrix-org/gomatrixserverlib"
"github.com/matrix-org/util"
"github.com/sirupsen/logrus"
)
// Setup registers HTTP handlers with the given ServeMux.
@ -48,6 +49,14 @@ func Setup(
v1fedmux.Handle("/send_relay/{txnID}/{userID}", MakeRelayAPI(
"send_relay_transaction", "", cfg.Matrix.IsLocalServerName, keys,
func(httpReq *http.Request, request *gomatrixserverlib.FederationRequest, vars map[string]string) util.JSONResponse {
logrus.Infof("Handling send_relay from: %s", request.Origin())
if !relayAPI.RelayingEnabled() {
logrus.Warnf("Dropping send_relay from: %s", request.Origin())
return util.JSONResponse{
Code: http.StatusNotFound,
}
}
userID, err := gomatrixserverlib.NewUserID(vars["userID"], false)
if err != nil {
return util.JSONResponse{
@ -65,6 +74,14 @@ func Setup(
v1fedmux.Handle("/relay_txn/{userID}", MakeRelayAPI(
"get_relay_transaction", "", cfg.Matrix.IsLocalServerName, keys,
func(httpReq *http.Request, request *gomatrixserverlib.FederationRequest, vars map[string]string) util.JSONResponse {
logrus.Infof("Handling relay_txn from: %s", request.Origin())
if !relayAPI.RelayingEnabled() {
logrus.Warnf("Dropping relay_txn from: %s", request.Origin())
return util.JSONResponse{
Code: http.StatusNotFound,
}
}
userID, err := gomatrixserverlib.NewUserID(vars["userID"], false)
if err != nil {
return util.JSONResponse{