mirror of
https://mau.dev/mautrix/go.git
synced 2026-03-14 14:25:53 +01:00
bridgev2/config: move msc4190 flag to encryption section
This commit is contained in:
parent
742af7f70b
commit
6bf21f1019
5 changed files with 20 additions and 8 deletions
|
|
@ -34,7 +34,6 @@ type AppserviceConfig struct {
|
|||
|
||||
EphemeralEvents bool `yaml:"ephemeral_events"`
|
||||
AsyncTransactions bool `yaml:"async_transactions"`
|
||||
MSC4190 bool `yaml:"msc4190"`
|
||||
|
||||
UsernameTemplate string `yaml:"username_template"`
|
||||
usernameTemplate *template.Template `yaml:"-"`
|
||||
|
|
@ -78,7 +77,11 @@ func (asc *AppserviceConfig) copyToRegistration(registration *appservice.Registr
|
|||
registration.RateLimited = &falseVal
|
||||
registration.EphemeralEvents = asc.EphemeralEvents
|
||||
registration.SoruEphemeralEvents = asc.EphemeralEvents
|
||||
registration.MSC4190 = asc.MSC4190
|
||||
}
|
||||
|
||||
func (ec *EncryptionConfig) applyUnstableFlags(registration *appservice.Registration) {
|
||||
registration.MSC4190 = ec.MSC4190
|
||||
registration.MSC3202 = ec.Appservice
|
||||
}
|
||||
|
||||
// GenerateRegistration generates a registration file for the homeserver.
|
||||
|
|
@ -87,6 +90,7 @@ func (config *Config) GenerateRegistration() *appservice.Registration {
|
|||
config.AppService.HSToken = registration.ServerToken
|
||||
config.AppService.ASToken = registration.AppToken
|
||||
config.AppService.copyToRegistration(registration)
|
||||
config.Encryption.applyUnstableFlags(registration)
|
||||
|
||||
registration.SenderLocalpart = random.String(32)
|
||||
botRegex := regexp.MustCompile(fmt.Sprintf("^@%s:%s$",
|
||||
|
|
@ -105,6 +109,7 @@ func (config *Config) MakeAppService() *appservice.AppService {
|
|||
as.Host.Hostname = config.AppService.Hostname
|
||||
as.Host.Port = config.AppService.Port
|
||||
as.Registration = config.AppService.GetRegistration()
|
||||
config.Encryption.applyUnstableFlags(as.Registration)
|
||||
return as
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ type EncryptionConfig struct {
|
|||
Default bool `yaml:"default"`
|
||||
Require bool `yaml:"require"`
|
||||
Appservice bool `yaml:"appservice"`
|
||||
MSC4190 bool `yaml:"msc4190"`
|
||||
|
||||
PlaintextMentions bool `yaml:"plaintext_mentions"`
|
||||
|
||||
|
|
|
|||
|
|
@ -82,7 +82,6 @@ func doUpgrade(helper up.Helper) {
|
|||
helper.Copy(up.Str, "appservice", "bot", "avatar")
|
||||
helper.Copy(up.Bool, "appservice", "ephemeral_events")
|
||||
helper.Copy(up.Bool, "appservice", "async_transactions")
|
||||
helper.Copy(up.Bool, "appservice", "msc4190")
|
||||
helper.Copy(up.Str, "appservice", "as_token")
|
||||
helper.Copy(up.Str, "appservice", "hs_token")
|
||||
helper.Copy(up.Str, "appservice", "username_template")
|
||||
|
|
@ -147,6 +146,11 @@ func doUpgrade(helper up.Helper) {
|
|||
helper.Copy(up.Bool, "encryption", "default")
|
||||
helper.Copy(up.Bool, "encryption", "require")
|
||||
helper.Copy(up.Bool, "encryption", "appservice")
|
||||
if val, ok := helper.Get(up.Bool, "appservice", "msc4190"); ok {
|
||||
helper.Set(up.Bool, val, "encryption", "msc4190")
|
||||
} else {
|
||||
helper.Copy(up.Bool, "encryption", "msc4190")
|
||||
}
|
||||
helper.Copy(up.Bool, "encryption", "allow_key_sharing")
|
||||
if secret, ok := helper.Get(up.Str, "encryption", "pickle_key"); !ok || secret == "generate" {
|
||||
helper.Set(up.Str, random.String(64), "encryption", "pickle_key")
|
||||
|
|
|
|||
|
|
@ -243,7 +243,7 @@ func (helper *CryptoHelper) loginBot(ctx context.Context) (*mautrix.Client, bool
|
|||
client := helper.bridge.AS.NewMautrixClient(helper.bridge.AS.BotMXID())
|
||||
|
||||
initialDeviceDisplayName := fmt.Sprintf("%s bridge", helper.bridge.Bridge.Network.GetName().DisplayName)
|
||||
if helper.bridge.Config.AppService.MSC4190 {
|
||||
if helper.bridge.Config.Encryption.MSC4190 {
|
||||
helper.log.Debug().Msg("Creating bot device with MSC4190")
|
||||
err = client.CreateDeviceMSC4190(ctx, deviceID, initialDeviceDisplayName)
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -193,10 +193,6 @@ appservice:
|
|||
# However, messages will not be guaranteed to be bridged in the same order they were sent in.
|
||||
# This value doesn't affect the registration file.
|
||||
async_transactions: false
|
||||
# Whether to use MSC4190 instead of appservice login to create the bridge bot device.
|
||||
# Requires the homeserver to support MSC4190 and the device masquerading parts of MSC3202.
|
||||
# Only relevant when using end-to-bridge encryption, required when using encryption with next-gen auth (MSC3861).
|
||||
msc4190: false
|
||||
|
||||
# Authentication tokens for AS <-> HS communication. Autogenerated; do not modify.
|
||||
as_token: "This value is generated when generating the registration"
|
||||
|
|
@ -343,7 +339,13 @@ encryption:
|
|||
require: false
|
||||
# Whether to use MSC2409/MSC3202 instead of /sync long polling for receiving encryption-related data.
|
||||
# This option is not yet compatible with standard Matrix servers like Synapse and should not be used.
|
||||
# Changing this option requires updating the appservice registration file.
|
||||
appservice: false
|
||||
# Whether to use MSC4190 instead of appservice login to create the bridge bot device.
|
||||
# Requires the homeserver to support MSC4190 and the device masquerading parts of MSC3202.
|
||||
# Only relevant when using end-to-bridge encryption, required when using encryption with next-gen auth (MSC3861).
|
||||
# Changing this option requires updating the appservice registration file.
|
||||
msc4190: false
|
||||
# Enable key sharing? If enabled, key requests for rooms where users are in will be fulfilled.
|
||||
# You must use a client that supports requesting keys from other users to use this feature.
|
||||
allow_key_sharing: true
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue