proxy

package
v0.7.9 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2024 License: AGPL-3.0 Imports: 31 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultBufferSize = 16 * 1024
)

Variables

This section is empty.

Functions

func AutoProxyURL added in v0.7.6

func AutoProxyURL(ctx *gin.Context, u, t string, headers map[string]string, token, roomId, movieId string, opts ...ProxyURLOption) error

func GetM3u8Target

func GetM3u8Target(token string) (*m3u8TargetClaims, error)

func NewM3u8TargetToken

func NewM3u8TargetToken(targetUrl, roomId, movieId string, isM3u8File bool) (string, error)

func ParseContentRangeStartAndEnd added in v0.7.7

func ParseContentRangeStartAndEnd(contentRange string) (int64, int64, error)

func ParseContentRangeTotalLength added in v0.7.7

func ParseContentRangeTotalLength(contentRange string) (int64, error)

ParseContentRangeTotalLength parses a Content-Range header value and returns the total length

func ProxyM3u8

func ProxyM3u8(ctx *gin.Context, u string, headers map[string]string, isM3u8File bool, token, roomId, movieId string, opts ...ProxyURLOption) error

only cache non-m3u8 files

func ProxyURL

func ProxyURL(ctx *gin.Context, u string, headers map[string]string, opts ...ProxyURLOption) error

Types

type ByteRange added in v0.7.7

type ByteRange struct {
	Start int64
	End   int64
}

ByteRange represents an HTTP Range header value

func ParseByteRange added in v0.7.7

func ParseByteRange(r string) (*ByteRange, error)

ParseByteRange parses a Range header value in the format: bytes=<start>-<end> where end is optional

type Cache added in v0.7.7

type Cache interface {
	Get(key string) (*CacheItem, bool, error)
	GetAnyWithPrefix(prefix string) (*CacheItem, bool, error)
	Set(key string, data *CacheItem) error
}

Cache defines the interface for cache implementations

type CacheItem added in v0.7.7

type CacheItem struct {
	Metadata *CacheMetadata
	Data     []byte
}

CacheItem represents a cached response with metadata and data

func (*CacheItem) ReadFrom added in v0.7.7

func (i *CacheItem) ReadFrom(r io.Reader) (int64, error)

ReadFrom implements io.ReaderFrom to deserialize the cache item

func (*CacheItem) WriteTo added in v0.7.7

func (i *CacheItem) WriteTo(w io.Writer) (int64, error)

WriteTo implements io.WriterTo to serialize the cache item

type CacheMetadata added in v0.7.7

type CacheMetadata struct {
	Headers            http.Header `json:"h,omitempty"`
	ContentType        string      `json:"ct,omitempty"`
	ContentTotalLength int64       `json:"ctl,omitempty"`
}

CacheMetadata stores metadata about a cached response

func (*CacheMetadata) MarshalBinary added in v0.7.7

func (m *CacheMetadata) MarshalBinary() ([]byte, error)

type FileCache added in v0.7.7

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

func NewFileCache added in v0.7.7

func NewFileCache(filePath string, opts ...FileCacheOption) *FileCache

func (*FileCache) Get added in v0.7.7

func (c *FileCache) Get(key string) (*CacheItem, bool, error)

func (*FileCache) GetAnyWithPrefix added in v0.7.8

func (c *FileCache) GetAnyWithPrefix(prefix string) (*CacheItem, bool, error)

func (*FileCache) Set added in v0.7.7

func (c *FileCache) Set(key string, data *CacheItem) error

type FileCacheOption added in v0.7.7

type FileCacheOption func(*FileCache)

func WithFileCacheMaxAge added in v0.7.7

func WithFileCacheMaxAge(age time.Duration) FileCacheOption

func WithFileCacheMaxSizeBytes added in v0.7.7

func WithFileCacheMaxSizeBytes(size int64) FileCacheOption

type Headers added in v0.7.7

type Headers interface {
	Headers() http.Header
}

Headers defines the interface for accessing response headers

type HttpReadSeekCloser added in v0.7.7

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

func NewHttpReadSeekCloser added in v0.7.7

func NewHttpReadSeekCloser(url string, conf ...HttpReadSeekerConf) *HttpReadSeekCloser

func (*HttpReadSeekCloser) Close added in v0.7.7

func (h *HttpReadSeekCloser) Close() error

func (*HttpReadSeekCloser) ContentLength added in v0.7.7

func (h *HttpReadSeekCloser) ContentLength() int64

func (*HttpReadSeekCloser) ContentTotalLength added in v0.7.7

func (h *HttpReadSeekCloser) ContentTotalLength() (int64, error)

func (*HttpReadSeekCloser) ContentType added in v0.7.7

func (h *HttpReadSeekCloser) ContentType() (string, error)

func (*HttpReadSeekCloser) FetchNextChunk added in v0.7.7

func (h *HttpReadSeekCloser) FetchNextChunk() error

func (*HttpReadSeekCloser) Offset added in v0.7.7

func (h *HttpReadSeekCloser) Offset() int64

func (*HttpReadSeekCloser) Read added in v0.7.7

func (h *HttpReadSeekCloser) Read(p []byte) (n int, err error)

func (*HttpReadSeekCloser) Seek added in v0.7.7

func (h *HttpReadSeekCloser) Seek(offset int64, whence int) (int64, error)

type HttpReadSeekerConf added in v0.7.7

type HttpReadSeekerConf func(h *HttpReadSeekCloser)

func AllowedContentTypes added in v0.7.7

func AllowedContentTypes(types ...string) HttpReadSeekerConf

func WithClient added in v0.7.7

func WithClient(client *http.Client) HttpReadSeekerConf

func WithContentTotalLength added in v0.7.8

func WithContentTotalLength(contentTotalLength int64) HttpReadSeekerConf

func WithContext added in v0.7.7

func WithContext(ctx context.Context) HttpReadSeekerConf

func WithForceNotSupportRange added in v0.7.9

func WithForceNotSupportRange(notSupportRange bool) HttpReadSeekerConf

func WithHeadMethod added in v0.7.7

func WithHeadMethod(method string) HttpReadSeekerConf

func WithHeaders added in v0.7.7

func WithHeaders(headers http.Header) HttpReadSeekerConf

func WithHeadersMap added in v0.7.7

func WithHeadersMap(headers map[string]string) HttpReadSeekerConf

func WithMethod added in v0.7.7

func WithMethod(method string) HttpReadSeekerConf

func WithNotSupportSeekWhenNotSupportRange added in v0.7.9

func WithNotSupportSeekWhenNotSupportRange(notSupportSeekWhenNotSupportRange bool) HttpReadSeekerConf

func WithPerLength added in v0.7.9

func WithPerLength(length int64) HttpReadSeekerConf

sets the per length of the request

type MemoryCache added in v0.7.7

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

MemoryCache implements an in-memory Cache with LRU eviction

func NewMemoryCache added in v0.7.7

func NewMemoryCache(capacity int, opts ...MemoryCacheOption) *MemoryCache

func (*MemoryCache) Get added in v0.7.7

func (c *MemoryCache) Get(key string) (*CacheItem, bool, error)

func (*MemoryCache) GetAnyWithPrefix added in v0.7.8

func (c *MemoryCache) GetAnyWithPrefix(prefix string) (*CacheItem, bool, error)

func (*MemoryCache) Set added in v0.7.7

func (c *MemoryCache) Set(key string, data *CacheItem) error

type MemoryCacheOption added in v0.7.7

type MemoryCacheOption func(*MemoryCache)

func WithMaxSizeBytes added in v0.7.7

func WithMaxSizeBytes(size int64) MemoryCacheOption

type Proxy added in v0.7.7

type Proxy interface {
	io.ReadSeeker
	ContentTotalLength() (int64, error)
	ContentType() (string, error)
}

Proxy defines the interface for proxy implementations

type ProxyURLOption added in v0.7.8

type ProxyURLOption func(o *ProxyURLOptions)

func WithProxyURLCache added in v0.7.8

func WithProxyURLCache(cache bool) ProxyURLOption

func WithProxyURLCacheKey added in v0.7.8

func WithProxyURLCacheKey(key string) ProxyURLOption

type ProxyURLOptions added in v0.7.8

type ProxyURLOptions struct {
	CacheKey string
	Cache    bool
}

func NewProxyURLOptions added in v0.7.8

func NewProxyURLOptions(opts ...ProxyURLOption) *ProxyURLOptions

type SliceCacheProxy added in v0.7.7

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

SliceCacheProxy implements caching of content slices

func NewSliceCacheProxy added in v0.7.7

func NewSliceCacheProxy(key string, sliceSize int64, r Proxy, cache Cache) *SliceCacheProxy

NewSliceCacheProxy creates a new SliceCacheProxy instance

func (*SliceCacheProxy) Proxy added in v0.7.7

func (*SliceCacheProxy) ServeHTTP added in v0.7.7

func (c *SliceCacheProxy) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP implements http.Handler interface

type TrieNode added in v0.7.8

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

TrieNode represents a node in the prefix tree

func NewTrieNode added in v0.7.8

func NewTrieNode() *TrieNode

Jump to

Keyboard shortcuts

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