mirror of
https://github.com/1f349/dendrite.git
synced 2024-11-22 11:41:38 +00:00
Fix keyring regressions in previous P2P demo
This commit is contained in:
parent
c3dda0779d
commit
3113210f17
@ -310,7 +310,7 @@ func (m *DendriteMonolith) Start() {
|
|||||||
rsAPI := roomserver.NewInternalAPI(base)
|
rsAPI := roomserver.NewInternalAPI(base)
|
||||||
|
|
||||||
fsAPI := federationapi.NewInternalAPI(
|
fsAPI := federationapi.NewInternalAPI(
|
||||||
base, federation, rsAPI, base.Caches, true,
|
base, federation, rsAPI, base.Caches, keyRing, true,
|
||||||
)
|
)
|
||||||
|
|
||||||
keyAPI := keyserver.NewInternalAPI(base, &base.Cfg.KeyServer, fsAPI)
|
keyAPI := keyserver.NewInternalAPI(base, &base.Cfg.KeyServer, fsAPI)
|
||||||
@ -325,8 +325,7 @@ func (m *DendriteMonolith) Start() {
|
|||||||
|
|
||||||
// The underlying roomserver implementation needs to be able to call the fedsender.
|
// The underlying roomserver implementation needs to be able to call the fedsender.
|
||||||
// This is different to rsAPI which can be the http client which doesn't need this dependency
|
// This is different to rsAPI which can be the http client which doesn't need this dependency
|
||||||
rsAPI.SetFederationAPI(fsAPI)
|
rsAPI.SetFederationAPI(fsAPI, keyRing)
|
||||||
rsAPI.SetKeyring(keyRing)
|
|
||||||
|
|
||||||
monolith := setup.Monolith{
|
monolith := setup.Monolith{
|
||||||
Config: base.Cfg,
|
Config: base.Cfg,
|
||||||
|
@ -114,7 +114,7 @@ func (m *DendriteMonolith) Start() {
|
|||||||
rsAPI := roomserver.NewInternalAPI(base)
|
rsAPI := roomserver.NewInternalAPI(base)
|
||||||
|
|
||||||
fsAPI := federationapi.NewInternalAPI(
|
fsAPI := federationapi.NewInternalAPI(
|
||||||
base, federation, rsAPI, base.Caches, true,
|
base, federation, rsAPI, base.Caches, keyRing, true,
|
||||||
)
|
)
|
||||||
|
|
||||||
keyAPI := keyserver.NewInternalAPI(base, &base.Cfg.KeyServer, federation)
|
keyAPI := keyserver.NewInternalAPI(base, &base.Cfg.KeyServer, federation)
|
||||||
@ -130,8 +130,7 @@ func (m *DendriteMonolith) Start() {
|
|||||||
|
|
||||||
// The underlying roomserver implementation needs to be able to call the fedsender.
|
// The underlying roomserver implementation needs to be able to call the fedsender.
|
||||||
// This is different to rsAPI which can be the http client which doesn't need this dependency
|
// This is different to rsAPI which can be the http client which doesn't need this dependency
|
||||||
rsAPI.SetFederationAPI(fsAPI)
|
rsAPI.SetFederationAPI(fsAPI, keyRing)
|
||||||
rsAPI.SetKeyring(keyRing)
|
|
||||||
|
|
||||||
monolith := setup.Monolith{
|
monolith := setup.Monolith{
|
||||||
Config: base.Cfg,
|
Config: base.Cfg,
|
||||||
|
@ -158,10 +158,10 @@ func main() {
|
|||||||
asAPI := appservice.NewInternalAPI(&base.Base, userAPI, rsAPI)
|
asAPI := appservice.NewInternalAPI(&base.Base, userAPI, rsAPI)
|
||||||
rsAPI.SetAppserviceAPI(asAPI)
|
rsAPI.SetAppserviceAPI(asAPI)
|
||||||
fsAPI := federationapi.NewInternalAPI(
|
fsAPI := federationapi.NewInternalAPI(
|
||||||
&base.Base, federation, rsAPI, base.Base.Caches, true,
|
&base.Base, federation, rsAPI, base.Base.Caches, nil, true,
|
||||||
)
|
)
|
||||||
keyRing := fsAPI.KeyRing()
|
keyRing := fsAPI.KeyRing()
|
||||||
rsAPI.SetFederationAPI(fsAPI)
|
rsAPI.SetFederationAPI(fsAPI, keyRing)
|
||||||
provider := newPublicRoomsProvider(base.LibP2PPubsub, rsAPI)
|
provider := newPublicRoomsProvider(base.LibP2PPubsub, rsAPI)
|
||||||
err = provider.Start()
|
err = provider.Start()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -185,7 +185,7 @@ func main() {
|
|||||||
rsComponent := roomserver.NewInternalAPI(base)
|
rsComponent := roomserver.NewInternalAPI(base)
|
||||||
rsAPI := rsComponent
|
rsAPI := rsComponent
|
||||||
fsAPI := federationapi.NewInternalAPI(
|
fsAPI := federationapi.NewInternalAPI(
|
||||||
base, federation, rsAPI, base.Caches, true,
|
base, federation, rsAPI, base.Caches, keyRing, true,
|
||||||
)
|
)
|
||||||
|
|
||||||
keyAPI := keyserver.NewInternalAPI(base, &base.Cfg.KeyServer, fsAPI)
|
keyAPI := keyserver.NewInternalAPI(base, &base.Cfg.KeyServer, fsAPI)
|
||||||
@ -198,8 +198,7 @@ func main() {
|
|||||||
|
|
||||||
asAPI := appservice.NewInternalAPI(base, userAPI, rsAPI)
|
asAPI := appservice.NewInternalAPI(base, userAPI, rsAPI)
|
||||||
|
|
||||||
rsComponent.SetFederationAPI(fsAPI)
|
rsComponent.SetFederationAPI(fsAPI, keyRing)
|
||||||
rsComponent.SetKeyring(keyRing)
|
|
||||||
|
|
||||||
monolith := setup.Monolith{
|
monolith := setup.Monolith{
|
||||||
Config: base.Cfg,
|
Config: base.Cfg,
|
||||||
|
@ -118,11 +118,10 @@ func main() {
|
|||||||
asAPI := appservice.NewInternalAPI(base, userAPI, rsAPI)
|
asAPI := appservice.NewInternalAPI(base, userAPI, rsAPI)
|
||||||
rsAPI.SetAppserviceAPI(asAPI)
|
rsAPI.SetAppserviceAPI(asAPI)
|
||||||
fsAPI := federationapi.NewInternalAPI(
|
fsAPI := federationapi.NewInternalAPI(
|
||||||
base, federation, rsAPI, base.Caches, true,
|
base, federation, rsAPI, base.Caches, keyRing, true,
|
||||||
)
|
)
|
||||||
|
|
||||||
rsComponent.SetFederationAPI(fsAPI)
|
rsComponent.SetFederationAPI(fsAPI, keyRing)
|
||||||
rsComponent.SetKeyring(keyRing)
|
|
||||||
|
|
||||||
monolith := setup.Monolith{
|
monolith := setup.Monolith{
|
||||||
Config: base.Cfg,
|
Config: base.Cfg,
|
||||||
|
@ -91,7 +91,7 @@ func main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fsAPI := federationapi.NewInternalAPI(
|
fsAPI := federationapi.NewInternalAPI(
|
||||||
base, federation, rsAPI, base.Caches, false,
|
base, federation, rsAPI, base.Caches, nil, false,
|
||||||
)
|
)
|
||||||
if base.UseHTTPAPIs {
|
if base.UseHTTPAPIs {
|
||||||
federationapi.AddInternalRoutes(base.InternalAPIMux, fsAPI)
|
federationapi.AddInternalRoutes(base.InternalAPIMux, fsAPI)
|
||||||
@ -101,7 +101,7 @@ func main() {
|
|||||||
|
|
||||||
// The underlying roomserver implementation needs to be able to call the fedsender.
|
// The underlying roomserver implementation needs to be able to call the fedsender.
|
||||||
// This is different to rsAPI which can be the http client which doesn't need this dependency
|
// This is different to rsAPI which can be the http client which doesn't need this dependency
|
||||||
rsImpl.SetFederationAPI(fsAPI)
|
rsImpl.SetFederationAPI(fsAPI, keyRing)
|
||||||
|
|
||||||
keyImpl := keyserver.NewInternalAPI(base, &base.Cfg.KeyServer, fsAPI)
|
keyImpl := keyserver.NewInternalAPI(base, &base.Cfg.KeyServer, fsAPI)
|
||||||
keyAPI := keyImpl
|
keyAPI := keyImpl
|
||||||
@ -134,7 +134,7 @@ func main() {
|
|||||||
// The underlying roomserver implementation needs to be able to call the fedsender.
|
// The underlying roomserver implementation needs to be able to call the fedsender.
|
||||||
// This is different to rsAPI which can be the http client which doesn't need this
|
// This is different to rsAPI which can be the http client which doesn't need this
|
||||||
// dependency. Other components also need updating after their dependencies are up.
|
// dependency. Other components also need updating after their dependencies are up.
|
||||||
rsImpl.SetFederationAPI(fsAPI)
|
rsImpl.SetFederationAPI(fsAPI, keyRing)
|
||||||
rsImpl.SetAppserviceAPI(asAPI)
|
rsImpl.SetAppserviceAPI(asAPI)
|
||||||
keyImpl.SetUserAPI(userAPI)
|
keyImpl.SetUserAPI(userAPI)
|
||||||
|
|
||||||
|
@ -35,7 +35,7 @@ func FederationAPI(base *basepkg.BaseDendrite, cfg *config.Dendrite) {
|
|||||||
&base.Cfg.MSCs, nil,
|
&base.Cfg.MSCs, nil,
|
||||||
)
|
)
|
||||||
|
|
||||||
intAPI := federationapi.NewInternalAPI(base, federation, rsAPI, base.Caches, true)
|
intAPI := federationapi.NewInternalAPI(base, federation, rsAPI, base.Caches, nil, true)
|
||||||
federationapi.AddInternalRoutes(base.InternalAPIMux, intAPI)
|
federationapi.AddInternalRoutes(base.InternalAPIMux, intAPI)
|
||||||
|
|
||||||
base.SetupAndServeHTTP(
|
base.SetupAndServeHTTP(
|
||||||
|
@ -24,7 +24,7 @@ func RoomServer(base *basepkg.BaseDendrite, cfg *config.Dendrite) {
|
|||||||
asAPI := base.AppserviceHTTPClient()
|
asAPI := base.AppserviceHTTPClient()
|
||||||
fsAPI := base.FederationAPIHTTPClient()
|
fsAPI := base.FederationAPIHTTPClient()
|
||||||
rsAPI := roomserver.NewInternalAPI(base)
|
rsAPI := roomserver.NewInternalAPI(base)
|
||||||
rsAPI.SetFederationAPI(fsAPI)
|
rsAPI.SetFederationAPI(fsAPI, fsAPI.KeyRing())
|
||||||
rsAPI.SetAppserviceAPI(asAPI)
|
rsAPI.SetAppserviceAPI(asAPI)
|
||||||
roomserver.AddInternalRoutes(base.InternalAPIMux, rsAPI)
|
roomserver.AddInternalRoutes(base.InternalAPIMux, rsAPI)
|
||||||
|
|
||||||
|
@ -199,8 +199,7 @@ func startup() {
|
|||||||
)
|
)
|
||||||
rsAPI.SetAppserviceAPI(asQuery)
|
rsAPI.SetAppserviceAPI(asQuery)
|
||||||
fedSenderAPI := federationapi.NewInternalAPI(base, federation, rsAPI, base.Caches, true)
|
fedSenderAPI := federationapi.NewInternalAPI(base, federation, rsAPI, base.Caches, true)
|
||||||
rsAPI.SetFederationAPI(fedSenderAPI)
|
rsAPI.SetFederationAPI(fedSenderAPI, keyRing)
|
||||||
rsAPI.SetKeyring(keyRing)
|
|
||||||
|
|
||||||
monolith := setup.Monolith{
|
monolith := setup.Monolith{
|
||||||
Config: base.Cfg,
|
Config: base.Cfg,
|
||||||
|
@ -211,8 +211,7 @@ func main() {
|
|||||||
)
|
)
|
||||||
rsAPI.SetAppserviceAPI(asQuery)
|
rsAPI.SetAppserviceAPI(asQuery)
|
||||||
fedSenderAPI := federationapi.NewInternalAPI(base, federation, rsAPI, base.Caches, true)
|
fedSenderAPI := federationapi.NewInternalAPI(base, federation, rsAPI, base.Caches, true)
|
||||||
rsAPI.SetFederationAPI(fedSenderAPI)
|
rsAPI.SetFederationAPI(fedSenderAPI, keyRing)
|
||||||
rsAPI.SetKeyring(keyRing)
|
|
||||||
p2pPublicRoomProvider := NewLibP2PPublicRoomsProvider(node, fedSenderAPI, federation)
|
p2pPublicRoomProvider := NewLibP2PPublicRoomsProvider(node, fedSenderAPI, federation)
|
||||||
|
|
||||||
monolith := setup.Monolith{
|
monolith := setup.Monolith{
|
||||||
|
@ -73,6 +73,7 @@ func NewInternalAPI(
|
|||||||
federation *gomatrixserverlib.FederationClient,
|
federation *gomatrixserverlib.FederationClient,
|
||||||
rsAPI roomserverAPI.RoomserverInternalAPI,
|
rsAPI roomserverAPI.RoomserverInternalAPI,
|
||||||
caches *caching.Caches,
|
caches *caching.Caches,
|
||||||
|
keyRing *gomatrixserverlib.KeyRing,
|
||||||
resetBlacklist bool,
|
resetBlacklist bool,
|
||||||
) api.FederationInternalAPI {
|
) api.FederationInternalAPI {
|
||||||
cfg := &base.Cfg.FederationAPI
|
cfg := &base.Cfg.FederationAPI
|
||||||
@ -125,5 +126,5 @@ func NewInternalAPI(
|
|||||||
logrus.WithError(err).Panic("failed to start key server consumer")
|
logrus.WithError(err).Panic("failed to start key server consumer")
|
||||||
}
|
}
|
||||||
|
|
||||||
return internal.NewFederationInternalAPI(federationDB, cfg, rsAPI, federation, stats, caches, queues)
|
return internal.NewFederationInternalAPI(federationDB, cfg, rsAPI, federation, stats, caches, queues, keyRing)
|
||||||
}
|
}
|
||||||
|
@ -94,7 +94,7 @@ func TestMain(m *testing.M) {
|
|||||||
|
|
||||||
// Finally, build the server key APIs.
|
// Finally, build the server key APIs.
|
||||||
sbase := base.NewBaseDendrite(cfg, "Monolith", base.NoCacheMetrics)
|
sbase := base.NewBaseDendrite(cfg, "Monolith", base.NoCacheMetrics)
|
||||||
s.api = NewInternalAPI(sbase, s.fedclient, nil, s.cache, true)
|
s.api = NewInternalAPI(sbase, s.fedclient, nil, s.cache, nil, true)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Now that we have built our server key APIs, start the
|
// Now that we have built our server key APIs, start the
|
||||||
|
@ -39,13 +39,15 @@ func NewFederationInternalAPI(
|
|||||||
statistics *statistics.Statistics,
|
statistics *statistics.Statistics,
|
||||||
caches *caching.Caches,
|
caches *caching.Caches,
|
||||||
queues *queue.OutgoingQueues,
|
queues *queue.OutgoingQueues,
|
||||||
|
keyRing *gomatrixserverlib.KeyRing,
|
||||||
) *FederationInternalAPI {
|
) *FederationInternalAPI {
|
||||||
serverKeyDB, err := cache.NewKeyDatabase(db, caches)
|
serverKeyDB, err := cache.NewKeyDatabase(db, caches)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logrus.WithError(err).Panicf("failed to set up caching wrapper for server key database")
|
logrus.WithError(err).Panicf("failed to set up caching wrapper for server key database")
|
||||||
}
|
}
|
||||||
|
|
||||||
keyRing := &gomatrixserverlib.KeyRing{
|
if keyRing == nil {
|
||||||
|
keyRing = &gomatrixserverlib.KeyRing{
|
||||||
KeyFetchers: []gomatrixserverlib.KeyFetcher{},
|
KeyFetchers: []gomatrixserverlib.KeyFetcher{},
|
||||||
KeyDatabase: serverKeyDB,
|
KeyDatabase: serverKeyDB,
|
||||||
}
|
}
|
||||||
@ -92,6 +94,7 @@ func NewFederationInternalAPI(
|
|||||||
"num_public_keys": len(ps.Keys),
|
"num_public_keys": len(ps.Keys),
|
||||||
}).Info("Enabled perspective key fetcher")
|
}).Info("Enabled perspective key fetcher")
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return &FederationInternalAPI{
|
return &FederationInternalAPI{
|
||||||
db: db,
|
db: db,
|
||||||
|
@ -12,9 +12,8 @@ import (
|
|||||||
type RoomserverInternalAPI interface {
|
type RoomserverInternalAPI interface {
|
||||||
// needed to avoid chicken and egg scenario when setting up the
|
// needed to avoid chicken and egg scenario when setting up the
|
||||||
// interdependencies between the roomserver and other input APIs
|
// interdependencies between the roomserver and other input APIs
|
||||||
SetFederationAPI(fsAPI fsAPI.FederationInternalAPI)
|
SetFederationAPI(fsAPI fsAPI.FederationInternalAPI, keyRing *gomatrixserverlib.KeyRing)
|
||||||
SetAppserviceAPI(asAPI asAPI.AppServiceQueryAPI)
|
SetAppserviceAPI(asAPI asAPI.AppServiceQueryAPI)
|
||||||
SetKeyring(keyRing *gomatrixserverlib.KeyRing)
|
|
||||||
|
|
||||||
InputRoomEvents(
|
InputRoomEvents(
|
||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
|
@ -17,12 +17,8 @@ type RoomserverInternalAPITrace struct {
|
|||||||
Impl RoomserverInternalAPI
|
Impl RoomserverInternalAPI
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *RoomserverInternalAPITrace) SetKeyring(keyRing *gomatrixserverlib.KeyRing) {
|
func (t *RoomserverInternalAPITrace) SetFederationAPI(fsAPI fsAPI.FederationInternalAPI, keyRing *gomatrixserverlib.KeyRing) {
|
||||||
t.Impl.SetKeyring(keyRing)
|
t.Impl.SetFederationAPI(fsAPI, keyRing)
|
||||||
}
|
|
||||||
|
|
||||||
func (t *RoomserverInternalAPITrace) SetFederationAPI(fsAPI fsAPI.FederationInternalAPI) {
|
|
||||||
t.Impl.SetFederationAPI(fsAPI)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *RoomserverInternalAPITrace) SetAppserviceAPI(asAPI asAPI.AppServiceQueryAPI) {
|
func (t *RoomserverInternalAPITrace) SetAppserviceAPI(asAPI asAPI.AppServiceQueryAPI) {
|
||||||
|
@ -73,18 +73,12 @@ func NewRoomserverAPI(
|
|||||||
return a
|
return a
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetKeyring sets the keyring to a given keyring. This is only useful for the P2P
|
|
||||||
// demos and must be called after SetFederationSenderInputAPI.
|
|
||||||
func (r *RoomserverInternalAPI) SetKeyring(keyRing *gomatrixserverlib.KeyRing) {
|
|
||||||
r.KeyRing = keyRing
|
|
||||||
}
|
|
||||||
|
|
||||||
// SetFederationInputAPI passes in a federation input API reference so that we can
|
// SetFederationInputAPI passes in a federation input API reference so that we can
|
||||||
// avoid the chicken-and-egg problem of both the roomserver input API and the
|
// avoid the chicken-and-egg problem of both the roomserver input API and the
|
||||||
// federation input API being interdependent.
|
// federation input API being interdependent.
|
||||||
func (r *RoomserverInternalAPI) SetFederationAPI(fsAPI fsAPI.FederationInternalAPI) {
|
func (r *RoomserverInternalAPI) SetFederationAPI(fsAPI fsAPI.FederationInternalAPI, keyRing *gomatrixserverlib.KeyRing) {
|
||||||
r.fsAPI = fsAPI
|
r.fsAPI = fsAPI
|
||||||
r.SetKeyring(fsAPI.KeyRing())
|
r.KeyRing = keyRing
|
||||||
|
|
||||||
r.Inviter = &perform.Inviter{
|
r.Inviter = &perform.Inviter{
|
||||||
DB: r.DB,
|
DB: r.DB,
|
||||||
|
@ -83,12 +83,8 @@ func NewRoomserverClient(
|
|||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetKeyring no-ops in HTTP client mode as there is no chicken/egg scenario
|
|
||||||
func (h *httpRoomserverInternalAPI) SetKeyring(keyRing *gomatrixserverlib.KeyRing) {
|
|
||||||
}
|
|
||||||
|
|
||||||
// SetFederationInputAPI no-ops in HTTP client mode as there is no chicken/egg scenario
|
// SetFederationInputAPI no-ops in HTTP client mode as there is no chicken/egg scenario
|
||||||
func (h *httpRoomserverInternalAPI) SetFederationAPI(fsAPI fsInputAPI.FederationInternalAPI) {
|
func (h *httpRoomserverInternalAPI) SetFederationAPI(fsAPI fsInputAPI.FederationInternalAPI, keyRing *gomatrixserverlib.KeyRing) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetAppserviceAPI no-ops in HTTP client mode as there is no chicken/egg scenario
|
// SetAppserviceAPI no-ops in HTTP client mode as there is no chicken/egg scenario
|
||||||
|
Loading…
Reference in New Issue
Block a user