core

package
v0.0.0-...-aba3ae9 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2026 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ErrorTypeAPI      = server.LegacyErrorTypeAPI
	ErrorTypeStore    = server.LegacyErrorTypeStore
	ErrorTypeUpstream = server.LegacyErrorTypeUpstream
	ErrorTypeUnknown  = server.LegacyErrorTypeUnknown
)
View Source
const (
	ErrorCodeUnknown                     = server.ErrorCodeUnknown
	ErrorCodeBadGateway                  = server.ErrorCodeBadGateway
	ErrorCodeBadRequest                  = server.ErrorCodeBadRequest
	ErrorCodeConflict                    = server.ErrorCodeConflict
	ErrorCodeForbidden                   = server.ErrorCodeForbidden
	ErrorCodeGone                        = server.ErrorCodeGone
	ErrorCodeInternalServerError         = server.ErrorCodeInternalServerError
	ErrorCodeMethodNotAllowed            = server.ErrorCodeMethodNotAllowed
	ErrorCodeNotFound                    = server.ErrorCodeNotFound
	ErrorCodeNotImplemented              = server.ErrorCodeNotImplemented
	ErrorCodePaymentRequired             = server.ErrorCodePaymentRequired
	ErrorCodeProxyAuthenticationRequired = server.ErrorCodeProxyAuthenticationRequired
	ErrorCodeServiceUnavailable          = server.ErrorCodeServiceUnavailable
	ErrorCodeTooManyRequests             = server.ErrorCodeTooManyRequests
	ErrorCodeUnauthorized                = server.ErrorCodeUnauthorized
	ErrorCodeUnavailableForLegalReasons  = server.ErrorCodeUnavailableForLegalReasons
	ErrorCodeUnprocessableEntity         = server.ErrorCodeUnprocessableEntity
	ErrorCodeUnsupportedMediaType        = server.ErrorCodeUnsupportedMediaType
	ErrorCodeStoreLimitExceeded          = server.ErrorCodeStoreLimitExceeded
	ErrorCodeStoreMagnetInvalid          = server.ErrorCodeStoreMagnetInvalid
	ErrorCodeStoreNameInvalid            = server.ErrorCodeStoreNameInvalid
	ErrorCodeStoreServerDown             = server.ErrorCodeStoreServerDown
)
View Source
const EncryptionFormat = "AES-GCM-256"

Variables

View Source
var HasVideoExtension = func() func(filename string) bool {
	videoExtensions := map[string]bool{
		".3g2":  true,
		".3gp":  true,
		".amv":  true,
		".asf":  true,
		".avi":  true,
		".drc":  true,
		".f4a":  true,
		".f4b":  true,
		".f4p":  true,
		".f4v":  true,
		".flv":  true,
		".gif":  true,
		".gifv": true,
		".m2ts": true,
		".m2v":  true,
		".m4p":  true,
		".m4v":  true,
		".mk3d": true,
		".mkv":  true,
		".mng":  true,
		".mov":  true,
		".mp2":  true,
		".mp4":  true,
		".mpe":  true,
		".mpeg": true,
		".mpg":  true,
		".mpv":  true,
		".mxf":  true,
		".nsv":  true,
		".ogg":  true,
		".ogm":  true,
		".ogv":  true,
		".qt":   true,
		".rm":   true,
		".rmvb": true,
		".roq":  true,
		".svi":  true,
		".ts":   true,
		".webm": true,
		".wmv":  true,
		".yuv":  true,
	}

	return func(filename string) bool {
		_, found := videoExtensions[strings.ToLower(filepath.Ext(filename))]
		return found
	}
}()

Functions

func CreateJWT

func CreateJWT[T any](secret string, claims JWTClaims[T]) (string, error)

func Decrypt

func Decrypt(secret, value string) (string, error)

func Encrypt

func Encrypt(secret, value string) (string, error)

func GetClientIP

func GetClientIP(r *http.Request) string

func GetRequestIPHeaders

func GetRequestIPHeaders(r *http.Request) map[string]string

func LogError

func LogError(r *http.Request, msg string, err error)

func NormalizeMagnetHash

func NormalizeMagnetHash(hash string) string

func ParseJWT

func ParseJWT[T any](secretFunc jwt.Keyfunc, encodedToken string, claims *JWTClaims[T], options ...jwt.ParserOption) (*jwt.Token, error)

func UnmarshalJSON

func UnmarshalJSON(statusCode int, body []byte, v any) error

Types

type APIError

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

func NewAPIError

func NewAPIError(msg string) *APIError

type Error

type Error = server.LegacyError

func NewError

func NewError(msg string) *Error

type ErrorCode

type ErrorCode = server.ErrorCode

type ErrorType

type ErrorType = server.LegacyErrorType

type JWTClaims

type JWTClaims[T any] struct {
	jwt.RegisteredClaims
	Data *T `json:"data,omitempty"`
}
type MagnetLink struct {
	Hash     string // xt - exact topic
	Link     string
	Name     string   // dn - display name
	Trackers []string // tr - address tracker
	RawLink  string
}
func ParseMagnetLink(value string) (MagnetLink, error)

type StoreError

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

func NewStoreError

func NewStoreError(msg string) *StoreError

type StremThruError

type StremThruError = server.StremThruError

type UpstreamError

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

func NewUpstreamError

func NewUpstreamError(msg string) *UpstreamError

Jump to

Keyboard shortcuts

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