bridgeconfig

package
v0.22.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 16, 2024 License: MPL-2.0 Imports: 20 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	PermissionLevelBlock    = Permissions{}
	PermissionLevelRelay    = Permissions{SendEvents: true}
	PermissionLevelCommands = Permissions{SendEvents: true, Commands: true, ManageRelay: true}
	PermissionLevelUser     = Permissions{SendEvents: true, Commands: true, ManageRelay: true, Login: true, DoublePuppet: true}
	PermissionLevelAdmin    = Permissions{SendEvents: true, Commands: true, ManageRelay: true, Login: true, DoublePuppet: true, Admin: true}
)
View Source
var HackyMigrateLegacyNetworkConfig func(up.Helper)
View Source
var SpacedBlocks = [][]string{
	{"bridge"},
	{"bridge", "bridge_matrix_leave"},
	{"bridge", "cleanup_on_logout"},
	{"bridge", "relay"},
	{"bridge", "permissions"},
	{"database"},
	{"homeserver"},
	{"homeserver", "software"},
	{"homeserver", "websocket"},
	{"appservice"},
	{"appservice", "hostname"},
	{"appservice", "id"},
	{"appservice", "ephemeral_events"},
	{"appservice", "as_token"},
	{"appservice", "username_template"},
	{"matrix"},
	{"analytics"},
	{"provisioning"},
	{"public_media"},
	{"direct_media"},
	{"backfill"},
	{"double_puppet"},
	{"encryption"},
	{"logging"},
}
View Source
var Upgrader up.SpacedUpgrader = &up.StructUpgrader{
	SimpleUpgrader: up.SimpleUpgrader(doUpgrade),
	Blocks:         SpacedBlocks,
}

Upgrader is a config upgrader that copies the default fields in the homeserver, appservice and logging blocks.

Functions

func CopyMapToOtherLocation

func CopyMapToOtherLocation(helper up.Helper, source, dest []string)

func CopyToOtherLocation

func CopyToOtherLocation(helper up.Helper, fieldType up.YAMLType, source, dest []string)

Types

type AnalyticsConfig added in v0.21.0

type AnalyticsConfig struct {
	Token  string `yaml:"token"`
	URL    string `yaml:"url"`
	UserID string `yaml:"user_id"`
}

type AppserviceConfig

type AppserviceConfig struct {
	Address       string `yaml:"address"`
	PublicAddress string `yaml:"public_address"`
	Hostname      string `yaml:"hostname"`
	Port          uint16 `yaml:"port"`

	ID  string        `yaml:"id"`
	Bot BotUserConfig `yaml:"bot"`

	ASToken string `yaml:"as_token"`
	HSToken string `yaml:"hs_token"`

	EphemeralEvents   bool `yaml:"ephemeral_events"`
	AsyncTransactions bool `yaml:"async_transactions"`

	UsernameTemplate string `yaml:"username_template"`
	// contains filtered or unexported fields
}

func (*AppserviceConfig) FormatUsername

func (asc *AppserviceConfig) FormatUsername(username string) string

func (*AppserviceConfig) GetRegistration

func (asc *AppserviceConfig) GetRegistration() *appservice.Registration

GetRegistration copies the data from the bridge config into an *appservice.Registration struct. This can't be used with the homeserver, see GenerateRegistration for generating files for the homeserver.

type BackfillConfig added in v0.20.0

type BackfillConfig struct {
	Enabled              bool `yaml:"enabled"`
	MaxInitialMessages   int  `yaml:"max_initial_messages"`
	MaxCatchupMessages   int  `yaml:"max_catchup_messages"`
	UnreadHoursThreshold int  `yaml:"unread_hours_threshold"`

	Threads BackfillThreadsConfig `yaml:"threads"`
	Queue   BackfillQueueConfig   `yaml:"queue"`
}

type BackfillQueueConfig added in v0.20.0

type BackfillQueueConfig struct {
	Enabled    bool `yaml:"enabled"`
	BatchSize  int  `yaml:"batch_size"`
	BatchDelay int  `yaml:"batch_delay"`
	MaxBatches int  `yaml:"max_batches"`

	MaxBatchesOverride map[string]int `yaml:"max_batches_override"`
}

func (*BackfillQueueConfig) GetOverride added in v0.20.0

func (bqc *BackfillQueueConfig) GetOverride(name string) int

type BackfillThreadsConfig added in v0.20.0

type BackfillThreadsConfig struct {
	MaxInitialMessages int `yaml:"max_initial_messages"`
}

type BotUserConfig

type BotUserConfig struct {
	Username    string `yaml:"username"`
	Displayname string `yaml:"displayname"`
	Avatar      string `yaml:"avatar"`

	ParsedAvatar id.ContentURI `yaml:"-"`
}

func (*BotUserConfig) UnmarshalYAML

func (buc *BotUserConfig) UnmarshalYAML(node *yaml.Node) error

type BridgeConfig

