refactor: update GMSL (#3058)

Sister PR to https://github.com/matrix-org/gomatrixserverlib/pull/364

Read this commit by commit to avoid going insane.
This commit is contained in:
kegsay 2023-04-19 15:50:33 +01:00 committed by GitHub
parent 9fa39263c0
commit 72285b2659
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
306 changed files with 2117 additions and 1934 deletions

View file

@ -9,6 +9,7 @@ import (
"github.com/matrix-org/gomatrixserverlib"
"github.com/matrix-org/gomatrixserverlib/fclient"
"github.com/matrix-org/gomatrixserverlib/spec"
"golang.org/x/crypto/ed25519"
)
@ -122,7 +123,7 @@ func (c *Global) Verify(configErrs *ConfigErrors) {
c.Cache.Verify(configErrs)
}
func (c *Global) IsLocalServerName(serverName gomatrixserverlib.ServerName) bool {
func (c *Global) IsLocalServerName(serverName spec.ServerName) bool {
if c.ServerName == serverName {
return true
}
@ -134,7 +135,7 @@ func (c *Global) IsLocalServerName(serverName gomatrixserverlib.ServerName) bool
return false
}
func (c *Global) SplitLocalID(sigil byte, id string) (string, gomatrixserverlib.ServerName, error) {
func (c *Global) SplitLocalID(sigil byte, id string) (string, spec.ServerName, error) {
u, s, err := gomatrixserverlib.SplitID(sigil, id)
if err != nil {
return u, s, err
@ -145,7 +146,7 @@ func (c *Global) SplitLocalID(sigil byte, id string) (string, gomatrixserverlib.
return u, s, nil
}
func (c *Global) VirtualHost(serverName gomatrixserverlib.ServerName) *VirtualHost {
func (c *Global) VirtualHost(serverName spec.ServerName) *VirtualHost {
for _, v := range c.VirtualHosts {
if v.ServerName == serverName {
return v
@ -154,7 +155,7 @@ func (c *Global) VirtualHost(serverName gomatrixserverlib.ServerName) *VirtualHo
return nil
}
func (c *Global) VirtualHostForHTTPHost(serverName gomatrixserverlib.ServerName) *VirtualHost {
func (c *Global) VirtualHostForHTTPHost(serverName spec.ServerName) *VirtualHost {
for _, v := range c.VirtualHosts {
if v.ServerName == serverName {
return v
@ -168,7 +169,7 @@ func (c *Global) VirtualHostForHTTPHost(serverName gomatrixserverlib.ServerName)
return nil
}
func (c *Global) SigningIdentityFor(serverName gomatrixserverlib.ServerName) (*fclient.SigningIdentity, error) {
func (c *Global) SigningIdentityFor(serverName spec.ServerName) (*fclient.SigningIdentity, error) {
for _, id := range c.SigningIdentities() {
if id.ServerName == serverName {
return id, nil
@ -205,7 +206,7 @@ type VirtualHost struct {
// Match these HTTP Host headers on the `/key/v2/server` endpoint, this needs
// to match all delegated names, likely including the port number too if
// the well-known delegation includes that also.
MatchHTTPHosts []gomatrixserverlib.ServerName `yaml:"match_http_hosts"`
MatchHTTPHosts []spec.ServerName `yaml:"match_http_hosts"`
// Is registration enabled on this virtual host?
AllowRegistration bool `yaml:"allow_registration"`
@ -236,14 +237,14 @@ type OldVerifyKeys struct {
PrivateKey ed25519.PrivateKey `yaml:"-"`
// The public key, in case only that part is known.
PublicKey gomatrixserverlib.Base64Bytes `yaml:"public_key"`
PublicKey spec.Base64Bytes `yaml:"public_key"`
// The key ID of the private key.
KeyID gomatrixserverlib.KeyID `yaml:"key_id"`
// When the private key was designed as "expired", as a UNIX timestamp
// in millisecond precision.
ExpiredAt gomatrixserverlib.Timestamp `yaml:"expired_at"`
ExpiredAt spec.Timestamp `yaml:"expired_at"`
}
// The configuration to use for Prometheus metrics