matrix

package
v1.3.8 Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2025 License: MIT Imports: 30 Imported by: 0

Documentation

Index

Constants

View Source
const NoSigningKey = ""

Variables

View Source
var ErrGuestToken = errors.New("token belongs to a guest")
View Source
var ErrInvalidToken = errors.New("missing or invalid access token")
View Source
var ErrNoXMatrixAuth = errors.New("no X-Matrix auth headers")
View Source
var ErrWrongDestination = errors.New("wrong destination")

Functions

func CreateXMatrixHeader added in v1.3.5

func CreateXMatrixHeader(origin string, destination string, requestMethod string, requestUri string, content []byte, key ed25519.PrivateKey, keyVersion string) (string, error)

func FederatedGet

func FederatedGet(ctx rcontext.RequestContext, reqUrl string, realHost string, destination string, useSigningKeyPath string, followRedirects bool) (*http.Response, error)

func FlushSigningKeyCache added in v1.3.5

func FlushSigningKeyCache()

func GetServerApiUrl

func GetServerApiUrl(hostname string) (string, string, error)

func GetUserIdFromToken

func GetUserIdFromToken(ctx rcontext.RequestContext, serverName string, accessToken string, appserviceUserId string, ipAddr string) (string, bool, error)

func IsUserAdmin

func IsUserAdmin(ctx rcontext.RequestContext, serverName string, accessToken string, ipAddr string) (bool, error)

func Logout

func Logout(ctx rcontext.RequestContext, serverName string, accessToken string, appserviceUserId string, ipAddr string) error

func LogoutAll

func LogoutAll(ctx rcontext.RequestContext, serverName string, accessToken string, appserviceUserId string, ipAddr string) error

func NewHttpClient added in v1.3.8

func NewHttpClient(ctx rcontext.RequestContext, clientConfig *HttpClientConfig) *http.Client

func TestsOnlyInjectSigningKey added in v1.3.5

func TestsOnlyInjectSigningKey(serverName string, httpFederationUrl string) error

TestsOnlyInjectSigningKey Deprecated: For tests only.

func ValidateXMatrixAuth added in v1.3.5

func ValidateXMatrixAuth(request *http.Request, expectNoContent bool) (string, error)

func ValidateXMatrixAuthHeader added in v1.3.5

func ValidateXMatrixAuthHeader(requestMethod string, requestUri string, content []byte, headers []util.XMatrixAuth, originKeys ServerSigningKeys, destinationHost string) error

Types

type ClientVersionsResponse added in v1.3.5

type ClientVersionsResponse struct {
	Versions         []string        `json:"versions"`
	UnstableFeatures map[string]bool `json:"unstable_features"`
}

func ClientVersions added in v1.3.5

func ClientVersions(ctx rcontext.RequestContext, serverName string, accessToken string, appserviceUserId string, ipAddr string) (*ClientVersionsResponse, error)

type ErrorResponse added in v1.3.5

type ErrorResponse struct {
	ErrorCode string `json:"errcode"`
	Message   string `json:"error"`
}

func (ErrorResponse) Error added in v1.3.5

func (e ErrorResponse) Error() string

type HttpClientConfig added in v1.3.8

type HttpClientConfig struct {
	Timeout                time.Duration
	AllowUnsafeCertificate bool
	AllowedCIDRs           []string
	DeniedCIDRs            []string
	// Used for federation. Set to the *real* server name, without port.
	TLSServerName   string
	FollowRedirects bool
}

type LocalSigningKey added in v1.3.5

type LocalSigningKey struct {
	Key     ed25519.PrivateKey
	Version string
}

type MediaListResponse

type MediaListResponse struct {
	LocalMxcs  []string `json:"local"`
	RemoteMxcs []string `json:"remote"`
}

func ListMedia

func ListMedia(ctx rcontext.RequestContext, serverName string, accessToken string, roomId string, ipAddr string) (*MediaListResponse, error)

type ServerKeyResult added in v1.3.5

type ServerKeyResult struct {
	ServerName    string                       `json:"server_name"`
	ValidUntilTs  int64                        `json:"valid_until_ts"`
	VerifyKeys    map[string]signingKey        `json:"verify_keys"`     // unpadded base64
	OldVerifyKeys map[string]signingKey        `json:"old_verify_keys"` // unpadded base64
	Signatures    map[string]map[string]string `json:"signatures"`      // unpadded base64; <name, <keyId, sig>>
}

type ServerNotAllowedError added in v1.3.5

type ServerNotAllowedError struct {
	ServerName string
	// contains filtered or unexported fields
}

func MakeServerNotAllowedError added in v1.3.5

func MakeServerNotAllowedError(serverName string) ServerNotAllowedError

type ServerSigningKeys added in v1.3.5

type ServerSigningKeys map[string]ed25519.PublicKey

func CheckSigningKeySignatures added in v1.3.5

func CheckSigningKeySignatures(serverName string, keyInfo *ServerKeyResult, raw database.AnonymousJson) (ServerSigningKeys, error)

func QuerySigningKeys added in v1.3.5

func QuerySigningKeys(serverName string) (ServerSigningKeys, error)

Jump to

Keyboard shortcuts

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