memostream

package
v0.0.0-...-717b50b Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2020 License: GPL-3.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Media_File     MediaProtocol = 0
	Media_Redirect MediaProtocol = 1
	Media_Proxy    MediaProtocol = 2

	Media_Public  MediaAccess = 0
	Media_Private MediaAccess = 1

	Media_OK    MediaStatus = 0
	Media_Error MediaStatus = 1
	Media_New               = 2
)

Variables

View Source
var (
	// conversion string to protocol
	MediaProtocolString = map[string]MediaProtocol{
		"file":     Media_File,
		"redirect": Media_Redirect,
		"proxy":    Media_Proxy,
	}
	// conversion protocol number to string
	MediaProtocolNum = map[MediaProtocol]string{
		Media_File:     "file",
		Media_Redirect: "redirect",
		Media_Proxy:    "proxy",
	}

	// conversion string to access type
	MediaAccessString = map[string]MediaAccess{
		"public": Media_Public,
		"closed": Media_Private,
	}
	// conversion access number to access string
	MediaAccessNum = map[MediaAccess]string{
		Media_Public:  "public",
		Media_Private: "closed",
	}

	MediaStatusString = map[string]MediaStatus{
		"ok":    Media_OK,
		"error": Media_Error,
		"new":   Media_New,
	}
	MediaStatusNum = map[MediaStatus]string{
		Media_OK:    "ok",
		Media_Error: "error",
		Media_New:   "new",
	}
)
View Source
var (
	VERSION string = "Memoriav Mediaserver 0.1"
)

Functions

func CheckJWT

func CheckJWT(tokenstring string, secret string, alg []string, subject string) error

func CheckRequestJWT

func CheckRequestJWT(req *http.Request, secret string, alg []string, subject string) error

func CreateLogger

func CreateLogger(module string, logfile string, loglevel string) (log *logging.Logger, lf *os.File)

func FileExists

func FileExists(filename string) bool

func NewJWT

func NewJWT(secret string, subject string, alg string, valid int64, domain string, issuer string) (tokenString string, err error)

func NewServer

func NewServer(
	urlPrefix,
	cmdPrefix,
	iiifPrefix,
	iiifBase,
	iiifUrl,
	iiifJwtSubPrefix,
	iiifViewerTemplate,
	addr string,
	resolver *ResolverCache,
	mapping *FileMapper,
	jwtSecret string,
	jwtAlg []string,
	log *logging.Logger,
	accesslog io.Writer,
	errorTemplate,
	videoViewerTemplate,
	audioViewerTemplate,
	staticPrefix,
	staticDir string) *memoServer

func NewTokenServiceServer

func NewTokenServiceServer(
	addr string,
	jwtSecret string,
	jwtAlg string,
	jwtValid time.Duration,
	jwtIssuer string,
	log *logging.Logger,
	accesslog io.Writer,
	errorTemplate string,
) *tokenServiceServer

func SingleJoiningSlash

func SingleJoiningSlash(a, b string) string

Types

type FileMapper

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

func NewFileMapper

func NewFileMapper(mapping map[string]string) *FileMapper

func (*FileMapper) Get

func (fm *FileMapper) Get(uri *url.URL) (string, error)

type IdleTimeoutConn

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

connection enhancment to make sure, that unused connections will be closed afert timeout

func NewIdleTimeoutConn

func NewIdleTimeoutConn(conn net.Conn, idleTimeout time.Duration) IdleTimeoutConn

func (IdleTimeoutConn) Read

func (itc IdleTimeoutConn) Read(buf []byte) (int, error)

func (IdleTimeoutConn) Write

func (itc IdleTimeoutConn) Write(buf []byte) (int, error)

type MediaAccess

type MediaAccess int

type MediaEntry

type MediaEntry struct {
	Signature string
	URI       *url.URL
	Protocol  MediaProtocol
	Access    MediaAccess
	Status    MediaStatus
}

Represents the data needed to stream media object

func NewMediaEntry

func NewMediaEntry(signature, uri, access, protocol, status string) (*MediaEntry, error)

type MediaProtocol

type MediaProtocol int

protocol and access types need to be enums

type MediaStatus

type MediaStatus int

type ResolverCache

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

the ResolvarCache contains the database resolver and a caching structure

func NewResolver

func NewResolver(r ResolverDB, cacheSize int) *ResolverCache

create a new ResolverCache

func (*ResolverCache) ClearCache

func (r *ResolverCache) ClearCache()

if data changes, we have to clear the cache to prevent the use of old content

type ResolverDB

type ResolverDB interface {
	Resolve(signature string) (*MediaEntry, error)
	Close()
}

for a type to be a ResolverDB there must be a function for resolving a signature and a close function for shtutdown

type ResolverDBMySQL

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

resolver for MySQL database (should work with PostGreSQL too)

func NewResolverDBMysql

func NewResolverDBMysql(db *sql.DB, query string) (*ResolverDBMySQL, error)

create new ResolverDBMySQL

func (*ResolverDBMySQL) Close

func (rdm *ResolverDBMySQL) Close()

shutdown resolver

func (*ResolverDBMySQL) Init

func (rdm *ResolverDBMySQL) Init() (err error)

initializes ResolverDBMySQL

func (*ResolverDBMySQL) Resolve

func (rdm *ResolverDBMySQL) Resolve(signature string) (*MediaEntry, error)

resolve MediaEntry for signature

type ResolverDBStatic

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

* Static resolver for testing the memoServer functionality

func NewResolverDBStatic

func NewResolverDBStatic(signatures map[string]Sig) *ResolverDBStatic

func (*ResolverDBStatic) Close

func (rds *ResolverDBStatic) Close()

func (*ResolverDBStatic) Resolve

func (rds *ResolverDBStatic) Resolve(signature string) (*MediaEntry, error)

type Sig

type Sig struct {
	Type   string
	Uri    string
	Access string
}

Jump to

Keyboard shortcuts

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