type BridgeConfig struct {
	CommandPrefix           string           `yaml:"command_prefix"`
	PersonalFilteringSpaces bool             `yaml:"personal_filtering_spaces"`
	PrivateChatPortalMeta   bool             `yaml:"private_chat_portal_meta"`
	AsyncEvents             bool             `yaml:"async_events"`
	SplitPortals            bool             `yaml:"split_portals"`
	ResendBridgeInfo        bool             `yaml:"resend_bridge_info"`
	BridgeMatrixLeave       bool             `yaml:"bridge_matrix_leave"`
	TagOnlyOnCreate         bool             `yaml:"tag_only_on_create"`
	OnlyBridgeTags          []event.RoomTag  `yaml:"only_bridge_tags"`
	MuteOnlyOnCreate        bool             `yaml:"mute_only_on_create"`
	OutgoingMessageReID     bool             `yaml:"outgoing_message_re_id"`
	CleanupOnLogout         CleanupOnLogouts `yaml:"cleanup_on_logout"`
	Relay                   RelayConfig      `yaml:"relay"`
	Permissions             PermissionConfig `yaml:"permissions"`
	Backfill                BackfillConfig   `yaml:"backfill"`
}

type CleanupAction added in v0.20.0

type CleanupAction string
const (
	CleanupActionNull     CleanupAction = ""
	CleanupActionNothing  CleanupAction = "nothing"
	CleanupActionKick     CleanupAction = "kick"
	CleanupActionUnbridge CleanupAction = "unbridge"
	CleanupActionDelete   CleanupAction = "delete"
)

type CleanupOnLogout added in v0.20.0

type CleanupOnLogout struct {
	Private        CleanupAction `yaml:"private"`
	Relayed        CleanupAction `yaml:"relayed"`
	SharedNoUsers  CleanupAction `yaml:"shared_no_users"`
	SharedHasUsers CleanupAction `yaml:"shared_has_users"`
}

type CleanupOnLogouts added in v0.20.0

type CleanupOnLogouts struct {
	Enabled        bool            `yaml:"enabled"`
	Manual         CleanupOnLogout `yaml:"manual"`
	BadCredentials CleanupOnLogout `yaml:"bad_credentials"`
}

type Config

type Config struct {
	Network      yaml.Node          `yaml:"network"`
	Bridge       BridgeConfig       `yaml:"bridge"`
	Database     dbutil.Config      `yaml:"database"`
	Homeserver   HomeserverConfig   `yaml:"homeserver"`
	AppService   AppserviceConfig   `yaml:"appservice"`
	Matrix       MatrixConfig       `yaml:"matrix"`
	Analytics    AnalyticsConfig    `yaml:"analytics"`
	Provisioning ProvisioningConfig `yaml:"provisioning"`
	PublicMedia  PublicMediaConfig  `yaml:"public_media"`
	DirectMedia  DirectMediaConfig  `yaml:"direct_media"`
	Backfill     BackfillConfig     `yaml:"backfill"`
	DoublePuppet DoublePuppetConfig `yaml:"double_puppet"`
	Encryption   EncryptionConfig   `yaml:"encryption"`
	Logging      zeroconfig.Config  `yaml:"logging"`

	ManagementRoomTexts ManagementRoomTexts `yaml:"management_room_texts"`
}

func (*Config) GenerateRegistration

func (config *Config) GenerateRegistration() *appservice.Registration

GenerateRegistration generates a registration file for the homeserver.

func (*Config) MakeAppService

func (config *Config) MakeAppService() *appservice.AppService

func (*Config) MakeUserIDRegex

func (config *Config) MakeUserIDRegex(matcher string) *regexp.Regexp

type DirectMediaConfig

type DirectMediaConfig struct {
	Enabled                bool   `yaml:"enabled"`
	MediaIDPrefix          string `yaml:"media_id_prefix"`
	mediaproxy.BasicConfig `yaml:",inline"`
}

type DoublePuppetConfig

type DoublePuppetConfig struct {
	Servers        map[string]string `yaml:"servers"`
	AllowDiscovery bool              `yaml:"allow_discovery"`
	Secrets        map[string]string `yaml:"secrets"`
}

type EncryptionConfig

