bridge

package
v0.22.1 Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2024 License: MPL-2.0 Imports: 36 Imported by: 9

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrMismatchingMXID = errors.New("whoami result does not match custom mxid")
	ErrNoAccessToken   = errors.New("no access token provided")
	ErrNoMXID          = errors.New("no mxid provided")
)
View Source
var DuplicateMessageIndex = crypto.DuplicateMessageIndex
View Source
var MinSpecVersion = mautrix.SpecV14
View Source
var NoSessionFound = crypto.NoSessionFound
View Source
var UnknownMessageIndex = olm.UnknownMessageIndex

Functions

This section is empty.

Types

type BanHandlingPortal added in v0.18.1

type BanHandlingPortal interface {
	Portal
	HandleMatrixBan(sender User, ghost Ghost, evt *event.Event)
	HandleMatrixUnban(sender User, ghost Ghost, evt *event.Event)
}

type Bridge

type Bridge struct {
	Name              string
	URL               string
	Description       string
	Version           string
	ProtocolName      string
	BeeperServiceName string
	BeeperNetworkName string

	AdditionalShortFlags string
	AdditionalLongFlags  string

	VersionDesc      string
	LinkifiedVersion string
	BuildTime        string

	PublicHSAddress *url.URL

	DoublePuppet *doublePuppetUtil

	AS               *appservice.AppService
	EventProcessor   *appservice.EventProcessor
	CommandProcessor CommandProcessor
	MatrixHandler    *MatrixHandler
	Bot              *appservice.IntentAPI
	Config           bridgeconfig.BaseConfig
	ConfigPath       string
	RegistrationPath string
	SaveConfig       bool
	ConfigUpgrader   configupgrade.BaseUpgrader
	DB               *dbutil.Database
	StateStore       *sqlstatestore.SQLStateStore
	Crypto           Crypto
	CryptoPickleKey  string

	ZLog *zerolog.Logger

	MediaConfig  mautrix.RespMediaConfig
	SpecVersions mautrix.RespVersions

	Child ChildOverride

	Stopping bool

	Websocket bool
	// contains filtered or unexported fields
}

func (*Bridge) GenerateRegistration

func (br *Bridge) GenerateRegistration()

func (*Bridge) InitVersion

func (br *Bridge) InitVersion(tag, commit, buildTime string)

func (*Bridge) LogDBUpgradeErrorAndExit

func (br *Bridge) LogDBUpgradeErrorAndExit(name string, err error)

func (*Bridge) Main

func (br *Bridge) Main()

func (*Bridge) ManualStop added in v0.12.1

func (br *Bridge) ManualStop(exitCode int)

func (*Bridge) NewBridgeStateQueue

func (br *Bridge) NewBridgeStateQueue(user status.BridgeStateFiller) *BridgeStateQueue

func (*Bridge) PingServer added in v0.15.3

func (br *Bridge) PingServer() (start, serverTs, end time.Time)

func (*Bridge) ResendBridgeInfo

func (br *Bridge) ResendBridgeInfo()

func (*Bridge) SendBridgeState

func (br *Bridge) SendBridgeState(ctx context.Context, state *status.BridgeState) error

func (*Bridge) SendGlobalBridgeState

func (br *Bridge) SendGlobalBridgeState(state status.BridgeState)

func (*Bridge) SendMessageCheckpoint

func (br *Bridge) SendMessageCheckpoint(evt *event.Event, step status.MessageCheckpointStep, err error, s status.MessageCheckpointStatus, retryNum int)

func (*Bridge) SendMessageCheckpoints

func (br *Bridge) SendMessageCheckpoints(checkpoints []*status.MessageCheckpoint) error

func (*Bridge) SendMessageErrorCheckpoint

func (br *Bridge) SendMessageErrorCheckpoint(evt *event.Event, step status.MessageCheckpointStep, err error, permanent bool, retryNum int)

func (*Bridge) SendMessageSuccessCheckpoint

func (br *Bridge) SendMessageSuccessCheckpoint(evt *event.Event, step status.MessageCheckpointStep, retryNum int)

func (*Bridge) SendRawMessageCheckpoint

func (br *Bridge) SendRawMessageCheckpoint(cp *status.MessageCheckpoint)

func (*Bridge) UpdateBotProfile

func (br *Bridge) UpdateBotProfile(ctx context.Context)

func (*Bridge) WaitWebsocketConnected added in v0.15.3

func (br *Bridge) WaitWebsocketConnected()

type BridgeStateQueue

type BridgeStateQueue struct {
	// contains filtered or unexported fields
}

func (*BridgeStateQueue) GetPrev

func (bsq *BridgeStateQueue) GetPrev() status.BridgeState

func (*BridgeStateQueue) Send

func (bsq *BridgeStateQueue) Send(state status.BridgeState)

func (*BridgeStateQueue) SetPrev

func (bsq *BridgeStateQueue) SetPrev(prev status.BridgeState)

type CSFeatureRequirer

type CSFeatureRequirer interface {
	CheckFeatures(versions *mautrix.RespVersions) (string, bool)
}

type ChildOverride

type ChildOverride interface {
	GetExampleConfig() string
	GetConfigPtr() interface{}

	Init()
	Start()
	Stop()

	GetIPortal(id.RoomID) Portal
	GetAllIPortals() []Portal
	GetIUser(id id.UserID, create bool) User
	IsGhost(id.UserID) bool
	GetIGhost(id.UserID) Ghost
	CreatePrivatePortal(id.RoomID, User, Ghost)
}

type CommandProcessor

type CommandProcessor interface {
	Handle(ctx context.Context, roomID id.RoomID, eventID id.EventID, user User, message string, replyTo id.EventID)
}

type ConfigValidatingBridge added in v0.17.0

type ConfigValidatingBridge interface {
	ChildOverride
	ValidateConfig() error
}

type Crypto

type Crypto interface {
	HandleMemberEvent(context.Context, *event.Event)
	Decrypt(context.Context, *event.Event) (*event.Event, error)
	Encrypt(context.Context, id.RoomID, event.Type, *event.Content) error
	WaitForSession(context.Context, id.RoomID, id.SenderKey, id.SessionID, time.Duration) bool
	RequestSession(context.Context, id.RoomID, id.SenderKey, id.SessionID, id.UserID, id.DeviceID)
	ResetSession(context.Context, id.RoomID)
	Init(ctx context.Context) error
	Start()
	Stop()
	Reset(ctx context.Context, startAfterReset bool)
	Client() *mautrix.Client
	ShareKeys(context.Context) error
}

func NewCryptoHelper

func NewCryptoHelper(bridge *Bridge) Crypto

type CryptoHelper

type CryptoHelper struct {
	// contains filtered or unexported fields
}

func (*CryptoHelper) Client

func (helper *CryptoHelper) Client() *mautrix.Client

func (*CryptoHelper) Decrypt

func (helper *CryptoHelper) Decrypt(ctx context.Context, evt *event.Event) (*event.Event, error)

func (*CryptoHelper) Encrypt

func (helper *CryptoHelper) Encrypt(ctx context.Context, roomID id.RoomID, evtType event.Type, content *event.Content) (err error)

func (*CryptoHelper) HandleMemberEvent

func (helper *CryptoHelper) HandleMemberEvent(ctx context.Context, evt *event.Event)

func (*CryptoHelper) Init

func (helper *CryptoHelper) Init(ctx context.Context) error

func (*CryptoHelper) RequestSession

func (helper *CryptoHelper) RequestSession(ctx context.Context, roomID id.RoomID, senderKey id.SenderKey, sessionID id.SessionID, userID id.UserID, deviceID id.DeviceID)

func (*CryptoHelper) Reset

func (helper *CryptoHelper) Reset(ctx context.Context, startAfterReset bool)

func (*CryptoHelper) ResetSession

func (helper *CryptoHelper) ResetSession(ctx context.Context, roomID id.RoomID)

func (*CryptoHelper) ShareKeys added in v0.16.0

func (helper *CryptoHelper) ShareKeys(ctx context.Context) error

ShareKeys uploads the given number of one-time-keys to the server.

func (*CryptoHelper) Start

func (helper *CryptoHelper) Start()

func (*CryptoHelper) Stop

func (helper *CryptoHelper) Stop()

func (*CryptoHelper) WaitForSession

func (helper *CryptoHelper) WaitForSession(ctx context.Context, roomID id.RoomID, senderKey id.SenderKey, sessionID id.SessionID, timeout time.Duration) bool

type DisappearingPortal

type DisappearingPortal interface {
	Portal
	ScheduleDisappearing()
}

type DoublePuppet

type DoublePuppet interface {
	CustomIntent() *appservice.IntentAPI
	SwitchCustomMXID(accessToken string, userID id.UserID) error
	ClearCustomMXID()
}

type FlagHandlingBridge

type FlagHandlingBridge interface {
	ChildOverride
	HandleFlags() bool
}

type Ghost

type Ghost interface {
	DoublePuppet
	DefaultIntent() *appservice.IntentAPI
	GetMXID() id.UserID
}

type GhostWithProfile

type GhostWithProfile interface {
	Ghost
	GetDisplayname() string
	GetAvatarURL() id.ContentURI
}

type InviteHandlingPortal added in v0.18.1

type InviteHandlingPortal interface {
	Portal
	HandleMatrixAcceptInvite(sender User, evt *event.Event)
	HandleMatrixRejectInvite(sender User, evt *event.Event)
	HandleMatrixRetractInvite(sender User, ghost Ghost, evt *event.Event)
}

type JoinRuleHandlingPortal added in v0.18.1

type JoinRuleHandlingPortal interface {
	Portal
	HandleMatrixJoinRule(sender User, evt *event.Event)
}

type KnockHandlingPortal added in v0.18.1

type KnockHandlingPortal interface {
	Portal
	HandleMatrixKnock(sender User, evt *event.Event)
	HandleMatrixRetractKnock(sender User, evt *event.Event)
	HandleMatrixAcceptKnock(sender User, ghost Ghost, evt *event.Event)
	HandleMatrixRejectKnock(sender User, ghost Ghost, evt *event.Event)
}

