Fix keyserver consumer maybe

This commit is contained in:
Neil Alexander 2022-11-15 09:57:40 +00:00
parent 2c92b29d22
commit 8f54d33f1d
No known key found for this signature in database
GPG key ID: A02A2019A2BB0944
2 changed files with 28 additions and 26 deletions

View file

@ -35,7 +35,7 @@ type DeviceListUpdateConsumer struct {
durable string
topic string
updater *internal.DeviceListUpdater
serverName gomatrixserverlib.ServerName
isLocalServerName func(gomatrixserverlib.ServerName) bool
}
// NewDeviceListUpdateConsumer creates a new DeviceListConsumer. Call Start() to begin consuming from key servers.
@ -51,7 +51,7 @@ func NewDeviceListUpdateConsumer(
durable: cfg.Matrix.JetStream.Prefixed("KeyServerInputDeviceListConsumer"),
topic: cfg.Matrix.JetStream.Prefixed(jetstream.InputDeviceListUpdate),
updater: updater,
serverName: cfg.Matrix.ServerName,
isLocalServerName: cfg.Matrix.IsLocalServerName,
}
}
@ -75,7 +75,7 @@ func (t *DeviceListUpdateConsumer) onMessage(ctx context.Context, msgs []*nats.M
origin := gomatrixserverlib.ServerName(msg.Header.Get("origin"))
if _, serverName, err := gomatrixserverlib.SplitID('@', m.UserID); err != nil {
return true
} else if serverName == t.serverName {
} else if t.isLocalServerName(serverName) {
return true
} else if serverName != origin {
return true

View file

@ -37,6 +37,7 @@ type SigningKeyUpdateConsumer struct {
topic string
keyAPI *internal.KeyInternalAPI
cfg *config.KeyServer
isLocalServerName func(gomatrixserverlib.ServerName) bool
}
// NewSigningKeyUpdateConsumer creates a new SigningKeyUpdateConsumer. Call Start() to begin consuming from key servers.
@ -53,6 +54,7 @@ func NewSigningKeyUpdateConsumer(
topic: cfg.Matrix.JetStream.Prefixed(jetstream.InputSigningKeyUpdate),
keyAPI: keyAPI,
cfg: cfg,
isLocalServerName: cfg.Matrix.IsLocalServerName,
}
}
@ -77,7 +79,7 @@ func (t *SigningKeyUpdateConsumer) onMessage(ctx context.Context, msgs []*nats.M
if _, serverName, err := gomatrixserverlib.SplitID('@', updatePayload.UserID); err != nil {
logrus.WithError(err).Error("failed to split user id")
return true
} else if serverName == t.cfg.Matrix.ServerName {
} else if t.isLocalServerName(serverName) {
logrus.Warn("dropping device key update from ourself")
return true
} else if serverName != origin {