type EncryptionConfig struct {
	Allow      bool `yaml:"allow"`
	Default    bool `yaml:"default"`
	Require    bool `yaml:"require"`
	Appservice bool `yaml:"appservice"`

	PlaintextMentions bool `yaml:"plaintext_mentions"`

	PickleKey string `yaml:"pickle_key"`

	DeleteKeys struct {
		DeleteOutboundOnAck       bool `yaml:"delete_outbound_on_ack"`
		DontStoreOutbound         bool `yaml:"dont_store_outbound"`
		RatchetOnDecrypt          bool `yaml:"ratchet_on_decrypt"`
		DeleteFullyUsedOnDecrypt  bool `yaml:"delete_fully_used_on_decrypt"`
		DeletePrevOnNewSession    bool `yaml:"delete_prev_on_new_session"`
		DeleteOnDeviceDelete      bool `yaml:"delete_on_device_delete"`
		PeriodicallyDeleteExpired bool `yaml:"periodically_delete_expired"`
		DeleteOutdatedInbound     bool `yaml:"delete_outdated_inbound"`
	} `yaml:"delete_keys"`

	VerificationLevels struct {
		Receive id.TrustState `yaml:"receive"`
		Send    id.TrustState `yaml:"send"`
		Share   id.TrustState `yaml:"share"`
	} `yaml:"verification_levels"`
	AllowKeySharing bool `yaml:"allow_key_sharing"`

	Rotation struct {
		EnableCustom bool  `yaml:"enable_custom"`
		Milliseconds int64 `yaml:"milliseconds"`
		Messages     int   `yaml:"messages"`

		DisableDeviceChangeKeyRotation bool `yaml:"disable_device_change_key_rotation"`
	} `yaml:"rotation"`
}

type HomeserverConfig

type HomeserverConfig struct {
	Address    string `yaml:"address"`
	Domain     string `yaml:"domain"`
	AsyncMedia bool   `yaml:"async_media"`

	PublicAddress string `yaml:"public_address,omitempty"`

	Software HomeserverSoftware `yaml:"software"`

	StatusEndpoint                string `yaml:"status_endpoint"`
	MessageSendCheckpointEndpoint string `yaml:"message_send_checkpoint_endpoint"`

	Websocket      bool   `yaml:"websocket"`
	WSProxy        string `yaml:"websocket_proxy"`
	WSPingInterval int    `yaml:"ping_interval_seconds"`
}

type HomeserverSoftware

type HomeserverSoftware string
const (
	SoftwareStandard HomeserverSoftware = "standard"
	SoftwareAsmux    HomeserverSoftware = "asmux"
	SoftwareHungry   HomeserverSoftware = "hungry"
)

type ManagementRoomTexts

type ManagementRoomTexts struct {
	Welcome            string `yaml:"welcome"`
	WelcomeConnected   string `yaml:"welcome_connected"`
	WelcomeUnconnected string `yaml:"welcome_unconnected"`
	AdditionalHelp     string `yaml:"additional_help"`
}

type MatrixConfig

type MatrixConfig struct {
	MessageStatusEvents bool  `yaml:"message_status_events"`
	DeliveryReceipts    bool  `yaml:"delivery_receipts"`
	MessageErrorNotices bool  `yaml:"message_error_notices"`
	SyncDirectChatList  bool  `yaml:"sync_direct_chat_list"`
	FederateRooms       bool  `yaml:"federate_rooms"`
	UploadFileThreshold int64 `yaml:"upload_file_threshold"`
}

type PermissionConfig

type PermissionConfig map[string]*Permissions

func (PermissionConfig) Get

func (pc PermissionConfig) Get(userID id.UserID) Permissions

func (PermissionConfig) IsConfigured

func (pc PermissionConfig) IsConfigured() bool

type Permissions

type Permissions struct {
	SendEvents   bool `yaml:"send_events"`
	Commands     bool `yaml:"commands"`
	Login        bool `yaml:"login"`
	DoublePuppet bool `yaml:"double_puppet"`
	Admin        bool `yaml:"admin"`
	ManageRelay  bool `yaml:"manage_relay"`
}

func (*Permissions) MarshalYAML

func (p *Permissions) MarshalYAML() (any, error)

func (*Permissions) UnmarshalYAML

func (p *Permissions) UnmarshalYAML(perm *yaml.Node) error

type ProvisioningConfig

type ProvisioningConfig struct {
	Prefix         string `yaml:"prefix"`
	SharedSecret   string `yaml:"shared_secret"`
	DebugEndpoints bool   `yaml:"debug_endpoints"`
}

type PublicMediaConfig added in v0.20.0

type PublicMediaConfig struct {
	Enabled    bool   `yaml:"enabled"`
	SigningKey string `yaml:"signing_key"`
	HashLength int    `yaml:"hash_length"`
	Expiry     int    `yaml:"expiry"`
}

type RelayConfig

type RelayConfig struct {
	Enabled           bool                         `yaml:"enabled"`
	AdminOnly         bool                         `yaml:"admin_only"`
	DefaultRelays     []networkid.UserLoginID      `yaml:"default_relays"`
	MessageFormats    map[event.MessageType]string `yaml:"message_formats"`
	DisplaynameFormat string                       `yaml:"displayname_format"`
	// contains filtered or unexported fields
}

func (*RelayConfig) FormatMessage

func (rc *RelayConfig) FormatMessage(content *event.MessageEventContent, sender any) (*event.MessageEventContent, error)

func (*RelayConfig) FormatName added in v0.20.0

func (rc *RelayConfig) FormatName(sender any) string

func (*RelayConfig) UnmarshalYAML

func (rc *RelayConfig) UnmarshalYAML(node *yaml.Node) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL