refactor: use latest GMSL which splits fed client from matrix room logic (#3051)

Part of a series of refactors on GMSL.
This commit is contained in:
kegsay 2023-04-06 09:55:01 +01:00 committed by GitHub
parent e093005bc2
commit 0db43f13a6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
86 changed files with 493 additions and 414 deletions

View file

@ -8,13 +8,14 @@ import (
"time"
"github.com/matrix-org/gomatrixserverlib"
"github.com/matrix-org/gomatrixserverlib/fclient"
"golang.org/x/crypto/ed25519"
)
type Global struct {
// Signing identity contains the server name, private key and key ID of
// the deployment.
gomatrixserverlib.SigningIdentity `yaml:",inline"`
fclient.SigningIdentity `yaml:",inline"`
// The secondary server names, used for virtual hosting.
VirtualHosts []*VirtualHost `yaml:"-"`
@ -167,7 +168,7 @@ func (c *Global) VirtualHostForHTTPHost(serverName gomatrixserverlib.ServerName)
return nil
}
func (c *Global) SigningIdentityFor(serverName gomatrixserverlib.ServerName) (*gomatrixserverlib.SigningIdentity, error) {
func (c *Global) SigningIdentityFor(serverName gomatrixserverlib.ServerName) (*fclient.SigningIdentity, error) {
for _, id := range c.SigningIdentities() {
if id.ServerName == serverName {
return id, nil
@ -176,8 +177,8 @@ func (c *Global) SigningIdentityFor(serverName gomatrixserverlib.ServerName) (*g
return nil, fmt.Errorf("no signing identity for %q", serverName)
}
func (c *Global) SigningIdentities() []*gomatrixserverlib.SigningIdentity {
identities := make([]*gomatrixserverlib.SigningIdentity, 0, len(c.VirtualHosts)+1)
func (c *Global) SigningIdentities() []*fclient.SigningIdentity {
identities := make([]*fclient.SigningIdentity, 0, len(c.VirtualHosts)+1)
identities = append(identities, &c.SigningIdentity)
for _, v := range c.VirtualHosts {
identities = append(identities, &v.SigningIdentity)
@ -188,7 +189,7 @@ func (c *Global) SigningIdentities() []*gomatrixserverlib.SigningIdentity {
type VirtualHost struct {
// Signing identity contains the server name, private key and key ID of
// the virtual host.
gomatrixserverlib.SigningIdentity `yaml:",inline"`
fclient.SigningIdentity `yaml:",inline"`
// Path to the private key. If not specified, the default global private key
// will be used instead.

View file

@ -20,6 +20,7 @@ import (
"testing"
"github.com/matrix-org/gomatrixserverlib"
"github.com/matrix-org/gomatrixserverlib/fclient"
"github.com/sirupsen/logrus"
"gopkg.in/yaml.v2"
)
@ -275,7 +276,7 @@ func Test_SigningIdentityFor(t *testing.T) {
name string
virtualHosts []*VirtualHost
serverName gomatrixserverlib.ServerName
want *gomatrixserverlib.SigningIdentity
want *fclient.SigningIdentity
wantErr bool
}{
{
@ -290,23 +291,23 @@ func Test_SigningIdentityFor(t *testing.T) {
{
name: "found identity",
serverName: gomatrixserverlib.ServerName("main"),
want: &gomatrixserverlib.SigningIdentity{ServerName: "main"},
want: &fclient.SigningIdentity{ServerName: "main"},
},
{
name: "identity found on virtual hosts",
serverName: gomatrixserverlib.ServerName("vh2"),
virtualHosts: []*VirtualHost{
{SigningIdentity: gomatrixserverlib.SigningIdentity{ServerName: "vh1"}},
{SigningIdentity: gomatrixserverlib.SigningIdentity{ServerName: "vh2"}},
{SigningIdentity: fclient.SigningIdentity{ServerName: "vh1"}},
{SigningIdentity: fclient.SigningIdentity{ServerName: "vh2"}},
},
want: &gomatrixserverlib.SigningIdentity{ServerName: "vh2"},
want: &fclient.SigningIdentity{ServerName: "vh2"},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
c := &Global{
VirtualHosts: tt.virtualHosts,
SigningIdentity: gomatrixserverlib.SigningIdentity{
SigningIdentity: fclient.SigningIdentity{
ServerName: "main",
},
}