diff options
author | kegsay <kegan@matrix.org> | 2023-04-19 15:50:33 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-04-19 15:50:33 +0100 |
commit | 72285b2659a31ebd52c91799c17105d81d996f40 (patch) | |
tree | 1855395f5efdc3ea6051dd502882bf62aaa57e7c /build | |
parent | 9fa39263c0a4a8d349c8715f6ba30cae30b1b73a (diff) |
refactor: update GMSL (#3058)
Sister PR to https://github.com/matrix-org/gomatrixserverlib/pull/364
Read this commit by commit to avoid going insane.
Diffstat (limited to 'build')
-rw-r--r-- | build/dendritejs-pinecone/main.go | 2 | ||||
-rw-r--r-- | build/gobind-pinecone/monolith.go | 19 | ||||
-rw-r--r-- | build/gobind-pinecone/monolith_test.go | 4 | ||||
-rw-r--r-- | build/gobind-yggdrasil/monolith.go | 3 |
4 files changed, 15 insertions, 13 deletions
diff --git a/build/dendritejs-pinecone/main.go b/build/dendritejs-pinecone/main.go index bc9535fc..61baed90 100644 --- a/build/dendritejs-pinecone/main.go +++ b/build/dendritejs-pinecone/main.go @@ -171,7 +171,7 @@ func startup() { cfg.Global.TrustedIDServers = []string{} cfg.Global.KeyID = gomatrixserverlib.KeyID(signing.KeyID) cfg.Global.PrivateKey = sk - cfg.Global.ServerName = gomatrixserverlib.ServerName(hex.EncodeToString(pk)) + cfg.Global.ServerName = spec.ServerName(hex.EncodeToString(pk)) cfg.ClientAPI.RegistrationDisabled = false cfg.ClientAPI.OpenRegistrationWithoutVerificationEnabled = true diff --git a/build/gobind-pinecone/monolith.go b/build/gobind-pinecone/monolith.go index 2e2ca04d..8718c71f 100644 --- a/build/gobind-pinecone/monolith.go +++ b/build/gobind-pinecone/monolith.go @@ -35,6 +35,7 @@ import ( "github.com/matrix-org/dendrite/setup/process" userapiAPI "github.com/matrix-org/dendrite/userapi/api" "github.com/matrix-org/gomatrixserverlib" + "github.com/matrix-org/gomatrixserverlib/spec" "github.com/matrix-org/pinecone/types" "github.com/sirupsen/logrus" @@ -140,9 +141,9 @@ func (m *DendriteMonolith) SetStaticPeer(uri string) { } } -func getServerKeyFromString(nodeID string) (gomatrixserverlib.ServerName, error) { - var nodeKey gomatrixserverlib.ServerName - if userID, err := gomatrixserverlib.NewUserID(nodeID, false); err == nil { +func getServerKeyFromString(nodeID string) (spec.ServerName, error) { + var nodeKey spec.ServerName + if userID, err := spec.NewUserID(nodeID, false); err == nil { hexKey, decodeErr := hex.DecodeString(string(userID.Domain())) if decodeErr != nil || len(hexKey) != ed25519.PublicKeySize { return "", fmt.Errorf("UserID domain is not a valid ed25519 public key: %v", userID.Domain()) @@ -154,7 +155,7 @@ func getServerKeyFromString(nodeID string) (gomatrixserverlib.ServerName, error) if decodeErr != nil || len(hexKey) != ed25519.PublicKeySize { return "", fmt.Errorf("Relay server uri is not a valid ed25519 public key: %v", nodeID) } else { - nodeKey = gomatrixserverlib.ServerName(nodeID) + nodeKey = spec.ServerName(nodeID) } } @@ -162,7 +163,7 @@ func getServerKeyFromString(nodeID string) (gomatrixserverlib.ServerName, error) } func (m *DendriteMonolith) SetRelayServers(nodeID string, uris string) { - relays := []gomatrixserverlib.ServerName{} + relays := []spec.ServerName{} for _, uri := range strings.Split(uris, ",") { uri = strings.TrimSpace(uri) if len(uri) == 0 { @@ -188,7 +189,7 @@ func (m *DendriteMonolith) SetRelayServers(nodeID string, uris string) { m.p2pMonolith.RelayRetriever.SetRelayServers(relays) } else { relay.UpdateNodeRelayServers( - gomatrixserverlib.ServerName(nodeKey), + spec.ServerName(nodeKey), relays, m.p2pMonolith.ProcessCtx.Context(), m.p2pMonolith.GetFederationAPI(), @@ -215,7 +216,7 @@ func (m *DendriteMonolith) GetRelayServers(nodeID string) string { relaysString += string(relay) } } else { - request := api.P2PQueryRelayServersRequest{Server: gomatrixserverlib.ServerName(nodeKey)} + request := api.P2PQueryRelayServersRequest{Server: spec.ServerName(nodeKey)} response := api.P2PQueryRelayServersResponse{} err := m.p2pMonolith.GetFederationAPI().P2PQueryRelayServers(m.p2pMonolith.ProcessCtx.Context(), &request, &response) if err != nil { @@ -291,7 +292,7 @@ func (m *DendriteMonolith) RegisterUser(localpart, password string) (string, err pubkey := m.p2pMonolith.Router.PublicKey() userID := userutil.MakeUserID( localpart, - gomatrixserverlib.ServerName(hex.EncodeToString(pubkey[:])), + spec.ServerName(hex.EncodeToString(pubkey[:])), ) userReq := &userapiAPI.PerformAccountCreationRequest{ AccountType: userapiAPI.AccountTypeUser, @@ -342,7 +343,7 @@ func (m *DendriteMonolith) Start() { prefix := hex.EncodeToString(pk) cfg := monolith.GenerateDefaultConfig(sk, m.StorageDirectory, m.CacheDirectory, prefix) - cfg.Global.ServerName = gomatrixserverlib.ServerName(hex.EncodeToString(pk)) + cfg.Global.ServerName = spec.ServerName(hex.EncodeToString(pk)) cfg.Global.KeyID = gomatrixserverlib.KeyID(signing.KeyID) cfg.Global.JetStream.InMemory = false // NOTE : disabled for now since there is a 64 bit alignment panic on 32 bit systems diff --git a/build/gobind-pinecone/monolith_test.go b/build/gobind-pinecone/monolith_test.go index 434e07ef..7a7e36c7 100644 --- a/build/gobind-pinecone/monolith_test.go +++ b/build/gobind-pinecone/monolith_test.go @@ -18,7 +18,7 @@ import ( "strings" "testing" - "github.com/matrix-org/gomatrixserverlib" + "github.com/matrix-org/gomatrixserverlib/spec" ) func TestMonolithStarts(t *testing.T) { @@ -110,7 +110,7 @@ func TestParseServerKey(t *testing.T) { name string serverKey string expectedErr bool - expectedKey gomatrixserverlib.ServerName + expectedKey spec.ServerName }{ { name: "valid userid as key", diff --git a/build/gobind-yggdrasil/monolith.go b/build/gobind-yggdrasil/monolith.go index 7ce1892c..720ce37e 100644 --- a/build/gobind-yggdrasil/monolith.go +++ b/build/gobind-yggdrasil/monolith.go @@ -33,6 +33,7 @@ import ( "github.com/matrix-org/dendrite/test" "github.com/matrix-org/dendrite/userapi" "github.com/matrix-org/gomatrixserverlib" + "github.com/matrix-org/gomatrixserverlib/spec" "github.com/sirupsen/logrus" _ "golang.org/x/mobile/bind" @@ -134,7 +135,7 @@ func (m *DendriteMonolith) Start() { Generate: true, SingleDatabase: true, }) - cfg.Global.ServerName = gomatrixserverlib.ServerName(hex.EncodeToString(pk)) + cfg.Global.ServerName = spec.ServerName(hex.EncodeToString(pk)) cfg.Global.PrivateKey = sk cfg.Global.KeyID = gomatrixserverlib.KeyID(signing.KeyID) cfg.Global.JetStream.StoragePath = config.Path(fmt.Sprintf("%s/", m.StorageDirectory)) |