mediaproxy

package
v0.19.0-mod-2 Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2024 License: MPL-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

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"`
	AllowProxy        bool   `yaml:"allow_proxy" json:"allow_proxy"`
	WellKnownResponse string `yaml:"well_known_response" json:"well_known_response"`
}

type GetMediaFunc

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

type GetMediaResponse

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

type GetMediaResponseData

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

type GetMediaResponseURL

type GetMediaResponseURL struct {
	URL       string
	ExpiresAt time.Time
}

type MediaProxy

type MediaProxy struct {
	KeyServer   *federation.KeyServer
	ProxyClient *http.Client

	ForceProxyLegacyFederation bool

	GetMedia            GetMediaFunc
	PrepareProxyRequest func(*http.Request)

	FederationRouter  *mux.Router
	LegacyMediaRouter *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) DisallowProxying

func (mp *MediaProxy) DisallowProxying()

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

type ResponseError struct {
	Status int
	Data   any
}

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