mirror of
https://github.com/hoernschen/dendrite.git
synced 2025-07-29 12:42:46 +00:00
Merge federationapi
, federationsender
, signingkeyserver
components (#2055)
* Initial federation sender -> federation API refactoring * Move base into own package, avoids import cycle * Fix build errors * Fix tests * Add signing key server tables * Try to fold signing key server into federation API * Fix dendritejs builds * Update embedded interfaces * Fix panic, fix lint error * Update configs, docker * Rename some things * Reuse same keyring on the implementing side * Fix federation tests, `NewBaseDendrite` can accept freeform options * Fix build * Update create_db, configs * Name tables back * Don't rename federationsender consumer for now
This commit is contained in:
parent
6e93531e94
commit
ec716793eb
136 changed files with 1211 additions and 1786 deletions
|
@ -30,14 +30,13 @@ import (
|
|||
"github.com/matrix-org/dendrite/appservice"
|
||||
"github.com/matrix-org/dendrite/cmd/dendrite-demo-yggdrasil/embed"
|
||||
"github.com/matrix-org/dendrite/eduserver"
|
||||
"github.com/matrix-org/dendrite/federationsender"
|
||||
"github.com/matrix-org/dendrite/federationapi"
|
||||
"github.com/matrix-org/dendrite/internal/httputil"
|
||||
"github.com/matrix-org/dendrite/keyserver"
|
||||
"github.com/matrix-org/dendrite/roomserver"
|
||||
"github.com/matrix-org/dendrite/setup"
|
||||
"github.com/matrix-org/dendrite/setup/config"
|
||||
"github.com/matrix-org/dendrite/setup/mscs"
|
||||
"github.com/matrix-org/dendrite/signingkeyserver"
|
||||
"github.com/matrix-org/dendrite/userapi"
|
||||
"github.com/matrix-org/gomatrixserverlib"
|
||||
|
||||
|
@ -50,7 +49,7 @@ import (
|
|||
|
||||
func createKeyDB(
|
||||
base *P2PDendrite,
|
||||
db gomatrixserverlib.KeyDatabase,
|
||||
db *gomatrixserverlib.KeyRing,
|
||||
) {
|
||||
mdns := mDNSListener{
|
||||
host: base.LibP2P,
|
||||
|
@ -125,14 +124,13 @@ func main() {
|
|||
cfg.Global.PrivateKey = privKey
|
||||
cfg.Global.KeyID = gomatrixserverlib.KeyID(fmt.Sprintf("ed25519:%s", *instanceName))
|
||||
cfg.Global.Kafka.UseNaffka = true
|
||||
cfg.FederationSender.FederationMaxRetries = 6
|
||||
cfg.FederationAPI.FederationMaxRetries = 6
|
||||
cfg.UserAPI.AccountDatabase.ConnectionString = config.DataSource(fmt.Sprintf("file:%s-account.db", *instanceName))
|
||||
cfg.UserAPI.DeviceDatabase.ConnectionString = config.DataSource(fmt.Sprintf("file:%s-device.db", *instanceName))
|
||||
cfg.MediaAPI.Database.ConnectionString = config.DataSource(fmt.Sprintf("file:%s-mediaapi.db", *instanceName))
|
||||
cfg.SyncAPI.Database.ConnectionString = config.DataSource(fmt.Sprintf("file:%s-syncapi.db", *instanceName))
|
||||
cfg.RoomServer.Database.ConnectionString = config.DataSource(fmt.Sprintf("file:%s-roomserver.db", *instanceName))
|
||||
cfg.SigningKeyServer.Database.ConnectionString = config.DataSource(fmt.Sprintf("file:%s-signingkeyserver.db", *instanceName))
|
||||
cfg.FederationSender.Database.ConnectionString = config.DataSource(fmt.Sprintf("file:%s-federationsender.db", *instanceName))
|
||||
cfg.FederationAPI.Database.ConnectionString = config.DataSource(fmt.Sprintf("file:%s-federationapi.db", *instanceName))
|
||||
cfg.AppServiceAPI.Database.ConnectionString = config.DataSource(fmt.Sprintf("file:%s-appservice.db", *instanceName))
|
||||
cfg.Global.Kafka.Database.ConnectionString = config.DataSource(fmt.Sprintf("file:%s-naffka.db", *instanceName))
|
||||
cfg.KeyServer.Database.ConnectionString = config.DataSource(fmt.Sprintf("file:%s-e2ekey.db", *instanceName))
|
||||
|
@ -151,32 +149,29 @@ func main() {
|
|||
userAPI := userapi.NewInternalAPI(accountDB, &cfg.UserAPI, nil, keyAPI)
|
||||
keyAPI.SetUserAPI(userAPI)
|
||||
|
||||
serverKeyAPI := signingkeyserver.NewInternalAPI(
|
||||
&base.Base.Cfg.SigningKeyServer, federation, base.Base.Caches,
|
||||
)
|
||||
keyRing := serverKeyAPI.KeyRing()
|
||||
createKeyDB(
|
||||
base, serverKeyAPI,
|
||||
)
|
||||
|
||||
rsAPI := roomserver.NewInternalAPI(
|
||||
&base.Base, keyRing,
|
||||
&base.Base,
|
||||
)
|
||||
eduInputAPI := eduserver.NewInternalAPI(
|
||||
&base.Base, cache.New(), userAPI,
|
||||
)
|
||||
asAPI := appservice.NewInternalAPI(&base.Base, userAPI, rsAPI)
|
||||
rsAPI.SetAppserviceAPI(asAPI)
|
||||
fsAPI := federationsender.NewInternalAPI(
|
||||
&base.Base, federation, rsAPI, keyRing, true,
|
||||
fsAPI := federationapi.NewInternalAPI(
|
||||
&base.Base, federation, rsAPI, base.Base.Caches, true,
|
||||
)
|
||||
rsAPI.SetFederationSenderAPI(fsAPI)
|
||||
keyRing := fsAPI.KeyRing()
|
||||
rsAPI.SetFederationAPI(fsAPI)
|
||||
provider := newPublicRoomsProvider(base.LibP2PPubsub, rsAPI)
|
||||
err = provider.Start()
|
||||
if err != nil {
|
||||
panic("failed to create new public rooms provider: " + err.Error())
|
||||
}
|
||||
|
||||
createKeyDB(
|
||||
base, keyRing,
|
||||
)
|
||||
|
||||
monolith := setup.Monolith{
|
||||
Config: base.Base.Cfg,
|
||||
AccountDB: accountDB,
|
||||
|
@ -186,9 +181,8 @@ func main() {
|
|||
|
||||
AppserviceAPI: asAPI,
|
||||
EDUInternalAPI: eduInputAPI,
|
||||
FederationSenderAPI: fsAPI,
|
||||
FederationAPI: fsAPI,
|
||||
RoomserverAPI: rsAPI,
|
||||
ServerKeyAPI: serverKeyAPI,
|
||||
UserAPI: userAPI,
|
||||
KeyAPI: keyAPI,
|
||||
ExtPublicRoomsProvider: provider,
|
||||
|
|
|
@ -25,7 +25,7 @@ import (
|
|||
)
|
||||
|
||||
type mDNSListener struct {
|
||||
keydb gomatrixserverlib.KeyDatabase
|
||||
keydb *gomatrixserverlib.KeyRing
|
||||
host host.Host
|
||||
}
|
||||
|
||||
|
@ -35,7 +35,7 @@ func (n *mDNSListener) HandlePeerFound(p peer.AddrInfo) {
|
|||
}
|
||||
if pubkey, err := p.ID.ExtractPublicKey(); err == nil {
|
||||
raw, _ := pubkey.Raw()
|
||||
if err := n.keydb.StoreKeys(
|
||||
if err := n.keydb.KeyDatabase.StoreKeys(
|
||||
context.Background(),
|
||||
map[gomatrixserverlib.PublicKeyLookupRequest]gomatrixserverlib.PublicKeyLookupResult{
|
||||
{
|
||||
|
|
|
@ -22,7 +22,6 @@ import (
|
|||
|
||||
pstore "github.com/libp2p/go-libp2p-core/peerstore"
|
||||
record "github.com/libp2p/go-libp2p-record"
|
||||
"github.com/matrix-org/dendrite/setup"
|
||||
|
||||
"github.com/libp2p/go-libp2p"
|
||||
circuit "github.com/libp2p/go-libp2p-circuit"
|
||||
|
@ -34,12 +33,13 @@ import (
|
|||
pubsub "github.com/libp2p/go-libp2p-pubsub"
|
||||
"github.com/matrix-org/gomatrixserverlib"
|
||||
|
||||
"github.com/matrix-org/dendrite/setup/base"
|
||||
"github.com/matrix-org/dendrite/setup/config"
|
||||
)
|
||||
|
||||
// P2PDendrite is a Peer-to-Peer variant of BaseDendrite.
|
||||
type P2PDendrite struct {
|
||||
Base setup.BaseDendrite
|
||||
Base base.BaseDendrite
|
||||
|
||||
// Store our libp2p object so that we can make outgoing connections from it
|
||||
// later
|
||||
|
@ -54,7 +54,7 @@ type P2PDendrite struct {
|
|||
// The componentName is used for logging purposes, and should be a friendly name
|
||||
// of the component running, e.g. SyncAPI.
|
||||
func NewP2PDendrite(cfg *config.Dendrite, componentName string) *P2PDendrite {
|
||||
baseDendrite := setup.NewBaseDendrite(cfg, componentName, false)
|
||||
baseDendrite := base.NewBaseDendrite(cfg, componentName)
|
||||
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue