sourceadmin

package
v0.3.5 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2026 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Overview

Package sourceadmin provides the private owner source-console protocol. It starts no workers and never accepts provider configuration or target URLs.

Index

Constants

View Source
const MaxItems = 100
View Source
const Path = "/cluster/runtime/source-admin"

Variables

View Source
var (
	ErrInvalid     = errors.New("sourceadmin: invalid request")
	ErrDenied      = errors.New("sourceadmin: denied")
	ErrUnsupported = errors.New("sourceadmin: unsupported")
	ErrUnavailable = errors.New("sourceadmin: unavailable")
)

Functions

This section is empty.

Types

type Cache

type Cache struct {
	Used     int64 `json:"used"`
	Budget   int64 `json:"budget"`
	Hits     int64 `json:"hits"`
	HotBytes int64 `json:"hotBytes"`
}

type Client

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

func NewClient

func NewClient(o ClientOptions) (*Client, error)

func (*Client) Call

func (c *Client) Call(ctx context.Context, credential string, r Request) (Response, error)

func (*Client) CloseIdleConnections

func (c *Client) CloseIdleConnections()

type ClientOptions

type ClientOptions struct {
	Guard *nodewire.Guard
	Peer  nodewire.Identity
	// Endpoint is an explicit origin (https://host:port), never caller input.
	Endpoint string
	// Authorize checks current exact local server and target source roles and
	// current resource eligibility before each dial. Guard additionally checks
	// fresh remote incarnation/revocation before any HTTP headers are sent.
	Authorize func(context.Context, nodewire.Identity, Request) error
	Timeout   time.Duration
}

type Diagnostics

type Diagnostics struct {
	Providers []Provider      `json:"providers"`
	Indexers  []Indexer       `json:"indexers"`
	Cache     *Cache          `json:"cache,omitempty"`
	Stream    *Stream         `json:"stream,omitempty"`
	Sources   []SourceStartup `json:"sources,omitempty"`
}

type Handler

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

func NewHandler

func NewHandler(o Options) (*Handler, error)

func (*Handler) ServeHTTP

func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request)

type Indexer

type Indexer struct {
	Slot           int   `json:"slot"`
	HitsUsed       int   `json:"hitsUsed"`
	HitsRemaining  int   `json:"hitsRemaining"`
	GrabsUsed      int   `json:"grabsUsed"`
	GrabsRemaining int   `json:"grabsRemaining"`
	RetryAt        int64 `json:"retryAt"`
	Enabled        bool  `json:"enabled"`
	Torrent        bool  `json:"torrent"`
}

type Operation

type Operation string
const (
	Snapshot       Operation = "snapshot"
	TestProvider   Operation = "test-provider"
	TestIndexer    Operation = "test-indexer"
	TestDebrid     Operation = "test-debrid"
	Traces         Operation = "traces"
	CacheStatus    Operation = "cache-status"
	ReleaseHistory Operation = "release-history"
	Variants       Operation = "variants"
)

type Options

type Options struct {
	Guard *nodewire.Guard
	Local nodewire.Identity
	// Authorize MUST freshly check exact caller boot/node has server role,
	// local boot/node has source role, and the operation's source/resource
	// remains eligible in current shared config. Unavailable policy denies.
	Authorize func(context.Context, nodewire.Identity, nodewire.Identity, Request) error
	// VerifyOwner independently checks the ORIGINAL opaque credential with
	// real current owner authority. No delegated/viewer/setup bypass is valid.
	VerifyOwner func(context.Context, string) error
	Services    Services
	Timeout     time.Duration
}

type Protocol

type Protocol string
const (
	Usenet  Protocol = "usenet"
	Torrent Protocol = "torrent"
)

type Provider

type Provider struct {
	// Slot indexes the CURRENT shared-config list, not an arbitrary label/host.
	Slot              int    `json:"slot"`
	State             Status `json:"state"`
	MaxConnections    int    `json:"maxConnections"`
	LiveConnections   int    `json:"liveConnections"`
	ActiveConnections int    `json:"activeConnections"`
	NodeShare         int    `json:"nodeShare"`
}

type Query

type Query struct {
	Limit   int   `json:"limit"`
	TitleID int64 `json:"titleID,omitempty"`
}

Query is deliberately not a generic payload: no host, path, headers, config, credential, viewer identity, or arbitrary search terms can cross this boundary.

type Release

type Release struct {
	HistoryID   int64  `json:"historyID,omitempty"`
	TitleID     int64  `json:"titleID"`
	AtUnixMilli int64  `json:"atUnixMilli,omitempty"`
	Size        int64  `json:"size"`
	Height      int    `json:"height,omitempty"`
	State       Status `json:"state"`
	Pinned      bool   `json:"pinned"`
	Automatic   bool   `json:"automatic"`
}

type Request

type Request struct {
	Operation  Operation `json:"operation"`
	RequestID  string    `json:"requestID"`
	ResourceID string    `json:"resourceID,omitempty"`
	Payload    *Query    `json:"payload,omitempty"`
}

type Response

type Response struct {
	Diagnostics *Diagnostics `json:"diagnostics,omitempty"`
	Cache       *Cache       `json:"cache,omitempty"`
	Traces      []Trace      `json:"traces,omitempty"`
	Releases    []Release    `json:"releases,omitempty"`
	Tested      bool         `json:"tested,omitempty"`
}

type Services

type Services struct {
	Snapshot       func(context.Context, int) (Diagnostics, error)
	TestProvider   func(context.Context, string) error
	TestIndexer    func(context.Context, string) error
	TestDebrid     func(context.Context, string) error
	Traces         func(context.Context, Query) ([]Trace, error)
	CacheStatus    func(context.Context, string) (Cache, error)
	ReleaseHistory func(context.Context, Query) ([]Release, error)
	Variants       func(context.Context, Query) ([]Release, error)
}

Services are real, cancellation-aware operations. Test callbacks resolve the ID against CURRENT shared config at invocation, never a cached config snapshot. Nil means unsupported. Callbacks must not substitute successful dummy results.

type SourceStartup

type SourceStartup struct {
	Protocol      Protocol `json:"protocol"`
	AverageMillis int64    `json:"averageMillis"`
	LastMillis    int64    `json:"lastMillis"`
	Samples       int64    `json:"samples"`
}

type Status

type Status string

Status and every other textual response field are closed enums. Real service adapters must project existing diagnostics, never copy raw errors/config/logs.

const (
	Healthy Status = "healthy"
	Backoff Status = "backoff"
	Failed  Status = "failed"
	Unknown Status = "unknown"
)

type Stream

type Stream struct {
	Fetches       int64 `json:"fetches"`
	FetchedBytes  int64 `json:"fetchedBytes"`
	Missing       int64 `json:"missing"`
	ActiveSources int64 `json:"activeSources"`
	OpenReleases  int   `json:"openReleases"`
}

type Trace

type Trace struct {
	TitleID           int64  `json:"titleID"`
	AtUnixMilli       int64  `json:"atUnixMilli"`
	State             Status `json:"state"`
	Candidates        int    `json:"candidates"`
	SearchMillis      int64  `json:"searchMillis"`
	PreparationMillis int64  `json:"preparationMillis"`
	TotalMillis       int64  `json:"totalMillis"`
	Failover          bool   `json:"failover"`
	Pinned            bool   `json:"pinned"`
}

Trace excludes raw candidate names, URLs, routing descriptions and errors.

Jump to

Keyboard shortcuts

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