mediaproxy

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: 18 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrUploadNotSupported = mautrix.MUnrecognized.
							WithMessage("This is a media proxy and does not support media uploads.").
							WithStatus(http.StatusNotImplemented)
	ErrPreviewURLNotSupported = mautrix.MUnrecognized.
								WithMessage("This is a media proxy and does not support URL previews.").
								WithStatus(http.StatusNotImplemented)
	ErrUnknownEndpoint = mautrix.MUnrecognized.
						WithMessage("Unrecognized endpoint")
	ErrUnsupportedMethod = mautrix.MUnrecognized.
							WithMessage("Invalid method for endpoint").
							WithStatus(http.StatusMethodNotAllowed)
)
View Source
var ErrInvalidMediaIDSyntax = errors.New("invalid media ID syntax")

Functions

This section is empty.

Types

type BasicConfig

type BasicConfig struct {
	ServerName        string `yaml:"server_name" json:"server_name"`
	ServerKey         string `yaml:"server_key" json:"server_key"`
	WellKnownResponse string `yaml:"well_known_response" json:"well_known_response"`
}

type GetMediaFunc

type GetMediaFunc = func(ctx context.Context, mediaID string, params map[string]string) (response GetMediaResponse, err error)

type GetMediaResponse

type GetMediaResponse interface {
	// contains filtered or unexported methods
}

type GetMediaResponseCallback added in v0.22.0

type GetMediaResponseCallback struct {
	Callback      func(w io.Writer) (int64, error)
	ContentType   string
	ContentLength int64
}

func (*GetMediaResponseCallback) GetContentLength added in v0.22.0

func (d *GetMediaResponseCallback) GetContentLength() int64

func (*GetMediaResponseCallback) GetContentType added in v0.22.0

func (d *GetMediaResponseCallback) GetContentType() string

func (*GetMediaResponseCallback) WriteTo added in v0.22.0

func (d *GetMediaResponseCallback) WriteTo(w io.Writer) (int64, error)

type GetMediaResponseData

type GetMediaResponseData struct {
	Reader        io.ReadCloser
	ContentType   string
	ContentLength int64
}

func (*GetMediaResponseData) GetContentLength added in v0.22.0

func (d *GetMediaResponseData) GetContentLength() int64

func (*GetMediaResponseData) GetContentType added in v0.22.0

func (d *GetMediaResponseData) GetContentType() string

func (*GetMediaResponseData) WriteTo added in v0.22.0

func (d *GetMediaResponseData) WriteTo(w io.Writer) (int64, error)

type GetMediaResponseFile added in v0.22.0

type GetMediaResponseFile struct {
	Callback    func(w *os.File) error
	ContentType string
}

type GetMediaResponseURL

type GetMediaResponseURL struct {
	URL       string
	ExpiresAt time.Time
}

type GetMediaResponseWriter added in v0.22.0

type GetMediaResponseWriter interface {
	GetMediaResponse
	io.WriterTo
	GetContentType() string
	GetContentLength() int64
}

type MediaProxy

type MediaProxy struct {
	KeyServer *federation.KeyServer

	ForceProxyLegacyFederation bool

	GetMedia            GetMediaFunc
	PrepareProxyRequest func(*http.Request)

	FederationRouter  *mux.Router
	ClientMediaRouter *mux.Router
	// contains filtered or unexported fields
}

func New

func New(serverName string, serverKey string, getMedia GetMediaFunc) (*MediaProxy, error)

func NewFromConfig

func NewFromConfig(cfg BasicConfig, getMedia GetMediaFunc) (*MediaProxy, error)

func (*MediaProxy) DownloadMedia

func (mp *MediaProxy) DownloadMedia(w http.ResponseWriter, r *http.Request)

func (*MediaProxy) DownloadMediaFederation

func (mp *MediaProxy) DownloadMediaFederation(w http.ResponseWriter, r *http.Request)

func (*MediaProxy) GetServerKey

func (mp *MediaProxy) GetServerKey() *federation.SigningKey

func (*MediaProxy) GetServerName

func (mp *MediaProxy) GetServerName() string

func (*MediaProxy) Listen

func (mp *MediaProxy) Listen(cfg ServerConfig) error

func (*MediaProxy) PreviewURLNotSupported

func (mp *MediaProxy) PreviewURLNotSupported(w http.ResponseWriter, r *http.Request)

func (*MediaProxy) RegisterRoutes

func (mp *MediaProxy) RegisterRoutes(router *mux.Router)

func (*MediaProxy) UnknownEndpoint

func (mp *MediaProxy) UnknownEndpoint(w http.ResponseWriter, r *http.Request)

func (*MediaProxy) UnsupportedMethod

func (mp *MediaProxy) UnsupportedMethod(w http.ResponseWriter, r *http.Request)

func (*MediaProxy) UploadNotSupported

func (mp *MediaProxy) UploadNotSupported(w http.ResponseWriter, r *http.Request)

type ResponseError deprecated

type ResponseError struct {
	Status int
	Data   any
}

Deprecated: use mautrix.RespError instead

func (*ResponseError) Error

func (err *ResponseError) Error() string

type ServerConfig

type ServerConfig struct {
	Hostname string `yaml:"hostname" json:"hostname"`
	Port     uint16 `yaml:"port" json:"port"`
}

Jump to

Keyboard shortcuts

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