type MatrixHandler

type MatrixHandler struct {
	TrackEventDuration func(event.Type) func()
	// contains filtered or unexported fields
}

func NewMatrixHandler

func NewMatrixHandler(br *Bridge) *MatrixHandler

func (*MatrixHandler) HandleBotInvite

func (mx *MatrixHandler) HandleBotInvite(ctx context.Context, evt *event.Event)

func (*MatrixHandler) HandleEncrypted

func (mx *MatrixHandler) HandleEncrypted(ctx context.Context, evt *event.Event)

func (*MatrixHandler) HandleEncryption

func (mx *MatrixHandler) HandleEncryption(ctx context.Context, evt *event.Event)

func (*MatrixHandler) HandleGhostInvite

func (mx *MatrixHandler) HandleGhostInvite(ctx context.Context, evt *event.Event, inviter User, ghost Ghost)

func (*MatrixHandler) HandleJoinRule added in v0.18.1

func (mx *MatrixHandler) HandleJoinRule(_ context.Context, evt *event.Event)

func (*MatrixHandler) HandleMembership

func (mx *MatrixHandler) HandleMembership(ctx context.Context, evt *event.Event)

func (*MatrixHandler) HandleMessage

func (mx *MatrixHandler) HandleMessage(ctx context.Context, evt *event.Event)

func (*MatrixHandler) HandlePowerLevels added in v0.18.0

func (mx *MatrixHandler) HandlePowerLevels(_ context.Context, evt *event.Event)

func (*MatrixHandler) HandleReaction

func (mx *MatrixHandler) HandleReaction(_ context.Context, evt *event.Event)

func (*MatrixHandler) HandleReceipt

func (mx *MatrixHandler) HandleReceipt(_ context.Context, evt *event.Event)

func (*MatrixHandler) HandleRedaction

func (mx *MatrixHandler) HandleRedaction(_ context.Context, evt *event.Event)

func (*MatrixHandler) HandleRoomMetadata

func (mx *MatrixHandler) HandleRoomMetadata(ctx context.Context, evt *event.Event)

func (*MatrixHandler) HandleTyping

func (mx *MatrixHandler) HandleTyping(_ context.Context, evt *event.Event)

type MembershipHandlingPortal

type MembershipHandlingPortal interface {
	Portal
	HandleMatrixLeave(sender User, evt *event.Event)
	HandleMatrixKick(sender User, ghost Ghost, evt *event.Event)
	HandleMatrixInvite(sender User, ghost Ghost, evt *event.Event)
}

type MetaHandlingPortal

type MetaHandlingPortal interface {
	Portal
	HandleMatrixMeta(sender User, evt *event.Event)
}

type Portal

type Portal interface {
	IsEncrypted() bool
	IsPrivateChat() bool
	MarkEncrypted()
	MainIntent() *appservice.IntentAPI

	ReceiveMatrixEvent(user User, evt *event.Event)
	UpdateBridgeInfo(ctx context.Context)
}

type PowerLevelHandlingPortal added in v0.18.0

type PowerLevelHandlingPortal interface {
	Portal
	HandleMatrixPowerLevels(sender User, evt *event.Event)
}

type PreInitableBridge

type PreInitableBridge interface {
	ChildOverride
	PreInit()
}

type ReadReceiptHandlingPortal

type ReadReceiptHandlingPortal interface {
	Portal
	HandleMatrixReadReceipt(sender User, eventID id.EventID, receipt event.ReadReceipt)
}

type SQLCryptoStore

type SQLCryptoStore struct {
	*crypto.SQLCryptoStore
	UserID        id.UserID
	GhostIDFormat string
}

func NewSQLCryptoStore

func NewSQLCryptoStore(db *dbutil.Database, log dbutil.DatabaseLogger, userID id.UserID, ghostIDFormat, pickleKey string) *SQLCryptoStore

func (*SQLCryptoStore) GetRoomJoinedOrInvitedMembers added in v0.15.0

func (store *SQLCryptoStore) GetRoomJoinedOrInvitedMembers(ctx context.Context, roomID id.RoomID) (members []id.UserID, err error)

type TypingPortal

type TypingPortal interface {
	Portal
	HandleMatrixTyping(userIDs []id.UserID)
}

type User

type User interface {
	GetPermissionLevel() bridgeconfig.PermissionLevel
	IsLoggedIn() bool
	GetManagementRoomID() id.RoomID
	SetManagementRoom(id.RoomID)
	GetMXID() id.UserID
	GetIDoublePuppet() DoublePuppet
	GetIGhost() Ghost
}

type VersionJSONOutput added in v0.16.0

type VersionJSONOutput struct {
	Name string
	URL  string

	Version          string
	IsRelease        bool
	Commit           string
	FormattedVersion string
	BuildTime        string

	OS   string
	Arch string

	Mautrix struct {
		Version string
		Commit  string
	}
}

type WebsocketStartingBridge added in v0.15.3

type WebsocketStartingBridge interface {
	ChildOverride
	OnWebsocketConnect()
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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