sitelogin

package
v0.35.2 Latest Latest
Warning

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

Go to latest
Published: Jun 9, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const ConsistencyDrift = "drift"

ConsistencyDrift is the sentinel string written into SiteLoginState.LastConsistencyCheck when the API and cookie last-login timestamps disagree by more than the threshold.

Variables

This section is empty.

Functions

func CheckConsistency

func CheckConsistency(api, cookie *time.Time) string

CheckConsistency compares two last-login timestamps after UTC normalization. Returns "drift" only when both pointers are non-nil and the absolute delta exceeds 24h; returns "" in all other cases (including either side being nil).

func TimeFromUnix

func TimeFromUnix(sec int64) *time.Time

TimeFromUnix converts a positive Unix timestamp to a UTC-normalized time pointer. UTC normalization prevents timezone drift bugs (Metis EC-9).

Types

type CloakTransport

type CloakTransport struct{}

CloakTransport is a placeholder for T11-T14, when concrete CloakBrowser schema drivers are wired under internal/cloakdriver/<schema>/.

func (CloakTransport) FetchUserInfo

func (CloakTransport) Name

func (CloakTransport) Name() string

type Clock

type Clock interface {
	Now() time.Time
}

type FakeClock

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

func NewFakeClock

func NewFakeClock(t time.Time) *FakeClock

func (*FakeClock) Advance

func (fc *FakeClock) Advance(d time.Duration)

func (*FakeClock) Now

func (fc *FakeClock) Now() time.Time

type HTTPTransport

type HTTPTransport struct{}

HTTPTransport delegates to the existing schema-specific probe functions.

func (HTTPTransport) FetchUserInfo

func (HTTPTransport) FetchUserInfo(ctx context.Context, def *v2.SiteDefinition, site v2.Site, clock Clock) (*ProbeResult, error)

func (HTTPTransport) Name

func (HTTPTransport) Name() string

type ProbeResult

type ProbeResult struct {
	Status       ProbeStatus
	LastLoginAt  *time.Time
	LastAccessAt *time.Time
	Source       ProbeSource
	RawError     error
	Diagnostic   string
}

func Probe

func Probe(ctx context.Context, def *v2.SiteDefinition, site v2.Site, clock Clock) (*ProbeResult, error)

Probe routes the request to the schema-specific probe function based on def.Schema. All I/O is performed through site.GetUserInfo, which inherits the project's circuit breaker and rate limiter from site/v2/http_client.go; dispatcher.go itself MUST NOT issue raw HTTP requests.

Panics raised by individual probes are recovered and surfaced as a ProbeResult with Status=UNKNOWN so that a single misbehaving probe cannot crash the LoginReminderMonitor goroutine and stop progress for other sites.

HDDolby and Rousi schemas share the NexusPHP probe implementation because their drivers expose the same UserInfo shape (LastAccess + LastLogin).

func ProbeGazelle

func ProbeGazelle(ctx context.Context, site sitev2.Site, clock Clock) (*ProbeResult, error)

func ProbeMTorrent

func ProbeMTorrent(ctx context.Context, site v2.Site, clock Clock) (*ProbeResult, error)

func ProbeNexusPHP

func ProbeNexusPHP(ctx context.Context, site v2.Site, clock Clock, source ProbeSource) (*ProbeResult, error)

ProbeNexusPHP wraps Site.GetUserInfo() for NexusPHP-schema sites. All I/O is delegated to the driver; this function performs only classification.

func ProbeUnit3D

func ProbeUnit3D(ctx context.Context, site v2.Site, clock Clock) (*ProbeResult, error)

ProbeUnit3D wraps a Unit3D Site.GetUserInfo call and classifies any error into the 8-status ProbeStatus taxonomy. It never issues raw HTTP requests; all transport flows through the underlying driver (which inherits circuit breaking and rate limiting from site/v2/http_client.go).

func ProbeWithFallback

func ProbeWithFallback(ctx context.Context, def *v2.SiteDefinition, site v2.Site, clock Clock, primary, fallback Transport) (*ProbeResult, error)

ProbeWithFallback runs the primary transport first and invokes fallback only for statuses that indicate transport-level blocking rather than invalid user credentials. It never runs both transports concurrently.

type ProbeSource

type ProbeSource string

ProbeSource identifies which authentication path produced a probe's last-login timestamp. The caller (LoginReminderMonitor) uses this to dispatch the timestamp into either ApiLastLoginAt (API key) or CookieLastLoginAt (cookie session).

const (
	ProbeSourceHTTPCookie ProbeSource = "http_cookie"
	ProbeSourceHTTPAPIKey ProbeSource = "http_api_key"
	ProbeSourceCloak      ProbeSource = "cloak"
)

type ProbeStatus

type ProbeStatus string
const (
	OK              ProbeStatus = "OK"
	SESSION_EXPIRED ProbeStatus = "SESSION_EXPIRED"
	CHALLENGE       ProbeStatus = "CHALLENGE"
	RATE_LIMITED    ProbeStatus = "RATE_LIMITED"
	NETWORK_ERROR   ProbeStatus = "NETWORK_ERROR"
	PARSE_ERROR     ProbeStatus = "PARSE_ERROR"
	KEY_ERROR       ProbeStatus = "KEY_ERROR"
	UNKNOWN         ProbeStatus = "UNKNOWN"
	// NOT_APPLICABLE marks a probe path that was deliberately skipped
	// (e.g. mTorrent CloakBrowser cookie path when no cookie is configured).
	// No Manager call is made and no error is recorded.
	NOT_APPLICABLE ProbeStatus = "NOT_APPLICABLE"
)

func (ProbeStatus) String

func (s ProbeStatus) String() string

type RealClock

type RealClock struct{}

func NewRealClock

func NewRealClock() *RealClock

func (*RealClock) Now

func (rc *RealClock) Now() time.Time

type Transport

type Transport interface {
	Name() string
	FetchUserInfo(ctx context.Context, def *v2.SiteDefinition, site v2.Site, clock Clock) (*ProbeResult, error)
}

Transport abstracts how a probe fetches user info from a PT site.

Metis AP-3: dispatcher uses a transport-pluggable single probe, not parallel dual probes. ProbeWithFallback selects at most one fallback after the primary result is classified as fallback-eligible.

Jump to

Keyboard shortcuts

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